mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-09-30 10:57:57 +03:00
https://github.com/XTLS/Xray-core/pull/6854#issuecomment-5895541650 Fixes https://github.com/XTLS/Xray-core/issues/6849
21 lines
439 B
Go
21 lines
439 B
Go
package net
|
|
|
|
// PacketConnWrapper wraps a PacketConn into a Conn with a fixed destination address.
|
|
type PacketConnWrapper struct {
|
|
PacketConn
|
|
Dest Addr
|
|
}
|
|
|
|
func (c *PacketConnWrapper) Read(p []byte) (int, error) {
|
|
n, _, err := c.PacketConn.ReadFrom(p)
|
|
return n, err
|
|
}
|
|
|
|
func (c *PacketConnWrapper) Write(p []byte) (int, error) {
|
|
return c.PacketConn.WriteTo(p, c.Dest)
|
|
}
|
|
|
|
func (c *PacketConnWrapper) RemoteAddr() Addr {
|
|
return c.Dest
|
|
}
|