bugfix iplist validation
This commit is contained in:
parent
e47ecba665
commit
21a0892146
|
@ -639,11 +639,23 @@ func tryToServeName(servername string, wconn *telebit.ConnWrap) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
remoteAddr := addr.String()
|
// 192.168.1.100:2345
|
||||||
if "127.0.0.1" != remoteAddr &&
|
// [::fe12]:2345
|
||||||
"::1" != remoteAddr &&
|
remoteIP := addr.String()
|
||||||
"localhost" != remoteAddr {
|
index := strings.LastIndex(remoteIP, ":")
|
||||||
ipAddr := net.ParseIP(remoteAddr)
|
if index < 1 {
|
||||||
|
// TODO how to handle unexpected invalid address?
|
||||||
|
wconn.Close()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
remoteIP = remoteIP[:index]
|
||||||
|
|
||||||
|
fmt.Println("remote addr:", remoteIP)
|
||||||
|
|
||||||
|
if "127.0.0.1" != remoteIP &&
|
||||||
|
"::1" != remoteIP &&
|
||||||
|
"localhost" != remoteIP {
|
||||||
|
ipAddr := net.ParseIP(remoteIP)
|
||||||
if nil == ipAddr {
|
if nil == ipAddr {
|
||||||
wconn.Close()
|
wconn.Close()
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -13,6 +13,9 @@ fi
|
||||||
|
|
||||||
source .env
|
source .env
|
||||||
|
|
||||||
|
SPF_HOSTNAME="${SPF_HOSTNAME:-""}"
|
||||||
|
#SPF_HOSTNAME="_allowed.example.com"
|
||||||
|
|
||||||
# For Tunnel Relay Server
|
# For Tunnel Relay Server
|
||||||
API_HOSTNAME=${API_HOSTNAME:-"devices.example.com"}
|
API_HOSTNAME=${API_HOSTNAME:-"devices.example.com"}
|
||||||
LISTEN="${LISTEN:-":80 :443"}"
|
LISTEN="${LISTEN:-":80 :443"}"
|
||||||
|
@ -29,6 +32,7 @@ ACME_AGREE=${ACME_AGREE:-}
|
||||||
ACME_EMAIL="${ACME_EMAIL:-}"
|
ACME_EMAIL="${ACME_EMAIL:-}"
|
||||||
|
|
||||||
./telebit \
|
./telebit \
|
||||||
|
--spf-domain $SPF_HOSTNAME \
|
||||||
--api-hostname $API_HOSTNAME \
|
--api-hostname $API_HOSTNAME \
|
||||||
--auth-url $AUTH_URL \
|
--auth-url $AUTH_URL \
|
||||||
--acme-agree "$ACME_AGREE" \
|
--acme-agree "$ACME_AGREE" \
|
||||||
|
|
|
@ -73,9 +73,10 @@ func updateTxt(txtDomain string) error {
|
||||||
if nil != err {
|
if nil != err {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if len(fields) > 0 {
|
if len(newFields) > 0 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
return fmt.Errorf("no spf records found")
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO put a lock here?
|
// TODO put a lock here?
|
||||||
|
|
Loading…
Reference in New Issue