mirror of
https://github.com/cmz0228/hysteria-dev.git
synced 2025-06-21 03:39:51 +00:00
chore: move common stuff to common.go
This commit is contained in:
parent
6ac5e0e455
commit
0119024392
@ -6,6 +6,11 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
packetQueueSize = 1024
|
||||||
|
udpBufferSize = 2048
|
||||||
|
)
|
||||||
|
|
||||||
// parseAddr parses the listen address and returns the host and ports.
|
// parseAddr parses the listen address and returns the host and ports.
|
||||||
// Format: "host:port1,port2,port3,..."
|
// Format: "host:port1,port2,port3,..."
|
||||||
func parseAddr(addr string) (host string, ports []uint16, err error) {
|
func parseAddr(addr string) (host string, ports []uint16, err error) {
|
||||||
@ -27,3 +32,21 @@ func parseAddr(addr string) (host string, ports []uint16, err error) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type udpHopAddr struct {
|
||||||
|
listen string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *udpHopAddr) Network() string {
|
||||||
|
return "udp-hop"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *udpHopAddr) String() string {
|
||||||
|
return a.listen
|
||||||
|
}
|
||||||
|
|
||||||
|
type udpPacket struct {
|
||||||
|
buf []byte
|
||||||
|
n int
|
||||||
|
addr net.Addr
|
||||||
|
}
|
@ -12,8 +12,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
packetQueueSize = 1024
|
|
||||||
udpBufferSize = 2048
|
|
||||||
addrMapEntryTTL = time.Minute
|
addrMapEntryTTL = time.Minute
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -32,29 +30,11 @@ type ObfsUDPHopServerPacketConn struct {
|
|||||||
bufPool sync.Pool
|
bufPool sync.Pool
|
||||||
}
|
}
|
||||||
|
|
||||||
type udpPacket struct {
|
|
||||||
buf []byte
|
|
||||||
n int
|
|
||||||
addr net.Addr
|
|
||||||
}
|
|
||||||
|
|
||||||
type addrMapEntry struct {
|
type addrMapEntry struct {
|
||||||
index int
|
index int
|
||||||
last time.Time
|
last time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
type udpHopAddr struct {
|
|
||||||
listen string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *udpHopAddr) Network() string {
|
|
||||||
return "udp-hop"
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *udpHopAddr) String() string {
|
|
||||||
return a.listen
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewObfsUDPHopServerPacketConn(listen string, obfs obfs.Obfuscator) (*ObfsUDPHopServerPacketConn, error) {
|
func NewObfsUDPHopServerPacketConn(listen string, obfs obfs.Obfuscator) (*ObfsUDPHopServerPacketConn, error) {
|
||||||
host, ports, err := parseAddr(listen)
|
host, ports, err := parseAddr(listen)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user