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 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") 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 usergenerated. There shouldn't be a security concern because the scope of
// sessionID is limited to its UID. // sessionID is limited to its UID.
quad := make([]byte, 4) quad := make([]byte, 4)
@ -179,7 +179,6 @@ func main() {
if adminUID != nil { if adminUID != nil {
log.Infof("API base is %v:%v", listeningIP, sta.LocalPort) log.Infof("API base is %v:%v", listeningIP, sta.LocalPort)
sta.IsAdmin = true
sta.SessionID = 0 sta.SessionID = 0
sta.UID = adminUID sta.UID = adminUID
sta.NumConn = 1 sta.NumConn = 1
@ -196,7 +195,7 @@ func main() {
continue continue
} }
if sesh == nil || sesh.IsClosed() { if sesh == nil || sesh.IsClosed() {
sesh = makeSession(sta) sesh = makeSession(sta, adminUID != nil)
} }
go func() { go func() {
data := make([]byte, 10240) data := make([]byte, 10240)

View File

@ -19,6 +19,8 @@ type rawConfig struct {
UID string UID string
PublicKey string PublicKey string
BrowserSig string BrowserSig string
Unordered bool
NumConn int NumConn int
} }
@ -33,7 +35,6 @@ type State struct {
SessionID uint32 SessionID uint32
UID []byte UID []byte
staticPub crypto.PublicKey staticPub crypto.PublicKey
IsAdmin bool
Browser Browser Browser Browser