Skip to content

Commit 5b24058

Browse files
committed
fixed "Connection refused" error when fast stop and start vpn. change ss-libev version
1 parent cc1c265 commit 5b24058

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+613
-326
lines changed

CHANGE.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
##1.0.5 Beta
2+
3+
+ Fixed "Connection refused" error when fast stop and start vpn.
4+
+ change ss-libev version
5+
6+
##1.0.4 Beta
7+
8+
+ Add SSR UI.
9+
110
##1.0.3 Beta Fix2
211

312
+ Fixed dns relay issue.

app/app.iml

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@
9494
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
9595
<orderEntry type="sourceFolder" forTests="false" />
9696
<orderEntry type="library" exported="" name="org.xbill.dns_2.1.7" level="project" />
97-
<orderEntry type="library" exported="" name="core-2.0" level="project" />
9897
<orderEntry type="library" exported="" name="gson-2.3.1" level="project" />
98+
<orderEntry type="library" exported="" name="core-2.0" level="project" />
9999
<orderEntry type="library" exported="" name="recyclerview-v7-23.0.1" level="project" />
100100
<orderEntry type="library" exported="" name="core-3.1.0" level="project" />
101101
<orderEntry type="library" exported="" name="android-2.0" level="project" />

app/build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ android {
1010
applicationId "com.proxy.shadowsocksr"
1111
minSdkVersion 17
1212
targetSdkVersion 23
13-
versionCode 5
14-
versionName "1.0.4 Beta"
13+
versionCode 6
14+
versionName "1.0.5 Beta"
1515
}
1616
buildTypes {
1717
debug {
1818
ndk {
1919
moduleName "Jni"
2020
stl "stlport_static"
21-
abiFilters "armeabi-v7a", "arm64-v8a", "x86_64"
21+
abiFilters "armeabi-v7a", "arm64-v8a"
2222
}
2323
minifyEnabled true
2424
shrinkResources true
0 Bytes
Binary file not shown.
4 KB
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

app/src/main/assets/x86_64/pdnsd

-210 KB
Binary file not shown.

app/src/main/assets/x86_64/redsocks

-132 KB
Binary file not shown.

app/src/main/assets/x86_64/ss-local

-663 KB
Binary file not shown.

app/src/main/assets/x86_64/ss-tunnel

-651 KB
Binary file not shown.

app/src/main/assets/x86_64/tun2socks

-164 KB
Binary file not shown.

app/src/main/java/com/proxy/shadowsocksr/MainActivity.java

+2
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ private void addNewServer(String server, int rmtPort, String method, String pwd)
374374
}
375375
try
376376
{
377+
fab.setEnabled(false);
377378
if (ssrs.status())
378379
{
379380
ssrs.stop();
@@ -501,5 +502,6 @@ public void switchUI(boolean enable)
501502
fab.setImageResource(android.R.drawable.ic_media_pause);
502503
//
503504
}
505+
fab.setEnabled(true);
504506
}
505507
}

app/src/main/java/com/proxy/shadowsocksr/SSRVPNService.java

+32-28
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,6 @@ public class SSRVPNService extends VpnService
6161

6262
@Override public void onRevoke()
6363
{
64-
if (vpnThread != null)
65-
{
66-
vpnThread.stopThread();
67-
vpnThread = null;
68-
}
69-
70-
isVPNConnected = false;
71-
72-
try
73-
{
74-
callback.onStatusChanged(Consts.STATUS_DISCONNECTED);
75-
}
76-
catch (RemoteException ignored)
77-
{
78-
}
79-
8064
stopRunner();
8165
}
8266

@@ -129,7 +113,14 @@ class SSRService extends ISSRService.Stub
129113

130114
@Override public void stop() throws RemoteException
131115
{
132-
onRevoke();
116+
stopRunner();
117+
try
118+
{
119+
callback.onStatusChanged(Consts.STATUS_DISCONNECTED);
120+
}
121+
catch (RemoteException ignored)
122+
{
123+
}
133124
}
134125
}
135126

@@ -477,14 +468,15 @@ private int startVpn()
477468

