mirror of
https://github.com/ehang-io/nps.git
synced 2025-09-02 11:56:53 +00:00
Url路由 泛解析
This commit is contained in:
@@ -110,19 +110,22 @@ func (s *httpServer) handleTunneling(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *httpServer) process(c *conn.Conn, r *http.Request) {
|
||||
//多客户端域名代理
|
||||
var (
|
||||
isConn = true
|
||||
lk *conn.Link
|
||||
host *file.Host
|
||||
tunnel *conn.Conn
|
||||
err error
|
||||
isConn = true
|
||||
lk *conn.Link
|
||||
host *file.Host
|
||||
tunnel *conn.Conn
|
||||
lastHost *file.Host
|
||||
err error
|
||||
)
|
||||
for {
|
||||
//首次获取conn
|
||||
if host, err = file.GetCsvDb().GetInfoByHost(r.Host, r); err != nil {
|
||||
lg.Printf("the url %s %s is not found !", r.Host, r.RequestURI)
|
||||
break
|
||||
} else if host != lastHost {
|
||||
lastHost = host
|
||||
isConn = true
|
||||
}
|
||||
if isConn {
|
||||
if host, err = file.GetCsvDb().GetInfoByHost(r.Host); err != nil {
|
||||
lg.Printf("the host %s is not found !", r.Host)
|
||||
break
|
||||
}
|
||||
//流量限制
|
||||
if host.Client.Flow.FlowLimit > 0 && (host.Client.Flow.FlowLimit<<20) < (host.Client.Flow.ExportFlow+host.Client.Flow.InletFlow) {
|
||||
break
|
||||
@@ -147,6 +150,7 @@ func (s *httpServer) process(c *conn.Conn, r *http.Request) {
|
||||
//根据设定,修改header和host
|
||||
common.ChangeHostAndHeader(r, host.HostChange, host.HeaderChange, c.Conn.RemoteAddr().String())
|
||||
b, err := httputil.DumpRequest(r, true)
|
||||
lg.Println(string(b), r.RequestURI)
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
|
@@ -49,7 +49,6 @@ const (
|
||||
|
||||
type Sock5ModeServer struct {
|
||||
server
|
||||
isVerify bool
|
||||
listener net.Listener
|
||||
}
|
||||
|
||||
@@ -208,12 +207,12 @@ func (s *Sock5ModeServer) handleConn(c net.Conn) {
|
||||
c.Close()
|
||||
return
|
||||
}
|
||||
if s.isVerify {
|
||||
if s.task.Client.Cnf.U != "" && s.task.Client.Cnf.P != "" {
|
||||
buf[1] = UserPassAuth
|
||||
c.Write(buf)
|
||||
if err := s.Auth(c); err != nil {
|
||||
c.Close()
|
||||
lg.Println("验证失败:", err)
|
||||
lg.Println("Validation failed:", err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
@@ -289,10 +288,5 @@ func NewSock5ModeServer(bridge *bridge.Bridge, task *file.Tunnel) *Sock5ModeServ
|
||||
s := new(Sock5ModeServer)
|
||||
s.bridge = bridge
|
||||
s.task = task
|
||||
if s.task.Client.Cnf.U != "" && s.task.Client.Cnf.P != "" {
|
||||
s.isVerify = true
|
||||
} else {
|
||||
s.isVerify = false
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
Reference in New Issue
Block a user