mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-21 20:45:33 +03:00
Pull request: all: imp docs, names
Merge in DNS/adguard-home from imp-text to master Squashed commit of the following: commit fa7d64014fb2ac379e1c137eaccc7aefca86419d Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Fri Jun 11 17:09:00 2021 +0300 all: imp docs, names
This commit is contained in:
parent
3ee0369cb9
commit
dab7b439d1
25 changed files with 110 additions and 112 deletions
2
.github/ISSUE_TEMPLATE/Bug_report.md
vendored
2
.github/ISSUE_TEMPLATE/Bug_report.md
vendored
|
@ -20,7 +20,7 @@ Please answer the following questions for yourself before submitting an issue. *
|
|||
* **Version of AdGuard Home server:**
|
||||
* <!-- (e.g. v0.123.4) -->
|
||||
* **How did you install AdGuard Home:**
|
||||
* <!-- (e.g. Built from source, Snapcraft, Docker, Github releases, etc.) -->
|
||||
* <!-- (e.g. Built from source, Snapcraft, Docker, GitHub releases, etc.) -->
|
||||
* **How did you setup DNS configuration:**
|
||||
* <!-- (System/Router/IoT) -->
|
||||
* **If it's a router or IoT, please write device model:**
|
||||
|
|
|
@ -34,11 +34,11 @@
|
|||
'jobs':
|
||||
- 'Publish to Snapstore'
|
||||
|
||||
- 'Publish to Github Releases':
|
||||
- 'Publish to GitHub Releases':
|
||||
'manual': false
|
||||
'final': false
|
||||
'jobs':
|
||||
- 'Publish to Github Releases'
|
||||
- 'Publish to GitHub Releases'
|
||||
|
||||
'Make release':
|
||||
'docker':
|
||||
|
@ -194,7 +194,7 @@
|
|||
'requirements':
|
||||
- 'adg-docker': 'true'
|
||||
|
||||
'Publish to Github Releases':
|
||||
'Publish to GitHub Releases':
|
||||
'key': 'PTGR'
|
||||
'other':
|
||||
'clean-working-dir': true
|
||||
|
@ -215,7 +215,7 @@
|
|||
export CHANNEL="${bamboo.channel}"
|
||||
if [ "$CHANNEL" != 'release' ] && [ "${CHANNEL}" != 'beta' ]
|
||||
then
|
||||
echo "don't publish to Github Releases for this channel"
|
||||
echo "don't publish to GitHub Releases for this channel"
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
|
|
@ -13,8 +13,8 @@ import (
|
|||
"github.com/AdguardTeam/golibs/errors"
|
||||
)
|
||||
|
||||
// hardwarePortInfo - information obtained using MacOS networksetup
|
||||
// about the current state of the internet connection
|
||||
// hardwarePortInfo contains information about the current state of the internet
|
||||
// connection obtained from macOS networksetup.
|
||||
type hardwarePortInfo struct {
|
||||
name string
|
||||
ip string
|
||||
|
|
|
@ -109,7 +109,7 @@ type quicSession interface {
|
|||
}
|
||||
|
||||
// processClientID extracts the client's ID from the server name of the client's
|
||||
// DOT or DOQ request or the path of the client's DOH.
|
||||
// DoT or DoQ request or the path of the client's DoH.
|
||||
func processClientID(dctx *dnsContext) (rc resultCode) {
|
||||
pctx := dctx.proxyCtx
|
||||
proto := pctx.Proto
|
||||
|
|
|
@ -167,7 +167,7 @@ type ServerConfig struct {
|
|||
FilteringConfig
|
||||
TLSConfig
|
||||
DNSCryptConfig
|
||||
TLSAllowUnencryptedDOH bool
|
||||
TLSAllowUnencryptedDoH bool
|
||||
|
||||
// UpstreamTimeout is the timeout for querying upstream servers.
|
||||
UpstreamTimeout time.Duration
|
||||
|
|
|
@ -32,7 +32,7 @@ type dnsContext struct {
|
|||
unreversedReqIP net.IP
|
||||
// err is the error returned from a processing function.
|
||||
err error
|
||||
// clientID is the clientID from DOH, DOQ, or DOT, if provided.
|
||||
// clientID is the clientID from DoH, DoQ, or DoT, if provided.
|
||||
clientID string
|
||||
// origQuestion is the question received from the client. It is set
|
||||
// when the request is modified by rewrites.
|
||||
|
|
|
@ -621,11 +621,11 @@ func (s *Server) handleTestUpstreamDNS(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// Control flow:
|
||||
// web
|
||||
// -> dnsforward.handleDOH -> dnsforward.ServeHTTP
|
||||
// -> dnsforward.handleDoH -> dnsforward.ServeHTTP
|
||||
// -> proxy.ServeHTTP -> proxy.handleDNSRequest
|
||||
// -> dnsforward.handleDNSRequest
|
||||
func (s *Server) handleDOH(w http.ResponseWriter, r *http.Request) {
|
||||
if !s.conf.TLSAllowUnencryptedDOH && r.TLS == nil {
|
||||
func (s *Server) handleDoH(w http.ResponseWriter, r *http.Request) {
|
||||
if !s.conf.TLSAllowUnencryptedDoH && r.TLS == nil {
|
||||
httpError(r, w, http.StatusNotFound, "Not Found")
|
||||
return
|
||||
}
|
||||
|
@ -653,6 +653,6 @@ func (s *Server) registerHandlers() {
|
|||
// See go doc net/http.ServeMux.
|
||||
//
|
||||
// See also https://github.com/AdguardTeam/AdGuardHome/issues/2628.
|
||||
s.conf.HTTPRegister("", "/dns-query", s.handleDOH)
|
||||
s.conf.HTTPRegister("", "/dns-query/", s.handleDOH)
|
||||
s.conf.HTTPRegister("", "/dns-query", s.handleDoH)
|
||||
s.conf.HTTPRegister("", "/dns-query/", s.handleDoH)
|
||||
}
|
||||
|
|
|
@ -44,11 +44,11 @@ func processQueryLogsAndStats(ctx *dnsContext) (rc resultCode) {
|
|||
|
||||
switch pctx.Proto {
|
||||
case proxy.ProtoHTTPS:
|
||||
p.ClientProto = querylog.ClientProtoDOH
|
||||
p.ClientProto = querylog.ClientProtoDoH
|
||||
case proxy.ProtoQUIC:
|
||||
p.ClientProto = querylog.ClientProtoDOQ
|
||||
p.ClientProto = querylog.ClientProtoDoQ
|
||||
case proxy.ProtoTLS:
|
||||
p.ClientProto = querylog.ClientProtoDOT
|
||||
p.ClientProto = querylog.ClientProtoDoT
|
||||
case proxy.ProtoDNSCrypt:
|
||||
p.ClientProto = querylog.ClientProtoDNSCrypt
|
||||
default:
|
||||
|
|
|
@ -69,7 +69,7 @@ func TestProcessQueryLogsAndStats(t *testing.T) {
|
|||
proto: proxy.ProtoTLS,
|
||||
addr: &net.TCPAddr{IP: net.IP{1, 2, 3, 4}, Port: 1234},
|
||||
clientID: "cli42",
|
||||
wantLogProto: querylog.ClientProtoDOT,
|
||||
wantLogProto: querylog.ClientProtoDoT,
|
||||
wantStatClient: "cli42",
|
||||
wantCode: resultCodeSuccess,
|
||||
reason: filtering.NotFilteredNotFound,
|
||||
|
@ -79,7 +79,7 @@ func TestProcessQueryLogsAndStats(t *testing.T) {
|
|||
proto: proxy.ProtoTLS,
|
||||
addr: &net.TCPAddr{IP: net.IP{1, 2, 3, 4}, Port: 1234},
|
||||
clientID: "",
|
||||
wantLogProto: querylog.ClientProtoDOT,
|
||||
wantLogProto: querylog.ClientProtoDoT,
|
||||
wantStatClient: "1.2.3.4",
|
||||
wantCode: resultCodeSuccess,
|
||||
reason: filtering.NotFilteredNotFound,
|
||||
|
@ -89,7 +89,7 @@ func TestProcessQueryLogsAndStats(t *testing.T) {
|
|||
proto: proxy.ProtoQUIC,
|
||||
addr: &net.UDPAddr{IP: net.IP{1, 2, 3, 4}, Port: 1234},
|
||||
clientID: "",
|
||||
wantLogProto: querylog.ClientProtoDOQ,
|
||||
wantLogProto: querylog.ClientProtoDoQ,
|
||||
wantStatClient: "1.2.3.4",
|
||||
wantCode: resultCodeSuccess,
|
||||
reason: filtering.NotFilteredNotFound,
|
||||
|
@ -99,7 +99,7 @@ func TestProcessQueryLogsAndStats(t *testing.T) {
|
|||
proto: proxy.ProtoHTTPS,
|
||||
addr: &net.TCPAddr{IP: net.IP{1, 2, 3, 4}, Port: 1234},
|
||||
clientID: "",
|
||||
wantLogProto: querylog.ClientProtoDOH,
|
||||
wantLogProto: querylog.ClientProtoDoH,
|
||||
wantStatClient: "1.2.3.4",
|
||||
wantCode: resultCodeSuccess,
|
||||
reason: filtering.NotFilteredNotFound,
|
||||
|
|
|
@ -63,13 +63,13 @@ const (
|
|||
|
||||
// RuntimeClient information
|
||||
type RuntimeClient struct {
|
||||
WhoisInfo *RuntimeClientWhoisInfo
|
||||
WHOISInfo *RuntimeClientWHOISInfo
|
||||
Host string
|
||||
Source clientSource
|
||||
}
|
||||
|
||||
// RuntimeClientWhoisInfo is the filtered WHOIS data for a runtime client.
|
||||
type RuntimeClientWhoisInfo struct {
|
||||
// RuntimeClientWHOISInfo is the filtered WHOIS data for a runtime client.
|
||||
type RuntimeClientWHOISInfo struct {
|
||||
City string `json:"city,omitempty"`
|
||||
Country string `json:"country,omitempty"`
|
||||
Orgname string `json:"orgname,omitempty"`
|
||||
|
@ -270,12 +270,12 @@ func (clients *clientsContainer) Exists(id string, source clientSource) (ok bool
|
|||
return source <= rc.Source
|
||||
}
|
||||
|
||||
func toQueryLogWhois(wi *RuntimeClientWhoisInfo) (cw *querylog.ClientWhois) {
|
||||
func toQueryLogWHOIS(wi *RuntimeClientWHOISInfo) (cw *querylog.ClientWHOIS) {
|
||||
if wi == nil {
|
||||
return &querylog.ClientWhois{}
|
||||
return &querylog.ClientWHOIS{}
|
||||
}
|
||||
|
||||
return &querylog.ClientWhois{
|
||||
return &querylog.ClientWHOIS{
|
||||
City: wi.City,
|
||||
Country: wi.Country,
|
||||
Orgname: wi.Orgname,
|
||||
|
@ -287,7 +287,7 @@ func toQueryLogWhois(wi *RuntimeClientWhoisInfo) (cw *querylog.ClientWhois) {
|
|||
func (clients *clientsContainer) findMultiple(ids []string) (c *querylog.Client, err error) {
|
||||
for _, id := range ids {
|
||||
var name string
|
||||
whois := &querylog.ClientWhois{}
|
||||
whois := &querylog.ClientWHOIS{}
|
||||
|
||||
c, ok := clients.Find(id)
|
||||
if ok {
|
||||
|
@ -300,7 +300,7 @@ func (clients *clientsContainer) findMultiple(ids []string) (c *querylog.Client,
|
|||
}
|
||||
|
||||
name = rc.Host
|
||||
whois = toQueryLogWhois(rc.WhoisInfo)
|
||||
whois = toQueryLogWHOIS(rc.WHOISInfo)
|
||||
}
|
||||
|
||||
ip := net.ParseIP(id)
|
||||
|
@ -309,7 +309,7 @@ func (clients *clientsContainer) findMultiple(ids []string) (c *querylog.Client,
|
|||
return &querylog.Client{
|
||||
Name: name,
|
||||
DisallowedRule: disallowedRule,
|
||||
Whois: whois,
|
||||
WHOIS: whois,
|
||||
Disallowed: disallowed,
|
||||
}, nil
|
||||
}
|
||||
|
@ -620,8 +620,8 @@ func (clients *clientsContainer) Update(name string, c *Client) (err error) {
|
|||
return nil
|
||||
}
|
||||
|
||||
// SetWhoisInfo sets the WHOIS information for a client.
|
||||
func (clients *clientsContainer) SetWhoisInfo(ip string, wi *RuntimeClientWhoisInfo) {
|
||||
// SetWHOISInfo sets the WHOIS information for a client.
|
||||
func (clients *clientsContainer) SetWHOISInfo(ip string, wi *RuntimeClientWHOISInfo) {
|
||||
clients.lock.Lock()
|
||||
defer clients.lock.Unlock()
|
||||
|
||||
|
@ -633,7 +633,7 @@ func (clients *clientsContainer) SetWhoisInfo(ip string, wi *RuntimeClientWhoisI
|
|||
|
||||
rc, ok := clients.ipToRC[ip]
|
||||
if ok {
|
||||
rc.WhoisInfo = wi
|
||||
rc.WHOISInfo = wi
|
||||
log.Debug("clients: set whois info for runtime client %s: %+v", rc.Host, wi)
|
||||
|
||||
return
|
||||
|
@ -645,7 +645,7 @@ func (clients *clientsContainer) SetWhoisInfo(ip string, wi *RuntimeClientWhoisI
|
|||
Source: ClientSourceWHOIS,
|
||||
}
|
||||
|
||||
rc.WhoisInfo = wi
|
||||
rc.WHOISInfo = wi
|
||||
clients.ipToRC[ip] = rc
|
||||
|
||||
log.Debug("clients: set whois info for runtime client with ip %s: %+v", ip, wi)
|
||||
|
@ -676,7 +676,7 @@ func (clients *clientsContainer) addHostLocked(ip, host string, src clientSource
|
|||
rc = &RuntimeClient{
|
||||
Host: host,
|
||||
Source: src,
|
||||
WhoisInfo: &RuntimeClientWhoisInfo{},
|
||||
WHOISInfo: &RuntimeClientWHOISInfo{},
|
||||
}
|
||||
|
||||
clients.ipToRC[ip] = rc
|
||||
|
|
|
@ -172,25 +172,25 @@ func TestClients(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestClientsWhois(t *testing.T) {
|
||||
func TestClientsWHOIS(t *testing.T) {
|
||||
clients := clientsContainer{
|
||||
testing: true,
|
||||
}
|
||||
clients.Init(nil, nil, nil)
|
||||
whois := &RuntimeClientWhoisInfo{
|
||||
whois := &RuntimeClientWHOISInfo{
|
||||
Country: "AU",
|
||||
Orgname: "Example Org",
|
||||
}
|
||||
|
||||
t.Run("new_client", func(t *testing.T) {
|
||||
clients.SetWhoisInfo("1.1.1.255", whois)
|
||||
clients.SetWHOISInfo("1.1.1.255", whois)
|
||||
|
||||
require.NotNil(t, clients.ipToRC["1.1.1.255"])
|
||||
|
||||
h := clients.ipToRC["1.1.1.255"]
|
||||
require.NotNil(t, h)
|
||||
|
||||
assert.Equal(t, h.WhoisInfo, whois)
|
||||
assert.Equal(t, h.WHOISInfo, whois)
|
||||
})
|
||||
|
||||
t.Run("existing_auto-client", func(t *testing.T) {
|
||||
|
@ -198,13 +198,13 @@ func TestClientsWhois(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
assert.True(t, ok)
|
||||
|
||||
clients.SetWhoisInfo("1.1.1.1", whois)
|
||||
clients.SetWHOISInfo("1.1.1.1", whois)
|
||||
|
||||
require.NotNil(t, clients.ipToRC["1.1.1.1"])
|
||||
h := clients.ipToRC["1.1.1.1"]
|
||||
require.NotNil(t, h)
|
||||
|
||||
assert.Equal(t, h.WhoisInfo, whois)
|
||||
assert.Equal(t, h.WHOISInfo, whois)
|
||||
})
|
||||
|
||||
t.Run("can't_set_manually-added", func(t *testing.T) {
|
||||
|
@ -215,7 +215,7 @@ func TestClientsWhois(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
assert.True(t, ok)
|
||||
|
||||
clients.SetWhoisInfo("1.1.1.2", whois)
|
||||
clients.SetWHOISInfo("1.1.1.2", whois)
|
||||
require.Nil(t, clients.ipToRC["1.1.1.2"])
|
||||
assert.True(t, clients.Del("client1"))
|
||||
})
|
||||
|
|
|
@ -24,7 +24,7 @@ type clientJSON struct {
|
|||
// the allowlist.
|
||||
DisallowedRule *string `json:"disallowed_rule,omitempty"`
|
||||
|
||||
WhoisInfo *RuntimeClientWhoisInfo `json:"whois_info,omitempty"`
|
||||
WHOISInfo *RuntimeClientWHOISInfo `json:"whois_info,omitempty"`
|
||||
|
||||
Name string `json:"name"`
|
||||
|
||||
|
@ -42,7 +42,7 @@ type clientJSON struct {
|
|||
}
|
||||
|
||||
type runtimeClientJSON struct {
|
||||
WhoisInfo *RuntimeClientWhoisInfo `json:"whois_info"`
|
||||
WHOISInfo *RuntimeClientWHOISInfo `json:"whois_info"`
|
||||
|
||||
IP string `json:"ip"`
|
||||
Name string `json:"name"`
|
||||
|
@ -70,7 +70,7 @@ func (clients *clientsContainer) handleGetClients(w http.ResponseWriter, _ *http
|
|||
cj := runtimeClientJSON{
|
||||
IP: ip,
|
||||
Name: rc.Host,
|
||||
WhoisInfo: rc.WhoisInfo,
|
||||
WHOISInfo: rc.WHOISInfo,
|
||||
}
|
||||
|
||||
cj.Source = "etc/hosts"
|
||||
|
@ -143,7 +143,7 @@ func runtimeClientToJSON(ip string, rc RuntimeClient) (cj clientJSON) {
|
|||
cj = clientJSON{
|
||||
Name: rc.Host,
|
||||
IDs: []string{ip},
|
||||
WhoisInfo: rc.WhoisInfo,
|
||||
WHOISInfo: rc.WHOISInfo,
|
||||
}
|
||||
|
||||
return cj
|
||||
|
@ -287,7 +287,7 @@ func (clients *clientsContainer) findRuntime(ip net.IP, idStr string) (cj client
|
|||
IDs: []string{idStr},
|
||||
Disallowed: &disallowed,
|
||||
DisallowedRule: &rule,
|
||||
WhoisInfo: &RuntimeClientWhoisInfo{},
|
||||
WHOISInfo: &RuntimeClientWHOISInfo{},
|
||||
}
|
||||
|
||||
return cj, true
|
||||
|
|
|
@ -135,11 +135,11 @@ type dnsConfig struct {
|
|||
}
|
||||
|
||||
type tlsConfigSettings struct {
|
||||
Enabled bool `yaml:"enabled" json:"enabled"` // Enabled is the encryption (DOT/DOH/HTTPS) status
|
||||
Enabled bool `yaml:"enabled" json:"enabled"` // Enabled is the encryption (DoT/DoH/HTTPS) status
|
||||
ServerName string `yaml:"server_name" json:"server_name,omitempty"` // ServerName is the hostname of your HTTPS/TLS server
|
||||
ForceHTTPS bool `yaml:"force_https" json:"force_https,omitempty"` // ForceHTTPS: if true, forces HTTP->HTTPS redirect
|
||||
PortHTTPS int `yaml:"port_https" json:"port_https,omitempty"` // HTTPS port. If 0, HTTPS will be disabled
|
||||
PortDNSOverTLS int `yaml:"port_dns_over_tls" json:"port_dns_over_tls,omitempty"` // DNS-over-TLS port. If 0, DOT will be disabled
|
||||
PortDNSOverTLS int `yaml:"port_dns_over_tls" json:"port_dns_over_tls,omitempty"` // DNS-over-TLS port. If 0, DoT will be disabled
|
||||
PortDNSOverQUIC int `yaml:"port_dns_over_quic" json:"port_dns_over_quic,omitempty"` // DNS-over-QUIC port. If 0, DoQ will be disabled
|
||||
|
||||
// PortDNSCrypt is the port for DNSCrypt requests. If it's zero,
|
||||
|
@ -152,8 +152,8 @@ type tlsConfigSettings struct {
|
|||
// https://github.com/ameshkov/dnscrypt.
|
||||
DNSCryptConfigFile string `yaml:"dnscrypt_config_file" json:"dnscrypt_config_file"`
|
||||
|
||||
// Allow DOH queries via unencrypted HTTP (e.g. for reverse proxying)
|
||||
AllowUnencryptedDOH bool `yaml:"allow_unencrypted_doh" json:"allow_unencrypted_doh"`
|
||||
// Allow DoH queries via unencrypted HTTP (e.g. for reverse proxying)
|
||||
AllowUnencryptedDoH bool `yaml:"allow_unencrypted_doh" json:"allow_unencrypted_doh"`
|
||||
|
||||
dnsforward.TLSConfig `yaml:",inline" json:",inline"`
|
||||
}
|
||||
|
|
|
@ -198,9 +198,9 @@ func registerControlHandlers() {
|
|||
httpRegister(http.MethodPost, "/control/update", handleUpdate)
|
||||
httpRegister(http.MethodGet, "/control/profile", handleGetProfile)
|
||||
|
||||
// No auth is necessary for DOH/DOT configurations
|
||||
Context.mux.HandleFunc("/apple/doh.mobileconfig", postInstall(handleMobileConfigDOH))
|
||||
Context.mux.HandleFunc("/apple/dot.mobileconfig", postInstall(handleMobileConfigDOT))
|
||||
// No auth is necessary for DoH/DoT configurations
|
||||
Context.mux.HandleFunc("/apple/doh.mobileconfig", postInstall(handleMobileConfigDoH))
|
||||
Context.mux.HandleFunc("/apple/dot.mobileconfig", postInstall(handleMobileConfigDoT))
|
||||
RegisterAuthHandlers()
|
||||
}
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ func initDNSServer() error {
|
|||
}
|
||||
|
||||
Context.rdns = NewRDNS(Context.dnsServer, &Context.clients, config.DNS.UsePrivateRDNS)
|
||||
Context.whois = initWhois(&Context.clients)
|
||||
Context.whois = initWHOIS(&Context.clients)
|
||||
|
||||
Context.filters.Init()
|
||||
return nil
|
||||
|
@ -194,7 +194,7 @@ func generateServerConfig() (newConf dnsforward.ServerConfig, err error) {
|
|||
|
||||
newConf.TLSv12Roots = Context.tlsRoots
|
||||
newConf.TLSCiphers = Context.tlsCiphers
|
||||
newConf.TLSAllowUnencryptedDOH = tlsConf.AllowUnencryptedDOH
|
||||
newConf.TLSAllowUnencryptedDoH = tlsConf.AllowUnencryptedDoH
|
||||
|
||||
newConf.FilterHandler = applyAdditionalFiltering
|
||||
newConf.GetCustomUpstreamByClient = Context.clients.findUpstreams
|
||||
|
|
|
@ -48,7 +48,7 @@ type homeContext struct {
|
|||
queryLog querylog.QueryLog // query log module
|
||||
dnsServer *dnsforward.Server // DNS module
|
||||
rdns *RDNS // rDNS module
|
||||
whois *Whois // WHOIS module
|
||||
whois *WHOIS // WHOIS module
|
||||
dnsFilter *filtering.DNSFilter // DNS filtering module
|
||||
dhcpServer *dhcpd.Server // DHCP module
|
||||
auth *Auth // HTTP authentication module
|
||||
|
|
|
@ -163,10 +163,10 @@ func handleMobileConfig(w http.ResponseWriter, r *http.Request, dnsp string) {
|
|||
_, _ = w.Write(mobileconfig)
|
||||
}
|
||||
|
||||
func handleMobileConfigDOH(w http.ResponseWriter, r *http.Request) {
|
||||
func handleMobileConfigDoH(w http.ResponseWriter, r *http.Request) {
|
||||
handleMobileConfig(w, r, dnsProtoHTTPS)
|
||||
}
|
||||
|
||||
func handleMobileConfigDOT(w http.ResponseWriter, r *http.Request) {
|
||||
func handleMobileConfigDoT(w http.ResponseWriter, r *http.Request) {
|
||||
handleMobileConfig(w, r, dnsProtoTLS)
|
||||
}
|
||||
|
|
|
@ -12,14 +12,14 @@ import (
|
|||
"howett.net/plist"
|
||||
)
|
||||
|
||||
func TestHandleMobileConfigDOH(t *testing.T) {
|
||||
func TestHandleMobileConfigDoH(t *testing.T) {
|
||||
t.Run("success", func(t *testing.T) {
|
||||
r, err := http.NewRequest(http.MethodGet, "https://example.com:12345/apple/doh.mobileconfig?host=example.org", nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
handleMobileConfigDOH(w, r)
|
||||
handleMobileConfigDoH(w, r)
|
||||
require.Equal(t, http.StatusOK, w.Code)
|
||||
|
||||
var mc mobileConfig
|
||||
|
@ -49,7 +49,7 @@ func TestHandleMobileConfigDOH(t *testing.T) {
|
|||
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
handleMobileConfigDOH(w, r)
|
||||
handleMobileConfigDoH(w, r)
|
||||
assert.Equal(t, http.StatusInternalServerError, w.Code)
|
||||
assert.JSONEq(t, w.Body.String(), b.String())
|
||||
})
|
||||
|
@ -60,7 +60,7 @@ func TestHandleMobileConfigDOH(t *testing.T) {
|
|||
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
handleMobileConfigDOH(w, r)
|
||||
handleMobileConfigDoH(w, r)
|
||||
require.Equal(t, http.StatusOK, w.Code)
|
||||
|
||||
var mc mobileConfig
|
||||
|
@ -74,14 +74,14 @@ func TestHandleMobileConfigDOH(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestHandleMobileConfigDOT(t *testing.T) {
|
||||
func TestHandleMobileConfigDoT(t *testing.T) {
|
||||
t.Run("success", func(t *testing.T) {
|
||||
r, err := http.NewRequest(http.MethodGet, "https://example.com:12345/apple/dot.mobileconfig?host=example.org", nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
handleMobileConfigDOT(w, r)
|
||||
handleMobileConfigDoT(w, r)
|
||||
require.Equal(t, http.StatusOK, w.Code)
|
||||
|
||||
var mc mobileConfig
|
||||
|
@ -111,7 +111,7 @@ func TestHandleMobileConfigDOT(t *testing.T) {
|
|||
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
handleMobileConfigDOT(w, r)
|
||||
handleMobileConfigDoT(w, r)
|
||||
assert.Equal(t, http.StatusInternalServerError, w.Code)
|
||||
|
||||
assert.JSONEq(t, w.Body.String(), b.String())
|
||||
|
@ -123,7 +123,7 @@ func TestHandleMobileConfigDOT(t *testing.T) {
|
|||
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
handleMobileConfigDOT(w, r)
|
||||
handleMobileConfigDoT(w, r)
|
||||
require.Equal(t, http.StatusOK, w.Code)
|
||||
|
||||
var mc mobileConfig
|
||||
|
|
|
@ -48,7 +48,7 @@ func tlsCreate(conf tlsConfigSettings) *TLSMod {
|
|||
PortHTTPS: conf.PortHTTPS,
|
||||
PortDNSOverTLS: conf.PortDNSOverTLS,
|
||||
PortDNSOverQUIC: conf.PortDNSOverQUIC,
|
||||
AllowUnencryptedDOH: conf.AllowUnencryptedDOH,
|
||||
AllowUnencryptedDoH: conf.AllowUnencryptedDoH,
|
||||
}}
|
||||
}
|
||||
t.setCertFileTime()
|
||||
|
|
|
@ -23,8 +23,8 @@ const (
|
|||
whoisTTL = 1 * 60 * 60 // 1 hour
|
||||
)
|
||||
|
||||
// Whois - module context
|
||||
type Whois struct {
|
||||
// WHOIS - module context
|
||||
type WHOIS struct {
|
||||
clients *clientsContainer
|
||||
ipChan chan net.IP
|
||||
|
||||
|
@ -41,9 +41,9 @@ type Whois struct {
|
|||
timeoutMsec uint
|
||||
}
|
||||
|
||||
// initWhois creates the Whois module context.
|
||||
func initWhois(clients *clientsContainer) *Whois {
|
||||
w := Whois{
|
||||
// initWHOIS creates the WHOIS module context.
|
||||
func initWHOIS(clients *clientsContainer) *WHOIS {
|
||||
w := WHOIS{
|
||||
timeoutMsec: 5000,
|
||||
clients: clients,
|
||||
ipAddrs: cache.New(cache.Config{
|
||||
|
@ -67,8 +67,8 @@ func trimValue(s string) string {
|
|||
return s[:maxValueLength-3] + "..."
|
||||
}
|
||||
|
||||
// isWhoisComment returns true if the string is empty or is a WHOIS comment.
|
||||
func isWhoisComment(s string) (ok bool) {
|
||||
// isWHOISComment returns true if the string is empty or is a WHOIS comment.
|
||||
func isWHOISComment(s string) (ok bool) {
|
||||
return len(s) == 0 || s[0] == '#' || s[0] == '%'
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ func whoisParse(data string) (m strmap) {
|
|||
var orgname string
|
||||
lines := strings.Split(data, "\n")
|
||||
for _, l := range lines {
|
||||
if isWhoisComment(l) {
|
||||
if isWHOISComment(l) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ func whoisParse(data string) (m strmap) {
|
|||
const MaxConnReadSize = 64 * 1024
|
||||
|
||||
// Send request to a server and receive the response
|
||||
func (w *Whois) query(ctx context.Context, target, serverAddr string) (data string, err error) {
|
||||
func (w *WHOIS) query(ctx context.Context, target, serverAddr string) (data string, err error) {
|
||||
addr, _, _ := net.SplitHostPort(serverAddr)
|
||||
if addr == "whois.arin.net" {
|
||||
target = "n + " + target
|
||||
|
@ -162,7 +162,7 @@ func (w *Whois) query(ctx context.Context, target, serverAddr string) (data stri
|
|||
}
|
||||
|
||||
// Query WHOIS servers (handle redirects)
|
||||
func (w *Whois) queryAll(ctx context.Context, target string) (string, error) {
|
||||
func (w *WHOIS) queryAll(ctx context.Context, target string) (string, error) {
|
||||
server := net.JoinHostPort(defaultServer, defaultPort)
|
||||
const maxRedirects = 5
|
||||
for i := 0; i != maxRedirects; i++ {
|
||||
|
@ -170,7 +170,7 @@ func (w *Whois) queryAll(ctx context.Context, target string) (string, error) {
|
|||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
log.Debug("Whois: received response (%d bytes) from %s IP:%s", len(resp), server, target)
|
||||
log.Debug("whois: received response (%d bytes) from %s IP:%s", len(resp), server, target)
|
||||
|
||||
m := whoisParse(resp)
|
||||
redir, ok := m["whois"]
|
||||
|
@ -186,25 +186,25 @@ func (w *Whois) queryAll(ctx context.Context, target string) (string, error) {
|
|||
server = redir
|
||||
}
|
||||
|
||||
log.Debug("Whois: redirected to %s IP:%s", redir, target)
|
||||
log.Debug("whois: redirected to %s IP:%s", redir, target)
|
||||
}
|
||||
return "", fmt.Errorf("whois: redirect loop")
|
||||
}
|
||||
|
||||
// Request WHOIS information
|
||||
func (w *Whois) process(ctx context.Context, ip net.IP) (wi *RuntimeClientWhoisInfo) {
|
||||
func (w *WHOIS) process(ctx context.Context, ip net.IP) (wi *RuntimeClientWHOISInfo) {
|
||||
resp, err := w.queryAll(ctx, ip.String())
|
||||
if err != nil {
|
||||
log.Debug("Whois: error: %s IP:%s", err, ip)
|
||||
log.Debug("whois: error: %s IP:%s", err, ip)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
log.Debug("Whois: IP:%s response: %d bytes", ip, len(resp))
|
||||
log.Debug("whois: IP:%s response: %d bytes", ip, len(resp))
|
||||
|
||||
m := whoisParse(resp)
|
||||
|
||||
wi = &RuntimeClientWhoisInfo{
|
||||
wi = &RuntimeClientWHOISInfo{
|
||||
City: m["city"],
|
||||
Country: m["country"],
|
||||
Orgname: m["orgname"],
|
||||
|
@ -212,7 +212,7 @@ func (w *Whois) process(ctx context.Context, ip net.IP) (wi *RuntimeClientWhoisI
|
|||
|
||||
// Don't return an empty struct so that the frontend doesn't get
|
||||
// confused.
|
||||
if *wi == (RuntimeClientWhoisInfo{}) {
|
||||
if *wi == (RuntimeClientWHOISInfo{}) {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -220,7 +220,7 @@ func (w *Whois) process(ctx context.Context, ip net.IP) (wi *RuntimeClientWhoisI
|
|||
}
|
||||
|
||||
// Begin - begin requesting WHOIS info
|
||||
func (w *Whois) Begin(ip net.IP) {
|
||||
func (w *WHOIS) Begin(ip net.IP) {
|
||||
now := uint64(time.Now().Unix())
|
||||
expire := w.ipAddrs.Get([]byte(ip))
|
||||
if len(expire) != 0 {
|
||||
|
@ -234,18 +234,18 @@ func (w *Whois) Begin(ip net.IP) {
|
|||
binary.BigEndian.PutUint64(expire, now+whoisTTL)
|
||||
_ = w.ipAddrs.Set([]byte(ip), expire)
|
||||
|
||||
log.Debug("Whois: adding %s", ip)
|
||||
log.Debug("whois: adding %s", ip)
|
||||
select {
|
||||
case w.ipChan <- ip:
|
||||
//
|
||||
default:
|
||||
log.Debug("Whois: queue is full")
|
||||
log.Debug("whois: queue is full")
|
||||
}
|
||||
}
|
||||
|
||||
// workerLoop processes the IP addresses it got from the channel and associates
|
||||
// the retrieving WHOIS info with a client.
|
||||
func (w *Whois) workerLoop() {
|
||||
func (w *WHOIS) workerLoop() {
|
||||
for ip := range w.ipChan {
|
||||
info := w.process(context.Background(), ip)
|
||||
if info == nil {
|
||||
|
@ -253,6 +253,6 @@ func (w *Whois) workerLoop() {
|
|||
}
|
||||
|
||||
id := ip.String()
|
||||
w.clients.SetWhoisInfo(id, info)
|
||||
w.clients.SetWHOISInfo(id, info)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ func (c *fakeConn) fakeDial(ctx context.Context, network, addr string) (conn net
|
|||
return c, nil
|
||||
}
|
||||
|
||||
func TestWhois(t *testing.T) {
|
||||
func TestWHOIS(t *testing.T) {
|
||||
const (
|
||||
nl = "\n"
|
||||
data = `OrgName: FakeOrg LLC` + nl +
|
||||
|
@ -62,7 +62,7 @@ func TestWhois(t *testing.T) {
|
|||
data: []byte(data),
|
||||
}
|
||||
|
||||
w := Whois{
|
||||
w := WHOIS{
|
||||
timeoutMsec: 5000,
|
||||
dialContext: fc.fakeDial,
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ func TestWhois(t *testing.T) {
|
|||
assert.Equal(t, "Nonreal", m["city"])
|
||||
}
|
||||
|
||||
func TestWhoisParse(t *testing.T) {
|
||||
func TestWHOISParse(t *testing.T) {
|
||||
const (
|
||||
city = "Nonreal"
|
||||
country = "Imagiland"
|
||||
|
|
|
@ -3,17 +3,17 @@ package querylog
|
|||
// Client is the information required by the query log to match against clients
|
||||
// during searches.
|
||||
type Client struct {
|
||||
Whois *ClientWhois `json:"whois,omitempty"`
|
||||
WHOIS *ClientWHOIS `json:"whois,omitempty"`
|
||||
Name string `json:"name"`
|
||||
DisallowedRule string `json:"disallowed_rule"`
|
||||
Disallowed bool `json:"disallowed"`
|
||||
}
|
||||
|
||||
// ClientWhois is the filtered WHOIS data for the client.
|
||||
// ClientWHOIS is the filtered WHOIS data for the client.
|
||||
//
|
||||
// TODO(a.garipov): Merge with home.RuntimeClientWhoisInfo after the
|
||||
// TODO(a.garipov): Merge with home.RuntimeClientWHOISInfo after the
|
||||
// refactoring is done.
|
||||
type ClientWhois struct {
|
||||
type ClientWHOIS struct {
|
||||
City string `json:"city,omitempty"`
|
||||
Country string `json:"country,omitempty"`
|
||||
Orgname string `json:"orgname,omitempty"`
|
||||
|
|
|
@ -42,9 +42,9 @@ type ClientProto string
|
|||
|
||||
// Client protocol names.
|
||||
const (
|
||||
ClientProtoDOH ClientProto = "doh"
|
||||
ClientProtoDOQ ClientProto = "doq"
|
||||
ClientProtoDOT ClientProto = "dot"
|
||||
ClientProtoDoH ClientProto = "doh"
|
||||
ClientProtoDoQ ClientProto = "doq"
|
||||
ClientProtoDoT ClientProto = "dot"
|
||||
ClientProtoDNSCrypt ClientProto = "dnscrypt"
|
||||
ClientProtoPlain ClientProto = ""
|
||||
)
|
||||
|
@ -54,9 +54,9 @@ const (
|
|||
func NewClientProto(s string) (cp ClientProto, err error) {
|
||||
switch cp = ClientProto(s); cp {
|
||||
case
|
||||
ClientProtoDOH,
|
||||
ClientProtoDOQ,
|
||||
ClientProtoDOT,
|
||||
ClientProtoDoH,
|
||||
ClientProtoDoQ,
|
||||
ClientProtoDoT,
|
||||
ClientProtoDNSCrypt,
|
||||
ClientProtoPlain:
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
- 'name': 'stats'
|
||||
'description': 'AdGuard Home statistics'
|
||||
- 'name': 'tls'
|
||||
'description': 'AdGuard Home HTTPS/DOH/DOT settings'
|
||||
'description': 'AdGuard Home HTTPS/DoH/DoQ/DoT settings'
|
||||
|
||||
'paths':
|
||||
'/status':
|
||||
|
@ -1877,7 +1877,7 @@
|
|||
'type': 'string'
|
||||
'client_id':
|
||||
'description': >
|
||||
The client ID, if provided in DOH, DOQ, or DOT.
|
||||
The client ID, if provided in DoH, DoQ, or DoT.
|
||||
'example': 'cli123'
|
||||
'type': 'string'
|
||||
'client_info':
|
||||
|
@ -2036,7 +2036,7 @@
|
|||
'enabled':
|
||||
'type': 'boolean'
|
||||
'example': true
|
||||
'description': 'enabled is the encryption (DOT/DOH/HTTPS) status'
|
||||
'description': 'enabled is the encryption (DoT/DoH/HTTPS) status'
|
||||
'server_name':
|
||||
'type': 'string'
|
||||
'example': 'example.org'
|
||||
|
@ -2054,12 +2054,12 @@
|
|||
'type': 'integer'
|
||||
'format': 'uint16'
|
||||
'example': 853
|
||||
'description': 'DNS-over-TLS port. If 0, DOT will be disabled.'
|
||||
'description': 'DNS-over-TLS port. If 0, DoT will be disabled.'
|
||||
'port_dns_over_quic':
|
||||
'type': 'integer'
|
||||
'format': 'uint16'
|
||||
'example': 784
|
||||
'description': 'DNS-over-QUIC port. If 0, DOQ will be disabled.'
|
||||
'description': 'DNS-over-QUIC port. If 0, DoQ will be disabled.'
|
||||
'certificate_chain':
|
||||
'type': 'string'
|
||||
'description': 'Base64 string with PEM-encoded certificates chain'
|
||||
|
|
|
@ -5,9 +5,6 @@ initialisms = [
|
|||
# Do not add "PTR" since we use "Ptr" as a suffix.
|
||||
"inherit"
|
||||
, "DHCP"
|
||||
, "DOH"
|
||||
, "DOQ"
|
||||
, "DOT"
|
||||
, "EDNS"
|
||||
, "MX"
|
||||
, "QUIC"
|
||||
|
@ -16,6 +13,7 @@ initialisms = [
|
|||
, "SLAAC"
|
||||
, "SVCB"
|
||||
, "TLD"
|
||||
, "WHOIS"
|
||||
]
|
||||
dot_import_whitelist = []
|
||||
http_status_code_whitelist = []
|
||||
|
|
Loading…
Reference in a new issue