1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
package otr3
type policies int
type policy int
const (
allowV2 policy = 2 << iota
allowV3
requireEncryption
sendWhitespaceTag
whitespaceStartAKE
errorStartAKE
)
func (p *policies) isOTREnabled() bool {
return p.has(allowV2) || p.has(allowV3)
}
func (p *policies) has(c policy) bool {
return int(*p)&int(c) == int(c)
}
func (p *policies) add(c policy) {
*p = policies(int(*p) | int(c))
}
func (p *policies) AllowV2() {
p.add(allowV2)
}
func (p *policies) AllowV3() {
p.add(allowV3)
}
func (p *policies) RequireEncryption() {
p.add(requireEncryption)
}
func (p *policies) SendWhitespaceTag() {
p.add(sendWhitespaceTag)
}
func (p *policies) WhitespaceStartAKE() {
p.add(whitespaceStartAKE)
}
func (p *policies) ErrorStartAKE() {
p.add(errorStartAKE)
}
|