Regenerate SessionID on reconnection

legacy-v1 v1.0.0
Qian Wang 5 years ago
parent a1d546dc0b
commit c44b202c27

@ -127,7 +127,7 @@ func main() {
}
if *isAdmin {
sta := client.InitState("", "", "", "", time.Now, 0)
sta := client.InitState("", "", "", "", time.Now)
err := sta.ParseConfig(pluginOpts)
if err != nil {
log.Fatal(err)
@ -139,12 +139,7 @@ func main() {
return
}
// 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 := client.InitState(localHost, localPort, remoteHost, remotePort, time.Now, sessionID)
sta := client.InitState(localHost, localPort, remoteHost, remotePort, time.Now)
err := sta.ParseConfig(pluginOpts)
if err != nil {
log.Fatal(err)
@ -167,6 +162,11 @@ func main() {
start:
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
valve := mux.MakeValve(1e12, 1e12, &UNLIMITED, &UNLIMITED)
obfs := mux.MakeObfs(sta.UID)

@ -42,19 +42,20 @@ type State struct {
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{
SS_LOCAL_HOST: localHost,
SS_LOCAL_PORT: localPort,
SS_REMOTE_HOST: remoteHost,
SS_REMOTE_PORT: remotePort,
Now: nowFunc,
sessionID: sessionID,
}
ret.keyPairs = make(map[int64]*keyPair)
return ret
}
func (sta *State) SetSessionID(id uint32) { sta.sessionID = id }
// semi-colon separated value. This is for Android plugin options
func ssvToJson(ssv string) (ret []byte) {
unescape := func(s string) string {

Loading…
Cancel
Save