diff options
| author | Paul Buetow <paul@buetow.org> | 2023-05-19 01:42:02 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2023-05-19 01:42:02 +0300 |
| commit | ca585bde1c27777917b9454fe1d9c3d736de143d (patch) | |
| tree | 702c4241ede146e07bd67cc536df132ba94a7043 /internal/config.go | |
| parent | 5dc583de26cc7fc9816ce6b44ca4e80e723b8311 (diff) | |
excluding votes for non-participants
Diffstat (limited to 'internal/config.go')
| -rw-r--r-- | internal/config.go | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/internal/config.go b/internal/config.go index 93549e2..17ec25b 100644 --- a/internal/config.go +++ b/internal/config.go @@ -38,11 +38,19 @@ func newConfig(configFile string) (config, error) { } func (c config) isParticipant(remoteAddr string) bool { - return c.isParticipantWithLookup(remoteAddr, net.LookupIP) + remoteAddr = stripPort(remoteAddr) + + for _, participant := range c.Participants { + if remoteAddr == stripPort(participant) { + return true + } + } + + return false } func (c config) isParticipantWithLookup(remoteAddr string, lookupIP func(string) ([]net.IP, error)) bool { - remoteIP := stripPort(remoteAddr) + remoteAddr = stripPort(remoteAddr) for _, participant := range c.Participants { ips, err := lookupIP(stripPort(participant)) @@ -52,7 +60,7 @@ func (c config) isParticipantWithLookup(remoteAddr string, lookupIP func(string) } for _, ip := range ips { - if remoteIP == ip.String() { + if remoteAddr == ip.String() { return true } } |
