mirror of
https://github.com/nadoo/glider.git
synced 2026-11-19 07:09:42 +08:00
socks5,ss: improve udp server
This commit is contained in:
1 parent
f3dc252967
commit
32e1c37cfe
6 files changed
+132
-88
No files matched your search
+8
-8
@@ -12,19 +12,19 @@ import (
|
||||
"github.com/nadoo/glider/proxy"
|
||||
)
|
||||
|
||||
// UDP struct.
|
||||
type UDP struct {
|
||||
addr string
|
||||
dialer proxy.Dialer
|
||||
proxy proxy.Proxy
|
||||
}
|
||||
var nm sync.Map
|
||||
|
||||
func init() {
|
||||
proxy.RegisterDialer("udp", NewUDPDialer)
|
||||
proxy.RegisterServer("udp", NewUDPServer)
|
||||
}
|
||||
|
||||
var nm sync.Map
|
||||
// UDP struct.
|
||||
type UDP struct {
|
||||
addr string
|
||||
dialer proxy.Dialer
|
||||
proxy proxy.Proxy
|
||||
}
|
||||
|
||||
// NewUDP returns a udp struct.
|
||||
func NewUDP(s string, d proxy.Dialer, p proxy.Proxy) (*UDP, error) {
|
||||
@@ -57,7 +57,7 @@ func NewUDPServer(s string, p proxy.Proxy) (proxy.Server, error) {
|
||||
func (s *UDP) ListenAndServe() {
|
||||
c, err := net.ListenPacket("udp", s.addr)
|
||||
if err != nil {
|
||||
log.F("[udp] failed to listen on %s: %v", s.addr, err)
|
||||
log.F("[udp] failed to listen on UDP %s: %v", s.addr, err)
|
||||
return
|
||||
}
|
||||
defer c.Close()
|
||||
|
||||
Reference in new issue
Block a user