478469
private void killProcesses()
479470
{
480-
String[] tasks = new String[]{"ss-local", "ss-tunnel", "pdnsd", "tun2socks"};
471+
final String[] tasks = new String[]{"ss-local", "ss-tunnel", "pdnsd", "tun2socks"};
481472
List<String> cmds = new ArrayList<>();
473+
String[] cmdarr;
482474

483475
for (String task : tasks)
484476
{
485477
cmds.add(String.format("chmod 666 %s%s-vpn.pid", Consts.baseDir, task));
486478
}
487-
String[] cmdarr = new String[cmds.size()];
479+
cmdarr = new String[cmds.size()];
488480
cmds.toArray(cmdarr);
489481
ShellUtil.runCmd(cmdarr);
490482
cmds.clear();
@@ -503,8 +495,6 @@ private void killProcesses()
503495
cmds.add(String.format("rm -f %s%s-vpn.conf", Consts.baseDir, t));
504496
cmds.add(String.format("rm -f %s%s-vpn.pid", Consts.baseDir, t));
505497
}
506-
cmds.add("rm -f " + Consts.baseDir + "protect_path");
507-
cmds.add("rm -f " + Consts.baseDir + "sock_path");
508498
cmdarr = new String[cmds.size()];
509499
cmds.toArray(cmdarr);
510500
ShellUtil.runCmd(cmdarr);
@@ -525,13 +515,30 @@ private void killProcesses()
525515
// return a == 10 || (a == 192 && b == 168) || (a == 172 && b >= 16 && b < 32);
526516
// }
527517

