mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-02-20 23:47:21 -05:00
KCP: discard useless conn in Accept
This commit is contained in:
parent
f4ff2e9366
commit
f601962391
@ -19,6 +19,12 @@ type KCPVlistener struct {
|
|||||||
previousSocketid_mapid int
|
previousSocketid_mapid int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*Accept Accept a KCP connection
|
||||||
|
Since KCP is stateless, if package deliver after it was closed,
|
||||||
|
It could be reconized as a new connection and call accept.
|
||||||
|
If we can detect that the connection is of such a kind,
|
||||||
|
we will discard that conn.
|
||||||
|
*/
|
||||||
func (kvl *KCPVlistener) Accept() (net.Conn, error) {
|
func (kvl *KCPVlistener) Accept() (net.Conn, error) {
|
||||||
conn, err := kvl.lst.Accept()
|
conn, err := kvl.lst.Accept()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -37,6 +43,7 @@ func (kvl *KCPVlistener) Accept() (net.Conn, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if badbit {
|
if badbit {
|
||||||
|
conn.Close()
|
||||||
return nil, errors.New("KCP:ConnDup, Don't worry~")
|
return nil, errors.New("KCP:ConnDup, Don't worry~")
|
||||||
} else {
|
} else {
|
||||||
kvl.previousSocketid_mapid++
|
kvl.previousSocketid_mapid++
|
||||||
|
@ -92,7 +92,7 @@ func (this *TCPHub) start() {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if this.accepting {
|
if this.accepting {
|
||||||
log.Warning("Listener: Failed to accept new TCP connection: ", err)
|
log.info("Listener: Failed to accept new TCP connection: ", err)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user