@@ -122,6 +122,7 @@ class SSRService extends ISSRService.Stub
122
122
{
123
123
proxyApps = cp .proxyApps ;
124
124
}
125
+ //
125
126
checkDaemonFile ();
126
127
startRunner ();
127
128
}
@@ -190,6 +191,13 @@ private void startRunner()
190
191
vpnThread = new SSRVPNThread ();
191
192
vpnThread .start ();
192
193
//
194
+ // Executors.newSingleThreadExecutor().submit(new Runnable()
195
+ // {
196
+ // @Override public void run()
197
+ // {
198
+ //
199
+ // }
200
+ // });
193
201
new Thread (new Runnable ()
194
202
{
195
203
@ Override public void run ()
@@ -270,7 +278,6 @@ private void stopRunner()
270
278
vpnThread .stopThread ();
271
279
vpnThread = null ;
272
280
}
273
-
274
281
//reset
275
282
killProcesses ();
276
283
@@ -301,15 +308,12 @@ private void startSSRDaemon()
301
308
ssrProfile .remotePort ,
302
309
ssrProfile .localPort ,
303
310
ssrProfile .passwd ,
304
- ssrProfile .cryptMethod ,
305
- 10 );
311
+ ssrProfile .cryptMethod , 10 );
306
312
ConfFileUtil .writeToFile (ssrconf , new File (Consts .baseDir + "ss-local-vpn.conf" ));
307
313
308
314
StringBuilder sb = new StringBuilder ();
309
- sb .append (
310
- Consts .baseDir + "ss-local -V -u -b 127.0.0.1 -t 600 -c " + Consts .baseDir +
311
- "ss-local-vpn.conf -f " + Consts .baseDir +
312
- "ss-local-vpn.pid" );
315
+ sb .append (Consts .baseDir + "ss-local -V -u -b 127.0.0.1 -t 600 -c " + Consts .baseDir +
316
+ "ss-local-vpn.conf -f " + Consts .baseDir + "ss-local-vpn.pid" );
313
317
314
318
//AUTH
315
319
@@ -530,13 +534,14 @@ class SSRVPNThread extends Thread
530
534
{
531
535
try
532
536
{
533
- LocalSocket ls = new LocalSocket ();
534
- ls .bind (new LocalSocketAddress (Consts .baseDir + "protect_path" ,
535
- LocalSocketAddress .Namespace .FILESYSTEM ));
536
- lss = new LocalServerSocket (ls .getFileDescriptor ());
537
+ LocalSocket stk = new LocalSocket ();
538
+ stk .bind (new LocalSocketAddress (Consts .baseDir + "protect_path" ,
539
+ LocalSocketAddress .Namespace .FILESYSTEM ));
540
+ lss = new LocalServerSocket (stk .getFileDescriptor ());
537
541
}
538
542
catch (IOException e )
539
543
{
544
+ Log .e ("EXCE-BIND ERR" , e .getMessage ());
540
545
return ;
541
546
}
542
547
@@ -547,6 +552,7 @@ class SSRVPNThread extends Thread
547
552
try
548
553
{
549
554
final LocalSocket ls = lss .accept ();
555
+
550
556
exec .execute (new Runnable ()
551
557
{
552
558
@ SuppressWarnings ("ResultOfMethodCallIgnored" ) @ Override public void run ()
@@ -560,10 +566,10 @@ class SSRVPNThread extends Thread
560
566
561
567
FileDescriptor [] fds = ls .getAncillaryFileDescriptors ();
562
568
563
- if (fds .length > 0 )
569
+ if (fds != null && fds .length > 0 )
564
570
{
565
- Method getInt = FileDescriptor .class
566
- . getDeclaredMethod ( "getInt$" );
571
+ Method getInt = FileDescriptor .class . getDeclaredMethod (
572
+ "getInt$" );
567
573
Integer fd = (Integer ) getInt .invoke (fds [0 ]);
568
574
boolean ret = protect (fd );
569
575
@@ -573,20 +579,25 @@ class SSRVPNThread extends Thread
573
579
574
580
is .close ();
575
581
os .close ();
576
- ls .close ();
577
582
}
578
583
}
579
584
catch (Exception e )
580
585
{
581
- Log .e ("EXCE" , e .getMessage ());
582
- e .printStackTrace ();
586
+ Log .e ("EXCE-internal" , e .getMessage ());
587
+ }
588
+ try
589
+ {
590
+ ls .close ();
591
+ }
592
+ catch (IOException ignored )
593
+ {
583
594
}
584
595
}
585
596
});
586
597
}
587
598
catch (Exception e )
588
599
{
589
- Log .e ("EXCE" , "OUT" );
600
+ Log .e ("EXCE-accept" , e . getMessage () );
590
601
return ;
591
602
}
592
603
}
@@ -607,7 +618,7 @@ private void closeServerSocket()
607
618
}
608
619
}
609
620
610
- private void stopThread ()
621
+ public void stopThread ()
611
622
{
612
623
isRunning = false ;
613
624
closeServerSocket ();
0 commit comments