func (m *ipWhitelistManager) addRecent(addr string) bool {
	m.mutex.Lock()
	defer m.mutex.Unlock()

	i := stringslice.StrIndex(m.recentIPAddresses, addr)
	if i != -1 {
		if i == 0 {
			// don't do anything if it's already at the start
			return true
		}

		// remove from the list
		m.recentIPAddresses = append(m.recentIPAddresses[:i], m.recentIPAddresses[i+1:]...)
	}

	// add to the top of the list
	m.recentIPAddresses = append([]string{addr}, m.recentIPAddresses...)

	if len(m.recentIPAddresses) > recentListLength {
		m.recentIPAddresses = m.recentIPAddresses[:recentListLength]
	}

	return i != -1
}
// addRecent adds the provided address to the recent IP addresses list if it
// was not already present. Returns true if it was already present.
addRecent adds the provided address to the recent IP addresses list if it
was not already present. Returns true if it was already present.
// addRecent adds the provided address to the recent IP addresses list if it // was not already present . Returns true if it was already present .
func (m *ipWhitelistManager) addRecent(addr string) bool {
	m.mutex.Lock()
	defer m.mutex.Unlock()
	i := stringslice.StrIndex(m.recentIPAddresses, addr)
	if i != -1 {
		if i == 0 {
			return true
		}
		m.recentIPAddresses = append(m.recentIPAddresses[:i], m.recentIPAddresses[i+1:]...)
	}
	m.recentIPAddresses = append([]string{addr}, m.recentIPAddresses...)
	if len(m.recentIPAddresses) > recentListLength {
		m.recentIPAddresses = m.recentIPAddresses[:recentListLength]
	}
	return i != -1
}
func ( m * ipWhitelistManager ) addRecent ( addr string ) bool { m . mutex . Lock ( ) defer m . mutex . Unlock ( ) i := stringslice . StrIndex ( m . recentIPAddresses , addr ) if i != - 1 { if i == 0 { return true } m . recentIPAddresses = append ( m . recentIPAddresses [ : i ] , m . recentIPAddresses [ i + 1 : ] ... ) } m . recentIPAddresses = append ( [ ] string { addr } , m . recentIPAddresses ... ) if len ( m . recentIPAddresses ) > recentListLength { m . recentIPAddresses = m . recentIPAddresses [ : recentListLength ] } return i != - 1 }
addRecent adds the provided address to the recent IP addresses list if it
was not already present.
addRecent adds the provided address to the recent IP addresses list if it was not already present .
// don't do anything if it's already at the start // remove from the list // add to the top of the list