Implement review suggestions

Fix local. resolving in Firefox
This commit is contained in:
Daniel
2020-07-15 13:59:56 +02:00
parent e369a9484a
commit 047352f9b5
9 changed files with 57 additions and 52 deletions

View File

@@ -2,7 +2,6 @@ package netenv
import (
"context"
"errors"
"io/ioutil"
"net"
"net/http"
@@ -111,30 +110,13 @@ var (
captivePortalLock sync.Mutex
)
// CaptivePortal holds information about a detected captive portal.
type CaptivePortal struct {
URL string
Domain string
IP net.IP
}
// IPasRR returns the captive portal IP as a DNS resource record.
func (p *CaptivePortal) IPasRR() (rr dns.RR, err error) {
switch {
case p.IP == nil:
return nil, errors.New("no portal IP present")
case p.Domain == "":
return nil, errors.New("no portal domain present")
case p.IP.To4() != nil:
rr, err = dns.NewRR(p.Domain + " 17 IN A " + p.IP.String())
default:
rr, err = dns.NewRR(p.Domain + " 17 IN AAAA " + p.IP.String())
}
if err != nil {
return nil, err
}
return rr, nil
}
func init() {
var onlineStatusValue int32
onlineStatus = &onlineStatusValue