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