mirror of
https://gitee.com/IrisVega/frp.git
synced 2024-11-01 22:31:29 +08:00
update golib
This commit is contained in:
parent
85dd41c17b
commit
aeb9f2b64d
4
Gopkg.lock
generated
4
Gopkg.lock
generated
@ -30,7 +30,7 @@
|
|||||||
"net/mux",
|
"net/mux",
|
||||||
"pool"
|
"pool"
|
||||||
]
|
]
|
||||||
revision = "674e937d2ef03e9ef7798c363071cad128f3c13b"
|
revision = "416571c55dbc32e13ce82c301a2a4b5a48ad7309"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "frp"
|
branch = "frp"
|
||||||
@ -169,7 +169,7 @@
|
|||||||
"ipv4",
|
"ipv4",
|
||||||
"proxy"
|
"proxy"
|
||||||
]
|
]
|
||||||
revision = "57065200b4b034a1c8ad54ff77069408c2218ae6"
|
revision = "dfa909b99c79129e1100513e5cd36307665e5723"
|
||||||
|
|
||||||
[solve-meta]
|
[solve-meta]
|
||||||
analyzer-name = "dep"
|
analyzer-name = "dep"
|
||||||
|
10
vendor/github.com/fatedier/golib/net/mux/mux.go
generated
vendored
10
vendor/github.com/fatedier/golib/net/mux/mux.go
generated
vendored
@ -35,8 +35,11 @@ type Mux struct {
|
|||||||
ln net.Listener
|
ln net.Listener
|
||||||
|
|
||||||
defaultLn *listener
|
defaultLn *listener
|
||||||
|
|
||||||
|
// sorted by priority
|
||||||
lns []*listener
|
lns []*listener
|
||||||
maxNeedBytesNum uint32
|
maxNeedBytesNum uint32
|
||||||
|
|
||||||
mu sync.RWMutex
|
mu sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,10 +50,12 @@ func NewMux() (mux *Mux) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// priority
|
||||||
func (mux *Mux) Listen(priority int, needBytesNum uint32, fn MatchFunc) net.Listener {
|
func (mux *Mux) Listen(priority int, needBytesNum uint32, fn MatchFunc) net.Listener {
|
||||||
ln := &listener{
|
ln := &listener{
|
||||||
c: make(chan net.Conn),
|
c: make(chan net.Conn),
|
||||||
mux: mux,
|
mux: mux,
|
||||||
|
priority: priority,
|
||||||
needBytesNum: needBytesNum,
|
needBytesNum: needBytesNum,
|
||||||
matchFn: fn,
|
matchFn: fn,
|
||||||
}
|
}
|
||||||
@ -63,7 +68,10 @@ func (mux *Mux) Listen(priority int, needBytesNum uint32, fn MatchFunc) net.List
|
|||||||
|
|
||||||
newlns := append(mux.copyLns(), ln)
|
newlns := append(mux.copyLns(), ln)
|
||||||
sort.Slice(newlns, func(i, j int) bool {
|
sort.Slice(newlns, func(i, j int) bool {
|
||||||
|
if newlns[i].priority == newlns[j].priority {
|
||||||
return newlns[i].needBytesNum < newlns[j].needBytesNum
|
return newlns[i].needBytesNum < newlns[j].needBytesNum
|
||||||
|
}
|
||||||
|
return newlns[i].priority < newlns[j].priority
|
||||||
})
|
})
|
||||||
mux.lns = newlns
|
mux.lns = newlns
|
||||||
return ln
|
return ln
|
||||||
@ -99,6 +107,7 @@ func (mux *Mux) release(ln *listener) bool {
|
|||||||
if l == ln {
|
if l == ln {
|
||||||
lns = append(lns[:i], lns[i+1:]...)
|
lns = append(lns[:i], lns[i+1:]...)
|
||||||
result = true
|
result = true
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mux.lns = lns
|
mux.lns = lns
|
||||||
@ -186,6 +195,7 @@ func (mux *Mux) handleConn(conn net.Conn) {
|
|||||||
type listener struct {
|
type listener struct {
|
||||||
mux *Mux
|
mux *Mux
|
||||||
|
|
||||||
|
priority int
|
||||||
needBytesNum uint32
|
needBytesNum uint32
|
||||||
matchFn MatchFunc
|
matchFn MatchFunc
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user