From f65a46f4a9c0bc41476c1cd01f5cc7cf870b2f1d Mon Sep 17 00:00:00 2001 From: Qian Wang Date: Mon, 12 Aug 2019 14:25:24 +0100 Subject: [PATCH] Remove unnecessary state variable IsAdmin --- cmd/ck-client/ck-client.go | 7 +++---- internal/client/state.go | 5 +++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/ck-client/ck-client.go b/cmd/ck-client/ck-client.go index 3e5d04d..136a572 100644 --- a/cmd/ck-client/ck-client.go +++ b/cmd/ck-client/ck-client.go @@ -23,9 +23,9 @@ import ( var version string -func makeSession(sta *client.State) *mux.Session { +func makeSession(sta *client.State, isAdmin bool) *mux.Session { log.Info("Attemtping to start a new session") - if !sta.IsAdmin { + if 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) @@ -179,7 +179,6 @@ func main() { if adminUID != nil { log.Infof("API base is %v:%v", listeningIP, sta.LocalPort) - sta.IsAdmin = true sta.SessionID = 0 sta.UID = adminUID sta.NumConn = 1 @@ -196,7 +195,7 @@ func main() { continue } if sesh == nil || sesh.IsClosed() { - sesh = makeSession(sta) + sesh = makeSession(sta, adminUID != nil) } go func() { data := make([]byte, 10240) diff --git a/internal/client/state.go b/internal/client/state.go index 56418c3..0d44229 100644 --- a/internal/client/state.go +++ b/internal/client/state.go @@ -19,7 +19,9 @@ type rawConfig struct { UID string PublicKey string BrowserSig string - NumConn int + Unordered bool + + NumConn int } // State stores global variables @@ -33,7 +35,6 @@ type State struct { SessionID uint32 UID []byte staticPub crypto.PublicKey - IsAdmin bool Browser Browser