Make receiver names consistent according to Golang coding standards

This commit is contained in:
Ola Bini 2019-12-21 22:51:15 +00:00
parent 861fae65a2
commit 92840d1770
No known key found for this signature in database
GPG key ID: 6786A150F6A2B28F
3 changed files with 39 additions and 39 deletions

View file

@ -269,36 +269,36 @@ func (client *Client) readProtoMessage() (msg *Message, err error) {
} }
// Send permission denied by type // Send permission denied by type
func (c *Client) sendPermissionDeniedType(denyType mumbleproto.PermissionDenied_DenyType) { func (client *Client) sendPermissionDeniedType(denyType mumbleproto.PermissionDenied_DenyType) {
c.sendPermissionDeniedTypeUser(denyType, nil) client.sendPermissionDeniedTypeUser(denyType, nil)
} }
// Send permission denied by type (and user) // Send permission denied by type (and user)
func (c *Client) sendPermissionDeniedTypeUser(denyType mumbleproto.PermissionDenied_DenyType, user *Client) { func (client *Client) sendPermissionDeniedTypeUser(denyType mumbleproto.PermissionDenied_DenyType, user *Client) {
pd := &mumbleproto.PermissionDenied{ pd := &mumbleproto.PermissionDenied{
Type: denyType.Enum(), Type: denyType.Enum(),
} }
if user != nil { if user != nil {
pd.Session = proto.Uint32(uint32(user.Session())) pd.Session = proto.Uint32(uint32(user.Session()))
} }
err := c.sendMessage(pd) err := client.sendMessage(pd)
if err != nil { if err != nil {
c.Panicf("%v", err.Error()) client.Panicf("%v", err.Error())
return return
} }
} }
// Send permission denied by who, what, where // Send permission denied by who, what, where
func (c *Client) sendPermissionDenied(who *Client, where *Channel, what acl.Permission) { func (client *Client) sendPermissionDenied(who *Client, where *Channel, what acl.Permission) {
pd := &mumbleproto.PermissionDenied{ pd := &mumbleproto.PermissionDenied{
Permission: proto.Uint32(uint32(what)), Permission: proto.Uint32(uint32(what)),
ChannelId: proto.Uint32(uint32(where.ID)), ChannelId: proto.Uint32(uint32(where.ID)),
Session: proto.Uint32(who.Session()), Session: proto.Uint32(who.Session()),
Type: mumbleproto.PermissionDenied_Permission.Enum(), Type: mumbleproto.PermissionDenied_Permission.Enum(),
} }
err := c.sendMessage(pd) err := client.sendMessage(pd)
if err != nil { if err != nil {
c.Panicf("%v", err.Error()) client.Panicf("%v", err.Error())
return return
} }
} }

View file

