Skip to content

Commit

Permalink
Merge branch 'release/0.2.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
lparam committed Sep 15, 2015
2 parents 8b84f1c + 7e15638 commit 2b17b50
Show file tree
Hide file tree
Showing 23 changed files with 111 additions and 85 deletions.
2 changes: 1 addition & 1 deletion 3rd/libsodium
Submodule libsodium updated 65 files
+2 −0 .gitignore
+12 −0 ChangeLog
+3 −0 THANKS
+20 −0 builds/msvc/properties/ARM.props
+1 −1 builds/msvc/properties/ReleaseDEXE.props
+21 −6 configure.ac
+6 −2 dist-build/Makefile.am
+4 −0 dist-build/android-armv8-a.sh
+9 −9 dist-build/android-build.sh
+4 −0 dist-build/android-mips64.sh
+4 −0 dist-build/android-x86-64.sh
+3 −3 dist-build/emscripten.sh
+5 −5 dist-build/ios.sh
+28 −0 dist-build/nativeclient.sh
+7 −0 examples/.gitignore
+21 −0 examples/Makefile
+68 −0 examples/auth.c
+133 −0 examples/box.c
+132 −0 examples/box_detached.c
+80 −0 examples/generichash.c
+58 −0 examples/generichash_stream.c
+58 −0 examples/shorthash.c
+78 −0 examples/sign.c
+106 −0 examples/utils.h
+1 −1 libsodium-uninstalled.pc.in
+2 −2 m4/ax_check_compile_flag.m4
+92 −0 m4/ax_check_define.m4
+3 −2 m4/ax_check_link_flag.m4
+10 −2 src/libsodium/Makefile.am
+137 −17 src/libsodium/crypto_aead/chacha20poly1305/sodium/aead_chacha20poly1305.c
+4 −4 src/libsodium/crypto_generichash/blake2/ref/blake2b-ref.c
+29 −23 src/libsodium/crypto_hash/sha256/cp/hash_sha256.c
+9 −10 src/libsodium/crypto_hash/sha512/cp/hash_sha512.c
+4 −2 src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt-common.c
+1 −0 src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt.h
+4 −0 src/libsodium/crypto_pwhash/scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c
+3 −0 src/libsodium/crypto_pwhash/scryptsalsa208sha256/pbkdf2-sha256.c
+2 −1 src/libsodium/crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c
+10 −10 src/libsodium/crypto_scalarmult/curve25519/ref10/fe_frombytes_curve25519_ref10.c
+10 −0 src/libsodium/crypto_stream/chacha20/ref/api.h
+51 −0 src/libsodium/crypto_stream/chacha20/ref/stream_chacha20_ref.c
+29 −0 src/libsodium/crypto_stream/chacha20/stream_chacha20_api.c
+5 −0 src/libsodium/include/Makefile.am
+3 −0 src/libsodium/include/sodium.h
+28 −2 src/libsodium/include/sodium/crypto_aead_chacha20poly1305.h
+1 −1 src/libsodium/include/sodium/crypto_hash_sha256.h
+23 −0 src/libsodium/include/sodium/crypto_stream_chacha20.h
+37 −0 src/libsodium/include/sodium/randombytes_nativeclient.h
+3 −2 src/libsodium/include/sodium/randombytes_salsa20_random.h
+3 −0 src/libsodium/include/sodium/utils.h
+49 −0 src/libsodium/randombytes/nativeclient/randombytes_nativeclient.c
+11 −1 src/libsodium/randombytes/randombytes.c
+30 −33 src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c
+2 −1 src/libsodium/sodium/runtime.c
+28 −11 src/libsodium/sodium/utils.c
+122 −0 test/default/Makefile.am
+150 −17 test/default/aead_chacha20poly1305.c
+51 −0 test/default/aead_chacha20poly1305.exp
+80 −5 test/default/chacha20.c
+11 −0 test/default/chacha20.exp
+26 −0 test/default/nacl-test-wrapper.sh
+4 −0 test/default/randombytes.c
+23 −0 test/default/sodium_utils.c
+5 −0 test/default/sodium_utils.exp
+1 −0 test/default/stream.c
2 changes: 1 addition & 1 deletion 3rd/libuv
Submodule libuv updated 74 files
+3 −0 .mailmap
+18 −0 AUTHORS
+141 −1 ChangeLog
+36 −0 MAINTAINERS.md
+2 −0 Makefile.am
+36 −0 README.md
+2 −2 android-configure
+36 −0 appveyor.yml
+4 −3 common.gypi
+1 −1 configure.ac
+1 −1 docs/src/check.rst
+4 −2 docs/src/errors.rst
+12 −0 docs/src/fs.rst
+1 −1 docs/src/fs_event.rst
+1 −1 docs/src/idle.rst
+1 −0 docs/src/index.rst
+0 −11 docs/src/misc.rst
+2 −2 docs/src/pipe.rst
+1 −1 docs/src/signal.rst
+3 −1 docs/src/stream.rst
+11 −2 docs/src/tcp.rst
+3 −3 docs/src/tty.rst
+10 −1 docs/src/udp.rst
+60 −0 docs/src/version.rst
+5 −1 include/uv-version.h
+6 −1 include/uv.h
+86 −0 libuv.nsi
+3 −1 src/queue.h
+4 −1 src/threadpool.c
+43 −144 src/unix/aix.c
+23 −7 src/unix/core.c
+26 −9 src/unix/freebsd.c
+98 −39 src/unix/fs.c
+1 −0 src/unix/internal.h
+10 −2 src/unix/kqueue.c
+1 −0 src/unix/pthread-fixes.c
+23 −13 src/unix/stream.c
+43 −8 src/unix/tcp.c
+7 −2 src/unix/tty.c
+37 −5 src/unix/udp.c
+20 −6 src/uv-common.c
+1 −1 src/uv-common.h
+1 −5 src/version.c
+19 −3 src/win/fs-event.c
+34 −21 src/win/fs.c
+1 −2 src/win/internal.h
+51 −12 src/win/pipe.c
+1 −1 src/win/process-stdio.c
+53 −25 src/win/tcp.c
+1 −0 src/win/thread.c
+110 −18 src/win/tty.c
+56 −20 src/win/udp.c
+1 −1 test/benchmark-fs-stat.c
+1 −1 test/echo-server.c
+5 −0 test/run-tests.c
+47 −13 test/runner-unix.c
+2 −2 test/task.h
+199 −74 test/test-fs-event.c
+345 −142 test/test-fs.c
+32 −0 test/test-list.h
+1 −0 test/test-signal-multiple-loops.c
+181 −17 test/test-spawn.c
+8 −4 test/test-tcp-close-while-connecting.c
+2 −0 test/test-tcp-connect-timeout.c
+206 −0 test/test-tcp-create-socket-early.c
+38 −0 test/test-tcp-open.c
+4 −2 test/test-threadpool-cancel.c
+132 −0 test/test-udp-create-socket-early.c
+1 −1 test/test-udp-multicast-interface.c
+2 −0 test/test-udp-multicast-join.c
+5 −0 test/test-udp-multicast-join6.c
+1 −1 test/test-udp-multicast-ttl.c
+38 −0 test/test-udp-open.c
+9 −1 uv.gyp
10 changes: 10 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
v0.2.5 (2015-9-15)
-----------
* Fix: Crypto init once only


