forked from GlenDC/go-external-ip
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtypes.go
More file actions
23 lines (20 loc) · 728 Bytes
/
types.go
File metadata and controls
23 lines (20 loc) · 728 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package externalip
import (
"log"
"net"
"time"
)
// Source defines the part of a voter which gives the actual voting value (IP).
type Source interface {
// IP returns IPv4/IPv6 address in a non-error case
// net.IP should never be <nil> when error is <nil>
// It is recommended that the IP function times out,
// if no result could be found, after the given timeout duration.
IP(timeout time.Duration, logger *log.Logger) (net.IP, error)
}
// voter adds weight to the IP given by a source.
// The weight has to be at least 1, and the more it is, the more power the voter has.
type voter struct {
source Source // provides the IP (see: vote)
weight uint // provides the weight of its vote (acts as a multiplier)
}