From 1099b558f1064e8d8e15c1a46579ecf11952654e Mon Sep 17 00:00:00 2001 From: Qian Wang Date: Sat, 27 Jul 2019 19:55:53 +0100 Subject: [PATCH] Fix admin mode --- cmd/ck-client/ck-client.go | 13 ++++++++----- internal/client/state.go | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cmd/ck-client/ck-client.go b/cmd/ck-client/ck-client.go index 2247be6..d8272ee 100644 --- a/cmd/ck-client/ck-client.go +++ b/cmd/ck-client/ck-client.go @@ -90,11 +90,13 @@ func makeRemoteConn(sta *client.State) (net.Conn, error) { func makeSession(sta *client.State) *mux.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. - quad := make([]byte, 4) - rand.Read(quad) - sta.SessionID = binary.BigEndian.Uint32(quad) + if !sta.IsAdmin { + // sessionID is usergenerated. There shouldn't be a security concern because the scope of + // sessionID is limited to its UID. + quad := make([]byte, 4) + rand.Read(quad) + sta.SessionID = binary.BigEndian.Uint32(quad) + } sta.UpdateIntervalKeys() @@ -208,6 +210,7 @@ func main() { } if adminUID != nil { + sta.IsAdmin = true sta.SessionID = 0 sta.UID = adminUID sta.NumConn = 1 diff --git a/internal/client/state.go b/internal/client/state.go index 3e1004c..9208180 100644 --- a/internal/client/state.go +++ b/internal/client/state.go @@ -46,6 +46,7 @@ type State struct { SessionID uint32 UID []byte staticPub crypto.PublicKey + IsAdmin bool intervalDataM sync.Mutex intervalData *tthIntervalKeys