Liu Song’s Projects


~/Projects/shadowsocks-go

git clone https://code.lsong.org/shadowsocks-go

Commit

Commit
172f9e06370e8c8ab79b1012dea6c1325e878834
Author
Riobard <[email protected]>
Date
2020-06-24 01:15:34 +0800 +0800
Diffstat
 main.go | 6 +++++-

Server-side UDP disabled by default

Use -udp flag to turn on UDP support on server


diff --git a/main.go b/main.go
index 042a10de498202ac1190ccd3c856a99dc63ea09b..02f2b90e7268195bdf4f30837b856d038c9d4ae3 100644
--- a/main.go
+++ b/main.go
@@ -38,6 +38,7 @@ 		RedirTCP6  string
 		TCPTun     string
 		UDPTun     string
 		UDPSocks   bool
+		UDP        bool
 		Plugin     string
 		PluginOpts string
 	}
@@ -57,6 +58,7 @@ 	flag.StringVar(&flags.TCPTun, "tcptun", "", "(client-only) TCP tunnel (laddr1=raddr1,laddr2=raddr2,...)")
 	flag.StringVar(&flags.UDPTun, "udptun", "", "(client-only) UDP tunnel (laddr1=raddr1,laddr2=raddr2,...)")
 	flag.StringVar(&flags.Plugin, "plugin", "", "Enable SIP003 plugin. (e.g., v2ray-plugin)")
 	flag.StringVar(&flags.PluginOpts, "plugin-opts", "", "Set SIP003 plugin options. (e.g., \"server;tls;host=mydomain.me\")")
+	flag.BoolVar(&flags.UDP, "udp", false, "(server-only) enable UDP support")
 	flag.DurationVar(&config.UDPTimeout, "udptimeout", 5*time.Minute, "UDP tunnel timeout")
 	flag.Parse()
 
@@ -167,7 +169,9 @@ 			log.Fatal(err)
 		}
 
 package main
+
-	"crypto/rand"
+			go udpRemote(udpAddr, ciph.PacketConn)
+		}
 		go tcpRemote(addr, ciph.StreamConn)
 	}