mirror of
https://github.com/mumble-voip/grumble.git
synced 2025-12-19 21:59:59 -08:00
Remove unreachable code reported by go vet
This commit is contained in:
parent
bbb589fb37
commit
d9b6cbb89f
4 changed files with 40 additions and 46 deletions
|
|
@ -392,10 +392,9 @@ func (client *Client) SendUDP(buf []byte) error {
|
||||||
crypted := make([]byte, len(buf)+client.crypt.Overhead())
|
crypted := make([]byte, len(buf)+client.crypt.Overhead())
|
||||||
client.crypt.Encrypt(crypted, buf)
|
client.crypt.Encrypt(crypted, buf)
|
||||||
return client.server.SendUDP(crypted, client.udpaddr)
|
return client.server.SendUDP(crypted, client.udpaddr)
|
||||||
} else {
|
|
||||||
return client.sendMessage(buf)
|
|
||||||
}
|
}
|
||||||
panic("unreachable")
|
|
||||||
|
return client.sendMessage(buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send a Message to the client. The Message in msg to the client's
|
// Send a Message to the client. The Message in msg to the client's
|
||||||
|
|
|
||||||
|
|
@ -869,13 +869,12 @@ func (server *Server) sendClientPermissions(client *Client, channel *Channel) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// fixme(mkrautz): re-add when we have ACL caching
|
// fixme(mkrautz): re-add when we have ACL caching
|
||||||
return
|
|
||||||
|
|
||||||
perm := acl.Permission(acl.NonePermission)
|
// perm := acl.Permission(acl.NonePermission)
|
||||||
client.sendMessage(&mumbleproto.PermissionQuery{
|
// client.sendMessage(&mumbleproto.PermissionQuery{
|
||||||
ChannelId: proto.Uint32(uint32(channel.Id)),
|
// ChannelId: proto.Uint32(uint32(channel.Id)),
|
||||||
Permissions: proto.Uint32(uint32(perm)),
|
// Permissions: proto.Uint32(uint32(perm)),
|
||||||
})
|
// })
|
||||||
}
|
}
|
||||||
|
|
||||||
type ClientPredicate func(client *Client) bool
|
type ClientPredicate func(client *Client) bool
|
||||||
|
|
|
||||||
|
|
@ -161,9 +161,7 @@ func HasPermission(ctx *Context, user User, perm Permission) bool {
|
||||||
// permissions exccept SpeakPermission and WhisperPermission.
|
// permissions exccept SpeakPermission and WhisperPermission.
|
||||||
if perm != SpeakPermission && perm != WhisperPermission {
|
if perm != SpeakPermission && perm != WhisperPermission {
|
||||||
return (granted & (perm | WritePermission)) != NonePermission
|
return (granted & (perm | WritePermission)) != NonePermission
|
||||||
} else {
|
|
||||||
return (granted & perm) != NonePermission
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return (granted & perm) != NonePermission
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -298,42 +298,40 @@ func GroupMemberCheck(current *Context, acl *Context, name string, user User) (o
|
||||||
pdepth := len(userChain) - 1
|
pdepth := len(userChain) - 1
|
||||||
return pdepth >= mindepth && pdepth <= maxdepth
|
return pdepth >= mindepth && pdepth <= maxdepth
|
||||||
|
|
||||||
} else {
|
|
||||||
// Non-magic groups
|
|
||||||
groups := []Group{}
|
|
||||||
|
|
||||||
iter := channel
|
|
||||||
for iter != nil {
|
|
||||||
if group, ok := iter.Groups[name]; ok {
|
|
||||||
// Skip non-inheritable groups if we're in parents
|
|
||||||
// of our evaluated context.
|
|
||||||
if iter != channel && !group.Inheritable {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
// Prepend group
|
|
||||||
groups = append([]Group{group}, groups...)
|
|
||||||
// If this group does not inherit from groups in its ancestors, stop looking
|
|
||||||
// for more ancestor groups.
|
|
||||||
if !group.Inherit {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
iter = iter.Parent
|
|
||||||
}
|
|
||||||
|
|
||||||
isMember := false
|
|
||||||
for _, group := range groups {
|
|
||||||
if group.AddContains(user.UserId()) || group.TemporaryContains(user.UserId()) || group.TemporaryContains(-int(user.Session())) {
|
|
||||||
isMember = true
|
|
||||||
}
|
|
||||||
if group.RemoveContains(user.UserId()) {
|
|
||||||
isMember = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return isMember
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
// Non-magic groups
|
||||||
|
groups := []Group{}
|
||||||
|
|
||||||
|
iter := channel
|
||||||
|
for iter != nil {
|
||||||
|
if group, ok := iter.Groups[name]; ok {
|
||||||
|
// Skip non-inheritable groups if we're in parents
|
||||||
|
// of our evaluated context.
|
||||||
|
if iter != channel && !group.Inheritable {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
// Prepend group
|
||||||
|
groups = append([]Group{group}, groups...)
|
||||||
|
// If this group does not inherit from groups in its ancestors, stop looking
|
||||||
|
// for more ancestor groups.
|
||||||
|
if !group.Inherit {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
iter = iter.Parent
|
||||||
|
}
|
||||||
|
|
||||||
|
isMember := false
|
||||||
|
for _, group := range groups {
|
||||||
|
if group.AddContains(user.UserId()) || group.TemporaryContains(user.UserId()) || group.TemporaryContains(-int(user.Session())) {
|
||||||
|
isMember = true
|
||||||
|
}
|
||||||
|
if group.RemoveContains(user.UserId()) {
|
||||||
|
isMember = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return isMember
|
||||||
}
|
}
|
||||||
|
|
||||||
// GroupNames gets the list of group names for the given ACL context.
|
// GroupNames gets the list of group names for the given ACL context.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue