Commit e636b9f7 authored by Max Lv's avatar Max Lv

Disable log of pdnsd

parent f833808b
...@@ -231,7 +231,7 @@ LOCAL_CFLAGS := -O2 -std=gnu99 -DUSE_IPTABLES \ ...@@ -231,7 +231,7 @@ LOCAL_CFLAGS := -O2 -std=gnu99 -DUSE_IPTABLES \
include $(BUILD_EXECUTABLE) include $(BUILD_EXECUTABLE)
######################################################## ########################################################
## pdnsd library ## pdnsd
######################################################## ########################################################
include $(CLEAR_VARS) include $(CLEAR_VARS)
...@@ -240,12 +240,12 @@ PDNSD_SOURCES := $(wildcard $(LOCAL_PATH)/pdnsd/src/*.c) ...@@ -240,12 +240,12 @@ PDNSD_SOURCES := $(wildcard $(LOCAL_PATH)/pdnsd/src/*.c)
LOCAL_MODULE := pdnsd LOCAL_MODULE := pdnsd
LOCAL_SRC_FILES := $(PDNSD_SOURCES:$(LOCAL_PATH)/%=%) LOCAL_SRC_FILES := $(PDNSD_SOURCES:$(LOCAL_PATH)/%=%)
LOCAL_CFLAGS := -Wall -O2 -I$(LOCAL_PATH)/pdnsd LOCAL_CFLAGS := -DANDROID -Wall -O2 -I$(LOCAL_PATH)/pdnsd
include $(BUILD_EXECUTABLE) include $(BUILD_EXECUTABLE)
######################################################## ########################################################
## shadowsocks-libev local library ## shadowsocks-libev local
######################################################## ########################################################
include $(CLEAR_VARS) include $(CLEAR_VARS)
......
...@@ -61,6 +61,7 @@ void crash_msg(char *msg) ...@@ -61,6 +61,7 @@ void crash_msg(char *msg)
* the optional following arguments are the arguments like in printf */ * the optional following arguments are the arguments like in printf */
void log_message(int prior, const char *s, ...) void log_message(int prior, const char *s, ...)
{ {
#ifndef ANDROID
int gotlock=0; int gotlock=0;
va_list va; va_list va;
FILE *f; FILE *f;
...@@ -112,6 +113,7 @@ void log_message(int prior, const char *s, ...) ...@@ -112,6 +113,7 @@ void log_message(int prior, const char *s, ...)
} }
if (gotlock) if (gotlock)
pthread_mutex_unlock(&loglock); pthread_mutex_unlock(&loglock);
#endif
} }
......
...@@ -39,6 +39,8 @@ ...@@ -39,6 +39,8 @@
package com.github.shadowsocks package com.github.shadowsocks
import java.util.{Timer, TimerTask}
import android.app.Notification import android.app.Notification
import android.content.Context import android.content.Context
import android.os.{Handler, RemoteCallbackList} import android.os.{Handler, RemoteCallbackList}
...@@ -49,7 +51,9 @@ trait BaseService { ...@@ -49,7 +51,9 @@ trait BaseService {
@volatile private var state = State.INIT @volatile private var state = State.INIT
@volatile private var callbackCount = 0 @volatile private var callbackCount = 0
@volatile private var trafficMonitorThread: TrafficMonitorThread = null
var timer: Timer = null
var trafficMonitorThread: TrafficMonitorThread = null
var config: Config = null var config: Config = null
final val callbacks = new RemoteCallbackList[IShadowsocksServiceCallback] final val callbacks = new RemoteCallbackList[IShadowsocksServiceCallback]
...@@ -99,14 +103,31 @@ trait BaseService { ...@@ -99,14 +103,31 @@ trait BaseService {
TrafficMonitor.reset() TrafficMonitor.reset()
trafficMonitorThread = new TrafficMonitorThread(this) trafficMonitorThread = new TrafficMonitorThread(this)
trafficMonitorThread.start() trafficMonitorThread.start()
val task = new TimerTask {
def run {
clearChildProcessStream()
}
}
timer = new Timer(true)
timer.schedule(task, 60 * 1000, 60 * 1000)
} }
def stopRunner() { def stopRunner() {
TrafficMonitor.reset() TrafficMonitor.reset()
if (trafficMonitorThread != null) { if (trafficMonitorThread != null) {
trafficMonitorThread.stopThread() trafficMonitorThread.stopThread()
trafficMonitorThread = null trafficMonitorThread = null
} }
if (timer != null) {
timer.cancel()
timer = null
}
} }
def clearChildProcessStream()
def stopBackgroundService() def stopBackgroundService()
def getServiceMode: Int def getServiceMode: Int
def getTag: String def getTag: String
......
...@@ -202,7 +202,7 @@ class ShadowsocksNatService extends Service with BaseService { ...@@ -202,7 +202,7 @@ class ShadowsocksNatService extends Service with BaseService {
if (BuildConfig.DEBUG) Log.d(TAG, cmd.mkString(" ")) if (BuildConfig.DEBUG) Log.d(TAG, cmd.mkString(" "))
sslocalProcess = new ProcessBuilder() sslocalProcess = new ProcessBuilder()
.command(cmd) .command(cmd)
.redirectErrorStream(false) .redirectErrorStream(true)
.start() .start()
} }
...@@ -230,7 +230,7 @@ class ShadowsocksNatService extends Service with BaseService { ...@@ -230,7 +230,7 @@ class ShadowsocksNatService extends Service with BaseService {
sstunnelProcess = new ProcessBuilder() sstunnelProcess = new ProcessBuilder()
.command(cmd) .command(cmd)
.redirectErrorStream(false) .redirectErrorStream(true)
.start() .start()
} else { } else {
...@@ -255,7 +255,7 @@ class ShadowsocksNatService extends Service with BaseService { ...@@ -255,7 +255,7 @@ class ShadowsocksNatService extends Service with BaseService {
sstunnelProcess = new ProcessBuilder() sstunnelProcess = new ProcessBuilder()
.command(cmdBuf) .command(cmdBuf)
.redirectErrorStream(false) .redirectErrorStream(true)
.start() .start()
} }
} }
...@@ -281,7 +281,7 @@ class ShadowsocksNatService extends Service with BaseService { ...@@ -281,7 +281,7 @@ class ShadowsocksNatService extends Service with BaseService {
pdnsdProcess = new ProcessBuilder() pdnsdProcess = new ProcessBuilder()
.command(cmd.split(" ").toSeq) .command(cmd.split(" ").toSeq)
.redirectErrorStream(false) .redirectErrorStream(true)
.start() .start()
} }
...@@ -308,7 +308,7 @@ class ShadowsocksNatService extends Service with BaseService { ...@@ -308,7 +308,7 @@ class ShadowsocksNatService extends Service with BaseService {
if (BuildConfig.DEBUG) Log.d(TAG, cmd) if (BuildConfig.DEBUG) Log.d(TAG, cmd)
redsocksProcess = new ProcessBuilder() redsocksProcess = new ProcessBuilder()
.command(cmd.split(" ").toSeq) .command(cmd.split(" ").toSeq)
.redirectErrorStream(false) .redirectErrorStream(true)
.start() .start()
} }
...@@ -429,6 +429,17 @@ class ShadowsocksNatService extends Service with BaseService { ...@@ -429,6 +429,17 @@ class ShadowsocksNatService extends Service with BaseService {
Console.runRootCommand(http_sb.toArray) Console.runRootCommand(http_sb.toArray)
} }
override def clearChildProcessStream() {
try {
sslocalProcess.getInputStream.skip(65535)
sstunnelProcess.getInputStream.skip(65535)
pdnsdProcess.getInputStream.skip(65535)
redsocksProcess.getInputStream.skip(65535)
} catch {
case ex: Exception => // Ignore
}
}
override def startRunner(config: Config) { override def startRunner(config: Config) {
super.startRunner(config) super.startRunner(config)
......
...@@ -214,6 +214,17 @@ class ShadowsocksVpnService extends VpnService with BaseService { ...@@ -214,6 +214,17 @@ class ShadowsocksVpnService extends VpnService with BaseService {
} }
} }
override def clearChildProcessStream() {
try {
sslocalProcess.getInputStream.skip(65535)
sstunnelProcess.getInputStream.skip(65535)
pdnsdProcess.getInputStream.skip(65535)
tun2socksProcess.getInputStream.skip(65535)
} catch {
case ex: Exception => // Ignore
}
}
override def startRunner(config: Config) { override def startRunner(config: Config) {
super.startRunner(config) super.startRunner(config)
...@@ -345,7 +356,7 @@ class ShadowsocksVpnService extends VpnService with BaseService { ...@@ -345,7 +356,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
sslocalProcess = new ProcessBuilder() sslocalProcess = new ProcessBuilder()
.command(cmd) .command(cmd)
.redirectErrorStream(false) .redirectErrorStream(true)
.start() .start()
} }
...@@ -372,7 +383,7 @@ class ShadowsocksVpnService extends VpnService with BaseService { ...@@ -372,7 +383,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
sstunnelProcess = new ProcessBuilder() sstunnelProcess = new ProcessBuilder()
.command(cmd) .command(cmd)
.redirectErrorStream(false) .redirectErrorStream(true)
.start() .start()
} }
...@@ -398,7 +409,7 @@ class ShadowsocksVpnService extends VpnService with BaseService { ...@@ -398,7 +409,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
pdnsdProcess = new ProcessBuilder() pdnsdProcess = new ProcessBuilder()
.command(cmd.split(" ").toSeq) .command(cmd.split(" ").toSeq)
.redirectErrorStream(false) .redirectErrorStream(true)
.start() .start()
} }
...@@ -492,7 +503,7 @@ class ShadowsocksVpnService extends VpnService with BaseService { ...@@ -492,7 +503,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
tun2socksProcess = new ProcessBuilder() tun2socksProcess = new ProcessBuilder()
.command(cmd.split(" ").toSeq) .command(cmd.split(" ").toSeq)
.redirectErrorStream(false) .redirectErrorStream(true)
.start() .start()
fd fd
......
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