mirror of
https://github.com/e1732a364fed/v2ray_simple.git
synced 2025-12-24 13:27:56 +08:00
修订代码,示例;修复一个 toml多行字符串的bug
This commit is contained in:
@@ -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 来存储多个用户
|
||||
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user