diff --git a/examples/socks5.toml b/examples/socks5.toml index 6f637b48..73e18d62 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 4ff37f52..f1631a2e 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 e6dd4097..3188759c 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