v2ray-core/transport/internet/udp/connection.go

31 lines
585 B
Go
Raw Normal View History

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