mirror of
https://github.com/mumble-voip/grumble.git
synced 2025-12-20 06:10:00 -08:00
Rename all Id to ID to conform with Golang coding standards
This commit is contained in:
parent
6fae18a9cd
commit
2937dab654
13 changed files with 156 additions and 156 deletions
|
|
@ -112,7 +112,7 @@ func (client *Client) IsSuperUser() bool {
|
||||||
if client.user == nil {
|
if client.user == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return client.user.Id == 0
|
return client.user.ID == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// ACLContext returns the access control list context for this client
|
// ACLContext returns the access control list context for this client
|
||||||
|
|
@ -135,13 +135,13 @@ func (client *Client) Tokens() []string {
|
||||||
return client.tokens
|
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.
|
// Returns -1 if the client is not a registered user.
|
||||||
func (client *Client) UserId() int {
|
func (client *Client) UserID() int {
|
||||||
if client.user == nil {
|
if client.user == nil {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
return int(client.user.Id)
|
return int(client.user.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ShownName gets the client's shown name.
|
// ShownName gets the client's shown name.
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ func (server *Server) openFreezeLog() error {
|
||||||
server.freezelog = nil
|
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)
|
err := os.Remove(logfn)
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
// fallthrough
|
// fallthrough
|
||||||
|
|
@ -237,10 +237,10 @@ func (c *Channel) Unfreeze(fc *freezer.Channel) {
|
||||||
if facl.ApplySubs != nil {
|
if facl.ApplySubs != nil {
|
||||||
aclEntry.ApplySubs = *facl.ApplySubs
|
aclEntry.ApplySubs = *facl.ApplySubs
|
||||||
}
|
}
|
||||||
if facl.UserId != nil {
|
if facl.UserID != nil {
|
||||||
aclEntry.UserId = int(*facl.UserId)
|
aclEntry.UserID = int(*facl.UserID)
|
||||||
} else {
|
} else {
|
||||||
aclEntry.UserId = -1
|
aclEntry.UserID = -1
|
||||||
}
|
}
|
||||||
if facl.Group != nil {
|
if facl.Group != nil {
|
||||||
aclEntry.Group = *facl.Group
|
aclEntry.Group = *facl.Group
|
||||||
|
|
@ -295,13 +295,13 @@ func (c *Channel) Unfreeze(fc *freezer.Channel) {
|
||||||
func (user *User) Freeze() (fu *freezer.User, err error) {
|
func (user *User) Freeze() (fu *freezer.User, err error) {
|
||||||
fu = new(freezer.User)
|
fu = new(freezer.User)
|
||||||
|
|
||||||
fu.Id = proto.Uint32(user.Id)
|
fu.Id = proto.Uint32(user.ID)
|
||||||
fu.Name = proto.String(user.Name)
|
fu.Name = proto.String(user.Name)
|
||||||
fu.CertHash = proto.String(user.CertHash)
|
fu.CertHash = proto.String(user.CertHash)
|
||||||
fu.Email = proto.String(user.Email)
|
fu.Email = proto.String(user.Email)
|
||||||
fu.TextureBlob = proto.String(user.TextureBlob)
|
fu.TextureBlob = proto.String(user.TextureBlob)
|
||||||
fu.CommentBlob = proto.String(user.CommentBlob)
|
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)
|
fu.LastActive = proto.Uint64(user.LastActive)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
@ -324,8 +324,8 @@ func (u *User) Unfreeze(fu *freezer.User) {
|
||||||
if fu.CommentBlob != nil {
|
if fu.CommentBlob != nil {
|
||||||
u.CommentBlob = *fu.CommentBlob
|
u.CommentBlob = *fu.CommentBlob
|
||||||
}
|
}
|
||||||
if fu.LastChannelId != nil {
|
if fu.LastChannelID != nil {
|
||||||
u.LastChannelId = int(*fu.LastChannelId)
|
u.LastChannelID = int(*fu.LastChannelID)
|
||||||
}
|
}
|
||||||
if fu.LastActive != nil {
|
if fu.LastActive != nil {
|
||||||
u.LastActive = *fu.LastActive
|
u.LastActive = *fu.LastActive
|
||||||
|
|
@ -336,8 +336,8 @@ func (u *User) Unfreeze(fu *freezer.User) {
|
||||||
// ready to be persisted to disk.
|
// ready to be persisted to disk.
|
||||||
func FreezeACL(aclEntry acl.ACL) (*freezer.ACL, error) {
|
func FreezeACL(aclEntry acl.ACL) (*freezer.ACL, error) {
|
||||||
frozenAcl := &freezer.ACL{}
|
frozenAcl := &freezer.ACL{}
|
||||||
if aclEntry.UserId != -1 {
|
if aclEntry.UserID != -1 {
|
||||||
frozenAcl.UserId = proto.Uint32(uint32(aclEntry.UserId))
|
frozenAcl.UserID = proto.Uint32(uint32(aclEntry.UserID))
|
||||||
} else {
|
} else {
|
||||||
frozenAcl.Group = proto.String(aclEntry.Group)
|
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,
|
// Update the server's nextChanId field if it needs to be,
|
||||||
// to make sure the server doesn't re-use channel id's.
|
// to make sure the server doesn't re-use channel id's.
|
||||||
c := NewChannel(int(*fc.Id), *fc.Name)
|
c := NewChannel(int(*fc.Id), *fc.Name)
|
||||||
if c.ID >= s.nextChanId {
|
if c.ID >= s.nextChanID {
|
||||||
s.nextChanId = c.ID + 1
|
s.nextChanID = c.ID + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the channel with the contents of the freezer.Channel.
|
// 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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if u.Id >= s.nextUserId {
|
if u.ID >= s.nextUserID {
|
||||||
s.nextUserId = u.Id + 1
|
s.nextUserID = u.ID + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// Merge the contents of the freezer.User into
|
// 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
|
// Update the server's user maps to point correctly
|
||||||
// to the new user.
|
// to the new user.
|
||||||
s.Users[u.Id] = u
|
s.Users[u.ID] = u
|
||||||
s.UserNameMap[u.Name] = u
|
s.UserNameMap[u.Name] = u
|
||||||
if len(u.CertHash) > 0 {
|
if len(u.CertHash) > 0 {
|
||||||
s.UserCertMap[u.CertHash] = u
|
s.UserCertMap[u.CertHash] = u
|
||||||
|
|
@ -520,14 +520,14 @@ func NewServerFromFrozen(name string) (s *Server, err error) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
userId := *fu.Id
|
userID := *fu.Id
|
||||||
|
|
||||||
// Determine whether the user already exists on the server or not.
|
// Determine whether the user already exists on the server or not.
|
||||||
// If the user already exists, this log entry simply updates the
|
// If the user already exists, this log entry simply updates the
|
||||||
// data for that user.
|
// data for that user.
|
||||||
// If the user doesn't exist, we create it with the data given in
|
// If the user doesn't exist, we create it with the data given in
|
||||||
// this log entry.
|
// this log entry.
|
||||||
user, ok := s.Users[userId]
|
user, ok := s.Users[userID]
|
||||||
if !ok {
|
if !ok {
|
||||||
// If no name is given in the log entry, skip this entry.
|
// If no name is given in the log entry, skip this entry.
|
||||||
// Also, warn the admin.
|
// 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.")
|
log.Printf("Skipped User creation log entry: No name given.")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// Create the new user and increment the UserId
|
// Create the new user and increment the UserID
|
||||||
// counter for the server if needed.
|
// counter for the server if needed.
|
||||||
user, err = NewUser(userId, *fu.Name)
|
user, err = NewUser(userID, *fu.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if user.Id >= s.nextUserId {
|
if user.ID >= s.nextUserID {
|
||||||
s.nextUserId = user.Id + 1
|
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
|
// Update the various user maps in the server to
|
||||||
// be able to correctly look up the user.
|
// be able to correctly look up the user.
|
||||||
s.Users[user.Id] = user
|
s.Users[user.ID] = user
|
||||||
s.UserNameMap[user.Name] = user
|
s.UserNameMap[user.Name] = user
|
||||||
if len(user.CertHash) > 0 {
|
if len(user.CertHash) > 0 {
|
||||||
s.UserCertMap[user.CertHash] = user
|
s.UserCertMap[user.CertHash] = user
|
||||||
|
|
@ -566,14 +566,14 @@ func NewServerFromFrozen(name string) (s *Server, err error) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
userId := *fu.Id
|
userID := *fu.Id
|
||||||
|
|
||||||
// Does this user even exist?
|
// Does this user even exist?
|
||||||
// Warn if we encounter an illegal delete op.
|
// Warn if we encounter an illegal delete op.
|
||||||
user, ok := s.Users[userId]
|
user, ok := s.Users[userID]
|
||||||
if ok {
|
if ok {
|
||||||
// Clear the server maps. That should do it.
|
// Clear the server maps. That should do it.
|
||||||
delete(s.Users, userId)
|
delete(s.Users, userID)
|
||||||
delete(s.UserNameMap, user.Name)
|
delete(s.UserNameMap, user.Name)
|
||||||
if len(user.CertHash) > 0 {
|
if len(user.CertHash) > 0 {
|
||||||
delete(s.UserCertMap, user.CertHash)
|
delete(s.UserCertMap, user.CertHash)
|
||||||
|
|
@ -591,9 +591,9 @@ func NewServerFromFrozen(name string) (s *Server, err error) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
channelId := int(*fc.Id)
|
channelID := int(*fc.Id)
|
||||||
|
|
||||||
channel, alreadyExists := s.Channels[channelId]
|
channel, alreadyExists := s.Channels[channelID]
|
||||||
if !alreadyExists {
|
if !alreadyExists {
|
||||||
if fc.Name == nil {
|
if fc.Name == nil {
|
||||||
log.Printf("Skipped Channel creation log entry: No name given.")
|
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
|
// Add the channel and increment the server's
|
||||||
// nextChanId field to a consistent state.
|
// nextChanId field to a consistent state.
|
||||||
channel = NewChannel(channelId, *fc.Name)
|
channel = NewChannel(channelID, *fc.Name)
|
||||||
if channel.ID >= s.nextChanId {
|
if channel.ID >= s.nextChanID {
|
||||||
s.nextChanId = channel.ID + 1
|
s.nextChanID = channel.ID + 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -612,7 +612,7 @@ func NewServerFromFrozen(name string) (s *Server, err error) {
|
||||||
channel.Unfreeze(fc)
|
channel.Unfreeze(fc)
|
||||||
// Re-add it to the server's channel map (in case
|
// Re-add it to the server's channel map (in case
|
||||||
// the channel was newly-created)
|
// the channel was newly-created)
|
||||||
s.Channels[channelId] = channel
|
s.Channels[channelID] = channel
|
||||||
|
|
||||||
// Mark the channel's parent
|
// Mark the channel's parent
|
||||||
if !alreadyExists {
|
if !alreadyExists {
|
||||||
|
|
@ -652,12 +652,12 @@ func NewServerFromFrozen(name string) (s *Server, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hook up children with their parents
|
// Hook up children with their parents
|
||||||
for chanId, parentId := range parents {
|
for chanID, parentID := range parents {
|
||||||
childChan, exists := s.Channels[int(chanId)]
|
childChan, exists := s.Channels[int(chanID)]
|
||||||
if !exists {
|
if !exists {
|
||||||
return nil, errors.New("Non-existant child channel")
|
return nil, errors.New("Non-existant child channel")
|
||||||
}
|
}
|
||||||
parentChan, exists := s.Channels[int(parentId)]
|
parentChan, exists := s.Channels[int(parentID)]
|
||||||
if !exists {
|
if !exists {
|
||||||
return nil, errors.New("Non-existant parent channel")
|
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 {
|
if len(channel.Links) > 0 {
|
||||||
links := channel.Links
|
links := channel.Links
|
||||||
channel.Links = make(map[int]*Channel)
|
channel.Links = make(map[int]*Channel)
|
||||||
for chanId, _ := range links {
|
for chanID, _ := range links {
|
||||||
targetChannel := s.Channels[chanId]
|
targetChannel := s.Channels[chanID]
|
||||||
if targetChannel != nil {
|
if targetChannel != nil {
|
||||||
s.LinkChannels(channel, targetChannel)
|
s.LinkChannels(channel, targetChannel)
|
||||||
}
|
}
|
||||||
|
|
@ -687,7 +687,7 @@ func (server *Server) UpdateFrozenUser(client *Client, state *mumbleproto.UserSt
|
||||||
// it includes a registration operation.
|
// it includes a registration operation.
|
||||||
user := client.user
|
user := client.user
|
||||||
nanos := time.Now().Unix()
|
nanos := time.Now().Unix()
|
||||||
if state == nil || state.UserId != nil {
|
if state == nil || state.UserID != nil {
|
||||||
fu, err := user.Freeze()
|
fu, err := user.Freeze()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
server.Fatal(err)
|
server.Fatal(err)
|
||||||
|
|
@ -699,9 +699,9 @@ func (server *Server) UpdateFrozenUser(client *Client, state *mumbleproto.UserSt
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fu := &freezer.User{}
|
fu := &freezer.User{}
|
||||||
fu.Id = proto.Uint32(user.Id)
|
fu.Id = proto.Uint32(user.ID)
|
||||||
if state.ChannelId != nil {
|
if state.ChannelId != nil {
|
||||||
fu.LastChannelId = proto.Uint32(uint32(client.Channel.ID))
|
fu.LastChannelID = proto.Uint32(uint32(client.Channel.ID))
|
||||||
}
|
}
|
||||||
if state.TextureHash != nil {
|
if state.TextureHash != nil {
|
||||||
fu.TextureBlob = proto.String(user.TextureBlob)
|
fu.TextureBlob = proto.String(user.TextureBlob)
|
||||||
|
|
@ -724,8 +724,8 @@ func (server *Server) UpdateFrozenUserLastChannel(client *Client) {
|
||||||
user := client.user
|
user := client.user
|
||||||
|
|
||||||
fu := &freezer.User{}
|
fu := &freezer.User{}
|
||||||
fu.Id = proto.Uint32(user.Id)
|
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()))
|
fu.LastActive = proto.Uint64(uint64(time.Now().Unix()))
|
||||||
|
|
||||||
err := server.freezelog.Put(fu)
|
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.
|
// DeleteFrozenUser will mark a user as deleted in the datstore.
|
||||||
func (server *Server) DeleteFrozenUser(user *User) {
|
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 {
|
if err != nil {
|
||||||
server.Fatal(err)
|
server.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ func (server *Server) freezeToFile() (err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -50,7 +50,7 @@ func (server *Server) freezeToFile() (err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -185,7 +185,7 @@ func main() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Unable to freeze server to disk: %v", err.Error())
|
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())
|
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)
|
os.Mkdir(filepath.Join(serversDirPath, fmt.Sprintf("%v", 1)), 0750)
|
||||||
err = s.FreezeToFile()
|
err = s.FreezeToFile()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -208,7 +208,7 @@ func main() {
|
||||||
for _, server := range servers {
|
for _, server := range servers {
|
||||||
err = server.Start()
|
err = server.Start()
|
||||||
if err != nil {
|
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())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -270,7 +270,7 @@ func (server *Server) handleChannelStateMessage(client *Client, msg *Message) {
|
||||||
// Add the creator to the channel's admin group
|
// Add the creator to the channel's admin group
|
||||||
if client.IsRegistered() {
|
if client.IsRegistered() {
|
||||||
grp := acl.EmptyGroupWithName("admin")
|
grp := acl.EmptyGroupWithName("admin")
|
||||||
grp.Add[client.UserId()] = true
|
grp.Add[client.UserID()] = true
|
||||||
channel.ACL.Groups["admin"] = grp
|
channel.ACL.Groups["admin"] = grp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -281,7 +281,7 @@ func (server *Server) handleChannelStateMessage(client *Client, msg *Message) {
|
||||||
aclEntry.ApplyHere = true
|
aclEntry.ApplyHere = true
|
||||||
aclEntry.ApplySubs = true
|
aclEntry.ApplySubs = true
|
||||||
if client.IsRegistered() {
|
if client.IsRegistered() {
|
||||||
aclEntry.UserId = client.UserId()
|
aclEntry.UserID = client.UserID()
|
||||||
} else {
|
} else {
|
||||||
aclEntry.Group = "$" + client.CertHash()
|
aclEntry.Group = "$" + client.CertHash()
|
||||||
}
|
}
|
||||||
|
|
@ -663,7 +663,7 @@ func (server *Server) handleUserStateMessage(client *Client, msg *Message) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Registration
|
// Registration
|
||||||
if userstate.UserId != nil {
|
if userstate.UserID != nil {
|
||||||
// If user == actor, check for SelfRegisterPermission on root channel.
|
// If user == actor, check for SelfRegisterPermission on root channel.
|
||||||
// If user != actor, check for RegisterPermission permission on root channel.
|
// If user != actor, check for RegisterPermission permission on root channel.
|
||||||
perm := acl.Permission(acl.RegisterPermission)
|
perm := acl.Permission(acl.RegisterPermission)
|
||||||
|
|
@ -799,13 +799,13 @@ func (server *Server) handleUserStateMessage(client *Client, msg *Message) {
|
||||||
}
|
}
|
||||||
|
|
||||||
userRegistrationChanged := false
|
userRegistrationChanged := false
|
||||||
if userstate.UserId != nil {
|
if userstate.UserID != nil {
|
||||||
uid, err := server.RegisterClient(target)
|
uid, err := server.RegisterClient(target)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
client.Printf("Unable to register: %v", err)
|
client.Printf("Unable to register: %v", err)
|
||||||
userstate.UserId = nil
|
userstate.UserID = nil
|
||||||
} else {
|
} else {
|
||||||
userstate.UserId = proto.Uint32(uid)
|
userstate.UserID = proto.Uint32(uid)
|
||||||
client.user = server.Users[uid]
|
client.user = server.Users[uid]
|
||||||
userRegistrationChanged = true
|
userRegistrationChanged = true
|
||||||
}
|
}
|
||||||
|
|
@ -1079,9 +1079,9 @@ func (server *Server) handleAclMessage(client *Client, msg *Message) {
|
||||||
mpacl.Inherited = proto.Bool(iter != channel)
|
mpacl.Inherited = proto.Bool(iter != channel)
|
||||||
mpacl.ApplyHere = proto.Bool(chanacl.ApplyHere)
|
mpacl.ApplyHere = proto.Bool(chanacl.ApplyHere)
|
||||||
mpacl.ApplySubs = proto.Bool(chanacl.ApplySubs)
|
mpacl.ApplySubs = proto.Bool(chanacl.ApplySubs)
|
||||||
if chanacl.UserId >= 0 {
|
if chanacl.UserID >= 0 {
|
||||||
mpacl.UserId = proto.Uint32(uint32(chanacl.UserId))
|
mpacl.UserID = proto.Uint32(uint32(chanacl.UserID))
|
||||||
users[chanacl.UserId] = true
|
users[chanacl.UserID] = true
|
||||||
} else {
|
} else {
|
||||||
mpacl.Group = proto.String(chanacl.Group)
|
mpacl.Group = proto.String(chanacl.Group)
|
||||||
}
|
}
|
||||||
|
|
@ -1210,8 +1210,8 @@ func (server *Server) handleAclMessage(client *Client, msg *Message) {
|
||||||
chanacl := acl.ACL{}
|
chanacl := acl.ACL{}
|
||||||
chanacl.ApplyHere = *pbacl.ApplyHere
|
chanacl.ApplyHere = *pbacl.ApplyHere
|
||||||
chanacl.ApplySubs = *pbacl.ApplySubs
|
chanacl.ApplySubs = *pbacl.ApplySubs
|
||||||
if pbacl.UserId != nil {
|
if pbacl.UserID != nil {
|
||||||
chanacl.UserId = int(*pbacl.UserId)
|
chanacl.UserID = int(*pbacl.UserID)
|
||||||
} else {
|
} else {
|
||||||
chanacl.Group = *pbacl.Group
|
chanacl.Group = *pbacl.Group
|
||||||
}
|
}
|
||||||
|
|
@ -1230,7 +1230,7 @@ func (server *Server) handleAclMessage(client *Client, msg *Message) {
|
||||||
chanacl.ApplyHere = true
|
chanacl.ApplyHere = true
|
||||||
chanacl.ApplySubs = false
|
chanacl.ApplySubs = false
|
||||||
if client.IsRegistered() {
|
if client.IsRegistered() {
|
||||||
chanacl.UserId = client.UserId()
|
chanacl.UserID = client.UserID()
|
||||||
} else if client.HasCertificate() {
|
} else if client.HasCertificate() {
|
||||||
chanacl.Group = "$" + client.CertHash()
|
chanacl.Group = "$" + client.CertHash()
|
||||||
}
|
}
|
||||||
|
|
@ -1271,7 +1271,7 @@ func (server *Server) handleQueryUsers(client *Client, msg *Message) {
|
||||||
for _, name := range query.Names {
|
for _, name := range query.Names {
|
||||||
user, exists := server.UserNameMap[name]
|
user, exists := server.UserNameMap[name]
|
||||||
if exists {
|
if exists {
|
||||||
reply.Ids = append(reply.Ids, user.Id)
|
reply.Ids = append(reply.Ids, user.ID)
|
||||||
reply.Names = append(reply.Names, name)
|
reply.Names = append(reply.Names, name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1568,7 +1568,7 @@ func (server *Server) handleUserList(client *Client, msg *Message) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
userlist.Users = append(userlist.Users, &mumbleproto.UserList_User{
|
userlist.Users = append(userlist.Users, &mumbleproto.UserList_User{
|
||||||
UserId: proto.Uint32(uid),
|
UserID: proto.Uint32(uid),
|
||||||
Name: proto.String(user.Name),
|
Name: proto.String(user.Name),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -1581,7 +1581,7 @@ func (server *Server) handleUserList(client *Client, msg *Message) {
|
||||||
if len(userlist.Users) > 0 {
|
if len(userlist.Users) > 0 {
|
||||||
tx := server.freezelog.BeginTx()
|
tx := server.freezelog.BeginTx()
|
||||||
for _, listUser := range userlist.Users {
|
for _, listUser := range userlist.Users {
|
||||||
uid := *listUser.UserId
|
uid := *listUser.UserID
|
||||||
if uid == 0 {
|
if uid == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
@ -1590,7 +1590,7 @@ func (server *Server) handleUserList(client *Client, msg *Message) {
|
||||||
if listUser.Name == nil {
|
if listUser.Name == nil {
|
||||||
// De-register
|
// De-register
|
||||||
server.RemoveRegistration(uid)
|
server.RemoveRegistration(uid)
|
||||||
err := tx.Put(&freezer.UserRemove{Id: listUser.UserId})
|
err := tx.Put(&freezer.UserRemove{Id: listUser.UserID})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
server.Fatal(err)
|
server.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
@ -1598,7 +1598,7 @@ func (server *Server) handleUserList(client *Client, msg *Message) {
|
||||||
// Rename user
|
// Rename user
|
||||||
// todo(mkrautz): Validate name.
|
// todo(mkrautz): Validate name.
|
||||||
user.Name = *listUser.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 {
|
if err != nil {
|
||||||
server.Fatal(err)
|
server.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,7 @@ func populateChannelInfoFromDatabase(server *Server, c *Channel, db *sql.DB) err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch description
|
// Fetch description
|
||||||
rows, err := stmt.Query(server.Id, c.ID, ChannelInfoDescription)
|
rows, err := stmt.Query(server.ID, c.ID, ChannelInfoDescription)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -167,7 +167,7 @@ func populateChannelInfoFromDatabase(server *Server, c *Channel, db *sql.DB) err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch position
|
// Fetch position
|
||||||
rows, err = stmt.Query(server.Id, c.ID, ChannelInfoPosition)
|
rows, err = stmt.Query(server.ID, c.ID, ChannelInfoPosition)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -190,36 +190,36 @@ func populateChannelACLFromDatabase(server *Server, c *Channel, db *sql.DB) erro
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
rows, err := stmt.Query(server.Id, c.ID)
|
rows, err := stmt.Query(server.ID, c.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var (
|
var (
|
||||||
UserId string
|
UserID string
|
||||||
Group string
|
Group string
|
||||||
ApplyHere bool
|
ApplyHere bool
|
||||||
ApplySub bool
|
ApplySub bool
|
||||||
Allow int64
|
Allow int64
|
||||||
Deny 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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
aclEntry := acl.ACL{}
|
aclEntry := acl.ACL{}
|
||||||
aclEntry.ApplyHere = ApplyHere
|
aclEntry.ApplyHere = ApplyHere
|
||||||
aclEntry.ApplySubs = ApplySub
|
aclEntry.ApplySubs = ApplySub
|
||||||
if len(UserId) > 0 {
|
if len(UserID) > 0 {
|
||||||
aclEntry.UserId, err = strconv.Atoi(UserId)
|
aclEntry.UserID, err = strconv.Atoi(UserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else if len(Group) > 0 {
|
} else if len(Group) > 0 {
|
||||||
aclEntry.Group = Group
|
aclEntry.Group = Group
|
||||||
} else {
|
} 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)
|
aclEntry.Deny = acl.Permission(Deny)
|
||||||
|
|
@ -237,7 +237,7 @@ func populateChannelGroupsFromDatabase(server *Server, c *Channel, db *sql.DB) e
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
rows, err := stmt.Query(server.Id, c.ID)
|
rows, err := stmt.Query(server.ID, c.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -246,13 +246,13 @@ func populateChannelGroupsFromDatabase(server *Server, c *Channel, db *sql.DB) e
|
||||||
|
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var (
|
var (
|
||||||
GroupId int64
|
GroupID int64
|
||||||
Name string
|
Name string
|
||||||
Inherit bool
|
Inherit bool
|
||||||
Inheritable 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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -260,7 +260,7 @@ func populateChannelGroupsFromDatabase(server *Server, c *Channel, db *sql.DB) e
|
||||||
g.Inherit = Inherit
|
g.Inherit = Inherit
|
||||||
g.Inheritable = Inheritable
|
g.Inheritable = Inheritable
|
||||||
c.ACL.Groups[g.Name] = g
|
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=?")
|
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 {
|
for gid, grp := range groups {
|
||||||
rows, err = stmt.Query(server.Id, gid)
|
rows, err = stmt.Query(server.ID, gid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var (
|
var (
|
||||||
UserId int64
|
UserID int64
|
||||||
Add bool
|
Add bool
|
||||||
)
|
)
|
||||||
|
|
||||||
if err := rows.Scan(&UserId, &Add); err != nil {
|
if err := rows.Scan(&UserID, &Add); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if Add {
|
if Add {
|
||||||
grp.Add[int(UserId)] = true
|
grp.Add[int(UserID)] = true
|
||||||
} else {
|
} 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.
|
// Populate the Server with Channels from the database.
|
||||||
func populateChannelsFromDatabase(server *Server, db *sql.DB, parentId int) error {
|
func populateChannelsFromDatabase(server *Server, db *sql.DB, parentID int) error {
|
||||||
parent, exists := server.Channels[parentId]
|
parent, exists := server.Channels[parentID]
|
||||||
if !exists {
|
if !exists {
|
||||||
return errors.New("Non-existant parent")
|
return errors.New("Non-existant parent")
|
||||||
}
|
}
|
||||||
|
|
@ -307,7 +307,7 @@ func populateChannelsFromDatabase(server *Server, db *sql.DB, parentId int) erro
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
rows, err := stmt.Query(server.Id, parentId)
|
rows, err := stmt.Query(server.ID, parentID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -371,26 +371,26 @@ func populateChannelLinkInfo(server *Server, db *sql.DB) (err error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
rows, err := stmt.Query(server.Id)
|
rows, err := stmt.Query(server.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var (
|
var (
|
||||||
ChannelId int
|
ChannelID int
|
||||||
LinkId int
|
LinkID int
|
||||||
)
|
)
|
||||||
if err := rows.Scan(&ChannelId, &LinkId); err != nil {
|
if err := rows.Scan(&ChannelID, &LinkID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
channel, exists := server.Channels[ChannelId]
|
channel, exists := server.Channels[ChannelID]
|
||||||
if !exists {
|
if !exists {
|
||||||
return errors.New("Attempt to perform link operation on non-existant channel.")
|
return errors.New("Attempt to perform link operation on non-existant channel.")
|
||||||
}
|
}
|
||||||
|
|
||||||
other, exists := server.Channels[LinkId]
|
other, exists := server.Channels[LinkID]
|
||||||
if !exists {
|
if !exists {
|
||||||
return errors.New("Attempt to perform link operation on non-existant channel.")
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
rows, err := stmt.Query(server.Id)
|
rows, err := stmt.Query(server.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var (
|
var (
|
||||||
UserId int64
|
UserID int64
|
||||||
UserName string
|
UserName string
|
||||||
SHA1Password string
|
SHA1Password string
|
||||||
LastChannel int
|
LastChannel int
|
||||||
|
|
@ -423,16 +423,16 @@ func populateUsers(server *Server, db *sql.DB) (err error) {
|
||||||
LastActive int64
|
LastActive int64
|
||||||
)
|
)
|
||||||
|
|
||||||
err = rows.Scan(&UserId, &UserName, &SHA1Password, &LastChannel, &Texture, &LastActive)
|
err = rows.Scan(&UserID, &UserName, &SHA1Password, &LastChannel, &Texture, &LastActive)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if UserId == 0 {
|
if UserID == 0 {
|
||||||
server.cfg.Set("SuperUserPassword", "sha1$$"+SHA1Password)
|
server.cfg.Set("SuperUserPassword", "sha1$$"+SHA1Password)
|
||||||
}
|
}
|
||||||
|
|
||||||
user, err := NewUser(uint32(UserId), UserName)
|
user, err := NewUser(uint32(UserID), UserName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -446,9 +446,9 @@ func populateUsers(server *Server, db *sql.DB) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
user.LastActive = uint64(LastActive)
|
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=?")
|
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
|
// Populate users with any new-style UserInfo records
|
||||||
for uid, user := range server.Users {
|
for uid, user := range server.Users {
|
||||||
rows, err = stmt.Query(server.Id, uid)
|
rows, err = stmt.Query(server.ID, uid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -505,7 +505,7 @@ func populateBans(server *Server, db *sql.DB) (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
rows, err := stmt.Query(server.Id)
|
rows, err := stmt.Query(server.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ type KeyValuePair struct {
|
||||||
|
|
||||||
// Server is a Grumble server instance
|
// Server is a Grumble server instance
|
||||||
type Server struct {
|
type Server struct {
|
||||||
Id int64
|
ID int64
|
||||||
|
|
||||||
tcpl *net.TCPListener
|
tcpl *net.TCPListener
|
||||||
tlsl net.Listener
|
tlsl net.Listener
|
||||||
|
|
@ -112,13 +112,13 @@ type Server struct {
|
||||||
|
|
||||||
// Channels
|
// Channels
|
||||||
Channels map[int]*Channel
|
Channels map[int]*Channel
|
||||||
nextChanId int
|
nextChanID int
|
||||||
|
|
||||||
// Users
|
// Users
|
||||||
Users map[uint32]*User
|
Users map[uint32]*User
|
||||||
UserCertMap map[string]*User
|
UserCertMap map[string]*User
|
||||||
UserNameMap map[string]*User
|
UserNameMap map[string]*User
|
||||||
nextUserId uint32
|
nextUserID uint32
|
||||||
|
|
||||||
// Sessions
|
// Sessions
|
||||||
pool *sessionpool.SessionPool
|
pool *sessionpool.SessionPool
|
||||||
|
|
@ -142,7 +142,7 @@ type clientLogForwarder struct {
|
||||||
|
|
||||||
func (lf clientLogForwarder) Write(incoming []byte) (int, error) {
|
func (lf clientLogForwarder) Write(incoming []byte) (int, error) {
|
||||||
buf := new(bytes.Buffer)
|
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)
|
buf.Write(incoming)
|
||||||
lf.logger.Output(3, buf.String())
|
lf.logger.Output(3, buf.String())
|
||||||
return len(incoming), nil
|
return len(incoming), nil
|
||||||
|
|
@ -152,7 +152,7 @@ func (lf clientLogForwarder) Write(incoming []byte) (int, error) {
|
||||||
func NewServer(id int64) (s *Server, err error) {
|
func NewServer(id int64) (s *Server, err error) {
|
||||||
s = new(Server)
|
s = new(Server)
|
||||||
|
|
||||||
s.Id = id
|
s.ID = id
|
||||||
|
|
||||||
s.cfg = serverconf.New(nil)
|
s.cfg = serverconf.New(nil)
|
||||||
|
|
||||||
|
|
@ -161,13 +161,13 @@ func NewServer(id int64) (s *Server, err error) {
|
||||||
s.UserNameMap = make(map[string]*User)
|
s.UserNameMap = make(map[string]*User)
|
||||||
s.Users[0], err = NewUser(0, "SuperUser")
|
s.Users[0], err = NewUser(0, "SuperUser")
|
||||||
s.UserNameMap["SuperUser"] = s.Users[0]
|
s.UserNameMap["SuperUser"] = s.Users[0]
|
||||||
s.nextUserId = 1
|
s.nextUserID = 1
|
||||||
|
|
||||||
s.Channels = make(map[int]*Channel)
|
s.Channels = make(map[int]*Channel)
|
||||||
s.Channels[0] = NewChannel(0, "Root")
|
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
|
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.
|
// AddChannel adds a new channel to the server. Automatically assign it a channel ID.
|
||||||
func (server *Server) AddChannel(name string) (channel *Channel) {
|
func (server *Server) AddChannel(name string) (channel *Channel) {
|
||||||
channel = NewChannel(server.nextChanId, name)
|
channel = NewChannel(server.nextChanID, name)
|
||||||
server.Channels[channel.ID] = channel
|
server.Channels[channel.ID] = channel
|
||||||
server.nextChanId += 1
|
server.nextChanID += 1
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -565,7 +565,7 @@ func (server *Server) finishAuthenticate(client *Client) {
|
||||||
if client.user != nil {
|
if client.user != nil {
|
||||||
found := false
|
found := false
|
||||||
for _, connectedClient := range server.clients {
|
for _, connectedClient := range server.clients {
|
||||||
if connectedClient.UserId() == client.UserId() {
|
if connectedClient.UserID() == client.UserID() {
|
||||||
found = true
|
found = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
@ -609,7 +609,7 @@ func (server *Server) finishAuthenticate(client *Client) {
|
||||||
|
|
||||||
channel := server.RootChannel()
|
channel := server.RootChannel()
|
||||||
if client.IsRegistered() {
|
if client.IsRegistered() {
|
||||||
lastChannel := server.Channels[client.user.LastChannelId]
|
lastChannel := server.Channels[client.user.LastChannelID]
|
||||||
if lastChannel != nil {
|
if lastChannel != nil {
|
||||||
channel = lastChannel
|
channel = lastChannel
|
||||||
}
|
}
|
||||||
|
|
@ -626,7 +626,7 @@ func (server *Server) finishAuthenticate(client *Client) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if client.IsRegistered() {
|
if client.IsRegistered() {
|
||||||
userstate.UserId = proto.Uint32(uint32(client.UserId()))
|
userstate.UserID = proto.Uint32(uint32(client.UserID()))
|
||||||
|
|
||||||
if client.user.HasTexture() {
|
if client.user.HasTexture() {
|
||||||
// Does the client support blobs?
|
// Does the client support blobs?
|
||||||
|
|
@ -810,7 +810,7 @@ func (server *Server) sendUserList(client *Client) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if connectedClient.IsRegistered() {
|
if connectedClient.IsRegistered() {
|
||||||
userstate.UserId = proto.Uint32(uint32(connectedClient.UserId()))
|
userstate.UserID = proto.Uint32(uint32(connectedClient.UserID()))
|
||||||
|
|
||||||
if connectedClient.user.HasTexture() {
|
if connectedClient.user.HasTexture() {
|
||||||
// Does the client support blobs?
|
// 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.
|
// RegisterClient will register a client on the server.
|
||||||
func (s *Server) RegisterClient(client *Client) (uid uint32, err error) {
|
func (s *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
|
s.nextUserID += 1
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
user, err := NewUser(s.nextUserId, client.Username)
|
user, err := NewUser(s.nextUserID, client.Username)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
@ -1119,7 +1119,7 @@ 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 = s.nextUserID
|
||||||
s.Users[uid] = user
|
s.Users[uid] = user
|
||||||
s.UserCertMap[client.CertHash()] = user
|
s.UserCertMap[client.CertHash()] = user
|
||||||
s.UserNameMap[client.Username] = user
|
s.UserNameMap[client.Username] = user
|
||||||
|
|
@ -1150,7 +1150,7 @@ func (s *Server) removeRegisteredUserFromChannel(uid uint32, channel *Channel) {
|
||||||
|
|
||||||
newACL := []acl.ACL{}
|
newACL := []acl.ACL{}
|
||||||
for _, chanacl := range channel.ACL.ACLs {
|
for _, chanacl := range channel.ACL.ACLs {
|
||||||
if chanacl.UserId == int(uid) {
|
if chanacl.UserID == int(uid) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
newACL = append(newACL, chanacl)
|
newACL = append(newACL, chanacl)
|
||||||
|
|
@ -1361,7 +1361,7 @@ func (server *Server) cleanPerLaunchData() {
|
||||||
func (server *Server) Port() int {
|
func (server *Server) Port() int {
|
||||||
port := server.cfg.IntValue("Port")
|
port := server.cfg.IntValue("Port")
|
||||||
if port == 0 {
|
if port == 0 {
|
||||||
return DefaultPort + int(server.Id) - 1
|
return DefaultPort + int(server.ID) - 1
|
||||||
}
|
}
|
||||||
return port
|
return port
|
||||||
}
|
}
|
||||||
|
|
@ -1371,7 +1371,7 @@ func (server *Server) Port() int {
|
||||||
func (server *Server) WebPort() int {
|
func (server *Server) WebPort() int {
|
||||||
port := server.cfg.IntValue("WebPort")
|
port := server.cfg.IntValue("WebPort")
|
||||||
if port == 0 {
|
if port == 0 {
|
||||||
return DefaultWebPort + int(server.Id) - 1
|
return DefaultWebPort + int(server.ID) - 1
|
||||||
}
|
}
|
||||||
return port
|
return port
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,14 +15,14 @@ import (
|
||||||
|
|
||||||
// User contains all user information
|
// User contains all user information
|
||||||
type User struct {
|
type User struct {
|
||||||
Id uint32
|
ID uint32
|
||||||
Name string
|
Name string
|
||||||
Password string
|
Password string
|
||||||
CertHash string
|
CertHash string
|
||||||
Email string
|
Email string
|
||||||
TextureBlob string
|
TextureBlob string
|
||||||
CommentBlob string
|
CommentBlob string
|
||||||
LastChannelId int
|
LastChannelID int
|
||||||
LastActive uint64
|
LastActive uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -36,7 +36,7 @@ func NewUser(id uint32, name string) (user *User, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return &User{
|
return &User{
|
||||||
Id: id,
|
ID: id,
|
||||||
Name: name,
|
Name: name,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ func (perm Permission) Clean() Permission {
|
||||||
type ACL struct {
|
type ACL struct {
|
||||||
// The user id that this ACL applied to. If this
|
// The user id that this ACL applied to. If this
|
||||||
// field is -1, the ACL is a group ACL.
|
// field is -1, the ACL is a group ACL.
|
||||||
UserId int
|
UserID int
|
||||||
// The group that this ACL applies to.
|
// The group that this ACL applies to.
|
||||||
Group string
|
Group string
|
||||||
|
|
||||||
|
|
@ -75,7 +75,7 @@ type ACL struct {
|
||||||
// IsUserACL returns true if the ACL is defined for a user,
|
// IsUserACL returns true if the ACL is defined for a user,
|
||||||
// as opposed to a group.
|
// as opposed to a group.
|
||||||
func (acl *ACL) IsUserACL() bool {
|
func (acl *ACL) IsUserACL() bool {
|
||||||
return acl.UserId != -1
|
return acl.UserID != -1
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsChannelACL returns true if the ACL is defined for a group,
|
// 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
|
// SuperUser can't speak or whisper, but everything else is OK
|
||||||
if user.UserId() == 0 {
|
if user.UserID() == 0 {
|
||||||
if perm == SpeakPermission || perm == WhisperPermission {
|
if perm == SpeakPermission || perm == WhisperPermission {
|
||||||
return false
|
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
|
// If it's a group ACL, we have to parse and interpret
|
||||||
// the group string in the current context to determine
|
// the group string in the current context to determine
|
||||||
// membership. For that we use GroupMemberCheck.
|
// 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)
|
matchGroup := GroupMemberCheck(origCtx, ctx, acl.Group, user)
|
||||||
if matchUser || matchGroup {
|
if matchUser || matchGroup {
|
||||||
if acl.Allow.isSet(TraversePermission) {
|
if acl.Allow.isSet(TraversePermission) {
|
||||||
|
|
|
||||||
|
|
@ -201,8 +201,8 @@ func GroupMemberCheck(current *Context, acl *Context, name string, user User) (o
|
||||||
return true
|
return true
|
||||||
} else if name == "auth" {
|
} else if name == "auth" {
|
||||||
// The user is part of the auth group is he is authenticated. That is,
|
// The user is part of the auth group is he is authenticated. That is,
|
||||||
// his UserId is >= 0.
|
// his UserID is >= 0.
|
||||||
return user.UserId() >= 0
|
return user.UserID() >= 0
|
||||||
} else if name == "strong" {
|
} else if name == "strong" {
|
||||||
// The user is part of the strong group if he is authenticated to the server
|
// 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
|
// 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
|
isMember := false
|
||||||
for _, group := range groups {
|
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
|
isMember = true
|
||||||
}
|
}
|
||||||
if group.RemoveContains(user.UserId()) {
|
if group.RemoveContains(user.UserID()) {
|
||||||
isMember = false
|
isMember = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ package acl
|
||||||
// permissions in an ACL context.
|
// permissions in an ACL context.
|
||||||
type User interface {
|
type User interface {
|
||||||
Session() uint32
|
Session() uint32
|
||||||
UserId() int
|
UserID() int
|
||||||
|
|
||||||
CertHash() string
|
CertHash() string
|
||||||
Tokens() []string
|
Tokens() []string
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,7 @@ type User struct {
|
||||||
Email *string `protobuf:"bytes,5,opt,name=email" json:"email,omitempty"`
|
Email *string `protobuf:"bytes,5,opt,name=email" json:"email,omitempty"`
|
||||||
TextureBlob *string `protobuf:"bytes,6,opt,name=texture_blob" json:"texture_blob,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"`
|
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"`
|
LastActive *uint64 `protobuf:"varint,9,opt,name=last_active" json:"last_active,omitempty"`
|
||||||
XXX_unrecognized []byte `json:"-"`
|
XXX_unrecognized []byte `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
@ -195,9 +195,9 @@ func (this *User) GetCommentBlob() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *User) GetLastChannelId() uint32 {
|
func (this *User) GetLastChannelID() uint32 {
|
||||||
if this != nil && this.LastChannelId != nil {
|
if this != nil && this.LastChannelID != nil {
|
||||||
return *this.LastChannelId
|
return *this.LastChannelID
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
@ -301,7 +301,7 @@ func (this *ChannelRemove) GetId() uint32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ACL struct {
|
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"`
|
Group *string `protobuf:"bytes,2,opt,name=group" json:"group,omitempty"`
|
||||||
ApplyHere *bool `protobuf:"varint,3,opt,name=apply_here" json:"apply_here,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"`
|
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 (this *ACL) String() string { return proto.CompactTextString(this) }
|
||||||
func (*ACL) ProtoMessage() {}
|
func (*ACL) ProtoMessage() {}
|
||||||
|
|
||||||
func (this *ACL) GetUserId() uint32 {
|
func (this *ACL) GetUserID() uint32 {
|
||||||
if this != nil && this.UserId != nil {
|
if this != nil && this.UserID != nil {
|
||||||
return *this.UserId
|
return *this.UserID
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -780,7 +780,7 @@ type UserState struct {
|
||||||
// User name, UTF-8 encoded.
|
// User name, UTF-8 encoded.
|
||||||
Name *string `protobuf:"bytes,3,opt,name=name" json:"name,omitempty"`
|
Name *string `protobuf:"bytes,3,opt,name=name" json:"name,omitempty"`
|
||||||
// Registered user ID if the user is registered.
|
// 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.
|
// Channel on which the user is.
|
||||||
ChannelId *uint32 `protobuf:"varint,5,opt,name=channel_id,json=channelId" json:"channel_id,omitempty"`
|
ChannelId *uint32 `protobuf:"varint,5,opt,name=channel_id,json=channelId" json:"channel_id,omitempty"`
|
||||||
// True if the user is muted by admin.
|
// True if the user is muted by admin.
|
||||||
|
|
@ -841,9 +841,9 @@ func (m *UserState) GetName() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *UserState) GetUserId() uint32 {
|
func (m *UserState) GetUserID() uint32 {
|
||||||
if m != nil && m.UserId != nil {
|
if m != nil && m.UserID != nil {
|
||||||
return *m.UserId
|
return *m.UserID
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
@ -1321,7 +1321,7 @@ type ACL_ChanACL struct {
|
||||||
// True if the ACL has been inherited from the parent.
|
// True if the ACL has been inherited from the parent.
|
||||||
Inherited *bool `protobuf:"varint,3,opt,name=inherited,def=1" json:"inherited,omitempty"`
|
Inherited *bool `protobuf:"varint,3,opt,name=inherited,def=1" json:"inherited,omitempty"`
|
||||||
// ID of the user that is affected by this ACL.
|
// 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.
|
// ID of the group that is affected by this ACL.
|
||||||
Group *string `protobuf:"bytes,5,opt,name=group" json:"group,omitempty"`
|
Group *string `protobuf:"bytes,5,opt,name=group" json:"group,omitempty"`
|
||||||
// Bit flag field of the permissions granted by this ACL.
|
// 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
|
return Default_ACL_ChanACL_Inherited
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ACL_ChanACL) GetUserId() uint32 {
|
func (m *ACL_ChanACL) GetUserID() uint32 {
|
||||||
if m != nil && m.UserId != nil {
|
if m != nil && m.UserID != nil {
|
||||||
return *m.UserId
|
return *m.UserID
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
@ -1561,7 +1561,7 @@ func (m *UserList) GetUsers() []*UserList_User {
|
||||||
|
|
||||||
type UserList_User struct {
|
type UserList_User struct {
|
||||||
// Registered user ID.
|
// 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.
|
// Registered user name.
|
||||||
Name *string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"`
|
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"`
|
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) ProtoMessage() {}
|
||||||
func (*UserList_User) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{18, 0} }
|
func (*UserList_User) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{18, 0} }
|
||||||
|
|
||||||
func (m *UserList_User) GetUserId() uint32 {
|
func (m *UserList_User) GetUserID() uint32 {
|
||||||
if m != nil && m.UserId != nil {
|
if m != nil && m.UserID != nil {
|
||||||
return *m.UserId
|
return *m.UserID
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue