Skip to content

Commit 5f3c2e1

Browse files
committed
Add ss-manager for multi-user control and traffic statistics.
1 parent e2654bf commit 5f3c2e1

13 files changed

+945
-27
lines changed

configure

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! /bin/sh
22
# Guess values for system-dependent variables and create Makefiles.
3-
# Generated by GNU Autoconf 2.69 for shadowsocks-libev 2.2.4.
3+
# Generated by GNU Autoconf 2.69 for shadowsocks-libev 2.3.0.
44
#
55
# Report bugs to <[email protected]>.
66
#
@@ -590,8 +590,8 @@ MAKEFLAGS=
590590
# Identity of this package.
591591
PACKAGE_NAME='shadowsocks-libev'
592592
PACKAGE_TARNAME='shadowsocks-libev'
593-
PACKAGE_VERSION='2.2.4'
594-
PACKAGE_STRING='shadowsocks-libev 2.2.4'
593+
PACKAGE_VERSION='2.3.0'
594+
PACKAGE_STRING='shadowsocks-libev 2.3.0'
595595
PACKAGE_BUGREPORT='[email protected]'
596596
PACKAGE_URL=''
597597

@@ -1339,7 +1339,7 @@ if test "$ac_init_help" = "long"; then
13391339
# Omit some internal or obsolete options to make the list less imposing.
13401340
# This message is too long to be a string in the A/UX 3.1 sh.
13411341
cat <<_ACEOF
1342-
\`configure' configures shadowsocks-libev 2.2.4 to adapt to many kinds of systems.
1342+
\`configure' configures shadowsocks-libev 2.3.0 to adapt to many kinds of systems.
13431343

13441344
Usage: $0 [OPTION]... [VAR=VALUE]...
13451345

@@ -1410,7 +1410,7 @@ fi
14101410

14111411
if test -n "$ac_init_help"; then
14121412
case $ac_init_help in
1413-
short | recursive ) echo "Configuration of shadowsocks-libev 2.2.4:";;
1413+
short | recursive ) echo "Configuration of shadowsocks-libev 2.3.0:";;
14141414
esac
14151415
cat <<\_ACEOF
14161416

@@ -1536,7 +1536,7 @@ fi
15361536
test -n "$ac_init_help" && exit $ac_status
15371537
if $ac_init_version; then
15381538
cat <<\_ACEOF
1539-
shadowsocks-libev configure 2.2.4
1539+
shadowsocks-libev configure 2.3.0
15401540
generated by GNU Autoconf 2.69
15411541

15421542
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2059,7 +2059,7 @@ cat >config.log <<_ACEOF
20592059
This file contains any messages produced by compilers while
20602060
running configure, to aid debugging if configure makes a mistake.
20612061

2062-
It was created by shadowsocks-libev $as_me 2.2.4, which was
2062+
It was created by shadowsocks-libev $as_me 2.3.0, which was
20632063
generated by GNU Autoconf 2.69. Invocation command line was
20642064

20652065
$ $0 $@
@@ -2880,7 +2880,7 @@ fi
28802880

28812881
# Define the identity of the package.
28822882
PACKAGE='shadowsocks-libev'
2883-
VERSION='2.2.4'
2883+
VERSION='2.3.0'
28842884

28852885

28862886
cat >>confdefs.h <<_ACEOF
@@ -15894,7 +15894,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
1589415894
# report actual input values of CONFIG_FILES etc. instead of their
1589515895
# values after options handling.
1589615896
ac_log="
15897-
This file was extended by shadowsocks-libev $as_me 2.2.4, which was
15897+
This file was extended by shadowsocks-libev $as_me 2.3.0, which was
1589815898
generated by GNU Autoconf 2.69. Invocation command line was
1589915899

1590015900
CONFIG_FILES = $CONFIG_FILES
@@ -15960,7 +15960,7 @@ _ACEOF
1596015960
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
1596115961
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
1596215962
ac_cs_version="\\
15963-
shadowsocks-libev config.status 2.2.4
15963+
shadowsocks-libev config.status 2.3.0
1596415964
configured by $0, generated by GNU Autoconf 2.69,
1596515965
with options \\"\$ac_cs_config\\"
1596615966

configure.ac

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ dnl -*- Autoconf -*-
22
dnl Process this file with autoconf to produce a configure script.
33

44
AC_PREREQ([2.67])
5-
AC_INIT([shadowsocks-libev], [2.2.4], [[email protected]])
5+
AC_INIT([shadowsocks-libev], [2.3.0], [[email protected]])
66
AC_CONFIG_SRCDIR([src/encrypt.c])
77
AC_CONFIG_HEADERS([config.h])
88
AC_CONFIG_AUX_DIR(auto)

debian/changelog

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
shadowsocks-libev (2.2.4-1) unstable; urgency=low
1+
shadowsocks-libev (2.3.0-1) unstable; urgency=low
22

3+
* Add manager mode to support multi-user and traffic stat.
34
* Fix a build issue on OS X El Capitan.
45

56
-- Max Lv <[email protected]> Thu, 30 Jul 2015 17:30:43 +0900

openwrt/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
include $(TOPDIR)/rules.mk
22

33
PKG_NAME:=shadowsocks-libev
4-
PKG_VERSION:=2.2.4
4+
PKG_VERSION:=2.3.0
55
PKG_RELEASE=$(PKG_SOURCE_VERSION)
66

77
PKG_SOURCE_URL:=https://github.com/shadowsocks/shadowsocks-libev/archive

src/Makefile.am

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ SS_COMMON_LIBS = $(PTHREAD_LIBS) \
1919

2020
bin_PROGRAMS = ss-local ss-tunnel
2121
if !BUILD_WINCOMPAT
22-
bin_PROGRAMS += ss-server
22+
bin_PROGRAMS += ss-server ss-manager
2323
endif
2424

2525
ss_local_SOURCES = utils.c \
@@ -52,9 +52,15 @@ ss_server_SOURCES = utils.c \
5252
resolv.c \
5353
server.c
5454

55+
ss_manager_SOURCES = utils.c \
56+
jconf.c \
57+
json.c \
58+
manager.c
59+
5560
ss_local_LDADD = $(SS_COMMON_LIBS)
5661
ss_tunnel_LDADD = $(SS_COMMON_LIBS)
5762
ss_server_LDADD = $(SS_COMMON_LIBS)
63+
ss_manager_LDADD = $(SS_COMMON_LIBS)
5864
ss_local_LDADD += $(top_builddir)/libudns/libudns.la
5965
ss_tunnel_LDADD += $(top_builddir)/libudns/libudns.la
6066
ss_server_LDADD += $(top_builddir)/libudns/libudns.la

src/Makefile.in

+25-5
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ build_triplet = @build@
5555
host_triplet = @host@
5656
bin_PROGRAMS = ss-local$(EXEEXT) ss-tunnel$(EXEEXT) $(am__EXEEXT_1) \
5757
$(am__EXEEXT_2)
58-
@BUILD_WINCOMPAT_FALSE@am__append_1 = ss-server
58+
@BUILD_WINCOMPAT_FALSE@am__append_1 = ss-server ss-manager
5959
@BUILD_WINCOMPAT_TRUE@am__append_2 = win32.c
6060
@BUILD_WINCOMPAT_TRUE@am__append_3 = win32.c
6161
@BUILD_REDIRECTOR_TRUE@am__append_4 = ss-redir
@@ -133,7 +133,8 @@ libshadowsocks_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
133133
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
134134
$(libshadowsocks_la_CFLAGS) $(CFLAGS) \
135135
$(libshadowsocks_la_LDFLAGS) $(LDFLAGS) -o $@
136-
@BUILD_WINCOMPAT_FALSE@am__EXEEXT_1 = ss-server$(EXEEXT)
136+
@BUILD_WINCOMPAT_FALSE@am__EXEEXT_1 = ss-server$(EXEEXT) \
137+
@BUILD_WINCOMPAT_FALSE@ ss-manager$(EXEEXT)
137138
@BUILD_REDIRECTOR_TRUE@am__EXEEXT_2 = ss-redir$(EXEEXT)
138139
PROGRAMS = $(bin_PROGRAMS)
139140
am__ss_local_SOURCES_DIST = utils.c jconf.c json.c encrypt.c \
@@ -151,6 +152,10 @@ ss_local_DEPENDENCIES = $(am__DEPENDENCIES_2) \
151152
ss_local_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
152153
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(ss_local_CFLAGS) \
153154
$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
155+
am_ss_manager_OBJECTS = utils.$(OBJEXT) jconf.$(OBJEXT) json.$(OBJEXT) \
156+
manager.$(OBJEXT)
157+
ss_manager_OBJECTS = $(am_ss_manager_OBJECTS)
158+
ss_manager_DEPENDENCIES = $(am__DEPENDENCIES_2)
154159
am__ss_redir_SOURCES_DIST = utils.c jconf.c json.c encrypt.c \
155160
netutils.c cache.c udprelay.c redir.c
156161
@BUILD_REDIRECTOR_TRUE@am_ss_redir_OBJECTS = ss_redir-utils.$(OBJEXT) \
@@ -220,10 +225,12 @@ AM_V_GEN = $(am__v_GEN_@AM_V@)
220225
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
221226
am__v_GEN_0 = @echo " GEN " $@;
222227
SOURCES = $(libshadowsocks_la_SOURCES) $(ss_local_SOURCES) \
223-
$(ss_redir_SOURCES) $(ss_server_SOURCES) $(ss_tunnel_SOURCES)
228+
$(ss_manager_SOURCES) $(ss_redir_SOURCES) $(ss_server_SOURCES) \
229+
$(ss_tunnel_SOURCES)
224230
DIST_SOURCES = $(am__libshadowsocks_la_SOURCES_DIST) \
225-
$(am__ss_local_SOURCES_DIST) $(am__ss_redir_SOURCES_DIST) \
226-
$(ss_server_SOURCES) $(am__ss_tunnel_SOURCES_DIST)
231+
$(am__ss_local_SOURCES_DIST) $(ss_manager_SOURCES) \
232+
$(am__ss_redir_SOURCES_DIST) $(ss_server_SOURCES) \
233+
$(am__ss_tunnel_SOURCES_DIST)
227234
am__can_run_installinfo = \
228235
case $$AM_UPDATE_INFO_DIR in \
229236
n|no|NO) false;; \
@@ -384,9 +391,15 @@ ss_server_SOURCES = utils.c \
384391
resolv.c \
385392
server.c
386393

394+
ss_manager_SOURCES = utils.c \
395+
jconf.c \
396+
json.c \
397+
manager.c
398+
387399
ss_local_LDADD = $(SS_COMMON_LIBS) $(top_builddir)/libudns/libudns.la
388400
ss_tunnel_LDADD = $(SS_COMMON_LIBS) $(top_builddir)/libudns/libudns.la
389401
ss_server_LDADD = $(SS_COMMON_LIBS) $(top_builddir)/libudns/libudns.la
402+
ss_manager_LDADD = $(SS_COMMON_LIBS)
390403
ss_local_CFLAGS = $(AM_CFLAGS) -DUDPRELAY_LOCAL
391404
ss_tunnel_CFLAGS = $(AM_CFLAGS) -DUDPRELAY_LOCAL -DUDPRELAY_TUNNEL
392405
ss_server_CFLAGS = $(AM_CFLAGS) -DUDPRELAY_REMOTE
@@ -525,6 +538,9 @@ clean-binPROGRAMS:
525538
ss-local$(EXEEXT): $(ss_local_OBJECTS) $(ss_local_DEPENDENCIES) $(EXTRA_ss_local_DEPENDENCIES)
526539
@rm -f ss-local$(EXEEXT)
527540
$(AM_V_CCLD)$(ss_local_LINK) $(ss_local_OBJECTS) $(ss_local_LDADD) $(LIBS)
541+
ss-manager$(EXEEXT): $(ss_manager_OBJECTS) $(ss_manager_DEPENDENCIES) $(EXTRA_ss_manager_DEPENDENCIES)
542+
@rm -f ss-manager$(EXEEXT)
543+
$(AM_V_CCLD)$(LINK) $(ss_manager_OBJECTS) $(ss_manager_LDADD) $(LIBS)
528544
ss-redir$(EXEEXT): $(ss_redir_OBJECTS) $(ss_redir_DEPENDENCIES) $(EXTRA_ss_redir_DEPENDENCIES)
529545
@rm -f ss-redir$(EXEEXT)
530546
$(AM_V_CCLD)$(ss_redir_LINK) $(ss_redir_OBJECTS) $(ss_redir_LDADD) $(LIBS)
@@ -541,6 +557,8 @@ mostlyclean-compile:
541557
distclean-compile:
542558
-rm -f *.tab.c
543559

560+
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jconf.Po@am__quote@
561+
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/json.Po@am__quote@
544562
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libshadowsocks_la-acl.Plo@am__quote@
545563
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libshadowsocks_la-cache.Plo@am__quote@
546564
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libshadowsocks_la-encrypt.Plo@am__quote@
@@ -551,6 +569,7 @@ distclean-compile:
551569
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libshadowsocks_la-udprelay.Plo@am__quote@
552570
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libshadowsocks_la-utils.Plo@am__quote@
553571
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libshadowsocks_la-win32.Plo@am__quote@
572+
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/manager.Po@am__quote@
554573
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ss_local-acl.Po@am__quote@
555574
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ss_local-cache.Po@am__quote@
556575
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ss_local-encrypt.Po@am__quote@
@@ -588,6 +607,7 @@ distclean-compile:
588607
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ss_tunnel-udprelay.Po@am__quote@
589608
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ss_tunnel-utils.Po@am__quote@
590609
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ss_tunnel-win32.Po@am__quote@
610+
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utils.Po@am__quote@
591611

592612
.c.o:
593613
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\

src/jconf.c

+15
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,21 @@ jconf_t *read_jconf(const char * file)
159159
conf.remote_addr[0].port = NULL;
160160
conf.remote_num = 1;
161161
}
162+
} else if (strcmp(name, "port_password") == 0) {
163+
if (value->type == json_object) {
164+
for (j = 0; j < value->u.object.length; j++) {
165+
if (j >= MAX_PORT_NUM) {
166+
break;
167+
}
168+
json_value *v = value->u.object.values[j].value;
169+
if (v->type == json_string) {
170+
conf.port_password[j].port = ss_strndup(value->u.object.values[j].name,
171+
value->u.object.values[j].name_length);
172+
conf.port_password[j].password = to_string(v);
173+
conf.port_password_num = j + 1;
174+
}
175+
}
176+
}
162177
} else if (strcmp(name, "server_port") == 0) {
163178
conf.remote_port = to_string(value);
164179
} else if (strcmp(name, "local_address") == 0) {

src/jconf.h

+9-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
#ifndef _JCONF_H
2323
#define _JCONF_H
2424

25+
#define MAX_PORT_NUM 1024
2526
#define MAX_REMOTE_NUM 10
26-
#define MAX_CONF_SIZE 16 * 1024
27+
#define MAX_CONF_SIZE 128 * 1024
2728
#define MAX_DNS_NUM 4
2829
#define MAX_CONNECT_TIMEOUT 10
2930
#define MIN_UDP_TIMEOUT 60
@@ -33,9 +34,16 @@ typedef struct {
3334
char *port;
3435
} ss_addr_t;
3536

37+
typedef struct {
38+
char *port;
39+
char *password;
40+
} ss_port_password_t;
41+
3642
typedef struct {
3743
int remote_num;
3844
ss_addr_t remote_addr[MAX_REMOTE_NUM];
45+
int port_password_num;
46+
ss_port_password_t port_password[MAX_PORT_NUM];
3947
char *remote_port;
4048
char *local_addr;
4149
char *local_port;

0 commit comments

Comments
 (0)