2016-06-14 16:54:08 -04:00
|
|
|
package udp
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net"
|
2016-08-20 14:55:45 -04:00
|
|
|
v2net "v2ray.com/core/common/net"
|
|
|
|
"v2ray.com/core/transport/internet"
|
2016-06-14 16:54:08 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
type Connection struct {
|
|
|
|
net.UDPConn
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *Connection) Reusable() bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *Connection) SetReusable(b bool) {}
|
|
|
|
|
|
|
|
func init() {
|
2016-09-30 10:53:40 -04:00
|
|
|
internet.UDPDialer = func(src v2net.Address, dest v2net.Destination, options internet.DialerOptions) (internet.Connection, error) {
|
2016-06-14 16:54:08 -04:00
|
|
|
conn, err := internet.DialToDest(src, dest)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2016-09-30 10:53:40 -04:00
|
|
|
// TODO: handle dialer options
|
2016-06-14 16:54:08 -04:00
|
|
|
return &Connection{
|
|
|
|
UDPConn: *(conn.(*net.UDPConn)),
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
}
|