mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-07-03 18:28:52 +00:00
36303694d1
https://github.com/XTLS/Xray-core/pull/5657#issuecomment-4446406536 https://github.com/XTLS/Xray-core/pull/6137#issuecomment-4469822775 Example: https://github.com/XTLS/Xray-core/pull/6137#issue-4454013510
28 lines
786 B
Go
28 lines
786 B
Go
package realm
|
|
|
|
import (
|
|
"net"
|
|
|
|
"github.com/xtls/xray-core/common/errors"
|
|
"github.com/xtls/xray-core/transport/internet"
|
|
"github.com/xtls/xray-core/transport/internet/hysteria/udphop"
|
|
)
|
|
|
|
func (c *Config) UDP() {}
|
|
|
|
func (c *Config) WrapPacketConnClient(raw net.PacketConn, level int, levelCount int) (net.PacketConn, error) {
|
|
_, ok1 := raw.(*internet.FakePacketConn)
|
|
_, ok2 := raw.(*udphop.UdpHopPacketConn)
|
|
if level != 0 || ok1 || ok2 {
|
|
return nil, errors.New("realm requires being at the outermost level")
|
|
}
|
|
return NewConnClient(c, raw)
|
|
}
|
|
|
|
func (c *Config) WrapPacketConnServer(raw net.PacketConn, level int, levelCount int) (net.PacketConn, error) {
|
|
if level != 0 {
|
|
return nil, errors.New("realm requires being at the outermost level")
|
|
}
|
|
return NewConnServer(c, raw)
|
|
}
|