mirror of https://github.com/cbeuw/Cloak
Regenerate SessionID on reconnection
This commit is contained in:
parent
a1d546dc0b
commit
c44b202c27
|
|
@ -127,7 +127,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if *isAdmin {
|
if *isAdmin {
|
||||||
sta := client.InitState("", "", "", "", time.Now, 0)
|
sta := client.InitState("", "", "", "", time.Now)
|
||||||
err := sta.ParseConfig(pluginOpts)
|
err := sta.ParseConfig(pluginOpts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|
@ -139,12 +139,7 @@ func main() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// sessionID is usergenerated. There shouldn't be a security concern because the scope of
|
sta := client.InitState(localHost, localPort, remoteHost, remotePort, time.Now)
|
||||||
// sessionID is limited to its UID.
|
|
||||||
rand.Seed(time.Now().UnixNano())
|
|
||||||
sessionID := rand.Uint32()
|
|
||||||
|
|
||||||
sta := client.InitState(localHost, localPort, remoteHost, remotePort, time.Now, sessionID)
|
|
||||||
err := sta.ParseConfig(pluginOpts)
|
err := sta.ParseConfig(pluginOpts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|
@ -167,6 +162,11 @@ func main() {
|
||||||
|
|
||||||
start:
|
start:
|
||||||
log.Println("Attemtping to start a new session")
|
log.Println("Attemtping to start a new session")
|
||||||
|
// sessionID is usergenerated. There shouldn't be a security concern because the scope of
|
||||||
|
// sessionID is limited to its UID.
|
||||||
|
rand.Seed(time.Now().UnixNano())
|
||||||
|
sessionID := rand.Uint32()
|
||||||
|
sta.SetSessionID(sessionID)
|
||||||
var UNLIMITED int64 = 1e12
|
var UNLIMITED int64 = 1e12
|
||||||
valve := mux.MakeValve(1e12, 1e12, &UNLIMITED, &UNLIMITED)
|
valve := mux.MakeValve(1e12, 1e12, &UNLIMITED, &UNLIMITED)
|
||||||
obfs := mux.MakeObfs(sta.UID)
|
obfs := mux.MakeObfs(sta.UID)
|
||||||
|
|
|
||||||
|
|
@ -42,19 +42,20 @@ type State struct {
|
||||||
NumConn int
|
NumConn int
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitState(localHost, localPort, remoteHost, remotePort string, nowFunc func() time.Time, sessionID uint32) *State {
|
func InitState(localHost, localPort, remoteHost, remotePort string, nowFunc func() time.Time) *State {
|
||||||
ret := &State{
|
ret := &State{
|
||||||
SS_LOCAL_HOST: localHost,
|
SS_LOCAL_HOST: localHost,
|
||||||
SS_LOCAL_PORT: localPort,
|
SS_LOCAL_PORT: localPort,
|
||||||
SS_REMOTE_HOST: remoteHost,
|
SS_REMOTE_HOST: remoteHost,
|
||||||
SS_REMOTE_PORT: remotePort,
|
SS_REMOTE_PORT: remotePort,
|
||||||
Now: nowFunc,
|
Now: nowFunc,
|
||||||
sessionID: sessionID,
|
|
||||||
}
|
}
|
||||||
ret.keyPairs = make(map[int64]*keyPair)
|
ret.keyPairs = make(map[int64]*keyPair)
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (sta *State) SetSessionID(id uint32) { sta.sessionID = id }
|
||||||
|
|
||||||
// semi-colon separated value. This is for Android plugin options
|
// semi-colon separated value. This is for Android plugin options
|
||||||
func ssvToJson(ssv string) (ret []byte) {
|
func ssvToJson(ssv string) (ret []byte) {
|
||||||
unescape := func(s string) string {
|
unescape := func(s string) string {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue