Exemplo n.º 1
0
func newPortMap() *portMap {
	m := &portMap{
		access:       sync.Mutex{},
		data:         make(map[uint16]*net.UDPAddr),
		removedPorts: collect.NewTimedQueue(1),
	}
	go m.removePorts(m.removedPorts.RemovedEntries())
	return m
}
Exemplo n.º 2
0
func NewTimedUserSet() UserSet {
	tus := &TimedUserSet{
		validUsers:          make([]config.User, 0, 16),
		userHash:            make(map[string]indexTimePair, 512),
		userHashDeleteQueue: collect.NewTimedQueue(updateIntervalSec),
		access:              sync.RWMutex{},
	}
	go tus.updateUserHash(time.Tick(updateIntervalSec * time.Second))
	go tus.removeEntries(tus.userHashDeleteQueue.RemovedEntries())
	return tus
}