mirror of
https://github.com/ehang-io/nps.git
synced 2025-07-03 13:10:42 +00:00
commit
4381eb44b4
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Create a report to help us improve
|
||||||
|
title: ''
|
||||||
|
labels: bug
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Describe the bug**
|
||||||
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
**To Reproduce**
|
||||||
|
Steps to reproduce the behavior:
|
||||||
|
1. Opening '...'
|
||||||
|
2. Click on '....'
|
||||||
|
3. See error
|
||||||
|
|
||||||
|
**Expected behavior**
|
||||||
|
A clear and concise description of what you expected to happen.
|
||||||
|
|
||||||
|
**Screenshots or logs**
|
||||||
|
Add screenshots or logs to help explain your problem.
|
||||||
|
|
||||||
|
**Server (please complete the following information):**
|
||||||
|
- OS: [e.g. Centos, Windows]
|
||||||
|
- ARCH: [e.g. Amd64, Arm]
|
||||||
|
- Tunnel [e.g. TCP, HTTP]
|
||||||
|
- Version [e.g. 0.24.0]
|
||||||
|
|
||||||
|
**Client (please complete the following information):**
|
||||||
|
- OS: [e.g. Centos, Windows]
|
||||||
|
- ARCH: [e.g. Amd64, Arm]
|
||||||
|
- Tunnel [e.g. TCP, HTTP]
|
||||||
|
- Version [e.g. 0.24.0]
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context about the problem here.
|
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Suggest an idea for this project
|
||||||
|
title: ''
|
||||||
|
labels: enhancement
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Is your feature request related to a problem? Please describe.**
|
||||||
|
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||||
|
|
||||||
|
**Describe the solution you'd like**
|
||||||
|
A clear and concise description of what you want to happen.
|
||||||
|
|
||||||
|
**Describe alternatives you've considered**
|
||||||
|
A clear and concise description of any alternative solutions or features you've considered.
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context or screenshots about the feature request here.
|
@ -575,11 +575,13 @@ vkey=123
|
|||||||
[socks5]
|
[socks5]
|
||||||
mode=socks5
|
mode=socks5
|
||||||
server_port=9004
|
server_port=9004
|
||||||
|
multi_account=multi_account.conf
|
||||||
```
|
```
|
||||||
项 | 含义
|
项 | 含义
|
||||||
---|---
|
---|---
|
||||||
mode | socks5
|
mode | socks5
|
||||||
server_port | 在服务端的代理端口
|
server_port | 在服务端的代理端口
|
||||||
|
multi_account | socks5多账号配置文件(可选),配置后使用basic_username和basic_password无法通过认证
|
||||||
##### 私密代理模式
|
##### 私密代理模式
|
||||||
|
|
||||||
```ini
|
```ini
|
||||||
|
@ -296,7 +296,7 @@ func (s *Bridge) register(c *conn.Conn) {
|
|||||||
func (s *Bridge) SendLinkInfo(clientId int, link *conn.Link, t *file.Tunnel) (target net.Conn, err error) {
|
func (s *Bridge) SendLinkInfo(clientId int, link *conn.Link, t *file.Tunnel) (target net.Conn, err error) {
|
||||||
//if the proxy type is local
|
//if the proxy type is local
|
||||||
if link.LocalProxy {
|
if link.LocalProxy {
|
||||||
target, err = net.Dial(link.ConnType, link.Host)
|
target, err = net.Dial("tcp", link.Host)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if v, ok := s.Client.Load(clientId); ok {
|
if v, ok := s.Client.Load(clientId); ok {
|
||||||
@ -488,6 +488,7 @@ loop:
|
|||||||
tl.Password = t.Password
|
tl.Password = t.Password
|
||||||
tl.LocalPath = t.LocalPath
|
tl.LocalPath = t.LocalPath
|
||||||
tl.StripPre = t.StripPre
|
tl.StripPre = t.StripPre
|
||||||
|
tl.MultiAccount = t.MultiAccount
|
||||||
if !client.HasTunnel(tl) {
|
if !client.HasTunnel(tl) {
|
||||||
if err := file.GetDb().NewTask(tl); err != nil {
|
if err := file.GetDb().NewTask(tl); err != nil {
|
||||||
logs.Notice("Add task error ", err.Error())
|
logs.Notice("Add task error ", err.Error())
|
||||||
|
@ -71,7 +71,11 @@ func check(t *file.Health) {
|
|||||||
var rs *http.Response
|
var rs *http.Response
|
||||||
for _, v := range arr {
|
for _, v := range arr {
|
||||||
if t.HealthCheckType == "tcp" {
|
if t.HealthCheckType == "tcp" {
|
||||||
_, err = net.DialTimeout("tcp", v, time.Duration(t.HealthCheckTimeout)*time.Second)
|
var c net.Conn
|
||||||
|
c, err = net.DialTimeout("tcp", v, time.Duration(t.HealthCheckTimeout)*time.Second)
|
||||||
|
if err == nil {
|
||||||
|
c.Close()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
client.Timeout = time.Duration(t.HealthCheckTimeout) * time.Second
|
client.Timeout = time.Duration(t.HealthCheckTimeout) * time.Second
|
||||||
|
2
conf/multi_account.conf
Normal file
2
conf/multi_account.conf
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# key -> user | value -> pwd
|
||||||
|
npc=npc.pwd
|
@ -40,6 +40,7 @@ server_port=10000
|
|||||||
[socks5]
|
[socks5]
|
||||||
mode=socks5
|
mode=socks5
|
||||||
server_port=19009
|
server_port=19009
|
||||||
|
multi_account=multi_account.conf
|
||||||
|
|
||||||
[file]
|
[file]
|
||||||
mode=file
|
mode=file
|
||||||
|
@ -239,12 +239,37 @@ func dealTunnel(s string) *file.Tunnel {
|
|||||||
t.LocalPath = item[1]
|
t.LocalPath = item[1]
|
||||||
case "strip_pre":
|
case "strip_pre":
|
||||||
t.StripPre = item[1]
|
t.StripPre = item[1]
|
||||||
|
case "multi_account":
|
||||||
|
t.MultiAccount = &file.MultiAccount{}
|
||||||
|
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.MultiAccount.AccountMap = dealMultiUser(content)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return t
|
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 {
|
func delLocalService(s string) *LocalServer {
|
||||||
l := new(LocalServer)
|
l := new(LocalServer)
|
||||||
for _, v := range splitStr(s) {
|
for _, v := range splitStr(s) {
|
||||||
|
@ -124,22 +124,23 @@ func (s *Client) HasHost(h *Host) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Tunnel struct {
|
type Tunnel struct {
|
||||||
Id int
|
Id int
|
||||||
Port int
|
Port int
|
||||||
ServerIp string
|
ServerIp string
|
||||||
Mode string
|
Mode string
|
||||||
Status bool
|
Status bool
|
||||||
RunStatus bool
|
RunStatus bool
|
||||||
Client *Client
|
Client *Client
|
||||||
Ports string
|
Ports string
|
||||||
Flow *Flow
|
Flow *Flow
|
||||||
Password string
|
Password string
|
||||||
Remark string
|
Remark string
|
||||||
TargetAddr string
|
TargetAddr string
|
||||||
NoStore bool
|
NoStore bool
|
||||||
LocalPath string
|
LocalPath string
|
||||||
StripPre string
|
StripPre string
|
||||||
Target *Target
|
Target *Target
|
||||||
|
MultiAccount *MultiAccount
|
||||||
Health
|
Health
|
||||||
sync.RWMutex
|
sync.RWMutex
|
||||||
}
|
}
|
||||||
@ -184,6 +185,10 @@ type Target struct {
|
|||||||
sync.RWMutex
|
sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type MultiAccount struct {
|
||||||
|
AccountMap map[string]string // multi account and pwd
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Target) GetRandomTarget() (string, error) {
|
func (s *Target) GetRandomTarget() (string, error) {
|
||||||
if s.TargetArr == nil {
|
if s.TargetArr == nil {
|
||||||
s.TargetArr = strings.Split(s.TargetStr, "\n")
|
s.TargetArr = strings.Split(s.TargetStr, "\n")
|
||||||
|
@ -199,7 +199,7 @@ func (s *Sock5ModeServer) handleConn(c net.Conn) {
|
|||||||
c.Close()
|
c.Close()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if s.task.Client.Cnf.U != "" && s.task.Client.Cnf.P != "" {
|
if (s.task.Client.Cnf.U != "" && s.task.Client.Cnf.P != "") || (s.task.MultiAccount != nil && len(s.task.MultiAccount.AccountMap) > 0) {
|
||||||
buf[1] = UserPassAuth
|
buf[1] = UserPassAuth
|
||||||
c.Write(buf)
|
c.Write(buf)
|
||||||
if err := s.Auth(c); err != nil {
|
if err := s.Auth(c); err != nil {
|
||||||
@ -236,7 +236,22 @@ func (s *Sock5ModeServer) Auth(c net.Conn) error {
|
|||||||
if _, err := io.ReadAtLeast(c, pass, passLen); err != nil {
|
if _, err := io.ReadAtLeast(c, pass, passLen); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if string(user) == s.task.Client.Cnf.U && string(pass) == s.task.Client.Cnf.P {
|
|
||||||
|
var U, P string
|
||||||
|
if s.task.MultiAccount != nil {
|
||||||
|
// enable multi user auth
|
||||||
|
U = string(user)
|
||||||
|
var ok bool
|
||||||
|
P, ok = s.task.MultiAccount.AccountMap[U]
|
||||||
|
if !ok {
|
||||||
|
return errors.New("验证不通过")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
U = s.task.Client.Cnf.U
|
||||||
|
P = s.task.Client.Cnf.P
|
||||||
|
}
|
||||||
|
|
||||||
|
if string(user) == U && string(pass) == P {
|
||||||
if _, err := c.Write([]byte{userAuthVersion, authSuccess}); err != nil {
|
if _, err := c.Write([]byte{userAuthVersion, authSuccess}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ func (self *LoginController) Verify() {
|
|||||||
if self.GetString("password") == beego.AppConfig.String("web_password") && self.GetString("username") == beego.AppConfig.String("web_username") {
|
if self.GetString("password") == beego.AppConfig.String("web_password") && self.GetString("username") == beego.AppConfig.String("web_username") {
|
||||||
self.SetSession("isAdmin", true)
|
self.SetSession("isAdmin", true)
|
||||||
auth = true
|
auth = true
|
||||||
server.Bridge.Register.Store(common.GetIpByAddr(self.Ctx.Request.RemoteAddr), time.Now().Add(time.Hour*time.Duration(2)))
|
server.Bridge.Register.Store(common.GetIpByAddr(self.Ctx.Input.IP()), time.Now().Add(time.Hour*time.Duration(2)))
|
||||||
}
|
}
|
||||||
b, err := beego.AppConfig.Bool("allow_user_login")
|
b, err := beego.AppConfig.Bool("allow_user_login")
|
||||||
if err == nil && b && !auth {
|
if err == nil && b && !auth {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user