Commit 27ba7d64 authored by Max Lv's avatar Max Lv

fix a very old bug in redsocks

parent 8fb5d7f8
...@@ -780,7 +780,7 @@ static int redsocks_init_instance(redsocks_instance *instance) ...@@ -780,7 +780,7 @@ static int redsocks_init_instance(redsocks_instance *instance)
int on = 1; int on = 1;
int fd = -1; int fd = -1;
fd = socket(AF_INET, SOCK_STREAM, 0); fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (fd == -1) { if (fd == -1) {
log_errno(LOG_ERR, "socket"); log_errno(LOG_ERR, "socket");
goto fail; goto fail;
......
/* /*
* Copyright (C) 2012-2013 Jorrit "Chainfire" Jongma * Copyright (C) 2012-2014 Jorrit "Chainfire" Jongma
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
......
/* /*
* Copyright (C) 2012-2013 Jorrit "Chainfire" Jongma * Copyright (C) 2012-2014 Jorrit "Chainfire" Jongma
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -18,6 +18,7 @@ package eu.chainfire.libsuperuser; ...@@ -18,6 +18,7 @@ package eu.chainfire.libsuperuser;
import android.os.Looper; import android.os.Looper;
import android.util.Log; import android.util.Log;
import com.github.shadowsocks.BuildConfig; import com.github.shadowsocks.BuildConfig;
/** /**
......
/* /*
* Copyright (C) 2012-2013 Jorrit "Chainfire" Jongma * Copyright (C) 2012-2014 Jorrit "Chainfire" Jongma
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
......
/* /*
* Copyright (C) 2012-2013 Jorrit "Chainfire" Jongma * Copyright (C) 2012-2014 Jorrit "Chainfire" Jongma
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
......
/* /*
* Copyright (C) 2012-2013 Jorrit "Chainfire" Jongma * Copyright (C) 2012-2014 Jorrit "Chainfire" Jongma
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
......
...@@ -341,6 +341,7 @@ class Shadowsocks ...@@ -341,6 +341,7 @@ class Shadowsocks
ab.clear() ab.clear()
ab.append("kill -9 `cat /data/data/com.github.shadowsocks/redsocks.pid`") ab.append("kill -9 `cat /data/data/com.github.shadowsocks/redsocks.pid`")
ab.append("rm /data/data/com.github.shadowsocks/redsocks.conf") ab.append("rm /data/data/com.github.shadowsocks/redsocks.conf")
ab.append("rm /data/data/com.github.shadowsocks/redsocks.pid")
ab.append(Utils.getIptables + " -t nat -F OUTPUT") ab.append(Utils.getIptables + " -t nat -F OUTPUT")
Console.runRootCommand(ab.toArray) Console.runRootCommand(ab.toArray)
......
...@@ -137,18 +137,27 @@ class ShadowsocksNatService extends Service with BaseService { ...@@ -137,18 +137,27 @@ class ShadowsocksNatService extends Service with BaseService {
if (BuildConfig.DEBUG) Log.d(TAG, cmd.mkString(" ")) if (BuildConfig.DEBUG) Log.d(TAG, cmd.mkString(" "))
Core.sstunnel(cmd.toArray) Core.sstunnel(cmd.toArray)
} else { } else {
val conf = { val cmdBuf = new ArrayBuffer[String]
ConfigUtils.PDNSD.format("127.0.0.1") cmdBuf += ("ss-tunnel"
} , "-b", "127.0.0.1"
, "-l", "8163"
, "-L", "8.8.8.8:53"
, "-s", config.proxy
, "-p", config.remotePort.toString
, "-k", config.sitekey
, "-m", config.encMethod
, "-f", Path.BASE + "ss-tunnel.pid")
if (BuildConfig.DEBUG) Log.d(TAG, cmdBuf.mkString(" "))
Core.sstunnel(cmdBuf.toArray)
val conf = ConfigUtils
.PDNSD_BYPASS.format("127.0.0.1", getString(R.string.exclude), 8163)
ConfigUtils.printToFile(new File(Path.BASE + "pdnsd.conf"))(p => { ConfigUtils.printToFile(new File(Path.BASE + "pdnsd.conf"))(p => {
p.println(conf) p.println(conf)
}) })
val cmd = Path.BASE + "pdnsd -c " + Path.BASE + "pdnsd.conf"
val args = "pdnsd -c " + Path.BASE + "pdnsd.conf"
val cmd = Path.BASE + args
if (BuildConfig.DEBUG) Log.d(TAG, cmd) if (BuildConfig.DEBUG) Log.d(TAG, cmd)
Console.runRootCommand(cmd) Core.pdnsd(cmd.split(" "))
} }
} }
...@@ -172,7 +181,7 @@ class ShadowsocksNatService extends Service with BaseService { ...@@ -172,7 +181,7 @@ class ShadowsocksNatService extends Service with BaseService {
p.println(conf) p.println(conf)
}) })
val cmd = Path.BASE + args val cmd = Path.BASE + args
Console.runRootCommand(cmd) Console.runCommand(cmd)
} }
/** Called when the activity is first created. */ /** Called when the activity is first created. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment