From 861fae65a2f16509b1de99023502445322843f6c Mon Sep 17 00:00:00 2001 From: Ola Bini Date: Sat, 21 Dec 2019 22:41:54 +0000 Subject: [PATCH] Rename more acronyms to their upper case versions, according to Golang coding standards --- cmd/grumble/freeze.go | 32 ++++++++++++++++---------------- cmd/grumble/message.go | 12 ++++++------ cmd/grumble/register.go | 8 ++++---- cmd/grumble/server.go | 2 +- pkg/ban/ban_test.go | 24 ++++++++++++------------ pkg/freezer/types.pb.go | 10 +++++----- pkg/mumbleproto/Mumble.pb.go | 18 +++++++++--------- 7 files changed, 53 insertions(+), 53 deletions(-) diff --git a/cmd/grumble/freeze.go b/cmd/grumble/freeze.go index dbe8a49..374a855 100644 --- a/cmd/grumble/freeze.go +++ b/cmd/grumble/freeze.go @@ -173,7 +173,7 @@ func (channel *Channel) Freeze() (fc *freezer.Channel, err error) { fc.ParentId = proto.Uint32(uint32(channel.parent.ID)) } fc.Position = proto.Int64(int64(channel.Position)) - fc.InheritAcl = proto.Bool(channel.ACL.InheritACL) + fc.InheritACL = proto.Bool(channel.ACL.InheritACL) // Freeze the channel's ACLs acls := []*freezer.ACL{} @@ -184,7 +184,7 @@ func (channel *Channel) Freeze() (fc *freezer.Channel, err error) { } acls = append(acls, facl) } - fc.Acl = acls + fc.ACL = acls // Freeze the channel's groups groups := []*freezer.Group{} @@ -219,17 +219,17 @@ func (c *Channel) Unfreeze(fc *freezer.Channel) { if fc.Position != nil { c.Position = int(*fc.Position) } - if fc.InheritAcl != nil { - c.ACL.InheritACL = *fc.InheritAcl + if fc.InheritACL != nil { + c.ACL.InheritACL = *fc.InheritACL } if fc.DescriptionBlob != nil { c.DescriptionBlob = *fc.DescriptionBlob } // Update ACLs - if fc.Acl != nil { + if fc.ACL != nil { c.ACL.ACLs = nil - for _, facl := range fc.Acl { + for _, facl := range fc.ACL { aclEntry := acl.ACL{} if facl.ApplyHere != nil { aclEntry.ApplyHere = *facl.ApplyHere @@ -335,17 +335,17 @@ func (u *User) Unfreeze(fu *freezer.User) { // FreezeACL will freeze a ChannelACL into it a flattened protobuf-based structure // ready to be persisted to disk. func FreezeACL(aclEntry acl.ACL) (*freezer.ACL, error) { - frozenAcl := &freezer.ACL{} + frozenACL := &freezer.ACL{} if aclEntry.UserID != -1 { - frozenAcl.UserID = proto.Uint32(uint32(aclEntry.UserID)) + frozenACL.UserID = proto.Uint32(uint32(aclEntry.UserID)) } else { - frozenAcl.Group = proto.String(aclEntry.Group) + frozenACL.Group = proto.String(aclEntry.Group) } - frozenAcl.ApplyHere = proto.Bool(aclEntry.ApplyHere) - frozenAcl.ApplySubs = proto.Bool(aclEntry.ApplySubs) - frozenAcl.Allow = proto.Uint32(uint32(aclEntry.Allow)) - frozenAcl.Deny = proto.Uint32(uint32(aclEntry.Deny)) - return frozenAcl, nil + frozenACL.ApplyHere = proto.Bool(aclEntry.ApplyHere) + frozenACL.ApplySubs = proto.Bool(aclEntry.ApplySubs) + frozenACL.Allow = proto.Uint32(uint32(aclEntry.Allow)) + frozenACL.Deny = proto.Uint32(uint32(aclEntry.Deny)) + return frozenACL, nil } // FreezeGroup will freeze a Group into a flattened protobuf-based structure @@ -785,7 +785,7 @@ func (server *Server) UpdateFrozenChannelACLs(channel *Channel) { fc := &freezer.Channel{} fc.Id = proto.Uint32(uint32(channel.ID)) - fc.InheritAcl = proto.Bool(channel.ACL.InheritACL) + fc.InheritACL = proto.Bool(channel.ACL.InheritACL) acls := []*freezer.ACL{} for _, aclEntry := range channel.ACL.ACLs { @@ -795,7 +795,7 @@ func (server *Server) UpdateFrozenChannelACLs(channel *Channel) { } acls = append(acls, facl) } - fc.Acl = acls + fc.ACL = acls groups := []*freezer.Group{} for _, grp := range channel.ACL.Groups { diff --git a/cmd/grumble/message.go b/cmd/grumble/message.go index 77c7650..4311094 100644 --- a/cmd/grumble/message.go +++ b/cmd/grumble/message.go @@ -1028,7 +1028,7 @@ func (server *Server) handleTextMessage(client *Client, msg *Message) { } // ACL set/query -func (server *Server) handleAclMessage(client *Client, msg *Message) { +func (server *Server) handleACLMessage(client *Client, msg *Message) { pacl := &mumbleproto.ACL{} err := proto.Unmarshal(msg.buf, pacl) if err != nil { @@ -1056,7 +1056,7 @@ func (server *Server) handleAclMessage(client *Client, msg *Message) { // Query the current ACL state for the channel if pacl.Query != nil && *pacl.Query != false { - reply.InheritAcls = proto.Bool(channel.ACL.InheritACL) + reply.InheritACLs = proto.Bool(channel.ACL.InheritACL) // Walk the channel tree to get all relevant channels. // (Stop if we reach a channel that doesn't have the InheritACL flag set) iter := channel @@ -1071,7 +1071,7 @@ func (server *Server) handleAclMessage(client *Client, msg *Message) { // Construct the protobuf ChanACL objects corresponding to the ACLs defined // in our channel list. - reply.Acls = []*mumbleproto.ACL_ChanACL{} + reply.ACLs = []*mumbleproto.ACL_ChanACL{} for _, iter := range channels { for _, chanacl := range iter.ACL.ACLs { if iter == channel || chanacl.ApplySubs { @@ -1087,7 +1087,7 @@ func (server *Server) handleAclMessage(client *Client, msg *Message) { } mpacl.Grant = proto.Uint32(uint32(chanacl.Allow)) mpacl.Deny = proto.Uint32(uint32(chanacl.Deny)) - reply.Acls = append(reply.Acls, mpacl) + reply.ACLs = append(reply.ACLs, mpacl) } } } @@ -1187,7 +1187,7 @@ func (server *Server) handleAclMessage(client *Client, msg *Message) { channel.ACL.Groups = map[string]acl.Group{} // Add the received groups to the channel. - channel.ACL.InheritACL = *pacl.InheritAcls + channel.ACL.InheritACL = *pacl.InheritACLs for _, pbgrp := range pacl.Groups { changroup := acl.EmptyGroupWithName(*pbgrp.Name) @@ -1206,7 +1206,7 @@ func (server *Server) handleAclMessage(client *Client, msg *Message) { channel.ACL.Groups[changroup.Name] = changroup } // Add the received ACLs to the channel. - for _, pbacl := range pacl.Acls { + for _, pbacl := range pacl.ACLs { chanacl := acl.ACL{} chanacl.ApplyHere = *pbacl.ApplyHere chanacl.ApplySubs = *pbacl.ApplySubs diff --git a/cmd/grumble/register.go b/cmd/grumble/register.go index 76d318f..0b4e028 100644 --- a/cmd/grumble/register.go +++ b/cmd/grumble/register.go @@ -25,14 +25,14 @@ type Register struct { Host string `xml:"host"` Password string `xml:"password"` Port int `xml:"port"` - Url string `xml:"url"` + URL string `xml:"url"` Digest string `xml:"digest"` Users int `xml:"users"` Channels int `xml:"channels"` Location string `xml:"location"` } -const registerUrl = "https://mumble.info/register.cgi" +const registerURL = "https://mumble.info/register.cgi" // IsPublic Determines whether a server is public by checking whether the // config values required for public registration are set. @@ -84,7 +84,7 @@ func (server *Server) RegisterPublicServer() { Name: server.cfg.StringValue("RegisterName"), Host: server.cfg.StringValue("RegisterHost"), Password: server.cfg.StringValue("RegisterPassword"), - Url: server.cfg.StringValue("RegisterWebUrl"), + URL: server.cfg.StringValue("RegisterWebUrl"), Location: server.cfg.StringValue("RegisterLocation"), Port: server.CurrentPort(), Digest: digest, @@ -106,7 +106,7 @@ func (server *Server) RegisterPublicServer() { TLSClientConfig: config, } client := &http.Client{Transport: tr} - r, err := client.Post(registerUrl, "text/xml", ioutil.NopCloser(buf)) + r, err := client.Post(registerURL, "text/xml", ioutil.NopCloser(buf)) if err != nil { server.Printf("register: unable to post registration request: %v", err) return diff --git a/cmd/grumble/server.go b/cmd/grumble/server.go index abb990f..28ebe0e 100644 --- a/cmd/grumble/server.go +++ b/cmd/grumble/server.go @@ -932,7 +932,7 @@ func (server *Server) handleIncomingMessage(client *Client, msg *Message) { case mumbleproto.MessageTextMessage: server.handleTextMessage(msg.client, msg) case mumbleproto.MessageACL: - server.handleAclMessage(msg.client, msg) + server.handleACLMessage(msg.client, msg) case mumbleproto.MessageQueryUsers: server.handleQueryUsers(msg.client, msg) case mumbleproto.MessageCryptSetup: diff --git a/pkg/ban/ban_test.go b/pkg/ban/ban_test.go index 56b0056..2a5608f 100644 --- a/pkg/ban/ban_test.go +++ b/pkg/ban/ban_test.go @@ -33,12 +33,12 @@ func TestMatchV4(t *testing.T) { t.Errorf("Invalid IP") } - clientIp := net.ParseIP("192.168.1.50") - if len(clientIp) == 0 { + clientIP := net.ParseIP("192.168.1.50") + if len(clientIP) == 0 { t.Errorf("Invalid IP") } - if b.Match(clientIp) != true { + if b.Match(clientIP) != true { t.Errorf("IPv4: unexpected match") } } @@ -51,12 +51,12 @@ func TestMismatchV4(t *testing.T) { t.Errorf("Invalid IP") } - clientIp := net.ParseIP("192.168.2.1") - if len(clientIp) == 0 { + clientIP := net.ParseIP("192.168.2.1") + if len(clientIP) == 0 { t.Errorf("Invalid IP") } - if b.Match(clientIp) == true { + if b.Match(clientIP) == true { t.Errorf("IPv4: unexpected mismatch") } } @@ -69,12 +69,12 @@ func TestMatchV6(t *testing.T) { t.Errorf("Invalid IP") } - clientIp := net.ParseIP("2a00:1450:400b:c00::54") - if len(clientIp) == 0 { + clientIP := net.ParseIP("2a00:1450:400b:c00::54") + if len(clientIP) == 0 { t.Errorf("Invalid IP") } - if b.Match(clientIp) != true { + if b.Match(clientIP) != true { t.Errorf("IPv6: unexpected match") } } @@ -88,12 +88,12 @@ func TestMismatchV6(t *testing.T) { t.Errorf("Invalid IP") } - clientIp := net.ParseIP("2a00:1450:400b:deaf:42f0:cafe:babe:54") - if len(clientIp) == 0 { + clientIP := net.ParseIP("2a00:1450:400b:deaf:42f0:cafe:babe:54") + if len(clientIP) == 0 { t.Errorf("Invalid IP") } - if b.Match(clientIp) == true { + if b.Match(clientIP) == true { t.Errorf("IPv6: unexpected mismatch") } } diff --git a/pkg/freezer/types.pb.go b/pkg/freezer/types.pb.go index 7862e4c..5c322d4 100644 --- a/pkg/freezer/types.pb.go +++ b/pkg/freezer/types.pb.go @@ -230,9 +230,9 @@ type Channel struct { Name *string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"` ParentId *uint32 `protobuf:"varint,3,opt,name=parent_id" json:"parent_id,omitempty"` Position *int64 `protobuf:"varint,4,opt,name=position" json:"position,omitempty"` - InheritAcl *bool `protobuf:"varint,5,opt,name=inherit_acl" json:"inherit_acl,omitempty"` + InheritACL *bool `protobuf:"varint,5,opt,name=inherit_acl" json:"inherit_acl,omitempty"` Links []uint32 `protobuf:"varint,6,rep,name=links" json:"links,omitempty"` - Acl []*ACL `protobuf:"bytes,7,rep,name=acl" json:"acl,omitempty"` + ACL []*ACL `protobuf:"bytes,7,rep,name=acl" json:"acl,omitempty"` Groups []*Group `protobuf:"bytes,8,rep,name=groups" json:"groups,omitempty"` DescriptionBlob *string `protobuf:"bytes,9,opt,name=description_blob" json:"description_blob,omitempty"` XXX_unrecognized []byte `json:"-"` @@ -270,9 +270,9 @@ func (this *Channel) GetPosition() int64 { return 0 } -func (this *Channel) GetInheritAcl() bool { - if this != nil && this.InheritAcl != nil { - return *this.InheritAcl +func (this *Channel) GetInheritACL() bool { + if this != nil && this.InheritACL != nil { + return *this.InheritACL } return false } diff --git a/pkg/mumbleproto/Mumble.pb.go b/pkg/mumbleproto/Mumble.pb.go index 64a5ab3..eeaf773 100644 --- a/pkg/mumbleproto/Mumble.pb.go +++ b/pkg/mumbleproto/Mumble.pb.go @@ -1183,11 +1183,11 @@ type ACL struct { // Channel ID of the channel this message affects. ChannelId *uint32 `protobuf:"varint,1,req,name=channel_id,json=channelId" json:"channel_id,omitempty"` // True if the channel inherits its parent's ACLs. - InheritAcls *bool `protobuf:"varint,2,opt,name=inherit_acls,json=inheritAcls,def=1" json:"inherit_acls,omitempty"` + InheritACLs *bool `protobuf:"varint,2,opt,name=inherit_acls,json=inheritACLs,def=1" json:"inherit_acls,omitempty"` // User group specifications. Groups []*ACL_ChanGroup `protobuf:"bytes,3,rep,name=groups" json:"groups,omitempty"` // ACL specifications. - Acls []*ACL_ChanACL `protobuf:"bytes,4,rep,name=acls" json:"acls,omitempty"` + ACLs []*ACL_ChanACL `protobuf:"bytes,4,rep,name=acls" json:"acls,omitempty"` // True if the message is a query for ACLs instead of setting them. Query *bool `protobuf:"varint,5,opt,name=query,def=0" json:"query,omitempty"` XXX_unrecognized []byte `json:"-"` @@ -1198,7 +1198,7 @@ func (m *ACL) String() string { return proto.CompactTextString(m) } func (*ACL) ProtoMessage() {} func (*ACL) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{13} } -const Default_ACL_InheritAcls bool = true +const Default_ACL_InheritACLs bool = true const Default_ACL_Query bool = false func (m *ACL) GetChannelId() uint32 { @@ -1208,11 +1208,11 @@ func (m *ACL) GetChannelId() uint32 { return 0 } -func (m *ACL) GetInheritAcls() bool { - if m != nil && m.InheritAcls != nil { - return *m.InheritAcls +func (m *ACL) GetInheritACLs() bool { + if m != nil && m.InheritACLs != nil { + return *m.InheritACLs } - return Default_ACL_InheritAcls + return Default_ACL_InheritACLs } func (m *ACL) GetGroups() []*ACL_ChanGroup { @@ -1222,9 +1222,9 @@ func (m *ACL) GetGroups() []*ACL_ChanGroup { return nil } -func (m *ACL) GetAcls() []*ACL_ChanACL { +func (m *ACL) GetACLs() []*ACL_ChanACL { if m != nil { - return m.Acls + return m.ACLs } return nil }