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)
int on = 1;
int fd = -1;
fd = socket(AF_INET, SOCK_STREAM, 0);
fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (fd == -1) {
log_errno(LOG_ERR, "socket");
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");
* 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");
* you may not use this file except in compliance with the License.
......@@ -18,6 +18,7 @@ package eu.chainfire.libsuperuser;
import android.os.Looper;
import android.util.Log;
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");
* 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");
* 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");
* you may not use this file except in compliance with the License.
......
......@@ -341,6 +341,7 @@ class Shadowsocks
ab.clear()
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.pid")
ab.append(Utils.getIptables + " -t nat -F OUTPUT")
Console.runRootCommand(ab.toArray)
......
......@@ -137,18 +137,27 @@ class ShadowsocksNatService extends Service with BaseService {
if (BuildConfig.DEBUG) Log.d(TAG, cmd.mkString(" "))
Core.sstunnel(cmd.toArray)
} else {
val conf = {
ConfigUtils.PDNSD.format("127.0.0.1")
}
val cmdBuf = new ArrayBuffer[String]
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 => {
p.println(conf)
})
val args = "pdnsd -c " + Path.BASE + "pdnsd.conf"
val cmd = Path.BASE + args
val cmd = Path.BASE + "pdnsd -c " + Path.BASE + "pdnsd.conf"
if (BuildConfig.DEBUG) Log.d(TAG, cmd)
Console.runRootCommand(cmd)
Core.pdnsd(cmd.split(" "))
}
}
......@@ -172,7 +181,7 @@ class ShadowsocksNatService extends Service with BaseService {
p.println(conf)
})
val cmd = Path.BASE + args
Console.runRootCommand(cmd)
Console.runCommand(cmd)
}
/** 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