diff --git a/cmd/grumble/channel.go b/cmd/grumble/channel.go index f9eaabd..2389436 100644 --- a/cmd/grumble/channel.go +++ b/cmd/grumble/channel.go @@ -12,7 +12,7 @@ import ( // Channel represents a Mumble channel type Channel struct { - Id int + ID int Name string Position int @@ -34,7 +34,7 @@ type Channel struct { // NewChannel creates a new Mumble channel func NewChannel(id int, name string) (channel *Channel) { channel = new(Channel) - channel.Id = id + channel.ID = id channel.Name = name channel.clients = make(map[uint32]*Client) channel.children = make(map[int]*Channel) @@ -47,14 +47,14 @@ func NewChannel(id int, name string) (channel *Channel) { func (channel *Channel) AddChild(child *Channel) { child.parent = channel child.ACL.Parent = &channel.ACL - channel.children[child.Id] = child + channel.children[child.ID] = child } // RemoveChild removes a child channel from a parent func (channel *Channel) RemoveChild(child *Channel) { child.parent = nil child.ACL.Parent = nil - delete(channel.children, child.Id) + delete(channel.children, child.ID) } // AddClient adds client @@ -93,8 +93,8 @@ func (channel *Channel) AllLinks() (seen map[int]*Channel) { current := walk[len(walk)-1] walk = walk[0 : len(walk)-1] for _, linked := range current.Links { - if _, alreadySeen := seen[linked.Id]; !alreadySeen { - seen[linked.Id] = linked + if _, alreadySeen := seen[linked.ID]; !alreadySeen { + seen[linked.ID] = linked walk = append(walk, linked) } } @@ -112,8 +112,8 @@ func (channel *Channel) AllSubChannels() (seen map[int]*Channel) { current := walk[len(walk)-1] walk = walk[0 : len(walk)-1] for _, child := range current.children { - if _, alreadySeen := seen[child.Id]; !alreadySeen { - seen[child.Id] = child + if _, alreadySeen := seen[child.ID]; !alreadySeen { + seen[child.ID] = child walk = append(walk, child) } } diff --git a/cmd/grumble/client.go b/cmd/grumble/client.go index 233958b..0c5d68c 100644 --- a/cmd/grumble/client.go +++ b/cmd/grumble/client.go @@ -292,7 +292,7 @@ func (c *Client) sendPermissionDeniedTypeUser(denyType mumbleproto.PermissionDen func (c *Client) sendPermissionDenied(who *Client, where *Channel, what acl.Permission) { pd := &mumbleproto.PermissionDenied{ Permission: proto.Uint32(uint32(what)), - ChannelId: proto.Uint32(uint32(where.Id)), + ChannelId: proto.Uint32(uint32(where.ID)), Session: proto.Uint32(who.Session()), Type: mumbleproto.PermissionDenied_Permission.Enum(), } @@ -593,11 +593,11 @@ func (client *Client) sendChannelList() { func (client *Client) sendChannelTree(channel *Channel) { chanstate := &mumbleproto.ChannelState{ - ChannelId: proto.Uint32(uint32(channel.Id)), + ChannelId: proto.Uint32(uint32(channel.ID)), Name: proto.String(channel.Name), } if channel.parent != nil { - chanstate.Parent = proto.Uint32(uint32(channel.parent.Id)) + chanstate.Parent = proto.Uint32(uint32(channel.parent.ID)) } if channel.HasDescription() { diff --git a/cmd/grumble/freeze.go b/cmd/grumble/freeze.go index 4b289dd..40de458 100644 --- a/cmd/grumble/freeze.go +++ b/cmd/grumble/freeze.go @@ -167,10 +167,10 @@ func FreezeBan(ban ban.Ban) (fb *freezer.Ban) { func (channel *Channel) Freeze() (fc *freezer.Channel, err error) { fc = new(freezer.Channel) - fc.Id = proto.Uint32(uint32(channel.Id)) + fc.Id = proto.Uint32(uint32(channel.ID)) fc.Name = proto.String(channel.Name) if channel.parent != nil { - fc.ParentId = proto.Uint32(uint32(channel.parent.Id)) + fc.ParentId = proto.Uint32(uint32(channel.parent.ID)) } fc.Position = proto.Int64(int64(channel.Position)) fc.InheritAcl = proto.Bool(channel.ACL.InheritACL) @@ -445,15 +445,15 @@ 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. c.Unfreeze(fc) // Add the channel's id to the server's channel-id-map. - s.Channels[c.Id] = c + s.Channels[c.ID] = c // Mark the channel's parent if fc.ParentId != nil { @@ -602,8 +602,8 @@ 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 + if channel.ID >= s.nextChanId { + s.nextChanId = channel.ID + 1 } } @@ -701,7 +701,7 @@ func (server *Server) UpdateFrozenUser(client *Client, state *mumbleproto.UserSt fu := &freezer.User{} 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) @@ -725,7 +725,7 @@ func (server *Server) UpdateFrozenUserLastChannel(client *Client) { fu := &freezer.User{} fu.Id = proto.Uint32(user.Id) - fu.LastChannelId = proto.Uint32(uint32(client.Channel.Id)) + fu.LastChannelId = proto.Uint32(uint32(client.Channel.ID)) fu.LastActive = proto.Uint64(uint64(time.Now().Unix())) err := server.freezelog.Put(fu) @@ -751,7 +751,7 @@ func (server *Server) DeleteFrozenUser(user *User) { // frozen.Channel to the datastore. func (server *Server) UpdateFrozenChannel(channel *Channel, state *mumbleproto.ChannelState) { fc := &freezer.Channel{} - fc.Id = proto.Uint32(uint32(channel.Id)) + fc.Id = proto.Uint32(uint32(channel.ID)) if state.Name != nil { fc.Name = state.Name } @@ -784,7 +784,7 @@ func (server *Server) UpdateFrozenChannel(channel *Channel, state *mumbleproto.C func (server *Server) UpdateFrozenChannelACLs(channel *Channel) { fc := &freezer.Channel{} - fc.Id = proto.Uint32(uint32(channel.Id)) + fc.Id = proto.Uint32(uint32(channel.ID)) fc.InheritAcl = proto.Bool(channel.ACL.InheritACL) acls := []*freezer.ACL{} @@ -816,7 +816,7 @@ func (server *Server) UpdateFrozenChannelACLs(channel *Channel) { // DeleteFrozenChannel will mark a channel as deleted in the datastore. func (server *Server) DeleteFrozenChannel(channel *Channel) { - err := server.freezelog.Put(&freezer.ChannelRemove{Id: proto.Uint32(uint32(channel.Id))}) + err := server.freezelog.Put(&freezer.ChannelRemove{Id: proto.Uint32(uint32(channel.ID))}) if err != nil { server.Fatal(err) } diff --git a/cmd/grumble/message.go b/cmd/grumble/message.go index b9e9780..4cdced7 100644 --- a/cmd/grumble/message.go +++ b/cmd/grumble/message.go @@ -204,7 +204,7 @@ func (server *Server) handleChannelStateMessage(client *Client, msg *Message) { name = *chanstate.Name // We don't allow renames for the root channel. - if channel != nil && channel.Id != 0 { + if channel != nil && channel.ID != 0 { // Pick a parent. If the name change is part of a re-parent (a channel move), // we must evaluate the parent variable. Since we're explicitly exlcuding the root // channel from renames, channels that are the target of renames are guaranteed to have @@ -293,7 +293,7 @@ func (server *Server) handleChannelStateMessage(client *Client, msg *Message) { server.ClearCaches() } - chanstate.ChannelId = proto.Uint32(uint32(channel.Id)) + chanstate.ChannelId = proto.Uint32(uint32(channel.ID)) // Broadcast channel add server.broadcastProtoMessageWithPredicate(chanstate, func(client *Client) bool { @@ -313,7 +313,7 @@ func (server *Server) handleChannelStateMessage(client *Client, msg *Message) { if channel.IsTemporary() { userstate := &mumbleproto.UserState{} userstate.Session = proto.Uint32(client.Session()) - userstate.ChannelId = proto.Uint32(uint32(channel.Id)) + userstate.ChannelId = proto.Uint32(uint32(channel.ID)) server.userEnterChannel(client, channel, userstate) server.broadcastProtoMessage(userstate) } @@ -325,7 +325,7 @@ func (server *Server) handleChannelStateMessage(client *Client, msg *Message) { if chanstate.Name != nil { // The client can only rename the channel if it has WritePermission in the channel. // Also, clients cannot change the name of the root channel. - if !acl.HasPermission(&channel.ACL, client, acl.WritePermission) || channel.Id == 0 { + if !acl.HasPermission(&channel.ACL, client, acl.WritePermission) || channel.ID == 0 { client.sendPermissionDenied(client, channel, acl.WritePermission) return } @@ -1049,7 +1049,7 @@ func (server *Server) handleAclMessage(client *Client, msg *Message) { } reply := &mumbleproto.ACL{} - reply.ChannelId = proto.Uint32(uint32(channel.Id)) + reply.ChannelId = proto.Uint32(uint32(channel.ID)) channels := []*Channel{} users := map[int]bool{} @@ -1533,7 +1533,7 @@ func (server *Server) handleRequestBlob(client *Client, msg *Message) { server.Panicf("Blobstore error: %v", err) return } - chanstate.ChannelId = proto.Uint32(uint32(channel.Id)) + chanstate.ChannelId = proto.Uint32(uint32(channel.ID)) chanstate.Description = proto.String(string(buf)) if err := client.sendMessage(chanstate); err != nil { client.Panic(err) diff --git a/cmd/grumble/murmurdb.go b/cmd/grumble/murmurdb.go index 55792e2..5996e53 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,7 +190,7 @@ 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 } @@ -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 } @@ -324,7 +324,7 @@ func populateChannelsFromDatabase(server *Server, db *sql.DB, parentId int) erro } c := NewChannel(chanid, name) - server.Channels[c.Id] = c + server.Channels[c.ID] = c c.ACL.InheritACL = inherit parent.AddChild(c) } diff --git a/cmd/grumble/server.go b/cmd/grumble/server.go index 03ed4ac..7a585a5 100644 --- a/cmd/grumble/server.go +++ b/cmd/grumble/server.go @@ -351,7 +351,7 @@ 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) - server.Channels[channel.Id] = channel + server.Channels[channel.ID] = channel server.nextChanId += 1 return @@ -359,24 +359,24 @@ func (server *Server) AddChannel(name string) (channel *Channel) { // RemoveChanel removes a channel from the server. func (server *Server) RemoveChanel(channel *Channel) { - if channel.Id == 0 { + if channel.ID == 0 { server.Printf("Attempted to remove root channel.") return } - delete(server.Channels, channel.Id) + delete(server.Channels, channel.ID) } // LinkChannels will link two channels func (server *Server) LinkChannels(channel *Channel, other *Channel) { - channel.Links[other.Id] = other - other.Links[channel.Id] = channel + channel.Links[other.ID] = other + other.Links[channel.ID] = channel } // UnlinkChannels will unlink two channels func (server *Server) UnlinkChannels(channel *Channel, other *Channel) { - delete(channel.Links, other.Id) - delete(other.Links, channel.Id) + delete(channel.Links, other.ID) + delete(other.Links, channel.ID) } // This is the synchronous handler goroutine. @@ -618,7 +618,7 @@ func (server *Server) finishAuthenticate(client *Client) { userstate := &mumbleproto.UserState{ Session: proto.Uint32(client.Session()), Name: proto.String(client.ShownName()), - ChannelId: proto.Uint32(uint32(channel.Id)), + ChannelId: proto.Uint32(uint32(channel.ID)), } if client.HasCertificate() { @@ -802,7 +802,7 @@ func (server *Server) sendUserList(client *Client) { userstate := &mumbleproto.UserState{ Session: proto.Uint32(connectedClient.Session()), Name: proto.String(connectedClient.ShownName()), - ChannelId: proto.Uint32(uint32(connectedClient.Channel.Id)), + ChannelId: proto.Uint32(uint32(connectedClient.Channel.ID)), } if connectedClient.HasCertificate() { @@ -1183,7 +1183,7 @@ func (server *Server) RemoveChannel(channel *Channel) { // Remove all links for _, linkedChannel := range channel.Links { - delete(linkedChannel.Links, channel.Id) + delete(linkedChannel.Links, channel.ID) } // Remove all subchannels @@ -1200,7 +1200,7 @@ func (server *Server) RemoveChannel(channel *Channel) { userstate := &mumbleproto.UserState{} userstate.Session = proto.Uint32(client.Session()) - userstate.ChannelId = proto.Uint32(uint32(target.Id)) + userstate.ChannelId = proto.Uint32(uint32(target.ID)) server.userEnterChannel(client, target, userstate) if err := server.broadcastProtoMessage(userstate); err != nil { server.Panicf("%v", err) @@ -1209,10 +1209,10 @@ func (server *Server) RemoveChannel(channel *Channel) { // Remove the channel itself parent := channel.parent - delete(parent.children, channel.Id) - delete(server.Channels, channel.Id) + delete(parent.children, channel.ID) + delete(server.Channels, channel.ID) chanremove := &mumbleproto.ChannelRemove{ - ChannelId: proto.Uint32(uint32(channel.Id)), + ChannelId: proto.Uint32(uint32(channel.ID)), } if err := server.broadcastProtoMessage(chanremove); err != nil { server.Panicf("%v", err) diff --git a/cmd/grumble/voicetarget.go b/cmd/grumble/voicetarget.go index 74d3175..6f7d4be 100644 --- a/cmd/grumble/voicetarget.go +++ b/cmd/grumble/voicetarget.go @@ -85,7 +85,7 @@ func (vt *VoiceTarget) SendVoiceBroadcast(vb *VoiceBroadcast) { if vtc.links { newchans = channel.AllLinks() } else { - newchans[channel.Id] = channel + newchans[channel.ID] = channel } if vtc.subChannels { subchans := channel.AllSubChannels()