udp_windows.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. //go:build windows
  2. // +build windows
  3. // TODO(tmthrgd): Remove this Windows-specific code if go.dev/issue/7175 and
  4. // go.dev/issue/7174 are ever fixed.
  5. package dns
  6. import "net"
  7. // SessionUDP holds the remote address
  8. type SessionUDP struct {
  9. raddr *net.UDPAddr
  10. }
  11. // RemoteAddr returns the remote network address.
  12. func (s *SessionUDP) RemoteAddr() net.Addr { return s.raddr }
  13. // ReadFromSessionUDP acts just like net.UDPConn.ReadFrom(), but returns a session object instead of a
  14. // net.UDPAddr.
  15. func ReadFromSessionUDP(conn *net.UDPConn, b []byte) (int, *SessionUDP, error) {
  16. n, raddr, err := conn.ReadFrom(b)
  17. if err != nil {
  18. return n, nil, err
  19. }
  20. return n, &SessionUDP{raddr.(*net.UDPAddr)}, err
  21. }
  22. // WriteToSessionUDP acts just like net.UDPConn.WriteTo(), but uses a *SessionUDP instead of a net.Addr.
  23. func WriteToSessionUDP(conn *net.UDPConn, b []byte, session *SessionUDP) (int, error) {
  24. return conn.WriteTo(b, session.raddr)
  25. }
  26. func setUDPSocketOptions(*net.UDPConn) error { return nil }
  27. func parseDstFromOOB([]byte, net.IP) net.IP { return nil }