mirror of
https://github.com/nadoo/glider.git
synced 2026-11-19 07:09:42 +08:00
proxy: nat fullcone support for tproxy, trojan, ss, socks5 (fix #253)
This commit is contained in:
1 parent
d68f361c35
commit
a98995e2cb
42 files changed
+366
-280
No files matched your search
@@ -32,21 +32,21 @@ func (s *Unix) Dial(network, addr string) (net.Conn, error) {
|
||||
|
||||
// DialUDP connects to the given address via the proxy.
|
||||
// NOTE: must be the first dialer in a chain
|
||||
func (s *Unix) DialUDP(network, addr string) (net.PacketConn, net.Addr, error) {
|
||||
func (s *Unix) DialUDP(network, addr string) (net.PacketConn, error) {
|
||||
laddru := s.addru + "_" + addr
|
||||
os.Remove(laddru)
|
||||
|
||||
luaddru, err := net.ResolveUnixAddr("unixgram", laddru)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
pc, err := net.ListenUnixgram("unixgram", luaddru)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &PktConn{pc, laddru, luaddru, s.uaddru}, s.uaddru, nil
|
||||
return &PktConn{pc, laddru, luaddru, s.uaddru}, nil
|
||||
}
|
||||
|
||||
// PktConn .
|
||||
|
||||
@@ -140,7 +140,7 @@ func (s *Unix) ServePacket(pc net.PacketConn) {
|
||||
}
|
||||
|
||||
func (s *Unix) serveSession(session *Session) {
|
||||
dstPC, dialer, writeTo, err := s.proxy.DialUDP("udp", "")
|
||||
dstPC, dialer, err := s.proxy.DialUDP("udp", "")
|
||||
if err != nil {
|
||||
log.F("[unix] remote dial error: %v", err)
|
||||
nm.Delete(session.key)
|
||||
@@ -159,9 +159,9 @@ func (s *Unix) serveSession(session *Session) {
|
||||
for {
|
||||
select {
|
||||
case p := <-session.msgCh:
|
||||
_, err = dstPC.WriteTo(p, writeTo)
|
||||
_, err = dstPC.WriteTo(p, nil)
|
||||
if err != nil {
|
||||
log.F("[unix] writeTo %s error: %v", writeTo, err)
|
||||
log.F("[unix] writeTo error: %v", err)
|
||||
}
|
||||
pool.PutBuffer(p)
|
||||
case <-session.finCh:
|
||||
|
||||
Reference in new issue
Block a user