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",
|
||||
"pool"
|
||||
]
|
||||
revision = "674e937d2ef03e9ef7798c363071cad128f3c13b"
|
||||
revision = "416571c55dbc32e13ce82c301a2a4b5a48ad7309"
|
||||
|
||||
[[projects]]
|
||||
branch = "frp"
|
||||
@ -169,7 +169,7 @@
|
||||
"ipv4",
|
||||
"proxy"
|
||||
]
|
||||
revision = "57065200b4b034a1c8ad54ff77069408c2218ae6"
|
||||
revision = "dfa909b99c79129e1100513e5cd36307665e5723"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
|
16
vendor/github.com/fatedier/golib/net/mux/mux.go
generated
vendored
16
vendor/github.com/fatedier/golib/net/mux/mux.go
generated
vendored
@ -34,10 +34,13 @@ const (
|
||||
type Mux struct {
|
||||
ln net.Listener
|
||||
|
||||
defaultLn *listener
|
||||
defaultLn *listener
|
||||
|
||||
// sorted by priority
|
||||
lns []*listener
|
||||
maxNeedBytesNum uint32
|
||||
mu sync.RWMutex
|
||||
|
||||
mu sync.RWMutex
|
||||
}
|
||||
|
||||
func NewMux() (mux *Mux) {
|
||||
@ -47,10 +50,12 @@ func NewMux() (mux *Mux) {
|
||||
return
|
||||
}
|
||||
|
||||
// priority
|
||||
func (mux *Mux) Listen(priority int, needBytesNum uint32, fn MatchFunc) net.Listener {
|
||||
ln := &listener{
|
||||
c: make(chan net.Conn),
|
||||
mux: mux,
|
||||
priority: priority,
|
||||
needBytesNum: needBytesNum,
|
||||
matchFn: fn,
|
||||
}
|
||||
@ -63,7 +68,10 @@ func (mux *Mux) Listen(priority int, needBytesNum uint32, fn MatchFunc) net.List
|
||||
|
||||
newlns := append(mux.copyLns(), ln)
|
||||
sort.Slice(newlns, func(i, j int) bool {
|
||||
return newlns[i].needBytesNum < newlns[j].needBytesNum
|
||||
if newlns[i].priority == newlns[j].priority {
|
||||
return newlns[i].needBytesNum < newlns[j].needBytesNum
|
||||
}
|
||||
return newlns[i].priority < newlns[j].priority
|
||||
})
|
||||
mux.lns = newlns
|
||||
return ln
|
||||
@ -99,6 +107,7 @@ func (mux *Mux) release(ln *listener) bool {
|
||||
if l == ln {
|
||||
lns = append(lns[:i], lns[i+1:]...)
|
||||
result = true
|
||||
break
|
||||
}
|
||||
}
|
||||
mux.lns = lns
|
||||
@ -186,6 +195,7 @@ func (mux *Mux) handleConn(conn net.Conn) {
|
||||
type listener struct {
|
||||
mux *Mux
|
||||
|
||||
priority int
|
||||
needBytesNum uint32
|
||||
matchFn MatchFunc
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user