diff --git a/libcork/include/libcork/config/config.h b/libcork/include/libcork/config/config.h index 5fa36f7d..3a288572 100644 --- a/libcork/include/libcork/config/config.h +++ b/libcork/include/libcork/config/config.h @@ -52,6 +52,10 @@ /* Do some BSD (4.3 code base or newer)specific autodetection. */ #include +#elif defined(__MINGW32__) +/* Do some mingw32 autodetection. */ +#include + #endif /* platforms */ diff --git a/libcork/include/libcork/config/mingw32.h b/libcork/include/libcork/config/mingw32.h new file mode 100644 index 00000000..c62cbc52 --- /dev/null +++ b/libcork/include/libcork/config/mingw32.h @@ -0,0 +1,52 @@ +/* -*- coding: utf-8 -*- + * ---------------------------------------------------------------------- + * Copyright © 2011, RedJack, LLC. + * All rights reserved. + * + * Please see the COPYING file in this distribution for license + * details. + * ---------------------------------------------------------------------- + */ + +#ifndef LIBCORK_CONFIG_MINGW32_H +#define LIBCORK_CONFIG_MINGW32_H + +#include + +/*----------------------------------------------------------------------- + * Endianness + */ + +/* Assume MinGW32 only works on x86 platform */ + +#define CORK_CONFIG_IS_BIG_ENDIAN 0 +#define CORK_CONFIG_IS_LITTLE_ENDIAN 1 + +#define CORK_HAVE_REALLOCF 0 +#define CORK_HAVE_PTHREADS 1 + +/* + * File io stuff. Odd that this is not defined by MinGW. + * Maybe there is an M$ish way to do it. + */ +#define F_SETFL 4 +#define O_NONBLOCK 0x4000 /* non blocking I/O (POSIX style) */ + +#define F_GETFD 1 +#define F_SETFD 2 +#define FD_CLOEXEC 0x1 + +#define WNOHANG 1 + +/* + * simple adaptors + */ + +static inline int mingw_mkdir(const char *path, int mode) +{ + return mkdir(path); +} +#define mkdir mingw_mkdir + + +#endif /* LIBCORK_CONFIG_MINGW32_H */ diff --git a/libcork/posix/subprocess.c b/libcork/posix/subprocess.c index a97b8043..f2a2442d 100644 --- a/libcork/posix/subprocess.c +++ b/libcork/posix/subprocess.c @@ -12,8 +12,10 @@ #include #include #include +#ifndef __MINGW32__ #include #include +#endif #include #include "libcork/core.h" @@ -506,7 +508,7 @@ cork_subprocess_is_finished(struct cork_subprocess *self) && cork_read_pipe_is_finished(&self->stderr_pipe); } -#if defined(__APPLE__) +#if defined(__APPLE__) || defined(__MINGW32__) #include #define THREAD_YIELD pthread_yield_np #elif defined(__linux__) || defined(BSD) diff --git a/src/acl.c b/src/acl.c index 28c10097..6e778969 100644 --- a/src/acl.c +++ b/src/acl.c @@ -1,12 +1,38 @@ +/* + * acl.c - Manage the ACL (Access Control List) + * + * Copyright (C) 2013 - 2014, Max Lv + * + * This file is part of the shadowsocks-libev. + * + * shadowsocks-libev is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * shadowsocks-libev is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with pdnsd; see the file COPYING. If not, see + * . + */ + #include +#include + #include "utils.h" -static struct ip_set set; +static struct ip_set acl_ip_set; +static struct cork_string_array acl_domain_array; static void parse_addr_cidr(const char *str, char **host, int *cidr) { int ret = -1, n = 0; char *pch; + pch = strchr(str, '/'); while (pch != NULL) { @@ -35,8 +61,12 @@ static void parse_addr_cidr(const char *str, char **host, int *cidr) int init_acl(const char *path) { + // initialize ipset ipset_init_library(); - ipset_init(&set); + ipset_init(&acl_ip_set); + + // initialize array + cork_string_array_init(&acl_domain_array); FILE *f = fopen(path, "r"); if (f == NULL) FATAL("Invalid acl path."); @@ -46,16 +76,33 @@ int init_acl(const char *path) { if (fgets(line, 256, f)) { + // Trim the newline + int len = strlen(line); + if (len > 0 && line[len - 1] == '\n') + { + line[len - 1] = '\0'; + } + char *host = NULL; int cidr; parse_addr_cidr(line, &host, &cidr); - struct cork_ipv4 addr; - int err = cork_ipv4_init(&addr, host); - if (err) continue; - if (cidr >= 0) - ipset_ipv4_add_network(&set, &addr, cidr); + + if (cidr == -1) + { + cork_string_array_append(&acl_domain_array, host); + } else - ipset_ipv4_add(&set, &addr); + { + struct cork_ipv4 addr; + int err = cork_ipv4_init(&addr, host); + if (!err) + { + if (cidr >= 0) + ipset_ipv4_add_network(&acl_ip_set, &addr, cidr); + else + ipset_ipv4_add(&acl_ip_set, &addr); + } + } if (host != NULL) free(host); } @@ -68,15 +115,43 @@ int init_acl(const char *path) void free_acl(void) { - ipset_done(&set); + ipset_done(&acl_ip_set); +} + +int acl_contains_domain(const char* domain) +{ + const char **list = acl_domain_array.items; + const int size = acl_domain_array.size; + const int domain_len = strlen(domain); + + for (int i = 0; i < size; i++) + { + const char *acl_domain = list[i]; + const int acl_domain_len = strlen(acl_domain); + if (acl_domain_len > domain_len) continue; + int match = true; + for (int offset = 1; offset <= acl_domain_len; offset++) + { + if (domain[domain_len - offset] != acl_domain[acl_domain_len - offset]) + { + match = false; + break; + } + } + if (match) return 1; + } + + + return 0; } -int acl_is_bypass(const char* host) +int acl_contains_ip(const char* host) { struct cork_ipv4 addr; int err = cork_ipv4_init(&addr, host); if (err) return 0; + struct cork_ip ip; cork_ip_from_ipv4(&ip, &addr); - return ipset_contains_ip(&set, &ip); + return ipset_contains_ip(&acl_ip_set, &ip); } diff --git a/src/acl.h b/src/acl.h index 2acb6678..04e0982b 100644 --- a/src/acl.h +++ b/src/acl.h @@ -1,8 +1,32 @@ +/* + * acl.h - Define the ACL interface + * + * Copyright (C) 2013 - 2014, Max Lv + * + * This file is part of the shadowsocks-libev. + * + * shadowsocks-libev is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * shadowsocks-libev is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with pdnsd; see the file COPYING. If not, see + * . + */ + #ifndef _ACL_H #define _ACL_H int init_acl(const char *path); void free_acl(void); -int acl_is_bypass(const char* host); + +int acl_contains_ip(const char* ip); +int acl_contains_domain(const char* domain); #endif // _ACL_H diff --git a/src/cache.c b/src/cache.c index e70e0998..077986f7 100644 --- a/src/cache.c +++ b/src/cache.c @@ -1,3 +1,25 @@ +/* + * cache.c - Manage the connection cache for UDPRELAY + * + * Copyright (C) 2013 - 2014, Max Lv + * + * This file is part of the shadowsocks-libev. + * + * shadowsocks-libev is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * shadowsocks-libev is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with pdnsd; see the file COPYING. If not, see + * . + */ + /* * Original Author: Oliver Lorenz (ol), olli@olorenz.org, https://olorenz.org * License: This is licensed under the same terms as uthash itself diff --git a/src/cache.h b/src/cache.h index b20b8b35..b53469d3 100644 --- a/src/cache.h +++ b/src/cache.h @@ -1,3 +1,25 @@ +/* + * cache.c - Define the cache manager interface + * + * Copyright (C) 2013 - 2014, Max Lv + * + * This file is part of the shadowsocks-libev. + * + * shadowsocks-libev is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * shadowsocks-libev is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with pdnsd; see the file COPYING. If not, see + * . + */ + /* * Original Author: Oliver Lorenz (ol), olli@olorenz.org, https://olorenz.org * License: This is licensed under the same terms as uthash itself diff --git a/src/encrypt.c b/src/encrypt.c index e31c3102..06c2e3b2 100644 --- a/src/encrypt.c +++ b/src/encrypt.c @@ -1,3 +1,25 @@ +/* + * encrypt.c - Manage the global encryptor + * + * Copyright (C) 2013 - 2014, Max Lv + * + * This file is part of the shadowsocks-libev. + * + * shadowsocks-libev is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * shadowsocks-libev is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with pdnsd; see the file COPYING. If not, see + * . + */ + #ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/src/encrypt.h b/src/encrypt.h index ae052b32..138dead2 100644 --- a/src/encrypt.h +++ b/src/encrypt.h @@ -1,3 +1,25 @@ +/* + * encrypt.h - Define the enryptor's interface + * + * Copyright (C) 2013 - 2014, Max Lv + * + * This file is part of the shadowsocks-libev. + * + * shadowsocks-libev is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * shadowsocks-libev is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with pdnsd; see the file COPYING. If not, see + * . + */ + #ifndef _ENCRYPT_H #define _ENCRYPT_H diff --git a/src/include.h b/src/include.h index 4f303776..dc218ffe 100644 --- a/src/include.h +++ b/src/include.h @@ -1,3 +1,24 @@ +/* + * include.h - Provide global definitions + * + * Copyright (C) 2013 - 2014, Max Lv + * + * This file is part of the shadowsocks-libev. + * shadowsocks-libev is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * shadowsocks-libev is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with pdnsd; see the file COPYING. If not, see + * . + */ + #ifndef _INCLUDE_H #define _INCLUDE_H @@ -8,7 +29,7 @@ #ifndef TCP_FASTOPEN #define TCP_FASTOPEN 23 #endif - + /* conditional define for MSG_FASTOPEN */ #ifndef MSG_FASTOPEN #define MSG_FASTOPEN 0x20000000 diff --git a/src/jconf.c b/src/jconf.c index d92f7dc8..e94d9263 100644 --- a/src/jconf.c +++ b/src/jconf.c @@ -1,3 +1,24 @@ +/* + * jconf.c - Parse the JSON format config file + * + * Copyright (C) 2013 - 2014, Max Lv + * + * This file is part of the shadowsocks-libev. + * shadowsocks-libev is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * shadowsocks-libev is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with pdnsd; see the file COPYING. If not, see + * . + */ + #include #include #include diff --git a/src/jconf.h b/src/jconf.h index c5663e3e..9ba5796a 100644 --- a/src/jconf.h +++ b/src/jconf.h @@ -1,3 +1,24 @@ +/* + * server.c - Define the config data structure + * + * Copyright (C) 2013 - 2014, Max Lv + * + * This file is part of the shadowsocks-libev. + * shadowsocks-libev is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * shadowsocks-libev is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with pdnsd; see the file COPYING. If not, see + * . + */ + #ifndef _JCONF_H #define _JCONF_H diff --git a/src/json.h b/src/json.h index 61d65aea..6175e12f 100644 --- a/src/json.h +++ b/src/json.h @@ -1,4 +1,3 @@ - /* vim: set et ts=3 sw=3 sts=3 ft=c: * * Copyright (C) 2012, 2013, 2014 James McLaughlin et al. All rights reserved. @@ -120,151 +119,151 @@ typedef struct _json_value } * values; #if defined(__cplusplus) && __cplusplus >= 201103L - decltype(values) begin () const - { - return values; - } - decltype(values) end () const - { - return values + length; - } + decltype(values) begin () const + { + return values; + } + decltype(values) end () const + { + return values + length; + } #endif - } object; + } object; - struct - { - unsigned int length; - struct _json_value ** values; + struct + { + unsigned int length; + struct _json_value ** values; #if defined(__cplusplus) && __cplusplus >= 201103L - decltype(values) begin () const - { - return values; - } - decltype(values) end () const - { - return values + length; - } + decltype(values) begin () const + { + return values; + } + decltype(values) end () const + { + return values + length; + } #endif - } array; + } array; - } u; + } u; - union - { - struct _json_value * next_alloc; - void * object_mem; + union + { + struct _json_value * next_alloc; + void * object_mem; - } _reserved; + } _reserved; - /* Some C++ operator sugar */ + /* Some C++ operator sugar */ #ifdef __cplusplus - public: +public: - inline _json_value () - { - memset (this, 0, sizeof (_json_value)); - } + inline _json_value () + { + memset (this, 0, sizeof (_json_value)); + } - inline const struct _json_value &operator [] (int index) const + inline const struct _json_value &operator [] (int index) const + { + if (type != json_array || index < 0 + || ((unsigned int) index) >= u.array.length) { - if (type != json_array || index < 0 - || ((unsigned int) index) >= u.array.length) - { - return json_value_none; - } - - return *u.array.values [index]; + return json_value_none; } - inline const struct _json_value &operator [] (const char * index) const - { - if (type != json_object) - return json_value_none; - - for (unsigned int i = 0; i < u.object.length; ++ i) - if (!strcmp (u.object.values [i].name, index)) - return *u.object.values [i].value; + return *u.array.values [index]; + } + inline const struct _json_value &operator [] (const char * index) const + { + if (type != json_object) return json_value_none; - } - inline operator const char * () const + for (unsigned int i = 0; i < u.object.length; ++ i) + if (!strcmp (u.object.values [i].name, index)) + return *u.object.values [i].value; + + return json_value_none; + } + + inline operator const char * () const + { + switch (type) { - switch (type) - { - case json_string: - return u.string.ptr; + case json_string: + return u.string.ptr; - default: - return ""; - }; - } + default: + return ""; + }; + } - inline operator json_int_t () const + inline operator json_int_t () const + { + switch (type) { - switch (type) - { - case json_integer: - return u.integer; + case json_integer: + return u.integer; - case json_double: - return (json_int_t) u.dbl; + case json_double: + return (json_int_t) u.dbl; - default: - return 0; - }; - } + default: + return 0; + }; + } - inline operator bool () const - { - if (type != json_boolean) - return false; + inline operator bool () const + { + if (type != json_boolean) + return false; - return u.boolean != 0; - } + return u.boolean != 0; + } - inline operator double () const + inline operator double () const + { + switch (type) { - switch (type) - { - case json_integer: - return (double) u.integer; + case json_integer: + return (double) u.integer; - case json_double: - return u.dbl; + case json_double: + return u.dbl; - default: - return 0; - }; - } + default: + return 0; + }; + } #endif - } json_value; +} json_value; - json_value * json_parse (const json_char * json, - size_t length); +json_value * json_parse (const json_char * json, + size_t length); #define json_error_max 128 - json_value * json_parse_ex (json_settings * settings, - const json_char * json, - size_t length, - char * error); +json_value * json_parse_ex (json_settings * settings, + const json_char * json, + size_t length, + char * error); - void json_value_free (json_value *); +void json_value_free (json_value *); - /* Not usually necessary, unless you used a custom mem_alloc and now want to - * use a custom mem_free. - */ - void json_value_free_ex (json_settings * settings, - json_value *); +/* Not usually necessary, unless you used a custom mem_alloc and now want to + * use a custom mem_free. + */ +void json_value_free_ex (json_settings * settings, + json_value *); #ifdef __cplusplus diff --git a/src/local.c b/src/local.c index 0abe9a77..ba259d85 100644 --- a/src/local.c +++ b/src/local.c @@ -1,3 +1,25 @@ +/* + * local.c - Setup a socks5 proxy through remote shadowsocks server + * + * Copyright (C) 2013 - 2014, Max Lv + * + * This file is part of the shadowsocks-libev. + * + * shadowsocks-libev is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * shadowsocks-libev is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with pdnsd; see the file COPYING. If not, see + * . + */ + #include #include #include @@ -361,7 +383,6 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents) host, INET_ADDRSTRLEN); sprintf(port, "%d", p); } - } else if (request->atyp == 3) { @@ -378,7 +399,6 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents) host[name_len] = '\0'; sprintf(port, "%d", p); } - } else if (request->atyp == 4) { @@ -394,7 +414,6 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents) host, INET6_ADDRSTRLEN); sprintf(port, "%d", p); } - } else { @@ -413,7 +432,8 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents) LOGD("connect to %s:%s", host, port); } - if (acl_is_bypass(host)) + if ((request->atyp == 1 && acl_contains_ip(host)) + || (request->atyp = 3 && acl_contains_domain(host))) { remote = connect_to_remote(server->listener, host, port); remote->direct = 1; diff --git a/src/local.h b/src/local.h index 9539c833..330a1f66 100644 --- a/src/local.h +++ b/src/local.h @@ -1,3 +1,25 @@ +/* + * local.h - Define the clinet's buffers and callbacks + * + * Copyright (C) 2013 - 2014, Max Lv + * + * This file is part of the shadowsocks-libev. + * + * shadowsocks-libev is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * shadowsocks-libev is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with pdnsd; see the file COPYING. If not, see + * . + */ + #ifndef _LOCAL_H #define _LOCAL_H diff --git a/src/redir.c b/src/redir.c index f2bebdfb..71c028f1 100644 --- a/src/redir.c +++ b/src/redir.c @@ -1,3 +1,26 @@ +/* + * redir.c - Provide a transparent TCP proxy through remote shadowsocks + * server + * + * Copyright (C) 2013 - 2014, Max Lv + * + * This file is part of the shadowsocks-libev. + * + * shadowsocks-libev is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * shadowsocks-libev is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with pdnsd; see the file COPYING. If not, see + * . + */ + #include #include #include diff --git a/src/redir.h b/src/redir.h index 4ec0ae47..6cb75d25 100644 --- a/src/redir.h +++ b/src/redir.h @@ -1,3 +1,25 @@ +/* + * redir.h - Define the redirector's buffers and callbacks + * + * Copyright (C) 2013 - 2014, Max Lv + * + * This file is part of the shadowsocks-libev. + * + * shadowsocks-libev is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * shadowsocks-libev is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with pdnsd; see the file COPYING. If not, see + * . + */ + #ifndef _LOCAL_H #define _LOCAL_H diff --git a/src/server.c b/src/server.c index bc51610c..ec1ebf52 100644 --- a/src/server.c +++ b/src/server.c @@ -1,3 +1,25 @@ +/* + * server.c - Provide shadowsocks service + * + * Copyright (C) 2013 - 2014, Max Lv + * + * This file is part of the shadowsocks-libev. + * + * shadowsocks-libev is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * shadowsocks-libev is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with pdnsd; see the file COPYING. If not, see + * . + */ + #include #include #include diff --git a/src/server.h b/src/server.h index 6e2a52d8..62442118 100644 --- a/src/server.h +++ b/src/server.h @@ -1,3 +1,25 @@ +/* + * server.h - Define shadowsocks server's buffers and callbacks + * + * Copyright (C) 2013 - 2014, Max Lv + * + * This file is part of the shadowsocks-libev. + * + * shadowsocks-libev is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * shadowsocks-libev is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with pdnsd; see the file COPYING. If not, see + * . + */ + #ifndef _SERVER_H #define _SERVER_H diff --git a/src/socks5.h b/src/socks5.h index d666a572..72ec327f 100644 --- a/src/socks5.h +++ b/src/socks5.h @@ -1,3 +1,25 @@ +/* + * socks5.h - Define SOCKS5's header + * + * Copyright (C) 2013, clowwindy + * + * This file is part of the shadowsocks-libev. + * + * shadowsocks-libev is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * shadowsocks-libev is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with pdnsd; see the file COPYING. If not, see + * . + */ + #ifndef _SOCKS5_H #define _SOCKS5_H diff --git a/src/tunnel.c b/src/tunnel.c index f57a4401..88f71296 100644 --- a/src/tunnel.c +++ b/src/tunnel.c @@ -1,3 +1,25 @@ +/* + * tunnel.c - Setup a local port forwarding through remote shadowsocks server + * + * Copyright (C) 2013 - 2014, Max Lv + * + * This file is part of the shadowsocks-libev. + * + * shadowsocks-libev is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * shadowsocks-libev is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with pdnsd; see the file COPYING. If not, see + * . + */ + #include #include #include diff --git a/src/tunnel.h b/src/tunnel.h index 594e52d8..99094059 100644 --- a/src/tunnel.h +++ b/src/tunnel.h @@ -1,5 +1,27 @@ -#ifndef _LOCAL_H -#define _LOCAL_H +/* + * tunnel.h - Define tunnel's buffers and callbacks + * + * Copyright (C) 2013 - 2014, Max Lv + * + * This file is part of the shadowsocks-libev. + * + * shadowsocks-libev is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * shadowsocks-libev is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with pdnsd; see the file COPYING. If not, see + * . + */ + +#ifndef _TUNNEL_H +#define _TUNNEL_H #include #include "encrypt.h" diff --git a/src/udprelay.c b/src/udprelay.c index c0b71373..887819d5 100644 --- a/src/udprelay.c +++ b/src/udprelay.c @@ -1,3 +1,25 @@ +/* + * udprelay.c - Setup UDP relay for both client and server + * + * Copyright (C) 2013 - 2014, Max Lv + * + * This file is part of the shadowsocks-libev. + * + * shadowsocks-libev is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * shadowsocks-libev is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with pdnsd; see the file COPYING. If not, see + * . + */ + #include #include #include diff --git a/src/udprelay.h b/src/udprelay.h index 095a1ab9..62f82cca 100644 --- a/src/udprelay.h +++ b/src/udprelay.h @@ -1,3 +1,25 @@ +/* + * udprelay.h - Define UDP relay's buffers and callbacks + * + * Copyright (C) 2013 - 2014, Max Lv + * + * This file is part of the shadowsocks-libev. + * + * shadowsocks-libev is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * shadowsocks-libev is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with pdnsd; see the file COPYING. If not, see + * . + */ + #ifndef _UDPRELAY_H #define _UDPRELAY_H diff --git a/src/utils.c b/src/utils.c index 5a16e406..3289b4bd 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1,3 +1,25 @@ +/* + * utils.c - Misc utilities + * + * Copyright (C) 2013 - 2014, Max Lv + * + * This file is part of the shadowsocks-libev. + * + * shadowsocks-libev is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * shadowsocks-libev is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with pdnsd; see the file COPYING. If not, see + * . + */ + #include #include #include diff --git a/src/utils.h b/src/utils.h index d9b42662..5ee98892 100644 --- a/src/utils.h +++ b/src/utils.h @@ -1,3 +1,25 @@ +/* + * utils.h - Misc utilities + * + * Copyright (C) 2013 - 2014, Max Lv + * + * This file is part of the shadowsocks-libev. + * + * shadowsocks-libev is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * shadowsocks-libev is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with pdnsd; see the file COPYING. If not, see + * . + */ + #ifndef _UTILS_H #define _UTILS_H diff --git a/src/win32.c b/src/win32.c index 8f50dd91..1aba91bd 100644 --- a/src/win32.c +++ b/src/win32.c @@ -1,3 +1,25 @@ +/* + * win32.c - Win32 port helpers + * + * Copyright (C) 2014, Linus Yang + * + * This file is part of the shadowsocks-libev. + * + * shadowsocks-libev is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * shadowsocks-libev is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with pdnsd; see the file COPYING. If not, see + * . + */ + #include "win32.h" #ifdef setsockopt diff --git a/src/win32.h b/src/win32.h index 91c50f2b..3508b2ff 100644 --- a/src/win32.h +++ b/src/win32.h @@ -1,3 +1,25 @@ +/* + * win32.c - Win32 port helpers + * + * Copyright (C) 2014, Linus Yang + * + * This file is part of the shadowsocks-libev. + * + * shadowsocks-libev is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * shadowsocks-libev is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with pdnsd; see the file COPYING. If not, see + * . + */ + #ifndef _WIN32_H #define _WIN32_H