v0.2.4 (2015-9-01)
-----------
* Change: Update xforwarder's arguments


v0.2.3 (2015-9-01)
-----------
* Fix: Don't use pthread_setname_p under non linux platform
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MAJOR = 0
MINOR = 2
PATCH = 4
PATCH = 5
NAME = xsocks

ifdef O
Expand Down
66 changes: 41 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,64 +87,80 @@ Modify your SERVER and PASSWORD in /etc/init.d/xsocks
START=72
STOP=30
FIREWALL_RELOAD=0

SERVER=IP:PORT
PASSWORD=PASSWORD

LISTEN_PORT=1070
IP_ROUTE_TABLE_NUMBER=100
FWMARK="0x01/0x01"
SETNAME=wall
CHAIN=XSOCKS


start() {
tproxy
tproxy_start
mkdir -p /var/run/xsocks
xsocks -s $SERVER -k $PASSWORD
xtproxy -s $SERVER -k $PASSWORD
xforwarder -l 0.0.0.0:5533 -t 8.8.8.8:53 -s $SERVER -k $PASSWORD
xforwarder -l 0.0.0.0:5533 -d 8.8.8.8:53 -s $SERVER -k $PASSWORD
}

stop() {
tproxy_stop
xsocks --signal stop
xtproxy --signal stop
xforwarder --signal stop
}

