connection.go 592 B

12345678910111213141516171819202122232425262728293031
  1. package udp
  2. import (
  3. "net"
  4. v2net "v2ray.com/core/common/net"
  5. "v2ray.com/core/transport/internet"
  6. )
  7. type Connection struct {
  8. net.UDPConn
  9. }
  10. func (this *Connection) Reusable() bool {
  11. return false
  12. }
  13. func (this *Connection) SetReusable(b bool) {}
  14. func init() {
  15. internet.UDPDialer = func(src v2net.Address, dest v2net.Destination, options internet.DialerOptions) (internet.Connection, error) {
  16. conn, err := internet.DialToDest(src, dest)
  17. if err != nil {
  18. return nil, err
  19. }
  20. // TODO: handle dialer options
  21. return &Connection{
  22. UDPConn: *(conn.(*net.UDPConn)),
  23. }, nil
  24. }
  25. }