Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMultipleAddresses is returned when the mirror has more than one address ErrMultipleAddresses = errors.New("the mirror has more than one IP address") )
Functions ¶
func ExtractRemoteIP ¶
ExtractRemoteIP extracts the remote IP from an X-Forwarded-For header
func LookupMirrorIP ¶
LookupMirrorIP returns the IP address of a mirror and returns an error if the DNS has more than one address
func RemoteIPFromAddr ¶
RemoteIPFromAddr removes the port from a remote address (x.x.x.x:yyyy)
Types ¶
type ClusterLock ¶
type ClusterLock struct {
// contains filtered or unexported fields
}
ClusterLock holds the internal structure of a ClusterLock
func NewClusterLock ¶
func NewClusterLock(redis *database.Redis, key, identifier string) *ClusterLock
NewClusterLock returns a new instance of a ClusterLock. A ClucterLock is used to maitain a lock on a mirror that is being scanned. The lock is renewed every lockRefresh seconds and is automatically released by the redis database every lockTTL seconds allowing the lock to be released even if the application is killed.
func (*ClusterLock) Get ¶
func (n *ClusterLock) Get() (<-chan struct{}, error)
Get tries to obtain an exclusive lock, cluster wide, for the given mirror
func (*ClusterLock) Release ¶
func (n *ClusterLock) Release()
Release releases the exclusive lock on the mirror
type GeoIP ¶
GeoIP contains methods to query the GeoIP database
func (*GeoIP) GetRecord ¶
func (g *GeoIP) GetRecord(ip string) (ret GeoIPRecord)
GetRecord return informations about the given ip address (works in IPv4 and v6)
type GeoIPError ¶
type GeoIPError struct { Errors []error // contains filtered or unexported fields }
GeoIPError holds errors while loading the different databases
func (GeoIPError) Error ¶
func (e GeoIPError) Error() string
func (GeoIPError) IsFatal ¶
func (e GeoIPError) IsFatal() bool
IsFatal returns true if the error is fatal
type GeoIPRecord ¶
type GeoIPRecord struct { // City DB CountryCode string ContinentCode string City string Country string Latitude float32 Longitude float32 // ASN DB ASName string ASNum uint }
GeoIPRecord defines a GeoIP record for a given IP address
func (*GeoIPRecord) IsValid ¶
func (g *GeoIPRecord) IsValid() bool
IsValid returns true if the given address is valid
type Geolocalizer ¶
Geolocalizer is an interface representing a GeoIP library