Fix listener error

This commit is contained in:
世界 2022-05-12 08:09:43 +08:00
parent b1ce47aaca
commit 1adec71629
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
2 changed files with 5 additions and 4 deletions

View file

@ -83,8 +83,9 @@ func (l *Listener) Close() error {
func (l *Listener) loop() {
for {
tcpConn, err := l.Accept()
tcpConn, err := l.AcceptTCP()
if err != nil {
l.handler.HandleError(E.New("tcp listener closed: ", err))
l.Close()
return
}

View file

@ -99,7 +99,7 @@ func (l *Listener) loop() {
for {
n, addr, err := l.ReadFromUDPAddrPort(data)
if err != nil {
l.handler.HandleError(err)
l.handler.HandleError(E.New("udp listener closed: ", err))
return
}
buffer.Resize(buf.ReversedHeader, n)
@ -118,13 +118,13 @@ func (l *Listener) loop() {
for {
n, oobN, _, addr, err := l.ReadMsgUDPAddrPort(data, oob)
if err != nil {
l.handler.HandleError(err)
l.handler.HandleError(E.New("udp listener closed: ", err))
return
}
destination, err := redir.GetOriginalDestinationFromOOB(oob[:oobN])
if err != nil {
l.handler.HandleError(E.Cause(err, "get original destination"))
return
continue
}
buffer.Resize(buf.ReversedHeader, n)
err = l.handler.NewPacket(l, buffer, M.Metadata{