瀏覽代碼

Pass the correct IP address to GeoIP

Ask Bjørn Hansen 13 年之前
父節點
當前提交
e09a7488a8
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      serve.go

+ 2 - 1
serve.go

@@ -5,6 +5,7 @@ import (
 	"github.com/abh/geodns/countries"
 	"github.com/abh/geodns/countries"
 	"github.com/miekg/dns"
 	"github.com/miekg/dns"
 	"log"
 	"log"
+	"net"
 	"os"
 	"os"
 	"strconv"
 	"strconv"
 	"strings"
 	"strings"
@@ -35,7 +36,7 @@ func serve(w dns.ResponseWriter, req *dns.Msg, z *Zone) {
 
 
 	var country string
 	var country string
 	if geoIP != nil {
 	if geoIP != nil {
-		ip := w.RemoteAddr().String()
+		ip, _, _ := net.SplitHostPort(w.RemoteAddr().String())
 		country = strings.ToLower(geoIP.GetCountry(ip))
 		country = strings.ToLower(geoIP.GetCountry(ip))
 		logPrintln("Country:", ip, country)
 		logPrintln("Country:", ip, country)
 	}
 	}