From 41db97b8cf51ca6ed1b9ac59ea1b76d1ee4fccd8 Mon Sep 17 00:00:00 2001 From: e1732a364fed <75717694+e1732a364fed@users.noreply.github.com> Date: Sat, 1 Jan 2000 00:00:00 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E8=AE=A2=E4=BB=A3=E7=A0=81=EF=BC=8C?= =?UTF-8?q?=E7=A4=BA=E4=BE=8B=EF=BC=9B=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=20toml=E5=A4=9A=E8=A1=8C=E5=AD=97=E7=AC=A6=E4=B8=B2=E7=9A=84bu?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/socks5.toml | 9 ++++++--- proxy/socks5/server.go | 2 +- utils/user.go | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/examples/socks5.toml b/examples/socks5.toml index 6f637b4..73e18d6 100644 --- a/examples/socks5.toml +++ b/examples/socks5.toml @@ -15,7 +15,8 @@ tag = "dial1" host = "127.0.0.1" port = 10801 -uuid = "user:very\npass:simple" +#uuid = "user:very\npass:simple" +uuid = "user:admin\npass:nimda" [[route]] fromTag = ["my_socks5_1"] @@ -34,8 +35,10 @@ user:admin pass:nimda """ -# 或者这种 -#uuid = "user:very\npass:simple" +# 上面这个格式 根据toml的规范,头部是没有 \n 的,但是尾部多了一个 \n, 不过不用担心,我们程序会修剪掉末尾的换行符. + +# 或者这种,但是看起来不太美观 +#uuid = "user:very\npass:simple" users = [ {user = "very", pass = "simple"}, {user = "v2ray", pass = "hard"} ] #也可以用users 来存储多个用户 diff --git a/proxy/socks5/server.go b/proxy/socks5/server.go index 4ff37f5..f1631a2 100644 --- a/proxy/socks5/server.go +++ b/proxy/socks5/server.go @@ -57,7 +57,7 @@ func (ServerCreator) NewServer(lc *proxy.ListenConf) (proxy.Server, error) { if userPass.InitWithStr(str) { s.AddUser(&userPass) } else { - if ce := utils.CanLogWarn("http: user and password format malformed. Will not use default uuid"); ce != nil { + if ce := utils.CanLogWarn("socks5: user and password format malformed. Will not use default uuid"); ce != nil { ce.Write() } } diff --git a/utils/user.go b/utils/user.go index e6dd409..3188759 100644 --- a/utils/user.go +++ b/utils/user.go @@ -158,6 +158,7 @@ func (ph *UserPass) InitWithUrl(u *url.URL) bool { //uuid: "user:xxxx\npass:xxxx" func (ph *UserPass) InitWithStr(str string) (ok bool) { + str = strings.TrimSuffix(str, "\n") strs := strings.SplitN(str, "\n", 2) if len(strs) != 2 { return