This commit is contained in:
2021-02-26 15:52:29 -05:00
parent 8dea2185fd
commit d085d0f3ee
10 changed files with 407 additions and 0 deletions

44
types/bitmasks.go Normal file
View File

@@ -0,0 +1,44 @@
package types
type BitMask interface {
HasFlag(bit MaskBit) bool
AddFlag(bit MaskBit)
ClearFlag(bit MaskBit)
ToggleFlag(bit MaskBit)
}
// BitMasks
type MaskBit uint8
// LDAP Connection flags
const (
LdapBindUndefined MaskBit = 1 << iota
LdapBindNone // GSSAPI via SASL or (TODO) Anonymous bind
LdapBindNet
LdapBindTls
LdapBindStartTls
LdapBindSasl
LdapBindNoPassword
)
func (f MaskBit) HasFlag(flag MaskBit) (r bool) {
if f&flag != 0 {
r = true
}
return
}
func (f *MaskBit) AddFlag(flag MaskBit) {
*f |= flag
return
}
func (f *MaskBit) ClearFlag(flag MaskBit) {
*f &= flag
return
}
func (f *MaskBit) ToggleFlag(flag MaskBit) {
*f ^= flag
return
}