mode.mx raw

   1  // Package mode provides a domain-local ACL mode indicator readable by
   2  // packages that need to know the current access control mode without
   3  // circular dependencies.
   4  package mode
   5  
   6  // ACLMode holds the current ACL mode. Plain variable - single
   7  // cooperative thread per domain, no atomic needed.
   8  var ACLMode []byte
   9  
  10  // IsOpenMode reports whether an ACL mode value means an open relay.
  11  func IsOpenMode(m []byte) (ok bool) {
  12  	return len(m) == 4 &&
  13  		m[0] == 'n' && m[1] == 'o' &&
  14  		m[2] == 'n' && m[3] == 'e'
  15  }
  16  
  17  // IsOpen returns true if the current ACL mode is "none" (open relay mode).
  18  func IsOpen() (ok bool) {
  19  	return IsOpenMode(ACLMode)
  20  }
  21