mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 20:57:36 +03:00
29 lines
498 B
Go
29 lines
498 B
Go
package quic
|
|
|
|
import "net"
|
|
|
|
type connection interface {
|
|
write([]byte) error
|
|
setCurrentRemoteAddr(interface{})
|
|
IP() net.IP
|
|
}
|
|
|
|
type udpConn struct {
|
|
conn *net.UDPConn
|
|
currentAddr *net.UDPAddr
|
|
}
|
|
|
|
var _ connection = &udpConn{}
|
|
|
|
func (c *udpConn) write(p []byte) error {
|
|
_, err := c.conn.WriteToUDP(p, c.currentAddr)
|
|
return err
|
|
}
|
|
|
|
func (c *udpConn) setCurrentRemoteAddr(addr interface{}) {
|
|
c.currentAddr = addr.(*net.UDPAddr)
|
|
}
|
|
|
|
func (c *udpConn) IP() net.IP {
|
|
return c.currentAddr.IP
|
|
}
|