Fix: ss udp return error when addr parse failed

This commit is contained in:
Dreamacro
2020-03-01 01:46:02 +08:00
parent e81b88fb94
commit 814bd05315
2 changed files with 8 additions and 3 deletions

View File

@ -4,6 +4,7 @@ import (
"context"
"crypto/tls"
"encoding/json"
"errors"
"fmt"
"net"
"strconv"
@ -209,7 +210,12 @@ func (spc *ssPacketConn) ReadFrom(b []byte) (int, net.Addr, error) {
if e != nil {
return 0, nil, e
}
addr := socks5.SplitAddr(b[:n])
if addr == nil {
return 0, nil, errors.New("parse addr error")
}
copy(b, b[len(addr):])
return n - len(addr), addr.UDPAddr(), e
}