@ -118,8 +118,8 @@ func (server *Server) Freeze() (fs *freezer.Server, err error) {
// UnfreezeBanList will merge the contents of a freezer.BanList into the server's // UnfreezeBanList will merge the contents of a freezer.BanList into the server's
// ban list. // ban list.
func (s *Server) UnfreezeBanList(fblist *freezer.BanList) { func (server *Server) UnfreezeBanList(fblist *freezer.BanList) {
s.Bans = nil server.Bans = nil
for _, fb := range fblist.Bans { for _, fb := range fblist.Bans {
ban := ban.Ban{} ban := ban.Ban{}
@ -143,7 +143,7 @@ func (s *Server) UnfreezeBanList(fblist *freezer.BanList) {
ban.Duration = *fb.Duration ban.Duration = *fb.Duration
} }
s.Bans = append(s.Bans, ban) server.Bans = append(server.Bans, ban)
} }
} }
@ -212,23 +212,23 @@ func (channel *Channel) Freeze() (fc *freezer.Channel, err error) {
// Unfreeze unfreezes the contents of a freezer.Channel // Unfreeze unfreezes the contents of a freezer.Channel
// into a channel. // into a channel.
func (c *Channel) Unfreeze(fc *freezer.Channel) { func (channel *Channel) Unfreeze(fc *freezer.Channel) {
if fc.Name != nil { if fc.Name != nil {
c.Name = *fc.Name channel.Name = *fc.Name
} }
if fc.Position != nil { if fc.Position != nil {
c.Position = int(*fc.Position) channel.Position = int(*fc.Position)
} }
if fc.InheritACL != nil { if fc.InheritACL != nil {
c.ACL.InheritACL = *fc.InheritACL channel.ACL.InheritACL = *fc.InheritACL
} }
if fc.DescriptionBlob != nil { if fc.DescriptionBlob != nil {
c.DescriptionBlob = *fc.DescriptionBlob channel.DescriptionBlob = *fc.DescriptionBlob
} }
// Update ACLs // Update ACLs
if fc.ACL != nil { if fc.ACL != nil {
c.ACL.ACLs = nil channel.ACL.ACLs = nil
for _, facl := range fc.ACL { for _, facl := range fc.ACL {
aclEntry := acl.ACL{} aclEntry := acl.ACL{}
if facl.ApplyHere != nil { if facl.ApplyHere != nil {
@ -251,13 +251,13 @@ func (c *Channel) Unfreeze(fc *freezer.Channel) {
if facl.Allow != nil { if facl.Allow != nil {
aclEntry.Allow = acl.Permission(*facl.Allow) aclEntry.Allow = acl.Permission(*facl.Allow)
} }
c.ACL.ACLs = append(c.ACL.ACLs, aclEntry) channel.ACL.ACLs = append(channel.ACL.ACLs, aclEntry)
} }
} }
// Update groups // Update groups
if fc.Groups != nil { if fc.Groups != nil {
c.ACL.Groups = make(map[string]acl.Group) channel.ACL.Groups = make(map[string]acl.Group)
for _, fgrp := range fc.Groups { for _, fgrp := range fc.Groups {
if fgrp.Name == nil { if fgrp.Name == nil {
continue continue
@ -275,7 +275,7 @@ func (c *Channel) Unfreeze(fc *freezer.Channel) {
for _, uid := range fgrp.Remove { for _, uid := range fgrp.Remove {
g.Remove[int(uid)] = true g.Remove[int(uid)] = true
} }
c.ACL.Groups[g.Name] = g channel.ACL.Groups[g.Name] = g
} }
} }
@ -283,9 +283,9 @@ func (c *Channel) Unfreeze(fc *freezer.Channel) {
// We can't be sure that the channels the links point to exist // We can't be sure that the channels the links point to exist
// yet, so we delay hooking up the map 'correctly' to later. // yet, so we delay hooking up the map 'correctly' to later.
if fc.Links != nil { if fc.Links != nil {
c.Links = make(map[int]*Channel) channel.Links = make(map[int]*Channel)
for _, link := range fc.Links { for _, link := range fc.Links {
c.Links[int(link)] = c channel.Links[int(link)] = channel
} }
} }
} }

View file

@ -953,8 +953,8 @@ func (server *Server) handleIncomingMessage(client *Client, msg *Message) {
} }
// SendUDP will send the content of buf as a UDP packet to addr. // SendUDP will send the content of buf as a UDP packet to addr.
func (s *Server) SendUDP(buf []byte, addr *net.UDPAddr) (err error) { func (server *Server) SendUDP(buf []byte, addr *net.UDPAddr) (err error) {
_, err = s.udpconn.WriteTo(buf, addr) _, err = server.udpconn.WriteTo(buf, addr)
return return
} }
@ -1098,15 +1098,15 @@ func (server *Server) userEnterChannel(client *Client, channel *Channel, usersta
} }
// RegisterClient will register a client on the server. // RegisterClient will register a client on the server.
func (s *Server) RegisterClient(client *Client) (uid uint32, err error) { func (server *Server) RegisterClient(client *Client) (uid uint32, err error) {
// Increment nextUserID only if registration succeeded. // Increment nextUserID only if registration succeeded.
defer func() { defer func() {
if err == nil { if err == nil {
s.nextUserID += 1 server.nextUserID += 1
} }
}() }()
user, err := NewUser(s.nextUserID, client.Username) user, err := NewUser(server.nextUserID, client.Username)
if err != nil { if err != nil {
return 0, err return 0, err
} }
@ -1119,34 +1119,34 @@ func (s *Server) RegisterClient(client *Client) (uid uint32, err error) {
user.Email = client.Email user.Email = client.Email
user.CertHash = client.CertHash() user.CertHash = client.CertHash()
uid = s.nextUserID uid = server.nextUserID
s.Users[uid] = user server.Users[uid] = user
s.UserCertMap[client.CertHash()] = user server.UserCertMap[client.CertHash()] = user
s.UserNameMap[client.Username] = user server.UserNameMap[client.Username] = user
return uid, nil return uid, nil
} }
// RemoveRegistration removes a registered user. // RemoveRegistration removes a registered user.
func (s *Server) RemoveRegistration(uid uint32) (err error) { func (server *Server) RemoveRegistration(uid uint32) (err error) {
user, ok := s.Users[uid] user, ok := server.Users[uid]
if !ok { if !ok {
return errors.New("Unknown user ID") return errors.New("Unknown user ID")
} }
// Remove from user maps // Remove from user maps
delete(s.Users, uid) delete(server.Users, uid)
delete(s.UserCertMap, user.CertHash) delete(server.UserCertMap, user.CertHash)
delete(s.UserNameMap, user.Name) delete(server.UserNameMap, user.Name)
// Remove from groups and ACLs. // Remove from groups and ACLs.
s.removeRegisteredUserFromChannel(uid, s.RootChannel()) server.removeRegisteredUserFromChannel(uid, server.RootChannel())
return nil return nil
} }
// Remove references for user id uid from channel. Traverses subchannels. // Remove references for user id uid from channel. Traverses subchannels.
func (s *Server) removeRegisteredUserFromChannel(uid uint32, channel *Channel) { func (server *Server) removeRegisteredUserFromChannel(uid uint32, channel *Channel) {
newACL := []acl.ACL{} newACL := []acl.ACL{}
for _, chanacl := range channel.ACL.ACLs { for _, chanacl := range channel.ACL.ACLs {
@ -1170,7 +1170,7 @@ func (s *Server) removeRegisteredUserFromChannel(uid uint32, channel *Channel) {
} }
for _, subChan := range channel.children { for _, subChan := range channel.children {
s.removeRegisteredUserFromChannel(uid, subChan) server.removeRegisteredUserFromChannel(uid, subChan)
} }
} }