diff --git a/cmd/grumble/client.go b/cmd/grumble/client.go index fd174fb..0e496e1 100644 --- a/cmd/grumble/client.go +++ b/cmd/grumble/client.go @@ -112,7 +112,7 @@ func (client *Client) IsSuperUser() bool { if client.user == nil { return false } - return client.user.Id == 0 + return client.user.ID == 0 } // ACLContext returns the access control list context for this client @@ -135,13 +135,13 @@ func (client *Client) Tokens() []string { return client.tokens } -// UserId gets the User ID of this client. +// UserID gets the User ID of this client. // Returns -1 if the client is not a registered user. -func (client *Client) UserId() int { +func (client *Client) UserID() int { if client.user == nil { return -1 } - return int(client.user.Id) + return int(client.user.ID) } // ShownName gets the client's shown name. diff --git a/cmd/grumble/freeze.go b/cmd/grumble/freeze.go index 40de458..dbe8a49 100644 --- a/cmd/grumble/freeze.go +++ b/cmd/grumble/freeze.go @@ -52,7 +52,7 @@ func (server *Server) openFreezeLog() error { server.freezelog = nil } - logfn := filepath.Join(Args.DataDir, "servers", strconv.FormatInt(server.Id, 10), "log.fz") + logfn := filepath.Join(Args.DataDir, "servers", strconv.FormatInt(server.ID, 10), "log.fz") err := os.Remove(logfn) if os.IsNotExist(err) { // fallthrough @@ -237,10 +237,10 @@ func (c *Channel) Unfreeze(fc *freezer.Channel) { if facl.ApplySubs != nil { aclEntry.ApplySubs = *facl.ApplySubs } - if facl.UserId != nil { - aclEntry.UserId = int(*facl.UserId) + if facl.UserID != nil { + aclEntry.UserID = int(*facl.UserID) } else { - aclEntry.UserId = -1 + aclEntry.UserID = -1 } if facl.Group != nil { aclEntry.Group = *facl.Group @@ -295,13 +295,13 @@ func (c *Channel) Unfreeze(fc *freezer.Channel) { func (user *User) Freeze() (fu *freezer.User, err error) { fu = new(freezer.User) - fu.Id = proto.Uint32(user.Id) + fu.Id = proto.Uint32(user.ID) fu.Name = proto.String(user.Name) fu.CertHash = proto.String(user.CertHash) fu.Email = proto.String(user.Email) fu.TextureBlob = proto.String(user.TextureBlob) fu.CommentBlob = proto.String(user.CommentBlob) - fu.LastChannelId = proto.Uint32(uint32(user.LastChannelId)) + fu.LastChannelID = proto.Uint32(uint32(user.LastChannelID)) fu.LastActive = proto.Uint64(user.LastActive) return @@ -324,8 +324,8 @@ func (u *User) Unfreeze(fu *freezer.User) { if fu.CommentBlob != nil { u.CommentBlob = *fu.CommentBlob } - if fu.LastChannelId != nil { - u.LastChannelId = int(*fu.LastChannelId) + if fu.LastChannelID != nil { + u.LastChannelID = int(*fu.LastChannelID) } if fu.LastActive != nil { u.LastActive = *fu.LastActive @@ -336,8 +336,8 @@ func (u *User) Unfreeze(fu *freezer.User) { // ready to be persisted to disk. func FreezeACL(aclEntry acl.ACL) (*freezer.ACL, error) { frozenAcl := &freezer.ACL{} - if aclEntry.UserId != -1 { - frozenAcl.UserId = proto.Uint32(uint32(aclEntry.UserId)) + if aclEntry.UserID != -1 { + frozenAcl.UserID = proto.Uint32(uint32(aclEntry.UserID)) } else { frozenAcl.Group = proto.String(aclEntry.Group) } @@ -445,8 +445,8 @@ func NewServerFromFrozen(name string) (s *Server, err error) { // Update the server's nextChanId field if it needs to be, // to make sure the server doesn't re-use channel id's. c := NewChannel(int(*fc.Id), *fc.Name) - if c.ID >= s.nextChanId { - s.nextChanId = c.ID + 1 + if c.ID >= s.nextChanID { + s.nextChanID = c.ID + 1 } // Update the channel with the contents of the freezer.Channel. @@ -472,8 +472,8 @@ func NewServerFromFrozen(name string) (s *Server, err error) { if err != nil { return nil, err } - if u.Id >= s.nextUserId { - s.nextUserId = u.Id + 1 + if u.ID >= s.nextUserID { + s.nextUserID = u.ID + 1 } // Merge the contents of the freezer.User into @@ -482,7 +482,7 @@ func NewServerFromFrozen(name string) (s *Server, err error) { // Update the server's user maps to point correctly // to the new user. - s.Users[u.Id] = u + s.Users[u.ID] = u s.UserNameMap[u.Name] = u if len(u.CertHash) > 0 { s.UserCertMap[u.CertHash] = u @@ -520,14 +520,14 @@ func NewServerFromFrozen(name string) (s *Server, err error) { continue } - userId := *fu.Id + userID := *fu.Id // Determine whether the user already exists on the server or not. // If the user already exists, this log entry simply updates the // data for that user. // If the user doesn't exist, we create it with the data given in // this log entry. - user, ok := s.Users[userId] + user, ok := s.Users[userID] if !ok { // If no name is given in the log entry, skip this entry. // Also, warn the admin. @@ -535,14 +535,14 @@ func NewServerFromFrozen(name string) (s *Server, err error) { log.Printf("Skipped User creation log entry: No name given.") continue } - // Create the new user and increment the UserId + // Create the new user and increment the UserID // counter for the server if needed. - user, err = NewUser(userId, *fu.Name) + user, err = NewUser(userID, *fu.Name) if err != nil { return nil, err } - if user.Id >= s.nextUserId { - s.nextUserId = user.Id + 1 + if user.ID >= s.nextUserID { + s.nextUserID = user.ID + 1 } } @@ -552,7 +552,7 @@ func NewServerFromFrozen(name string) (s *Server, err error) { // Update the various user maps in the server to // be able to correctly look up the user. - s.Users[user.Id] = user + s.Users[user.ID] = user s.UserNameMap[user.Name] = user if len(user.CertHash) > 0 { s.UserCertMap[user.CertHash] = user @@ -566,14 +566,14 @@ func NewServerFromFrozen(name string) (s *Server, err error) { continue } - userId := *fu.Id + userID := *fu.Id // Does this user even exist? // Warn if we encounter an illegal delete op. - user, ok := s.Users[userId] + user, ok := s.Users[userID] if ok { // Clear the server maps. That should do it. - delete(s.Users, userId) + delete(s.Users, userID) delete(s.UserNameMap, user.Name) if len(user.CertHash) > 0 { delete(s.UserCertMap, user.CertHash) @@ -591,9 +591,9 @@ func NewServerFromFrozen(name string) (s *Server, err error) { continue } - channelId := int(*fc.Id) + channelID := int(*fc.Id) - channel, alreadyExists := s.Channels[channelId] + channel, alreadyExists := s.Channels[channelID] if !alreadyExists { if fc.Name == nil { log.Printf("Skipped Channel creation log entry: No name given.") @@ -601,9 +601,9 @@ func NewServerFromFrozen(name string) (s *Server, err error) { } // Add the channel and increment the server's // nextChanId field to a consistent state. - channel = NewChannel(channelId, *fc.Name) - if channel.ID >= s.nextChanId { - s.nextChanId = channel.ID + 1 + channel = NewChannel(channelID, *fc.Name) + if channel.ID >= s.nextChanID { + s.nextChanID = channel.ID + 1 } } @@ -612,7 +612,7 @@ func NewServerFromFrozen(name string) (s *Server, err error) { channel.Unfreeze(fc) // Re-add it to the server's channel map (in case // the channel was newly-created) - s.Channels[channelId] = channel + s.Channels[channelID] = channel // Mark the channel's parent if !alreadyExists { @@ -652,12 +652,12 @@ func NewServerFromFrozen(name string) (s *Server, err error) { } // Hook up children with their parents - for chanId, parentId := range parents { - childChan, exists := s.Channels[int(chanId)] + for chanID, parentID := range parents { + childChan, exists := s.Channels[int(chanID)] if !exists { return nil, errors.New("Non-existant child channel") } - parentChan, exists := s.Channels[int(parentId)] + parentChan, exists := s.Channels[int(parentID)] if !exists { return nil, errors.New("Non-existant parent channel") } @@ -669,8 +669,8 @@ func NewServerFromFrozen(name string) (s *Server, err error) { if len(channel.Links) > 0 { links := channel.Links channel.Links = make(map[int]*Channel) - for chanId, _ := range links { - targetChannel := s.Channels[chanId] + for chanID, _ := range links { + targetChannel := s.Channels[chanID] if targetChannel != nil { s.LinkChannels(channel, targetChannel) } @@ -687,7 +687,7 @@ func (server *Server) UpdateFrozenUser(client *Client, state *mumbleproto.UserSt // it includes a registration operation. user := client.user nanos := time.Now().Unix() - if state == nil || state.UserId != nil { + if state == nil || state.UserID != nil { fu, err := user.Freeze() if err != nil { server.Fatal(err) @@ -699,9 +699,9 @@ func (server *Server) UpdateFrozenUser(client *Client, state *mumbleproto.UserSt } } else { fu := &freezer.User{} - fu.Id = proto.Uint32(user.Id) + fu.Id = proto.Uint32(user.ID) if state.ChannelId != nil { - fu.LastChannelId = proto.Uint32(uint32(client.Channel.ID)) + fu.LastChannelID = proto.Uint32(uint32(client.Channel.ID)) } if state.TextureHash != nil { fu.TextureBlob = proto.String(user.TextureBlob) @@ -724,8 +724,8 @@ func (server *Server) UpdateFrozenUserLastChannel(client *Client) { user := client.user fu := &freezer.User{} - fu.Id = proto.Uint32(user.Id) - fu.LastChannelId = proto.Uint32(uint32(client.Channel.ID)) + fu.Id = proto.Uint32(user.ID) + fu.LastChannelID = proto.Uint32(uint32(client.Channel.ID)) fu.LastActive = proto.Uint64(uint64(time.Now().Unix())) err := server.freezelog.Put(fu) @@ -739,7 +739,7 @@ func (server *Server) UpdateFrozenUserLastChannel(client *Client) { // DeleteFrozenUser will mark a user as deleted in the datstore. func (server *Server) DeleteFrozenUser(user *User) { - err := server.freezelog.Put(&freezer.UserRemove{Id: proto.Uint32(user.Id)}) + err := server.freezelog.Put(&freezer.UserRemove{Id: proto.Uint32(user.ID)}) if err != nil { server.Fatal(err) } diff --git a/cmd/grumble/freeze_unix.go b/cmd/grumble/freeze_unix.go index 5974539..8a90891 100644 --- a/cmd/grumble/freeze_unix.go +++ b/cmd/grumble/freeze_unix.go @@ -30,7 +30,7 @@ func (server *Server) freezeToFile() (err error) { if err != nil { return err } - f, err := ioutil.TempFile(filepath.Join(Args.DataDir, "servers", strconv.FormatInt(server.Id, 10)), ".main.fz_") + f, err := ioutil.TempFile(filepath.Join(Args.DataDir, "servers", strconv.FormatInt(server.ID, 10)), ".main.fz_") if err != nil { return err } @@ -50,7 +50,7 @@ func (server *Server) freezeToFile() (err error) { if err != nil { return err } - err = os.Rename(f.Name(), filepath.Join(Args.DataDir, "servers", strconv.FormatInt(server.Id, 10), "main.fz")) + err = os.Rename(f.Name(), filepath.Join(Args.DataDir, "servers", strconv.FormatInt(server.ID, 10), "main.fz")) if err != nil { return err } diff --git a/cmd/grumble/grumble.go b/cmd/grumble/grumble.go index 56eaa9a..0bd7aaf 100644 --- a/cmd/grumble/grumble.go +++ b/cmd/grumble/grumble.go @@ -185,7 +185,7 @@ func main() { if err != nil { log.Fatalf("Unable to freeze server to disk: %v", err.Error()) } - servers[s.Id] = s + servers[s.ID] = s } } @@ -196,7 +196,7 @@ func main() { log.Fatalf("Couldn't start server: %s", err.Error()) } - servers[s.Id] = s + servers[s.ID] = s os.Mkdir(filepath.Join(serversDirPath, fmt.Sprintf("%v", 1)), 0750) err = s.FreezeToFile() if err != nil { @@ -208,7 +208,7 @@ func main() { for _, server := range servers { err = server.Start() if err != nil { - log.Printf("Unable to start server %v: %v", server.Id, err.Error()) + log.Printf("Unable to start server %v: %v", server.ID, err.Error()) } } diff --git a/cmd/grumble/message.go b/cmd/grumble/message.go index ad76599..77c7650 100644 --- a/cmd/grumble/message.go +++ b/cmd/grumble/message.go @@ -270,7 +270,7 @@ func (server *Server) handleChannelStateMessage(client *Client, msg *Message) { // Add the creator to the channel's admin group if client.IsRegistered() { grp := acl.EmptyGroupWithName("admin") - grp.Add[client.UserId()] = true + grp.Add[client.UserID()] = true channel.ACL.Groups["admin"] = grp } @@ -281,7 +281,7 @@ func (server *Server) handleChannelStateMessage(client *Client, msg *Message) { aclEntry.ApplyHere = true aclEntry.ApplySubs = true if client.IsRegistered() { - aclEntry.UserId = client.UserId() + aclEntry.UserID = client.UserID() } else { aclEntry.Group = "$" + client.CertHash() } @@ -663,7 +663,7 @@ func (server *Server) handleUserStateMessage(client *Client, msg *Message) { } // Registration - if userstate.UserId != nil { + if userstate.UserID != nil { // If user == actor, check for SelfRegisterPermission on root channel. // If user != actor, check for RegisterPermission permission on root channel. perm := acl.Permission(acl.RegisterPermission) @@ -799,13 +799,13 @@ func (server *Server) handleUserStateMessage(client *Client, msg *Message) { } userRegistrationChanged := false - if userstate.UserId != nil { + if userstate.UserID != nil { uid, err := server.RegisterClient(target) if err != nil { client.Printf("Unable to register: %v", err) - userstate.UserId = nil + userstate.UserID = nil } else { - userstate.UserId = proto.Uint32(uid) + userstate.UserID = proto.Uint32(uid) client.user = server.Users[uid] userRegistrationChanged = true } @@ -1079,9 +1079,9 @@ func (server *Server) handleAclMessage(client *Client, msg *Message) { mpacl.Inherited = proto.Bool(iter != channel) mpacl.ApplyHere = proto.Bool(chanacl.ApplyHere) mpacl.ApplySubs = proto.Bool(chanacl.ApplySubs) - if chanacl.UserId >= 0 { - mpacl.UserId = proto.Uint32(uint32(chanacl.UserId)) - users[chanacl.UserId] = true + if chanacl.UserID >= 0 { + mpacl.UserID = proto.Uint32(uint32(chanacl.UserID)) + users[chanacl.UserID] = true } else { mpacl.Group = proto.String(chanacl.Group) } @@ -1210,8 +1210,8 @@ func (server *Server) handleAclMessage(client *Client, msg *Message) { chanacl := acl.ACL{} chanacl.ApplyHere = *pbacl.ApplyHere chanacl.ApplySubs = *pbacl.ApplySubs - if pbacl.UserId != nil { - chanacl.UserId = int(*pbacl.UserId) + if pbacl.UserID != nil { + chanacl.UserID = int(*pbacl.UserID) } else { chanacl.Group = *pbacl.Group } @@ -1230,7 +1230,7 @@ func (server *Server) handleAclMessage(client *Client, msg *Message) { chanacl.ApplyHere = true chanacl.ApplySubs = false if client.IsRegistered() { - chanacl.UserId = client.UserId() + chanacl.UserID = client.UserID() } else if client.HasCertificate() { chanacl.Group = "$" + client.CertHash() } @@ -1271,7 +1271,7 @@ func (server *Server) handleQueryUsers(client *Client, msg *Message) { for _, name := range query.Names { user, exists := server.UserNameMap[name] if exists { - reply.Ids = append(reply.Ids, user.Id) + reply.Ids = append(reply.Ids, user.ID) reply.Names = append(reply.Names, name) } } @@ -1568,7 +1568,7 @@ func (server *Server) handleUserList(client *Client, msg *Message) { continue } userlist.Users = append(userlist.Users, &mumbleproto.UserList_User{ - UserId: proto.Uint32(uid), + UserID: proto.Uint32(uid), Name: proto.String(user.Name), }) } @@ -1581,7 +1581,7 @@ func (server *Server) handleUserList(client *Client, msg *Message) { if len(userlist.Users) > 0 { tx := server.freezelog.BeginTx() for _, listUser := range userlist.Users { - uid := *listUser.UserId + uid := *listUser.UserID if uid == 0 { continue } @@ -1590,7 +1590,7 @@ func (server *Server) handleUserList(client *Client, msg *Message) { if listUser.Name == nil { // De-register server.RemoveRegistration(uid) - err := tx.Put(&freezer.UserRemove{Id: listUser.UserId}) + err := tx.Put(&freezer.UserRemove{Id: listUser.UserID}) if err != nil { server.Fatal(err) } @@ -1598,7 +1598,7 @@ func (server *Server) handleUserList(client *Client, msg *Message) { // Rename user // todo(mkrautz): Validate name. user.Name = *listUser.Name - err := tx.Put(&freezer.User{Id: listUser.UserId, Name: listUser.Name}) + err := tx.Put(&freezer.User{Id: listUser.UserID, Name: listUser.Name}) if err != nil { server.Fatal(err) } diff --git a/cmd/grumble/murmurdb.go b/cmd/grumble/murmurdb.go index 5996e53..24d4f60 100644 --- a/cmd/grumble/murmurdb.go +++ b/cmd/grumble/murmurdb.go @@ -146,7 +146,7 @@ func populateChannelInfoFromDatabase(server *Server, c *Channel, db *sql.DB) err } // Fetch description - rows, err := stmt.Query(server.Id, c.ID, ChannelInfoDescription) + rows, err := stmt.Query(server.ID, c.ID, ChannelInfoDescription) if err != nil { return err } @@ -167,7 +167,7 @@ func populateChannelInfoFromDatabase(server *Server, c *Channel, db *sql.DB) err } // Fetch position - rows, err = stmt.Query(server.Id, c.ID, ChannelInfoPosition) + rows, err = stmt.Query(server.ID, c.ID, ChannelInfoPosition) if err != nil { return err } @@ -190,36 +190,36 @@ func populateChannelACLFromDatabase(server *Server, c *Channel, db *sql.DB) erro return err } - rows, err := stmt.Query(server.Id, c.ID) + rows, err := stmt.Query(server.ID, c.ID) if err != nil { return err } for rows.Next() { var ( - UserId string + UserID string Group string ApplyHere bool ApplySub bool Allow int64 Deny int64 ) - if err := rows.Scan(&UserId, &Group, &ApplyHere, &ApplySub, &Allow, &Deny); err != nil { + if err := rows.Scan(&UserID, &Group, &ApplyHere, &ApplySub, &Allow, &Deny); err != nil { return err } aclEntry := acl.ACL{} aclEntry.ApplyHere = ApplyHere aclEntry.ApplySubs = ApplySub - if len(UserId) > 0 { - aclEntry.UserId, err = strconv.Atoi(UserId) + if len(UserID) > 0 { + aclEntry.UserID, err = strconv.Atoi(UserID) if err != nil { return err } } else if len(Group) > 0 { aclEntry.Group = Group } else { - return errors.New("Invalid ACL: Neither Group or UserId specified") + return errors.New("Invalid ACL: Neither Group or UserID specified") } aclEntry.Deny = acl.Permission(Deny) @@ -237,7 +237,7 @@ func populateChannelGroupsFromDatabase(server *Server, c *Channel, db *sql.DB) e return err } - rows, err := stmt.Query(server.Id, c.ID) + rows, err := stmt.Query(server.ID, c.ID) if err != nil { return err } @@ -246,13 +246,13 @@ func populateChannelGroupsFromDatabase(server *Server, c *Channel, db *sql.DB) e for rows.Next() { var ( - GroupId int64 + GroupID int64 Name string Inherit bool Inheritable bool ) - if err := rows.Scan(&GroupId, &Name, &Inherit, &Inheritable); err != nil { + if err := rows.Scan(&GroupID, &Name, &Inherit, &Inheritable); err != nil { return err } @@ -260,7 +260,7 @@ func populateChannelGroupsFromDatabase(server *Server, c *Channel, db *sql.DB) e g.Inherit = Inherit g.Inheritable = Inheritable c.ACL.Groups[g.Name] = g - groups[GroupId] = g + groups[GroupID] = g } stmt, err = db.Prepare("SELECT user_id, addit FROM group_members WHERE server_id=? AND group_id=?") @@ -269,25 +269,25 @@ func populateChannelGroupsFromDatabase(server *Server, c *Channel, db *sql.DB) e } for gid, grp := range groups { - rows, err = stmt.Query(server.Id, gid) + rows, err = stmt.Query(server.ID, gid) if err != nil { return err } for rows.Next() { var ( - UserId int64 + UserID int64 Add bool ) - if err := rows.Scan(&UserId, &Add); err != nil { + if err := rows.Scan(&UserID, &Add); err != nil { return err } if Add { - grp.Add[int(UserId)] = true + grp.Add[int(UserID)] = true } else { - grp.Remove[int(UserId)] = true + grp.Remove[int(UserID)] = true } } } @@ -296,8 +296,8 @@ func populateChannelGroupsFromDatabase(server *Server, c *Channel, db *sql.DB) e } // Populate the Server with Channels from the database. -func populateChannelsFromDatabase(server *Server, db *sql.DB, parentId int) error { - parent, exists := server.Channels[parentId] +func populateChannelsFromDatabase(server *Server, db *sql.DB, parentID int) error { + parent, exists := server.Channels[parentID] if !exists { return errors.New("Non-existant parent") } @@ -307,7 +307,7 @@ func populateChannelsFromDatabase(server *Server, db *sql.DB, parentId int) erro return err } - rows, err := stmt.Query(server.Id, parentId) + rows, err := stmt.Query(server.ID, parentID) if err != nil { return err } @@ -371,26 +371,26 @@ func populateChannelLinkInfo(server *Server, db *sql.DB) (err error) { return err } - rows, err := stmt.Query(server.Id) + rows, err := stmt.Query(server.ID) if err != nil { return err } for rows.Next() { var ( - ChannelId int - LinkId int + ChannelID int + LinkID int ) - if err := rows.Scan(&ChannelId, &LinkId); err != nil { + if err := rows.Scan(&ChannelID, &LinkID); err != nil { return err } - channel, exists := server.Channels[ChannelId] + channel, exists := server.Channels[ChannelID] if !exists { return errors.New("Attempt to perform link operation on non-existant channel.") } - other, exists := server.Channels[LinkId] + other, exists := server.Channels[LinkID] if !exists { return errors.New("Attempt to perform link operation on non-existant channel.") } @@ -408,14 +408,14 @@ func populateUsers(server *Server, db *sql.DB) (err error) { return } - rows, err := stmt.Query(server.Id) + rows, err := stmt.Query(server.ID) if err != nil { return } for rows.Next() { var ( - UserId int64 + UserID int64 UserName string SHA1Password string LastChannel int @@ -423,16 +423,16 @@ func populateUsers(server *Server, db *sql.DB) (err error) { LastActive int64 ) - err = rows.Scan(&UserId, &UserName, &SHA1Password, &LastChannel, &Texture, &LastActive) + err = rows.Scan(&UserID, &UserName, &SHA1Password, &LastChannel, &Texture, &LastActive) if err != nil { continue } - if UserId == 0 { + if UserID == 0 { server.cfg.Set("SuperUserPassword", "sha1$$"+SHA1Password) } - user, err := NewUser(uint32(UserId), UserName) + user, err := NewUser(uint32(UserID), UserName) if err != nil { return err } @@ -446,9 +446,9 @@ func populateUsers(server *Server, db *sql.DB) (err error) { } user.LastActive = uint64(LastActive) - user.LastChannelId = LastChannel + user.LastChannelID = LastChannel - server.Users[user.Id] = user + server.Users[user.ID] = user } stmt, err = db.Prepare("SELECT key, value FROM user_info WHERE server_id=? AND user_id=?") @@ -458,7 +458,7 @@ func populateUsers(server *Server, db *sql.DB) (err error) { // Populate users with any new-style UserInfo records for uid, user := range server.Users { - rows, err = stmt.Query(server.Id, uid) + rows, err = stmt.Query(server.ID, uid) if err != nil { return err } @@ -505,7 +505,7 @@ func populateBans(server *Server, db *sql.DB) (err error) { return } - rows, err := stmt.Query(server.Id) + rows, err := stmt.Query(server.ID) if err != nil { return err } diff --git a/cmd/grumble/server.go b/cmd/grumble/server.go index a7ef1cd..abb990f 100644 --- a/cmd/grumble/server.go +++ b/cmd/grumble/server.go @@ -71,7 +71,7 @@ type KeyValuePair struct { // Server is a Grumble server instance type Server struct { - Id int64 + ID int64 tcpl *net.TCPListener tlsl net.Listener @@ -112,13 +112,13 @@ type Server struct { // Channels Channels map[int]*Channel - nextChanId int + nextChanID int // Users Users map[uint32]*User UserCertMap map[string]*User UserNameMap map[string]*User - nextUserId uint32 + nextUserID uint32 // Sessions pool *sessionpool.SessionPool @@ -142,7 +142,7 @@ type clientLogForwarder struct { func (lf clientLogForwarder) Write(incoming []byte) (int, error) { buf := new(bytes.Buffer) - buf.WriteString(fmt.Sprintf("<%v:%v(%v)> ", lf.client.Session(), lf.client.ShownName(), lf.client.UserId())) + buf.WriteString(fmt.Sprintf("<%v:%v(%v)> ", lf.client.Session(), lf.client.ShownName(), lf.client.UserID())) buf.Write(incoming) lf.logger.Output(3, buf.String()) return len(incoming), nil @@ -152,7 +152,7 @@ func (lf clientLogForwarder) Write(incoming []byte) (int, error) { func NewServer(id int64) (s *Server, err error) { s = new(Server) - s.Id = id + s.ID = id s.cfg = serverconf.New(nil) @@ -161,13 +161,13 @@ func NewServer(id int64) (s *Server, err error) { s.UserNameMap = make(map[string]*User) s.Users[0], err = NewUser(0, "SuperUser") s.UserNameMap["SuperUser"] = s.Users[0] - s.nextUserId = 1 + s.nextUserID = 1 s.Channels = make(map[int]*Channel) s.Channels[0] = NewChannel(0, "Root") - s.nextChanId = 1 + s.nextChanID = 1 - s.Logger = log.New(&logtarget.Target, fmt.Sprintf("[%v] ", s.Id), log.LstdFlags|log.Lmicroseconds) + s.Logger = log.New(&logtarget.Target, fmt.Sprintf("[%v] ", s.ID), log.LstdFlags|log.Lmicroseconds) return } @@ -350,9 +350,9 @@ func (server *Server) RemoveClient(client *Client, kicked bool) { // AddChannel adds a new channel to the server. Automatically assign it a channel ID. func (server *Server) AddChannel(name string) (channel *Channel) { - channel = NewChannel(server.nextChanId, name) + channel = NewChannel(server.nextChanID, name) server.Channels[channel.ID] = channel - server.nextChanId += 1 + server.nextChanID += 1 return } @@ -565,7 +565,7 @@ func (server *Server) finishAuthenticate(client *Client) { if client.user != nil { found := false for _, connectedClient := range server.clients { - if connectedClient.UserId() == client.UserId() { + if connectedClient.UserID() == client.UserID() { found = true break } @@ -609,7 +609,7 @@ func (server *Server) finishAuthenticate(client *Client) { channel := server.RootChannel() if client.IsRegistered() { - lastChannel := server.Channels[client.user.LastChannelId] + lastChannel := server.Channels[client.user.LastChannelID] if lastChannel != nil { channel = lastChannel } @@ -626,7 +626,7 @@ func (server *Server) finishAuthenticate(client *Client) { } if client.IsRegistered() { - userstate.UserId = proto.Uint32(uint32(client.UserId())) + userstate.UserID = proto.Uint32(uint32(client.UserID())) if client.user.HasTexture() { // Does the client support blobs? @@ -810,7 +810,7 @@ func (server *Server) sendUserList(client *Client) { } if connectedClient.IsRegistered() { - userstate.UserId = proto.Uint32(uint32(connectedClient.UserId())) + userstate.UserID = proto.Uint32(uint32(connectedClient.UserID())) if connectedClient.user.HasTexture() { // Does the client support blobs? @@ -1099,14 +1099,14 @@ func (server *Server) userEnterChannel(client *Client, channel *Channel, usersta // RegisterClient will register a client on the server. func (s *Server) RegisterClient(client *Client) (uid uint32, err error) { - // Increment nextUserId only if registration succeeded. + // Increment nextUserID only if registration succeeded. defer func() { if err == nil { - s.nextUserId += 1 + s.nextUserID += 1 } }() - user, err := NewUser(s.nextUserId, client.Username) + user, err := NewUser(s.nextUserID, client.Username) if err != nil { return 0, err } @@ -1119,7 +1119,7 @@ func (s *Server) RegisterClient(client *Client) (uid uint32, err error) { user.Email = client.Email user.CertHash = client.CertHash() - uid = s.nextUserId + uid = s.nextUserID s.Users[uid] = user s.UserCertMap[client.CertHash()] = user s.UserNameMap[client.Username] = user @@ -1150,7 +1150,7 @@ func (s *Server) removeRegisteredUserFromChannel(uid uint32, channel *Channel) { newACL := []acl.ACL{} for _, chanacl := range channel.ACL.ACLs { - if chanacl.UserId == int(uid) { + if chanacl.UserID == int(uid) { continue } newACL = append(newACL, chanacl) @@ -1361,7 +1361,7 @@ func (server *Server) cleanPerLaunchData() { func (server *Server) Port() int { port := server.cfg.IntValue("Port") if port == 0 { - return DefaultPort + int(server.Id) - 1 + return DefaultPort + int(server.ID) - 1 } return port } @@ -1371,7 +1371,7 @@ func (server *Server) Port() int { func (server *Server) WebPort() int { port := server.cfg.IntValue("WebPort") if port == 0 { - return DefaultWebPort + int(server.Id) - 1 + return DefaultWebPort + int(server.ID) - 1 } return port } diff --git a/cmd/grumble/user.go b/cmd/grumble/user.go index 47ab09b..0c1aae8 100644 --- a/cmd/grumble/user.go +++ b/cmd/grumble/user.go @@ -15,14 +15,14 @@ import ( // User contains all user information type User struct { - Id uint32 + ID uint32 Name string Password string CertHash string Email string TextureBlob string CommentBlob string - LastChannelId int + LastChannelID int LastActive uint64 } @@ -36,7 +36,7 @@ func NewUser(id uint32, name string) (user *User, err error) { } return &User{ - Id: id, + ID: id, Name: name, }, nil } diff --git a/pkg/acl/acl.go b/pkg/acl/acl.go index 08fc761..0cf766d 100644 --- a/pkg/acl/acl.go +++ b/pkg/acl/acl.go @@ -54,7 +54,7 @@ func (perm Permission) Clean() Permission { type ACL struct { // The user id that this ACL applied to. If this // field is -1, the ACL is a group ACL. - UserId int + UserID int // The group that this ACL applies to. Group string @@ -75,7 +75,7 @@ type ACL struct { // IsUserACL returns true if the ACL is defined for a user, // as opposed to a group. func (acl *ACL) IsUserACL() bool { - return acl.UserId != -1 + return acl.UserID != -1 } // IsChannelACL returns true if the ACL is defined for a group, @@ -93,7 +93,7 @@ func HasPermission(ctx *Context, user User, perm Permission) bool { } // SuperUser can't speak or whisper, but everything else is OK - if user.UserId() == 0 { + if user.UserID() == 0 { if perm == SpeakPermission || perm == WhisperPermission { return false } @@ -125,7 +125,7 @@ func HasPermission(ctx *Context, user User, perm Permission) bool { // If it's a group ACL, we have to parse and interpret // the group string in the current context to determine // membership. For that we use GroupMemberCheck. - matchUser := acl.IsUserACL() && acl.UserId == user.UserId() + matchUser := acl.IsUserACL() && acl.UserID == user.UserID() matchGroup := GroupMemberCheck(origCtx, ctx, acl.Group, user) if matchUser || matchGroup { if acl.Allow.isSet(TraversePermission) { diff --git a/pkg/acl/group.go b/pkg/acl/group.go index b2b282f..615e878 100644 --- a/pkg/acl/group.go +++ b/pkg/acl/group.go @@ -201,8 +201,8 @@ func GroupMemberCheck(current *Context, acl *Context, name string, user User) (o return true } else if name == "auth" { // The user is part of the auth group is he is authenticated. That is, - // his UserId is >= 0. - return user.UserId() >= 0 + // his UserID is >= 0. + return user.UserID() >= 0 } else if name == "strong" { // The user is part of the strong group if he is authenticated to the server // via a strong certificate (i.e. non-self-signed, trusted by the server's @@ -325,10 +325,10 @@ func GroupMemberCheck(current *Context, acl *Context, name string, user User) (o isMember := false for _, group := range groups { - if group.AddContains(user.UserId()) || group.TemporaryContains(user.UserId()) || group.TemporaryContains(-int(user.Session())) { + if group.AddContains(user.UserID()) || group.TemporaryContains(user.UserID()) || group.TemporaryContains(-int(user.Session())) { isMember = true } - if group.RemoveContains(user.UserId()) { + if group.RemoveContains(user.UserID()) { isMember = false } } diff --git a/pkg/acl/interfaces.go b/pkg/acl/interfaces.go index 40a3b94..738a569 100644 --- a/pkg/acl/interfaces.go +++ b/pkg/acl/interfaces.go @@ -10,7 +10,7 @@ package acl // permissions in an ACL context. type User interface { Session() uint32 - UserId() int + UserID() int CertHash() string Tokens() []string diff --git a/pkg/freezer/types.pb.go b/pkg/freezer/types.pb.go index 58bd40a..7862e4c 100644 --- a/pkg/freezer/types.pb.go +++ b/pkg/freezer/types.pb.go @@ -137,7 +137,7 @@ type User struct { Email *string `protobuf:"bytes,5,opt,name=email" json:"email,omitempty"` TextureBlob *string `protobuf:"bytes,6,opt,name=texture_blob" json:"texture_blob,omitempty"` CommentBlob *string `protobuf:"bytes,7,opt,name=comment_blob" json:"comment_blob,omitempty"` - LastChannelId *uint32 `protobuf:"varint,8,opt,name=last_channel_id" json:"last_channel_id,omitempty"` + LastChannelID *uint32 `protobuf:"varint,8,opt,name=last_channel_id" json:"last_channel_id,omitempty"` LastActive *uint64 `protobuf:"varint,9,opt,name=last_active" json:"last_active,omitempty"` XXX_unrecognized []byte `json:"-"` } @@ -195,9 +195,9 @@ func (this *User) GetCommentBlob() string { return "" } -func (this *User) GetLastChannelId() uint32 { - if this != nil && this.LastChannelId != nil { - return *this.LastChannelId +func (this *User) GetLastChannelID() uint32 { + if this != nil && this.LastChannelID != nil { + return *this.LastChannelID } return 0 } @@ -301,7 +301,7 @@ func (this *ChannelRemove) GetId() uint32 { } type ACL struct { - UserId *uint32 `protobuf:"varint,1,opt,name=user_id" json:"user_id,omitempty"` + UserID *uint32 `protobuf:"varint,1,opt,name=user_id" json:"user_id,omitempty"` Group *string `protobuf:"bytes,2,opt,name=group" json:"group,omitempty"` ApplyHere *bool `protobuf:"varint,3,opt,name=apply_here" json:"apply_here,omitempty"` ApplySubs *bool `protobuf:"varint,4,opt,name=apply_subs" json:"apply_subs,omitempty"` @@ -314,9 +314,9 @@ func (this *ACL) Reset() { *this = ACL{} } func (this *ACL) String() string { return proto.CompactTextString(this) } func (*ACL) ProtoMessage() {} -func (this *ACL) GetUserId() uint32 { - if this != nil && this.UserId != nil { - return *this.UserId +func (this *ACL) GetUserID() uint32 { + if this != nil && this.UserID != nil { + return *this.UserID } return 0 } diff --git a/pkg/mumbleproto/Mumble.pb.go b/pkg/mumbleproto/Mumble.pb.go index db112df..64a5ab3 100644 --- a/pkg/mumbleproto/Mumble.pb.go +++ b/pkg/mumbleproto/Mumble.pb.go @@ -780,7 +780,7 @@ type UserState struct { // User name, UTF-8 encoded. Name *string `protobuf:"bytes,3,opt,name=name" json:"name,omitempty"` // Registered user ID if the user is registered. - UserId *uint32 `protobuf:"varint,4,opt,name=user_id,json=userId" json:"user_id,omitempty"` + UserID *uint32 `protobuf:"varint,4,opt,name=user_id,json=userId" json:"user_id,omitempty"` // Channel on which the user is. ChannelId *uint32 `protobuf:"varint,5,opt,name=channel_id,json=channelId" json:"channel_id,omitempty"` // True if the user is muted by admin. @@ -841,9 +841,9 @@ func (m *UserState) GetName() string { return "" } -func (m *UserState) GetUserId() uint32 { - if m != nil && m.UserId != nil { - return *m.UserId +func (m *UserState) GetUserID() uint32 { + if m != nil && m.UserID != nil { + return *m.UserID } return 0 } @@ -1321,7 +1321,7 @@ type ACL_ChanACL struct { // True if the ACL has been inherited from the parent. Inherited *bool `protobuf:"varint,3,opt,name=inherited,def=1" json:"inherited,omitempty"` // ID of the user that is affected by this ACL. - UserId *uint32 `protobuf:"varint,4,opt,name=user_id,json=userId" json:"user_id,omitempty"` + UserID *uint32 `protobuf:"varint,4,opt,name=user_id,json=userId" json:"user_id,omitempty"` // ID of the group that is affected by this ACL. Group *string `protobuf:"bytes,5,opt,name=group" json:"group,omitempty"` // Bit flag field of the permissions granted by this ACL. @@ -1361,9 +1361,9 @@ func (m *ACL_ChanACL) GetInherited() bool { return Default_ACL_ChanACL_Inherited } -func (m *ACL_ChanACL) GetUserId() uint32 { - if m != nil && m.UserId != nil { - return *m.UserId +func (m *ACL_ChanACL) GetUserID() uint32 { + if m != nil && m.UserID != nil { + return *m.UserID } return 0 } @@ -1561,7 +1561,7 @@ func (m *UserList) GetUsers() []*UserList_User { type UserList_User struct { // Registered user ID. - UserId *uint32 `protobuf:"varint,1,req,name=user_id,json=userId" json:"user_id,omitempty"` + UserID *uint32 `protobuf:"varint,1,req,name=user_id,json=userId" json:"user_id,omitempty"` // Registered user name. Name *string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"` LastSeen *string `protobuf:"bytes,3,opt,name=last_seen,json=lastSeen" json:"last_seen,omitempty"` @@ -1574,9 +1574,9 @@ func (m *UserList_User) String() string { return proto.CompactTextStr func (*UserList_User) ProtoMessage() {} func (*UserList_User) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{18, 0} } -func (m *UserList_User) GetUserId() uint32 { - if m != nil && m.UserId != nil { - return *m.UserId +func (m *UserList_User) GetUserID() uint32 { + if m != nil && m.UserID != nil { + return *m.UserID } return 0 }