1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-09-06 03:54:22 -04:00
v2fly/transport/internet/udp/connection.go

32 lines
586 B
Go
Raw Normal View History

2016-06-14 16:54:08 -04:00
package udp
import (
"net"
2016-12-21 09:37:16 -05:00
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
}
2016-11-27 15:39:09 -05:00
func (v *Connection) Reusable() bool {
2016-06-14 16:54:08 -04:00
return false
}
2016-11-27 15:39:09 -05:00
func (v *Connection) SetReusable(b bool) {}
2016-06-14 16:54:08 -04:00
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
}
}