diff --git a/CHANGELOG.md b/CHANGELOG.md index 1040d68d..d1062462 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,8 +15,6 @@ and this project adheres to ### Added -- DNS server IP addresses to the `mobileconfig` API responses ([#3568], - [#3607]). - Setting the timeout for IP address pinging in the "Fastest IP address" mode through the new `fastest_timeout` field in the configuration file ([#1992]). - Static IP address detection on FreeBSD ([#3289]). @@ -116,7 +114,8 @@ In this release, the schema version has changed from 10 to 12. ### Fixed -- Adding an IP into only one of the matching ipsets on Linux ([#3638]). +- Addition of IPs into only one as opposed to all matching ipsets on Linux + ([#3638]). - Removal of temporary filter files ([#3567]). - Panic when an upstream server responds with an empty question section ([#3551]). diff --git a/internal/home/mobileconfig.go b/internal/home/mobileconfig.go index 560407b0..82d0dbf1 100644 --- a/internal/home/mobileconfig.go +++ b/internal/home/mobileconfig.go @@ -32,6 +32,10 @@ type dnsSettings struct { ServerName string `plist:",omitempty"` // ServerAddresses is a list IP addresses of the server. + // + // TODO(a.garipov): Allow users to set this. + // + // See https://github.com/AdguardTeam/AdGuardHome/issues/3607. ServerAddresses []net.IP `plist:",omitempty"` } @@ -157,19 +161,9 @@ func handleMobileConfig(w http.ResponseWriter, r *http.Request, dnsp string) { } } - dnsIPs, err := collectDNSIPs() - if err != nil { - // Don't add a lot of formatting, since the error is already - // wrapped by collectDNSIPs. - respondJSONError(w, http.StatusInternalServerError, err.Error()) - - return - } - d := &dnsSettings{ - DNSProtocol: dnsp, - ServerName: host, - ServerAddresses: dnsIPs, + DNSProtocol: dnsp, + ServerName: host, } mobileconfig, err := encodeMobileConfig(d, clientID) @@ -203,25 +197,3 @@ func handleMobileConfigDoH(w http.ResponseWriter, r *http.Request) { func handleMobileConfigDoT(w http.ResponseWriter, r *http.Request) { handleMobileConfig(w, r, dnsProtoTLS) } - -// collectDNSIPs returns a slice of IP addresses the server is listening -// on, including the addresses on all interfaces in cases of unspecified IPs but -// excluding loopback addresses. -func collectDNSIPs() (ips []net.IP, err error) { - // TODO(a.garipov): This really shouldn't be a function that parses - // a list of strings. Instead, we need a function that returns this - // data as []net.IP or []*netutil.IPPort. Maybe someday. - addrs, err := collectDNSAddresses() - if err != nil { - return nil, err - } - - for _, addr := range addrs { - ip := net.ParseIP(addr) - if ip != nil && !ip.IsLoopback() { - ips = append(ips, ip) - } - } - - return ips, nil -} diff --git a/internal/home/mobileconfig_test.go b/internal/home/mobileconfig_test.go index 87b69f10..03b16611 100644 --- a/internal/home/mobileconfig_test.go +++ b/internal/home/mobileconfig_test.go @@ -58,7 +58,6 @@ func TestHandleMobileConfigDoH(t *testing.T) { s := mc.PayloadContent[0].DNSSettings require.NotNil(t, s) - assert.NotEmpty(t, s.ServerAddresses) assert.Empty(t, s.ServerName) assert.Equal(t, "https://example.org/dns-query", s.ServerURL) }) @@ -104,7 +103,6 @@ func TestHandleMobileConfigDoH(t *testing.T) { s := mc.PayloadContent[0].DNSSettings require.NotNil(t, s) - assert.NotEmpty(t, s.ServerAddresses) assert.Empty(t, s.ServerName) assert.Equal(t, "https://example.org/dns-query/cli42", s.ServerURL) }) @@ -132,7 +130,6 @@ func TestHandleMobileConfigDoT(t *testing.T) { s := mc.PayloadContent[0].DNSSettings require.NotNil(t, s) - assert.NotEmpty(t, s.ServerAddresses) assert.Equal(t, "example.org", s.ServerName) assert.Empty(t, s.ServerURL) }) @@ -179,7 +176,6 @@ func TestHandleMobileConfigDoT(t *testing.T) { s := mc.PayloadContent[0].DNSSettings require.NotNil(t, s) - assert.NotEmpty(t, s.ServerAddresses) assert.Equal(t, "cli42.example.org", s.ServerName) assert.Empty(t, s.ServerURL) })