mirror of
https://github.com/ehang-io/nps.git
synced 2025-09-02 03:16:53 +00:00
new feature multi user auth with socks5
This commit is contained in:
@@ -239,12 +239,38 @@ func dealTunnel(s string) *file.Tunnel {
|
||||
t.LocalPath = item[1]
|
||||
case "strip_pre":
|
||||
t.StripPre = item[1]
|
||||
case "multi_user":
|
||||
// TODO 解析多账号配置文件
|
||||
t.Client.Cnf.MultiUser = true
|
||||
if b, err := common.ReadAllFromFile(item[1]); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
if content, err := common.ParseStr(string(b)); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
t.Client.Cnf.MultiUserMap = dealMultiUser(content)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return t
|
||||
|
||||
}
|
||||
|
||||
func dealMultiUser(s string) map[string]string {
|
||||
multiUserMap := make(map[string]string)
|
||||
for _, v := range splitStr(s) {
|
||||
item := strings.Split(v, "=")
|
||||
if len(item) == 0 {
|
||||
continue
|
||||
} else if len(item) == 1 {
|
||||
item = append(item, "")
|
||||
}
|
||||
multiUserMap[strings.TrimSpace(item[0])] = item[1]
|
||||
}
|
||||
return multiUserMap
|
||||
}
|
||||
|
||||
func delLocalService(s string) *LocalServer {
|
||||
l := new(LocalServer)
|
||||
for _, v := range splitStr(s) {
|
||||
|
@@ -25,10 +25,12 @@ func (s *Flow) Add(in, out int64) {
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
U string
|
||||
P string
|
||||
Compress bool
|
||||
Crypt bool
|
||||
U string
|
||||
P string
|
||||
Compress bool
|
||||
Crypt bool
|
||||
MultiUser bool // enable multi user authentication.
|
||||
MultiUserMap map[string]string // multi user and pwd
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
|
Reference in New Issue
Block a user