shutdown() {
tproxy_stop
xsocks --signal quit
xtproxy --signal quit
xforwarder --signal quit
}

tproxy() {
local LISTEN_PORT=1070
local IP_ROUTE_TABLE_NUMBER=100
local FWMARK="0x01/0x01"
local SETNAME=wall

iptables -t nat -D PREROUTING -p tcp -j XSOCKS
iptables -t nat -F XSOCKS
iptables -t nat -X XSOCKS
tproxy_start() {
iptables -t nat -D PREROUTING -p tcp -j $CHAIN > /dev/null 2>&1
iptables -t nat -F $CHAIN > /dev/null 2>&1
iptables -t nat -X $CHAIN > /dev/null 2>&1

iptables -t mangle -D PREROUTING -j XSOCKS
iptables -t mangle -F XSOCKS
iptables -t mangle -X XSOCKS
iptables -t mangle -D PREROUTING -j $CHAIN > /dev/null 2>&1
iptables -t mangle -F $CHAIN > /dev/null 2>&1
iptables -t mangle -X $CHAIN > /dev/null 2>&1

iptables -t nat -N XSOCKS
iptables -t mangle -N XSOCKS
iptables -t nat -N $CHAIN
iptables -t mangle -N $CHAIN

ipset -F $SETNAME
ipset -X $SETNAME
ipset -N $SETNAME iphash
ipset -N $SETNAME iphash -exist

### TCP
iptables -t nat -A XSOCKS -p tcp -m set --match-set $SETNAME dst -j REDIRECT --to-port $LISTEN_PORT
iptables -t nat -A PREROUTING -p tcp -j XSOCKS
iptables -t nat -A $CHAIN -p tcp -m set --match-set $SETNAME dst -j REDIRECT --to-port $LISTEN_PORT
iptables -t nat -A PREROUTING -p tcp -j $CHAIN

### UDP
ip rule del fwmark $FWMARK table $IP_ROUTE_TABLE_NUMBER
ip route del local 0.0.0.0/0 dev lo table $IP_ROUTE_TABLE_NUMBER
ip rule del fwmark $FWMARK table $IP_ROUTE_TABLE_NUMBER > /dev/null 2>&1
ip route del local 0.0.0.0/0 dev lo table $IP_ROUTE_TABLE_NUMBER > /dev/null 2>&1

ip rule add fwmark $FWMARK table $IP_ROUTE_TABLE_NUMBER
ip route add local 0.0.0.0/0 dev lo table $IP_ROUTE_TABLE_NUMBER

iptables -t mangle -A XSOCKS -p udp -m set --match-set $SETNAME dst -j TPROXY \
iptables -t mangle -A $CHAIN -p udp -m set --match-set $SETNAME dst -j TPROXY \
--on-port $LISTEN_PORT --tproxy-mark $FWMARK
iptables -t mangle -A PREROUTING -j XSOCKS
iptables -t mangle -A PREROUTING -j $CHAIN
}

tproxy_stop() {
iptables -t nat -D PREROUTING -p tcp -j $CHAIN > /dev/null 2>&1
iptables -t nat -F $CHAIN > /dev/null 2>&1
iptables -t nat -X $CHAIN > /dev/null 2>&1

iptables -t mangle -D PREROUTING -j $CHAIN > /dev/null 2>&1
iptables -t mangle -F $CHAIN > /dev/null 2>&1
iptables -t mangle -X $CHAIN > /dev/null 2>&1

ip rule del fwmark $FWMARK table $IP_ROUTE_TABLE_NUMBER > /dev/null 2>&1
ip route del local 0.0.0.0/0 dev lo table $IP_ROUTE_TABLE_NUMBER > /dev/null 2>&1
}
```

Expand Down
2 changes: 1 addition & 1 deletion openwrt/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=xsocks
PKG_VERSION:=0.2.4
PKG_VERSION:=0.2.5
PKG_RELEASE=

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
Expand Down
6 changes: 3 additions & 3 deletions src/cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* License: This is licensed under the same terms as uthash itself
*/

#ifndef _CACHE_
#define _CACHE_
#ifndef CACHE_H
#define CACHE_H

#include "uthash.h"

Expand Down Expand Up @@ -36,4 +36,4 @@ extern int cache_insert(struct cache *cache, char *key, void *data);
extern int cache_remove(struct cache *cache, char *key);
extern int cache_removeall(struct cache *cache, void *opaque, int (*select_cb)(void *element, void *opaque));

#endif
#endif // for #ifndef CACHE_H
8 changes: 4 additions & 4 deletions src/common.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#ifndef _COMMON_H
#define _COMMON_H
#ifndef COMMON_H
#define COMMON_H

#include "uv.h"
#include "socks.h"

#define XSOCKS_VERSION "0.2.4"
#define XSOCKS_VERSION "0.2.5"

struct server_context {
int index;
Expand Down Expand Up @@ -36,4 +36,4 @@ void consumer_start(void *arg);
int parse_target_address(const struct xsocks_request *req, struct sockaddr *addr, char *host);
void cache_log(uint8_t atyp, const struct sockaddr *src_addr, const struct sockaddr *dst_addr, const char *host, uint16_t port, int hit);

#endif // for #ifndef _COMMON_H
#endif // for #ifndef COMMON_H
12 changes: 8 additions & 4 deletions src/daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ already_running(const char *pidfile) {
close(fd);
return(1);
}
logger_stderr("can't lock %s: %s\n", pidfile, strerror(errno));
logger_stderr("can't lock %s: %s", pidfile, strerror(errno));
exit(1);
}

/*
* create pid file
*/
if (ftruncate(fd, 0)) {
fprintf(stderr, "can't truncate %s: %s", pidfile, strerror(errno));
logger_stderr("can't truncate %s: %s", pidfile, strerror(errno));
exit(1);
}
sprintf(buf, "%ld\n", (long)getpid());
if (write(fd, buf, strlen(buf)+1) == -1) {
fprintf(stderr, "can't write %s: %s", pidfile, strerror(errno));
logger_stderr("can't write %s: %s", pidfile, strerror(errno));
exit(1);
}

Expand Down Expand Up @@ -92,7 +92,11 @@ daemonize(void) {

setsid();

if ((fd = open("/dev/null", O_RDWR, 0)) != -1) {
if ((fd = open("/dev/null", O_RDWR, 0)) == -1) {
logger_stderr("open [/dev/null] failed (%d: %s)", errno, strerror(errno));
return -1;

} else {
dup2(fd, STDIN_FILENO);
dup2(fd, STDOUT_FILENO);
/* dup2(fd, STDERR_FILENO); */
Expand Down
6 changes: 3 additions & 3 deletions src/daemon.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef _DAEMON_H
#define _DAEMON_H
#ifndef DAEMON_H
#define DAEMON_H

int daemonize(void);
int already_running(const char *pidfile);
void create_pidfile(const char *pidfile);
void delete_pidfile(const char *pidfile);

#endif // for #ifndef _DAEMON_H
#endif // for #ifndef DAEMON_H
10 changes: 3 additions & 7 deletions src/getopt-win.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,8 @@ PROFITS, BUSINESS INTERRUPTION, LOSS OF PROGRAMS OR OTHER DATA ON
YOUR INFORMATION HANDLING SYSTEM OR OTHERWISE, EVEN If WE ARE
EXPRESSLY ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
#ifndef __GETOPT_H_
#define __GETOPT_H_

#ifdef _GETOPT_API
#undef _GETOPT_API
#endif
#ifndef GETOPT_WIN_H
#define GETOPT_WIN_H

#if defined(EXPORTS_GETOPT) && defined(STATIC_GETOPT)
#error "The preprocessor definitions of EXPORTS_GETOPT and STATIC_GETOPT can only be used individually"
Expand Down Expand Up @@ -135,4 +131,4 @@ _END_EXTERN_C
#define option option_a
#define optarg optarg_a
#endif
#endif // __GETOPT_H_
#endif // for #ifndef GETOPT_WIN_H
6 changes: 3 additions & 3 deletions src/logger.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef _LOGGER_H
#define _LOGGER_H
#ifndef LOGGER_H
#define LOGGER_H

#include <stdint.h>

Expand All @@ -21,4 +21,4 @@ void logger_exit(void);
void logger_stderr(const char *msg, ...);
void logger_log(uint32_t level, const char *msg, ...);

#endif // for #ifndef _LOGGER_H
#endif // for #ifndef LOGGER_H
6 changes: 3 additions & 3 deletions src/packet.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef _PACKET_H
#define _PACKET_H
#ifndef PACKET_H
#define PACKET_H

#include <stdint.h>
#include <stdlib.h>
Expand All @@ -25,4 +25,4 @@ struct packet {
int packet_filter(struct packet *packet, const char *buf, ssize_t buflen);
void packet_reset(struct packet *packet);

#endif // for #ifndef _PACKET_H
#endif // for #ifndef PACKET_H
6 changes: 3 additions & 3 deletions src/resolver.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef _RESOLVER_H
#define _RESOLVER_H
#ifndef RESOLVER_H
#define RESOLVER_H

#include <stdint.h>
#include "uv.h"
Expand All @@ -25,4 +25,4 @@ void resolver_shutdown(struct resolver_context *ctx);
void resolver_destroy(struct resolver_context *ctx);
const char * resolver_error(struct resolver_query *query);

#endif // for #ifndef _RESOLVER_H
#endif // for #ifndef RESOLVER_H
6 changes: 3 additions & 3 deletions src/socks.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef _SOCKS_H
#define _SOCKS_H
#ifndef SOCKS_H
#define SOCKS_H

#pragma pack(push,1)

Expand Down Expand Up @@ -83,4 +83,4 @@ enum xstage {
XSTAGE_DEAD,
};

#endif // for #ifndef _SOCKS_H
#endif // for #ifndef SOCKS_H
6 changes: 3 additions & 3 deletions src/udprelay.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef _UDPRELAY_H
#define _UDPRELAY_H
#ifndef UDPRELAY_H
#define UDPRELAY_H

#include "uv.h"
#include "common.h"
Expand All @@ -9,4 +9,4 @@ int udprelay_start(uv_loop_t *loop, struct server_context *server);
void udprelay_close(struct server_context *server);
void udprelay_destroy();

#endif // for #ifndef _UDPRELAY_H
#endif // for #ifndef UDPRELAY_H
6 changes: 3 additions & 3 deletions src/util.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef _UTIL_H
#define _UTIL_H
#ifndef UTIL_H
#define UTIL_H

#include <stdio.h>
#include <stdint.h>
Expand All @@ -16,4 +16,4 @@ int ip_name(const struct sockaddr *ip, char *name, size_t size);
uv_os_sock_t create_socket(int type, int reuse);
void dump_hex(const void *data, uint32_t len, char *title);

#endif // for #ifndef _UTIL_H
#endif // for #ifndef UTIL_H
6 changes: 3 additions & 3 deletions src/xforwarder.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef _XFORWARDER_H
#define _XFORWARDER_H
#ifndef XFORWARDER_H
#define XFORWARDER_H

#include "uv.h"
#include "socks.h"
Expand Down Expand Up @@ -62,4 +62,4 @@ struct sockaddr bind_addr;
struct sockaddr dest_addr;
struct sockaddr server_addr;

#endif // for #ifndef _XFORWARDER_H
#endif // for #ifndef XFORWARDER_H
6 changes: 3 additions & 3 deletions src/xsocks.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef _XSOCKS_H
#define _XSOCKS_H
#ifndef XSOCKS_H
#define XSOCKS_H

#include "uv.h"
#include "socks.h"
Expand Down Expand Up @@ -60,4 +60,4 @@ uint16_t idle_timeout;
struct sockaddr bind_addr;
struct sockaddr server_addr;

#endif // for #ifndef _XSOCKS_H
#endif // for #ifndef XSOCKS_H
4 changes: 2 additions & 2 deletions src/xsocksd.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,6 @@ main(int argc, char *argv[]) {
}
#endif

init();

#ifndef _WIN32
if (daemon_mode) {
if (daemonize()) {
Expand All @@ -258,6 +256,8 @@ main(int argc, char *argv[]) {
}
#endif

init();

loop = uv_default_loop();

rc = resolve_addr(local_addrbuf, &local_addr);
Expand Down
6 changes: 3 additions & 3 deletions src/xsocksd.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef _XSOCKSD_H
#define _XSOCKSD_H
#ifndef XSOCKSD_H
#define XSOCKSD_H

#include "uv.h"
#include "socks.h"
Expand Down Expand Up @@ -63,4 +63,4 @@ int verbose;
uint16_t idle_timeout;
uv_key_t thread_resolver_key;

#endif // for #ifndef _XSOCKSD_H
#endif // for #ifndef XSOCKSD_H
Loading

0 comments on commit 2b17b50

Please sign in to comment.