518+
private void rebootThread()
519+
{//May be accept() throw exception
520+
if (vpnThread != null)
521+
{
522+
vpnThread.stopThread();
523+
}
524+
vpnThread = new SSRVPNThread();
525+
vpnThread.start();
526+
}
527+
528528
class SSRVPNThread extends Thread
529529
{
530530
volatile private LocalServerSocket lss;
531531
volatile private boolean isRunning = true;
532532

533-
@Override public void run()
533+
@SuppressWarnings("ResultOfMethodCallIgnored") @Override public void run()
534534
{
535+
try
536+
{
537+
new File(Consts.baseDir + "protect_path").delete();
538+
}
539+
catch (Exception ignored)
540+
{}
541+
535542
try
536543
{
537544
LocalSocket stk = new LocalSocket();
@@ -541,7 +548,6 @@ class SSRVPNThread extends Thread
541548
}
542549
catch (IOException e)
543550
{
544-
Log.e("EXCE-BIND ERR", e.getMessage());
545551
return;
546552
}
547553

@@ -552,7 +558,6 @@ class SSRVPNThread extends Thread
552558
try
553559
{
554560
final LocalSocket ls = lss.accept();
555-
556561
exec.execute(new Runnable()
557562
{
558563
@SuppressWarnings("ResultOfMethodCallIgnored") @Override public void run()
@@ -563,10 +568,9 @@ class SSRVPNThread extends Thread
563568
OutputStream os = ls.getOutputStream();
564569

565570
is.read();
566-
567571
FileDescriptor[] fds = ls.getAncillaryFileDescriptors();
568572

569-
if (fds!=null && fds.length > 0)
573+
if (fds != null && fds.length > 0)
570574
{
571575
Method getInt = FileDescriptor.class.getDeclaredMethod(
572576
"getInt$");
@@ -581,9 +585,8 @@ class SSRVPNThread extends Thread
581585
os.close();
582586
}
583587
}
584-
catch (Exception e)
588+
catch (Exception ignored)
585589
{
586-
Log.e("EXCE-internal", e.getMessage());
587590
}
588591
try
589592
{
@@ -598,6 +601,7 @@ class SSRVPNThread extends Thread
598601
catch (Exception e)
599602
{
600603
Log.e("EXCE-accept", e.getMessage());
604+
rebootThread();
601605
return;
602606
}
603607
}

app/src/main/jni/Application.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
#APP_ABI := armeabi-v7a
12
APP_ABI := armeabi-v7a arm64-v8a x86 x86_64
2-
#APP_ABI := armeabi-v7a arm64-v8a x86 x86_64
33
APP_PLATFORM := android-17
44
APP_STL := stlport_static
55
NDK_TOOLCHAIN_VERSION := 4.9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
SUBDIRS = libsodium libcork libipset libudns libev src
22

33
ACLOCAL_AMFLAGS = -I m4
4-
man_MANS = shadowsocks-libev.8
4+
man_MANS = man/shadowsocks-libev.8 man/ss-server.1 man/ss-local.1 man/ss-redir.1\
5+
man/ss-manager.1 man/ss-tunnel.1
56

67
pkgconfiglibdir = $(libdir)/pkgconfig
78
pkgconfiglib_DATA = shadowsocks-libev.pc

app/src/main/jni/shadowsocks-libev/Makefile.in

+57-9
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/acx_pthread.m4 \
6565
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
6666
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/mbedtls.m4 \
6767
$(top_srcdir)/m4/openssl.m4 $(top_srcdir)/m4/polarssl.m4 \
68-
$(top_srcdir)/libev/libev.m4 $(top_srcdir)/configure.ac
68+
$(top_srcdir)/m4/zlib.m4 $(top_srcdir)/libev/libev.m4 \
69+
$(top_srcdir)/configure.ac
6970
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
7071
$(ACLOCAL_M4)
7172
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
@@ -121,9 +122,10 @@ am__uninstall_files_from_dir = { \
121122
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
122123
$(am__cd) "$$dir" && rm -f $$files; }; \
123124
}
124-
man8dir = $(mandir)/man8
125-
am__installdirs = "$(DESTDIR)$(man8dir)" \
125+
man1dir = $(mandir)/man1
126+
am__installdirs = "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man8dir)" \
126127
"$(DESTDIR)$(pkgconfiglibdir)"
128+
man8dir = $(mandir)/man8
127129
NROFF = nroff
128130
MANS = $(man_MANS)
129131
DATA = $(pkgconfiglib_DATA)
@@ -298,7 +300,9 @@ top_builddir = @top_builddir@
298300
top_srcdir = @top_srcdir@
299301
SUBDIRS = libsodium libcork libipset libudns libev src
300302
ACLOCAL_AMFLAGS = -I m4
301-
man_MANS = shadowsocks-libev.8
303+
man_MANS = man/shadowsocks-libev.8 man/ss-server.1 man/ss-local.1 man/ss-redir.1\
304+
man/ss-manager.1 man/ss-tunnel.1
305+
302306
pkgconfiglibdir = $(libdir)/pkgconfig
303307
pkgconfiglib_DATA = shadowsocks-libev.pc
304308
all: config.h
@@ -365,6 +369,49 @@ clean-libtool:
365369

366370
distclean-libtool:
367371
-rm -f libtool config.lt
372+
install-man1: $(man_MANS)
373+
@$(NORMAL_INSTALL)
374+
@list1=''; \
375+
list2='$(man_MANS)'; \
376+
test -n "$(man1dir)" \
377+
&& test -n "`echo $$list1$$list2`" \
378+
|| exit 0; \
379+
echo " $(MKDIR_P) '$(DESTDIR)$(man1dir)'"; \
380+
$(MKDIR_P) "$(DESTDIR)$(man1dir)" || exit 1; \
381+
{ for i in $$list1; do echo "$$i"; done; \
382+
if test -n "$$list2"; then \
383+
for i in $$list2; do echo "$$i"; done \
384+
| sed -n '/\.1[a-z]*$$/p'; \
385+
fi; \
386+
} | while read p; do \
387+
if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
388+
echo "$$d$$p"; echo "$$p"; \
389+
done | \
390+
sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
391+
-e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
392+
sed 'N;N;s,\n, ,g' | { \
393+
list=; while read file base inst; do \
394+
if test "$$base" = "$$inst"; then list="$$list $$file"; else \
395+
echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \
396+
$(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \
397+
fi; \
398+
done; \
399+
for i in $$list; do echo "$$i"; done | $(am__base_list) | \
400+
while read files; do \
401+
test -z "$$files" || { \
402+
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \
403+
$(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \
404+
done; }
405+
406+
uninstall-man1:
407+
@$(NORMAL_UNINSTALL)
408+
@list=''; test -n "$(man1dir)" || exit 0; \
409+
files=`{ for i in $$list; do echo "$$i"; done; \
410+
l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \
411+
sed -n '/\.1[a-z]*$$/p'; \
412+
} | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
413+
-e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
414+
dir='$(DESTDIR)$(man1dir)'; $(am__uninstall_files_from_dir)
368415
install-man8: $(man_MANS)
369416
@$(NORMAL_INSTALL)
370417
@list1=''; \
@@ -770,7 +817,7 @@ check: check-recursive
770817
all-am: Makefile $(MANS) $(DATA) config.h
771818
installdirs: installdirs-recursive
772819
installdirs-am:
773-
for dir in "$(DESTDIR)$(man8dir)" "$(DESTDIR)$(pkgconfiglibdir)"; do \
820+
for dir in "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man8dir)" "$(DESTDIR)$(pkgconfiglibdir)"; do \
774821
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
775822
done
776823
install: install-recursive
@@ -841,7 +888,7 @@ install-info: install-info-recursive
841888

842889
install-info-am:
843890

844-
install-man: install-man8
891+
install-man: install-man1 install-man8
845892

846893
install-pdf: install-pdf-recursive
847894

@@ -873,7 +920,7 @@ ps-am:
873920

874921
uninstall-am: uninstall-man uninstall-pkgconfiglibDATA
875922

876-
uninstall-man: uninstall-man8
923+
uninstall-man: uninstall-man1 uninstall-man8
877924

878925
.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all \
879926
ctags-recursive install-am install-strip tags-recursive
@@ -888,13 +935,14 @@ uninstall-man: uninstall-man8
888935
install install-am install-data install-data-am install-dvi \
889936
install-dvi-am install-exec install-exec-am install-html \
890937
install-html-am install-info install-info-am install-man \
891-
install-man8 install-pdf install-pdf-am \
938+
install-man1 install-man8 install-pdf install-pdf-am \
892939
install-pkgconfiglibDATA install-ps install-ps-am \
893940
install-strip installcheck installcheck-am installdirs \
894941
installdirs-am maintainer-clean maintainer-clean-generic \
895942
mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
896943
ps ps-am tags tags-recursive uninstall uninstall-am \
897-
uninstall-man uninstall-man8 uninstall-pkgconfiglibDATA
944+
uninstall-man uninstall-man1 uninstall-man8 \
945+
uninstall-pkgconfiglibDATA
898946

899947

900948
# Tell versions [3.59,3.63) of GNU make to not export all variables.

app/src/main/jni/shadowsocks-libev/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ It is a port of [shadowsocks](https://github.com/shadowsocks/shadowsocks)
1111
created by [@clowwindy](https://github.com/clowwindy) maintained by
1212
[@madeye](https://github.com/madeye) and [@linusyang](https://github.com/linusyang).
1313

14-
Current version: 2.3.1 | [Changelog](debian/changelog)
14+
Current version: 2.3.3 | [Changelog](debian/changelog)
1515

1616
Travis CI: [![Travis CI](https://travis-ci.org/shadowsocks/shadowsocks-libev.png?branch=master)](https://travis-ci.org/shadowsocks/shadowsocks-libev) | Jenkins Matrix: [![Jenkins](https://jenkins.shadowvpn.org/buildStatus/icon?job=Shadowsocks-libev)](https://jenkins.shadowvpn.org/job/Shadowsocks-libev/)
1717

app/src/main/jni/shadowsocks-libev/aclocal.m4

+1
Original file line numberDiff line numberDiff line change
@@ -1173,3 +1173,4 @@ m4_include([m4/lt~obsolete.m4])
11731173
m4_include([m4/mbedtls.m4])
11741174
m4_include([m4/openssl.m4])
11751175
m4_include([m4/polarssl.m4])
1176+
m4_include([m4/zlib.m4])

app/src/main/jni/shadowsocks-libev/config.h.in

+6
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,12 @@
245245
/* Define to 1 if you have the <ws2tcpip.h> header file. */
246246
#undef HAVE_WS2TCPIP_H
247247

248+
/* have zlib compression support */
249+
#undef HAVE_ZLIB
250+
251+
/* Define to 1 if you have the <zlib.h> header file. */
252+
#undef HAVE_ZLIB_H
253+
248254
/* Define to the sub-directory in which libtool stores uninstalled libraries.
249255
*/
250256
#undef LT_OBJDIR

0 commit comments

Comments
 (0)