Added config option to check for a header value for clinet IP

This commit is contained in:
Joona Hoikkala
2016-12-02 17:04:16 +02:00
parent 8c99346b01
commit bf9eaf2f32
8 changed files with 116 additions and 4 deletions

18
util.go
View File

@ -2,12 +2,13 @@ package main
import (
"crypto/rand"
"github.com/BurntSushi/toml"
log "github.com/Sirupsen/logrus"
"github.com/miekg/dns"
"math/big"
"regexp"
"strings"
"github.com/BurntSushi/toml"
log "github.com/Sirupsen/logrus"
"github.com/miekg/dns"
)
func readConfig(fname string) DNSConfig {
@ -68,3 +69,14 @@ func startDNS(listen string, proto string) *dns.Server {
go server.ListenAndServe()
return server
}
func getIPListFromHeader(header string) []string {
iplist := []string{}
for _, v := range strings.Split(header, ",") {
if len(v) > 0 {
// Ignore empty values
iplist = append(iplist, strings.TrimSpace(v))
}
}
return iplist
}