mirror of
https://github.com/nadoo/glider.git
synced 2026-11-19 07:09:42 +08:00
ss: handle unexpect situation to avoid panic #132
This commit is contained in:
1 parent
4e1cb6ebf6
commit
2520a1c8b4
7 files changed
+33
-16
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package ss
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net"
|
||||
|
||||
"github.com/nadoo/glider/common/socks"
|
||||
@@ -38,7 +39,14 @@ func (pc *PktConn) ReadFrom(b []byte) (int, net.Addr, error) {
|
||||
return n, raddr, err
|
||||
}
|
||||
|
||||
if n < socks.MinAddrLen {
|
||||
return n, raddr, errors.New("not enough size to get addr")
|
||||
}
|
||||
|
||||
tgtAddr := socks.SplitAddr(buf)
|
||||
if tgtAddr == nil {
|
||||
return n, raddr, errors.New("can not get addr")
|
||||
}
|
||||
copy(b, buf[len(tgtAddr):])
|
||||
|
||||
//test
|
||||
|
||||
Reference in new issue
Block a user