summaryrefslogtreecommitdiff
path: root/internal/config.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2023-05-19 01:42:02 +0300
committerPaul Buetow <paul@buetow.org>2023-05-19 01:42:02 +0300
commitca585bde1c27777917b9454fe1d9c3d736de143d (patch)
tree702c4241ede146e07bd67cc536df132ba94a7043 /internal/config.go
parent5dc583de26cc7fc9816ce6b44ca4e80e723b8311 (diff)
excluding votes for non-participants
Diffstat (limited to 'internal/config.go')
-rw-r--r--internal/config.go14
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
}
}