Skip to content
This repository has been archived by the owner on Mar 17, 2024. It is now read-only.

Commit

Permalink
修订代码,示例;修复一个 toml多行字符串的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
e1732a364fed committed May 16, 2022
1 parent bdcda5b commit 41db97b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
9 changes: 6 additions & 3 deletions examples/socks5.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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 来存储多个用户

Expand Down
2 changes: 1 addition & 1 deletion proxy/socks5/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down
1 change: 1 addition & 0 deletions utils/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 41db97b

Please sign in to comment.