Remove unnecessary state variable IsAdmin

This commit is contained in:
Qian Wang 2019-08-12 14:25:24 +01:00
parent 58cbb73f0f
commit f65a46f4a9
2 changed files with 6 additions and 6 deletions

View File

@ -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)

View File

@ -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