mirror of https://github.com/cbeuw/Cloak
Allow UDP option to be set in both commandline and json
This commit is contained in:
parent
b2660a9f88
commit
25e41d0941
|
|
@ -106,6 +106,8 @@ func main() {
|
||||||
rawConfig.RemoteHost = remoteHost
|
rawConfig.RemoteHost = remoteHost
|
||||||
case "p":
|
case "p":
|
||||||
rawConfig.RemotePort = remotePort
|
rawConfig.RemotePort = remotePort
|
||||||
|
case "u":
|
||||||
|
rawConfig.UDP = udp
|
||||||
case "proxy":
|
case "proxy":
|
||||||
rawConfig.ProxyMethod = proxyMethod
|
rawConfig.ProxyMethod = proxyMethod
|
||||||
}
|
}
|
||||||
|
|
@ -148,12 +150,10 @@ func main() {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var network string
|
var network string
|
||||||
if udp {
|
if authInfo.Unordered {
|
||||||
network = "UDP"
|
network = "UDP"
|
||||||
authInfo.Unordered = true
|
|
||||||
} else {
|
} else {
|
||||||
network = "TCP"
|
network = "TCP"
|
||||||
authInfo.Unordered = false
|
|
||||||
}
|
}
|
||||||
log.Infof("Listening on %v %v for %v client", network, localConfig.LocalAddr, authInfo.ProxyMethod)
|
log.Infof("Listening on %v %v for %v client", network, localConfig.LocalAddr, authInfo.ProxyMethod)
|
||||||
seshMaker = func() *mux.Session {
|
seshMaker = func() *mux.Session {
|
||||||
|
|
@ -161,7 +161,7 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if udp {
|
if authInfo.Unordered {
|
||||||
client.RouteUDP(localConfig, seshMaker)
|
client.RouteUDP(localConfig, seshMaker)
|
||||||
} else {
|
} else {
|
||||||
client.RouteTCP(localConfig, seshMaker)
|
client.RouteTCP(localConfig, seshMaker)
|
||||||
|
|
|
||||||
|
|
@ -27,9 +27,9 @@ type rawConfig struct {
|
||||||
LocalPort string // jsonOptional
|
LocalPort string // jsonOptional
|
||||||
RemoteHost string // jsonOptional
|
RemoteHost string // jsonOptional
|
||||||
RemotePort string // jsonOptional
|
RemotePort string // jsonOptional
|
||||||
//TODO: udp
|
|
||||||
|
|
||||||
// defaults set in SplitConfigs
|
// defaults set in SplitConfigs
|
||||||
|
UDP bool // nullable
|
||||||
BrowserSig string // nullable
|
BrowserSig string // nullable
|
||||||
Transport string // nullable
|
Transport string // nullable
|
||||||
StreamTimeout int // nullable
|
StreamTimeout int // nullable
|
||||||
|
|
@ -57,7 +57,7 @@ func ssvToJson(ssv string) (ret []byte) {
|
||||||
r = strings.Replace(r, `\;`, `;`, -1)
|
r = strings.Replace(r, `\;`, `;`, -1)
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
unquoted := []string{"NumConn", "StreamTimeout", "KeepAlive"}
|
unquoted := []string{"NumConn", "StreamTimeout", "KeepAlive", "UDP"}
|
||||||
lines := strings.Split(unescape(ssv), ";")
|
lines := strings.Split(unescape(ssv), ";")
|
||||||
ret = []byte("{")
|
ret = []byte("{")
|
||||||
for _, ln := range lines {
|
for _, ln := range lines {
|
||||||
|
|
@ -107,6 +107,8 @@ func (raw *rawConfig) SplitConfigs() (local *localConnConfig, remote *remoteConn
|
||||||
}
|
}
|
||||||
|
|
||||||
auth = new(authInfo)
|
auth = new(authInfo)
|
||||||
|
auth.UID = raw.UID
|
||||||
|
auth.Unordered = raw.UDP
|
||||||
if raw.ServerName == "" {
|
if raw.ServerName == "" {
|
||||||
return nullErr("ServerName")
|
return nullErr("ServerName")
|
||||||
}
|
}
|
||||||
|
|
@ -118,7 +120,6 @@ func (raw *rawConfig) SplitConfigs() (local *localConnConfig, remote *remoteConn
|
||||||
if len(raw.UID) == 0 {
|
if len(raw.UID) == 0 {
|
||||||
return nullErr("UID")
|
return nullErr("UID")
|
||||||
}
|
}
|
||||||
auth.UID = raw.UID
|
|
||||||
|
|
||||||
// static public key
|
// static public key
|
||||||
if len(raw.PublicKey) == 0 {
|
if len(raw.PublicKey) == 0 {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue