mirror of https://github.com/cbeuw/Cloak
Clarify the code to enter admin mode
This commit is contained in:
parent
1cb7bff8b3
commit
23a06c6a52
|
|
@ -124,18 +124,25 @@ func main() {
|
|||
return
|
||||
}
|
||||
|
||||
log.Printf("Starting standalone mode. Listening for ss on %v:%v\n", localHost, localPort)
|
||||
log.Println("Starting standalone mode")
|
||||
}
|
||||
|
||||
if *isAdmin {
|
||||
sta := client.InitState("", "", "", "", time.Now, 0)
|
||||
err := sta.ParseConfig(pluginOpts)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = adminPrompt(sta)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
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())
|
||||
var sessionID uint32
|
||||
if *isAdmin {
|
||||
sessionID = 0
|
||||
} else {
|
||||
sessionID = rand.Uint32()
|
||||
}
|
||||
sessionID := rand.Uint32()
|
||||
|
||||
// opaque is used to generate the padding of session ticket
|
||||
sta := client.InitState(localHost, localPort, remoteHost, remotePort, time.Now, sessionID)
|
||||
|
|
@ -144,14 +151,6 @@ func main() {
|
|||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if *isAdmin {
|
||||
err = adminPrompt(sta)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if sta.SS_LOCAL_PORT == "" {
|
||||
log.Fatal("Must specify localPort")
|
||||
}
|
||||
|
|
@ -184,6 +183,7 @@ func main() {
|
|||
wg.Wait()
|
||||
|
||||
listener, err := net.Listen("tcp", sta.SS_LOCAL_HOST+":"+sta.SS_LOCAL_PORT)
|
||||
log.Println("Listening for ss on " + sta.SS_LOCAL_HOST + ":" + sta.SS_LOCAL_PORT)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,6 +128,7 @@ func (sb *switchboard) removeConn(closing *connEnclave) {
|
|||
sb.cesM.Unlock()
|
||||
}
|
||||
|
||||
// actively triggered by session.Close()
|
||||
func (sb *switchboard) shutdown() {
|
||||
for _, ce := range sb.ces {
|
||||
ce.remoteConn.Close()
|
||||
|
|
|
|||
Loading…
Reference in New Issue