From 8feb587ebe9455ffbad9cac0b2fad2e9d2f99a19 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Fri, 7 Oct 2016 16:54:25 +0800 Subject: [PATCH] Fix #923 --- .../com/github/shadowsocks/ShadowsocksNatService.scala | 8 +++++++- .../com/github/shadowsocks/ShadowsocksVpnService.scala | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com/github/shadowsocks/ShadowsocksNatService.scala b/src/main/scala/com/github/shadowsocks/ShadowsocksNatService.scala index 317feeff..a518dc24 100644 --- a/src/main/scala/com/github/shadowsocks/ShadowsocksNatService.scala +++ b/src/main/scala/com/github/shadowsocks/ShadowsocksNatService.scala @@ -112,8 +112,14 @@ class ShadowsocksNatService extends BaseService { def startKcptunDaemon() { if (profile.kcpcli == null) profile.kcpcli = "" + val host = if (profile.host.contains(":")) { + "[" + profile.host + "]" + } else { + profile.host + } + val cmd = ArrayBuffer[String](getApplicationInfo.dataDir + "/kcptun" - , "-r", profile.host + ":" + profile.kcpPort + , "-r", host + ":" + profile.kcpPort , "-l", "127.0.0.1:" + (profile.localPort + 90)) try cmd ++= Utils.translateCommandline(profile.kcpcli) catch { case exc: Exception => throw KcpcliParseException(exc) diff --git a/src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala b/src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala index e4da6b5f..0c174bd3 100644 --- a/src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala +++ b/src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala @@ -190,8 +190,14 @@ class ShadowsocksVpnService extends VpnService with BaseService { def startKcptunDaemon() { if (profile.kcpcli == null) profile.kcpcli = "" + val host = if (profile.host.contains(":")) { + "[" + profile.host + "]" + } else { + profile.host + } + val cmd = ArrayBuffer(getApplicationInfo.dataDir + "/kcptun" - , "-r", profile.host + ":" + profile.kcpPort + , "-r", host + ":" + profile.kcpPort , "-l", "127.0.0.1:" + (profile.localPort + 90) , "--path", protectPath) try cmd ++= Utils.translateCommandline(profile.kcpcli) catch {