connection.go 553 B

123456789101112131415161718192021222324252627282930
  1. package udp
  2. import (
  3. "net"
  4. v2net "github.com/v2ray/v2ray-core/common/net"
  5. "github.com/v2ray/v2ray-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) (internet.Connection, error) {
  16. conn, err := internet.DialToDest(src, dest)
  17. if err != nil {
  18. return nil, err
  19. }
  20. return &Connection{
  21. UDPConn: *(conn.(*net.UDPConn)),
  22. }, nil
  23. }
  24. }