Allow UDP option to be set in both commandline and json

pull/108/head
Andy Wang 4 years ago
parent b2660a9f88
commit 25e41d0941

@ -106,6 +106,8 @@ func main() {
rawConfig.RemoteHost = remoteHost
case "p":
rawConfig.RemotePort = remotePort
case "u":
rawConfig.UDP = udp
case "proxy":
rawConfig.ProxyMethod = proxyMethod
}
@ -148,12 +150,10 @@ func main() {
}
} else {
var network string
if udp {
if authInfo.Unordered {
network = "UDP"
authInfo.Unordered = true
} else {
network = "TCP"
authInfo.Unordered = false
}
log.Infof("Listening on %v %v for %v client", network, localConfig.LocalAddr, authInfo.ProxyMethod)
seshMaker = func() *mux.Session {
@ -161,7 +161,7 @@ func main() {
}
}
if udp {
if authInfo.Unordered {
client.RouteUDP(localConfig, seshMaker)
} else {
client.RouteTCP(localConfig, seshMaker)

@ -27,9 +27,9 @@ type rawConfig struct {
LocalPort string // jsonOptional
RemoteHost string // jsonOptional
RemotePort string // jsonOptional
//TODO: udp
// defaults set in SplitConfigs
UDP bool // nullable
BrowserSig string // nullable
Transport string // nullable
StreamTimeout int // nullable
@ -57,7 +57,7 @@ func ssvToJson(ssv string) (ret []byte) {
r = strings.Replace(r, `\;`, `;`, -1)
return r
}
unquoted := []string{"NumConn", "StreamTimeout", "KeepAlive"}
unquoted := []string{"NumConn", "StreamTimeout", "KeepAlive", "UDP"}
lines := strings.Split(unescape(ssv), ";")
ret = []byte("{")
for _, ln := range lines {
@ -107,6 +107,8 @@ func (raw *rawConfig) SplitConfigs() (local *localConnConfig, remote *remoteConn
}
auth = new(authInfo)
auth.UID = raw.UID
auth.Unordered = raw.UDP
if raw.ServerName == "" {
return nullErr("ServerName")
}
@ -118,7 +120,6 @@ func (raw *rawConfig) SplitConfigs() (local *localConnConfig, remote *remoteConn
if len(raw.UID) == 0 {
return nullErr("UID")
}
auth.UID = raw.UID
// static public key
if len(raw.PublicKey) == 0 {

Loading…
Cancel
Save