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:
@@ -240,15 +240,14 @@ func dealTunnel(s string) *file.Tunnel {
|
||||
case "strip_pre":
|
||||
t.StripPre = item[1]
|
||||
case "multi_user":
|
||||
// TODO add test with multi user config file
|
||||
t.Client.Cnf.MultiUser = true
|
||||
t.MultiUser = new(file.MultiUser)
|
||||
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)
|
||||
t.MultiUser.UserMap = dealMultiUser(content)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -25,12 +25,10 @@ func (s *Flow) Add(in, out int64) {
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
U string
|
||||
P string
|
||||
Compress bool
|
||||
Crypt bool
|
||||
MultiUser bool // enable multi user authentication.
|
||||
MultiUserMap map[string]string // multi user and pwd
|
||||
U string
|
||||
P string
|
||||
Compress bool
|
||||
Crypt bool
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
@@ -142,6 +140,7 @@ type Tunnel struct {
|
||||
LocalPath string
|
||||
StripPre string
|
||||
Target *Target
|
||||
MultiUser *MultiUser
|
||||
Health
|
||||
sync.RWMutex
|
||||
}
|
||||
@@ -186,6 +185,10 @@ type Target struct {
|
||||
sync.RWMutex
|
||||
}
|
||||
|
||||
type MultiUser struct {
|
||||
UserMap map[string]string // multi user and pwd
|
||||
}
|
||||
|
||||
func (s *Target) GetRandomTarget() (string, error) {
|
||||
if s.TargetArr == nil {
|
||||
s.TargetArr = strings.Split(s.TargetStr, "\n")
|
||||
|
Reference in New Issue
Block a user