mirror of
https://github.com/nadoo/glider.git
synced 2026-11-19 07:09:42 +08:00
chore: document works and code optimizations
This commit is contained in:
1 parent
142865535e
commit
2db84bb7aa
17 files changed
+43
-54
No files matched your search
@@ -77,5 +77,5 @@ func (s *HTTP) Dial(network, addr string) (net.Conn, error) {
|
||||
|
||||
// DialUDP connects to the given address via the proxy.
|
||||
func (s *HTTP) DialUDP(network, addr string) (pc net.PacketConn, writeTo net.Addr, err error) {
|
||||
return nil, nil, errors.New("http client does not support udp")
|
||||
return nil, nil, proxy.ErrNotSupported
|
||||
}
|
||||
+1
-1
@@ -241,7 +241,7 @@ func (s *KCP) Dial(network, addr string) (net.Conn, error) {
|
||||
|
||||
// DialUDP connects to the given address via the proxy.
|
||||
func (s *KCP) DialUDP(network, addr string) (net.PacketConn, net.Addr, error) {
|
||||
return nil, nil, errors.New("kcp client does not support udp now")
|
||||
return nil, nil, proxy.ErrNotSupported
|
||||
}
|
||||
|
||||
func (s *KCP) setParams(c *kcp.UDPSession) {
|
||||
|
||||
+1
-1
@@ -107,5 +107,5 @@ func (s *Obfs) Dial(network, addr string) (net.Conn, error) {
|
||||
|
||||
// DialUDP connects to the given address via the proxy.
|
||||
func (s *Obfs) DialUDP(network, addr string) (net.PacketConn, net.Addr, error) {
|
||||
return nil, nil, errors.New("obfs client does not support udp now")
|
||||
return nil, nil, proxy.ErrNotSupported
|
||||
}
|
||||
@@ -86,7 +86,7 @@ func (s *SOCKS4) Dial(network, addr string) (net.Conn, error) {
|
||||
|
||||
// DialUDP connects to the given address via the proxy.
|
||||
func (s *SOCKS4) DialUDP(network, addr string) (pc net.PacketConn, writeTo net.Addr, err error) {
|
||||
return nil, nil, errors.New("[socks4] DialUDP are not supported by Socks4")
|
||||
return nil, nil, proxy.ErrNotSupported
|
||||
}
|
||||
|
||||
func (s *SOCKS4) lookupIP(host string) (ip net.IP, err error) {
|
||||
|
||||
@@ -124,7 +124,7 @@ func (s *Socks5) ListenAndServeUDP() {
|
||||
continue
|
||||
}
|
||||
|
||||
lpc, _, nextHop, err := s.proxy.DialUDP("udp", c.tgtAddr.String())
|
||||
lpc, dialer, nextHop, err := s.proxy.DialUDP("udp", c.tgtAddr.String())
|
||||
if err != nil {
|
||||
log.F("[socks5u] remote dial error: %v", err)
|
||||
continue
|
||||
@@ -139,7 +139,7 @@ func (s *Socks5) ListenAndServeUDP() {
|
||||
nm.Delete(raddr.String())
|
||||
}()
|
||||
|
||||
log.F("[socks5u] %s <-> %s via %s", raddr, c.tgtAddr, nextHop)
|
||||
log.F("[socks5u] %s <-> %s via %s", raddr, c.tgtAddr, dialer.Addr())
|
||||
|
||||
} else {
|
||||
pc = v.(*PktConn)
|
||||
|
||||
+2
-2
@@ -108,7 +108,7 @@ func (s *SS) ListenAndServeUDP() {
|
||||
var pc *PktConn
|
||||
v, ok := nm.Load(raddr.String())
|
||||
if !ok && v == nil {
|
||||
lpc, _, nextHop, err := s.proxy.DialUDP("udp", c.tgtAddr.String())
|
||||
lpc, dialer, nextHop, err := s.proxy.DialUDP("udp", c.tgtAddr.String())
|
||||
if err != nil {
|
||||
log.F("[ssu] remote dial error: %v", err)
|
||||
continue
|
||||
@@ -123,7 +123,7 @@ func (s *SS) ListenAndServeUDP() {
|
||||
nm.Delete(raddr.String())
|
||||
}()
|
||||
|
||||
log.F("[ssu] %s <-> %s via %s", raddr, c.tgtAddr, nextHop)
|
||||
log.F("[ssu] %s <-> %s via %s", raddr, c.tgtAddr, dialer.Addr())
|
||||
|
||||
} else {
|
||||
pc = v.(*PktConn)
|
||||
|
||||
+1
-2
@@ -1,7 +1,6 @@
|
||||
package ssh
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/url"
|
||||
@@ -101,7 +100,7 @@ func (s *SSH) Dial(network, addr string) (net.Conn, error) {
|
||||
|
||||
// DialUDP connects to the given address via the proxy.
|
||||
func (s *SSH) DialUDP(network, addr string) (pc net.PacketConn, writeTo net.Addr, err error) {
|
||||
return nil, nil, errors.New("ssh client does not support udp")
|
||||
return nil, nil, proxy.ErrNotSupported
|
||||
}
|
||||
|
||||
func privateKeyAuth(file string) (ssh.AuthMethod, error) {
|
||||
|
||||
+1
-1
@@ -153,5 +153,5 @@ func (s *SSR) Dial(network, addr string) (net.Conn, error) {
|
||||
|
||||
// DialUDP connects to the given address via the proxy.
|
||||
func (s *SSR) DialUDP(network, addr string) (net.PacketConn, net.Addr, error) {
|
||||
return nil, nil, errors.New("[ssr] udp not supported now")
|
||||
return nil, nil, proxy.ErrNotSupported
|
||||
}
|
||||
+1
-1
@@ -190,5 +190,5 @@ func (s *TLS) Dial(network, addr string) (net.Conn, error) {
|
||||
|
||||
// DialUDP connects to the given address via the proxy.
|
||||
func (s *TLS) DialUDP(network, addr string) (net.PacketConn, net.Addr, error) {
|
||||
return nil, nil, errors.New("tls client does not support udp now")
|
||||
return nil, nil, proxy.ErrNotSupported
|
||||
}
|
||||
+3
-1
@@ -103,7 +103,9 @@ func (s *UDP) ListenAndServe() {
|
||||
continue
|
||||
}
|
||||
|
||||
log.F("[udp] %s <-> %s", lraddr, dialer.Addr())
|
||||
if dialer != nil {
|
||||
log.F("[udp] %s <-> %s", lraddr, dialer.Addr())
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +143,9 @@ func (s *Unix) ListenAndServeUDP() {
|
||||
continue
|
||||
}
|
||||
|
||||
log.F("[unix] %s <-> %s", s.addru, dialer.Addr())
|
||||
if dialer != nil {
|
||||
log.F("[unix] %s <-> %s", s.addru, dialer.Addr())
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package vmess
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net"
|
||||
"net/url"
|
||||
"strconv"
|
||||
@@ -98,5 +97,5 @@ func (s *VMess) Dial(network, addr string) (net.Conn, error) {
|
||||
|
||||
// DialUDP connects to the given address via the proxy.
|
||||
func (s *VMess) DialUDP(network, addr string) (net.PacketConn, net.Addr, error) {
|
||||
return nil, nil, errors.New("vmess client does not support udp now")
|
||||
return nil, nil, proxy.ErrNotSupported
|
||||
}
|
||||
+1
-1
@@ -39,7 +39,7 @@ func (s *WS) Dial(network, addr string) (net.Conn, error) {
|
||||
|
||||
// DialUDP connects to the given address via the proxy.
|
||||
func (s *WS) DialUDP(network, addr string) (net.PacketConn, net.Addr, error) {
|
||||
return nil, nil, errors.New("[ws] ws client does not support udp now")
|
||||
return nil, nil, proxy.ErrNotSupported
|
||||
}
|
||||
|
||||
// ClientConn is a connection to ws server.
|
||||
|
||||
Reference in new issue
Block a user