// Copyright (c) 2011 The Grumble Authors // The use of this source code is goverened by a BSD-style // license that can be found in the LICENSE-file. package ban import ( "net" "time" ) const ( ISODate = "2006-01-02T15:04:05" ) type Ban struct { IP net.IP Mask int Username string CertHash string Reason string Start int64 Duration uint32 } // Create a net.IPMask from a specified amount of mask bits func (ban Ban) IPMask() (mask net.IPMask) { allbits := ban.Mask for i := 0; i < 16; i++ { bits := allbits if bits > 0 { if bits > 8 { bits = 8 } mask = append(mask, byte((1< expiryTime { return true } return false }