Remove origin check for peer UDP packets

Checking source IP address is far from enough to ensure authenticity, it
is better to simply remove this and let the higher layer to worry about
peer authentication.
This commit is contained in:
Eric Yan
2017-05-28 15:28:28 +08:00
parent f19e36a17a
commit 17a9f1bdda

View File

@@ -32,16 +32,7 @@ func New(local, remote string) (*Conn, error) {
// Read reads data from the peer. // Read reads data from the peer.
func (c *Conn) Read(b []byte) (int, error) { func (c *Conn) Read(b []byte) (int, error) {
n, addr, err := c.ReadFromUDP(b) n, _, err := c.ReadFromUDP(b)
if err != nil {
return n, err
}
// Discard packets not from the peer
if addr.String() != c.remoteAddr.String() {
return 0, nil
}
return n, err return n, err
} }