code_before
stringlengths
16
1.81M
edits
stringlengths
4
328k
next_edit
stringlengths
0
76.5k
code_after
stringlengths
3
49.9M
label_window
sequencelengths
4
1.81k
instruction
stringlengths
20
51.9k
html_url
stringlengths
74
116
file_name
stringlengths
3
311
} } } macFound := config.dhcpServer.FindMACbyIP(ipAddr) if macFound == nil { return Client{}, false } for _, c = range clients.list { for _, id := range c.IDs {
</s> remove leases := config.dhcpServer.Leases() </s> add if clients.dhcpServer == nil { return } leases := clients.dhcpServer.Leases() </s> remove ok, _ := config.clients.AddHost(l.IP.String(), l.Hostname, ClientSourceDHCP) </s> add ok, _ := clients.AddHost(l.IP.String(), l.Hostname, ClientSourceDHCP) </s> remove func (clients *clientsContainer) Init(objects []clientObject) { </s> add func (clients *clientsContainer) Init(objects []clientObject, dhcpServer *dhcpd.Server) {
if clients.dhcpServer == nil { return Client{}, false } macFound := clients.dhcpServer.FindMACbyIP(ipAddr)
} } } if clients.dhcpServer == nil { return Client{}, false } macFound := clients.dhcpServer.FindMACbyIP(ipAddr) if macFound == nil { return Client{}, false } for _, c = range clients.list { for _, id := range c.IDs {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* dhcp,clients: DHCP server module is passed to Clients module during initialization.
https://github.com/AdguardTeam/AdGuardHome/commit/149fcc0f2dccbe0018122f1efa5b8977cf6ff273
home/clients.go
} // add clients from DHCP that have non-empty Hostname property func (clients *clientsContainer) addFromDHCP() { leases := config.dhcpServer.Leases() n := 0 for _, l := range leases { if len(l.Hostname) == 0 { continue }
</s> remove ok, _ := config.clients.AddHost(l.IP.String(), l.Hostname, ClientSourceDHCP) </s> add ok, _ := clients.AddHost(l.IP.String(), l.Hostname, ClientSourceDHCP) </s> remove macFound := config.dhcpServer.FindMACbyIP(ipAddr) </s> add if clients.dhcpServer == nil { return Client{}, false } macFound := clients.dhcpServer.FindMACbyIP(ipAddr) </s> remove func (clients *clientsContainer) Init(objects []clientObject) { </s> add func (clients *clientsContainer) Init(objects []clientObject, dhcpServer *dhcpd.Server) { </s> remove config.clients.Init(config.Clients) </s> add config.dhcpServer = dhcpd.Create(config.DHCP) config.clients.Init(config.Clients, config.dhcpServer)
if clients.dhcpServer == nil { return } leases := clients.dhcpServer.Leases()
} // add clients from DHCP that have non-empty Hostname property func (clients *clientsContainer) addFromDHCP() { if clients.dhcpServer == nil { return } leases := clients.dhcpServer.Leases() n := 0 for _, l := range leases { if len(l.Hostname) == 0 { continue }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* dhcp,clients: DHCP server module is passed to Clients module during initialization.
https://github.com/AdguardTeam/AdGuardHome/commit/149fcc0f2dccbe0018122f1efa5b8977cf6ff273
home/clients.go
for _, l := range leases { if len(l.Hostname) == 0 { continue } ok, _ := config.clients.AddHost(l.IP.String(), l.Hostname, ClientSourceDHCP) if ok { n++ } } log.Debug("Added %d client aliases from DHCP", n)
</s> remove leases := config.dhcpServer.Leases() </s> add if clients.dhcpServer == nil { return } leases := clients.dhcpServer.Leases() </s> remove macFound := config.dhcpServer.FindMACbyIP(ipAddr) </s> add if clients.dhcpServer == nil { return Client{}, false } macFound := clients.dhcpServer.FindMACbyIP(ipAddr) </s> remove config.clients.Init(config.Clients) </s> add config.dhcpServer = dhcpd.Create(config.DHCP) config.clients.Init(config.Clients, config.dhcpServer)
ok, _ := clients.AddHost(l.IP.String(), l.Hostname, ClientSourceDHCP)
for _, l := range leases { if len(l.Hostname) == 0 { continue } ok, _ := clients.AddHost(l.IP.String(), l.Hostname, ClientSourceDHCP) if ok { n++ } } log.Debug("Added %d client aliases from DHCP", n)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* dhcp,clients: DHCP server module is passed to Clients module during initialization.
https://github.com/AdguardTeam/AdGuardHome/commit/149fcc0f2dccbe0018122f1efa5b8977cf6ff273
home/clients.go
var e error var b bool clients := clientsContainer{} clients.Init(nil) // add c = Client{ IDs: []string{"1.1.1.1", "aa:aa:aa:aa:aa:aa"}, Name: "client1",
</s> remove clients.Init(nil) </s> add clients.Init(nil, nil) </s> remove leases := config.dhcpServer.Leases() </s> add if clients.dhcpServer == nil { return } leases := clients.dhcpServer.Leases()
clients.Init(nil, nil)
var e error var b bool clients := clientsContainer{} clients.Init(nil, nil) // add c = Client{ IDs: []string{"1.1.1.1", "aa:aa:aa:aa:aa:aa"}, Name: "client1",
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* dhcp,clients: DHCP server module is passed to Clients module during initialization.
https://github.com/AdguardTeam/AdGuardHome/commit/149fcc0f2dccbe0018122f1efa5b8977cf6ff273
home/clients_test.go
func TestClientsWhois(t *testing.T) { var c Client clients := clientsContainer{} clients.Init(nil) whois := [][]string{{"orgname", "orgname-val"}, {"country", "country-val"}} // set whois info on new client clients.SetWhoisInfo("1.1.1.255", whois) assert.True(t, clients.ipHost["1.1.1.255"].WhoisInfo[0][1] == "orgname-val")
</s> remove clients.Init(nil) </s> add clients.Init(nil, nil) </s> remove leases := config.dhcpServer.Leases() </s> add if clients.dhcpServer == nil { return } leases := clients.dhcpServer.Leases() </s> remove ok, _ := config.clients.AddHost(l.IP.String(), l.Hostname, ClientSourceDHCP) </s> add ok, _ := clients.AddHost(l.IP.String(), l.Hostname, ClientSourceDHCP) </s> remove macFound := config.dhcpServer.FindMACbyIP(ipAddr) </s> add if clients.dhcpServer == nil { return Client{}, false } macFound := clients.dhcpServer.FindMACbyIP(ipAddr)
clients.Init(nil, nil)
func TestClientsWhois(t *testing.T) { var c Client clients := clientsContainer{} clients.Init(nil, nil) whois := [][]string{{"orgname", "orgname-val"}, {"country", "country-val"}} // set whois info on new client clients.SetWhoisInfo("1.1.1.255", whois) assert.True(t, clients.ipHost["1.1.1.255"].WhoisInfo[0][1] == "orgname-val")
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* dhcp,clients: DHCP server module is passed to Clients module during initialization.
https://github.com/AdguardTeam/AdGuardHome/commit/149fcc0f2dccbe0018122f1efa5b8977cf6ff273
home/clients_test.go
dnsctx dnsContext dnsFilter *dnsfilter.Dnsfilter dnsServer *dnsforward.Server dhcpServer dhcpd.Server httpServer *http.Server httpsServer HTTPSServer BindHost string `yaml:"bind_host"` // BindHost is the IP address of the HTTP server to bind to BindPort int `yaml:"bind_port"` // BindPort is the port the HTTP server
</s> remove func (clients *clientsContainer) Init(objects []clientObject) { </s> add func (clients *clientsContainer) Init(objects []clientObject, dhcpServer *dhcpd.Server) { </s> remove clients.Init(nil) </s> add clients.Init(nil, nil)
dhcpServer *dhcpd.Server
dnsctx dnsContext dnsFilter *dnsfilter.Dnsfilter dnsServer *dnsforward.Server dhcpServer *dhcpd.Server httpServer *http.Server httpsServer HTTPSServer BindHost string `yaml:"bind_host"` // BindHost is the IP address of the HTTP server to bind to BindPort int `yaml:"bind_port"` // BindPort is the port the HTTP server
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* dhcp,clients: DHCP server module is passed to Clients module during initialization.
https://github.com/AdguardTeam/AdGuardHome/commit/149fcc0f2dccbe0018122f1efa5b8977cf6ff273
home/config.go
config.DNS.DnsfilterConf = c } configFile := config.getConfigFilename() log.Debug("Writing YAML file: %s", configFile) yamlText, err := yaml.Marshal(&config) config.Clients = nil if err != nil { log.Error("Couldn't generate YAML file: %s", err)
</s> remove config.clients.Init(config.Clients) </s> add config.dhcpServer = dhcpd.Create(config.DHCP) config.clients.Init(config.Clients, config.dhcpServer) </s> remove macFound := config.dhcpServer.FindMACbyIP(ipAddr) </s> add if clients.dhcpServer == nil { return Client{}, false } macFound := clients.dhcpServer.FindMACbyIP(ipAddr) </s> remove func (clients *clientsContainer) Init(objects []clientObject) { </s> add func (clients *clientsContainer) Init(objects []clientObject, dhcpServer *dhcpd.Server) {
if config.dhcpServer != nil { c := dhcpd.ServerConfig{} config.dhcpServer.WriteDiskConfig(&c) config.DHCP = c }
config.DNS.DnsfilterConf = c } if config.dhcpServer != nil { c := dhcpd.ServerConfig{} config.dhcpServer.WriteDiskConfig(&c) config.DHCP = c } configFile := config.getConfigFilename() log.Debug("Writing YAML file: %s", configFile) yamlText, err := yaml.Marshal(&config) config.Clients = nil if err != nil { log.Error("Couldn't generate YAML file: %s", err)
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
* dhcp,clients: DHCP server module is passed to Clients module during initialization.
https://github.com/AdguardTeam/AdGuardHome/commit/149fcc0f2dccbe0018122f1efa5b8977cf6ff273
home/config.go
"syscall" "time" "github.com/AdguardTeam/golibs/log" "github.com/NYTimes/gziphandler" "github.com/gobuffalo/packr" )
</s> remove config.clients.Init(config.Clients) </s> add config.dhcpServer = dhcpd.Create(config.DHCP) config.clients.Init(config.Clients, config.dhcpServer) </s> remove dhcpServer dhcpd.Server </s> add dhcpServer *dhcpd.Server </s> remove clients.Init(nil) </s> add clients.Init(nil, nil)
"github.com/AdguardTeam/AdGuardHome/dhcpd"
"syscall" "time" "github.com/AdguardTeam/AdGuardHome/dhcpd" "github.com/AdguardTeam/golibs/log" "github.com/NYTimes/gziphandler" "github.com/gobuffalo/packr" )
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
* dhcp,clients: DHCP server module is passed to Clients module during initialization.
https://github.com/AdguardTeam/AdGuardHome/commit/149fcc0f2dccbe0018122f1efa5b8977cf6ff273
home/home.go
os.Exit(0) } } config.clients.Init(config.Clients) config.Clients = nil if (runtime.GOOS == "linux" || runtime.GOOS == "darwin") && config.RlimitNoFile != 0 { setRlimit(config.RlimitNoFile)
</s> remove leases := config.dhcpServer.Leases() </s> add if clients.dhcpServer == nil { return } leases := clients.dhcpServer.Leases() </s> remove macFound := config.dhcpServer.FindMACbyIP(ipAddr) </s> add if clients.dhcpServer == nil { return Client{}, false } macFound := clients.dhcpServer.FindMACbyIP(ipAddr) </s> remove ok, _ := config.clients.AddHost(l.IP.String(), l.Hostname, ClientSourceDHCP) </s> add ok, _ := clients.AddHost(l.IP.String(), l.Hostname, ClientSourceDHCP) </s> remove func (clients *clientsContainer) Init(objects []clientObject) { </s> add func (clients *clientsContainer) Init(objects []clientObject, dhcpServer *dhcpd.Server) {
config.dhcpServer = dhcpd.Create(config.DHCP) config.clients.Init(config.Clients, config.dhcpServer)
os.Exit(0) } } config.dhcpServer = dhcpd.Create(config.DHCP) config.clients.Init(config.Clients, config.dhcpServer) config.Clients = nil if (runtime.GOOS == "linux" || runtime.GOOS == "darwin") && config.RlimitNoFile != 0 { setRlimit(config.RlimitNoFile)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
* dhcp,clients: DHCP server module is passed to Clients module during initialization.
https://github.com/AdguardTeam/AdGuardHome/commit/149fcc0f2dccbe0018122f1efa5b8977cf6ff273
home/home.go
"example_regex_meaning": "block access to the domains matching the specified regular expression", "example_upstream_regular": "regular DNS (over UDP)", "example_upstream_dot": "encrypted <0>DNS-over-TLS</0>", "example_upstream_doh": "encrypted <0>DNS-over-HTTPS</0>", "example_upstream_sdns": "you can use <0>DNS Stamps</0> for <1>DNSCrypt</1> or <2>DNS-over-HTTPS</2> resolvers", "example_upstream_tcp": "regular DNS (over TCP)", "all_lists_up_to_date_toast": "All lists are already up-to-date", "updated_upstream_dns_toast": "Updated the upstream DNS servers", "dns_test_ok_toast": "Specified DNS servers are working correctly",
</s> remove color: var(--red); </s> add color: #cd201f;
"example_upstream_doq": "encrypted <0>DNS-over-QUIC</0>",
"example_regex_meaning": "block access to the domains matching the specified regular expression", "example_upstream_regular": "regular DNS (over UDP)", "example_upstream_dot": "encrypted <0>DNS-over-TLS</0>", "example_upstream_doh": "encrypted <0>DNS-over-HTTPS</0>", "example_upstream_doq": "encrypted <0>DNS-over-QUIC</0>", "example_upstream_sdns": "you can use <0>DNS Stamps</0> for <1>DNSCrypt</1> or <2>DNS-over-HTTPS</2> resolvers", "example_upstream_tcp": "regular DNS (over TCP)", "all_lists_up_to_date_toast": "All lists are already up-to-date", "updated_upstream_dns_toast": "Updated the upstream DNS servers", "dns_test_ok_toast": "Specified DNS servers are working correctly",
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
+ client: Add experimental DNS-over-QUIC support
https://github.com/AdguardTeam/AdGuardHome/commit/14bc5297ac6cb7c6dbc74d55239eeb16c041c048
client/src/__locales/en.json
"encryption_https": "HTTPS port", "encryption_https_desc": "If HTTPS port is configured, AdGuard Home admin interface will be accessible via HTTPS, and it will also provide DNS-over-HTTPS on '/dns-query' location.", "encryption_dot": "DNS-over-TLS port", "encryption_dot_desc": "If this port is configured, AdGuard Home will run a DNS-over-TLS server on this port.", "encryption_certificates": "Certificates", "encryption_certificates_desc": "In order to use encryption, you need to provide a valid SSL certificates chain for your domain. You can get a free certificate on <0>{{link}}</0> or you can buy it from one of the trusted Certificate Authorities.", "encryption_certificates_input": "Copy/paste your PEM-encoded certificates here.", "encryption_status": "Status", "encryption_expire": "Expires",
</s> remove import { validateIsSafePort, validatePort, validatePortTLS } from '../../../helpers/validators'; </s> add import { validateIsSafePort, validatePort, validatePortQuic, validatePortTLS, } from '../../../helpers/validators'; </s> remove import { DNS_OVER_TLS_PORT, FORM_NAME, STANDARD_HTTPS_PORT } from '../../../helpers/constants'; </s> add import { DNS_OVER_QUIC_PORT, DNS_OVER_TLS_PORT, FORM_NAME, STANDARD_HTTPS_PORT, } from '../../../helpers/constants';
"encryption_doq": "DNS-over-QUIC port", "encryption_doq_desc": "If this port is configured, AdGuard Home will run a DNS-over-QUIC server on this port. It's experimental and may not be reliable at the moment. The only DNS provider that supports it now is AdGuard DNS",
"encryption_https": "HTTPS port", "encryption_https_desc": "If HTTPS port is configured, AdGuard Home admin interface will be accessible via HTTPS, and it will also provide DNS-over-HTTPS on '/dns-query' location.", "encryption_dot": "DNS-over-TLS port", "encryption_dot_desc": "If this port is configured, AdGuard Home will run a DNS-over-TLS server on this port.", "encryption_doq": "DNS-over-QUIC port", "encryption_doq_desc": "If this port is configured, AdGuard Home will run a DNS-over-QUIC server on this port. It's experimental and may not be reliable at the moment. The only DNS provider that supports it now is AdGuard DNS", "encryption_certificates": "Certificates", "encryption_certificates_desc": "In order to use encryption, you need to provide a valid SSL certificates chain for your domain. You can get a free certificate on <0>{{link}}</0> or you can buy it from one of the trusted Certificate Authorities.", "encryption_certificates_input": "Copy/paste your PEM-encoded certificates here.", "encryption_status": "Status", "encryption_expire": "Expires",
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
+ client: Add experimental DNS-over-QUIC support
https://github.com/AdguardTeam/AdGuardHome/commit/14bc5297ac6cb7c6dbc74d55239eeb16c041c048
client/src/__locales/en.json
"setup_config_to_enable_dhcp_server": "Setup config to enable DHCP server", "original_response": "Original response", "click_to_view_queries": "Click to view queries", "port_53_faq_link": "Port 53 is often occupied by \"DNSStubListener\" or \"systemd-resolved\" services. Please read <0>this instruction</0> on how to resolve this.", "adg_will_drop_dns_queries": "AdGuard Home will be dropping all DNS queries from this client." ======= "adg_will_drop_dns_queries": "AdGuard Home will be dropping all DNS queries from this client.", "experimental": "Experimental"
</s> remove import { validateIsSafePort, validatePort, validatePortTLS } from '../../../helpers/validators'; </s> add import { validateIsSafePort, validatePort, validatePortQuic, validatePortTLS, } from '../../../helpers/validators'; </s> remove import { DNS_OVER_TLS_PORT, FORM_NAME, STANDARD_HTTPS_PORT } from '../../../helpers/constants'; </s> add import { DNS_OVER_QUIC_PORT, DNS_OVER_TLS_PORT, FORM_NAME, STANDARD_HTTPS_PORT, } from '../../../helpers/constants';
<<<<<<< Updated upstream
"setup_config_to_enable_dhcp_server": "Setup config to enable DHCP server", "original_response": "Original response", "click_to_view_queries": "Click to view queries", "port_53_faq_link": "Port 53 is often occupied by \"DNSStubListener\" or \"systemd-resolved\" services. Please read <0>this instruction</0> on how to resolve this.", <<<<<<< Updated upstream "adg_will_drop_dns_queries": "AdGuard Home will be dropping all DNS queries from this client." ======= "adg_will_drop_dns_queries": "AdGuard Home will be dropping all DNS queries from this client.", "experimental": "Experimental"
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
+ client: Add experimental DNS-over-QUIC support
https://github.com/AdguardTeam/AdGuardHome/commit/14bc5297ac6cb7c6dbc74d55239eeb16c041c048
client/src/__locales/en.json
values.certificate_chain = btoa(values.certificate_chain); values.private_key = btoa(values.private_key); values.port_https = values.port_https || 0; values.port_dns_over_tls = values.port_dns_over_tls || 0; const response = await apiClient.setTlsConfig(values); response.certificate_chain = atob(response.certificate_chain); response.private_key = atob(response.private_key); dispatch(setTlsConfigSuccess(response)); dispatch(addSuccessToast('encryption_config_saved'));
</s> remove import { DNS_OVER_TLS_PORT, FORM_NAME, STANDARD_HTTPS_PORT } from '../../../helpers/constants'; </s> add import { DNS_OVER_QUIC_PORT, DNS_OVER_TLS_PORT, FORM_NAME, STANDARD_HTTPS_PORT, } from '../../../helpers/constants';
values.port_dns_over_quic = values.port_dns_over_quic || 0;
values.certificate_chain = btoa(values.certificate_chain); values.private_key = btoa(values.private_key); values.port_https = values.port_https || 0; values.port_dns_over_tls = values.port_dns_over_tls || 0; values.port_dns_over_quic = values.port_dns_over_quic || 0; const response = await apiClient.setTlsConfig(values); response.certificate_chain = atob(response.certificate_chain); response.private_key = atob(response.private_key); dispatch(setTlsConfigSuccess(response)); dispatch(addSuccessToast('encryption_config_saved'));
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
+ client: Add experimental DNS-over-QUIC support
https://github.com/AdguardTeam/AdGuardHome/commit/14bc5297ac6cb7c6dbc74d55239eeb16c041c048
client/src/actions/encryption.js
values.port_https = values.port_https || 0; values.port_dns_over_tls = values.port_dns_over_tls || 0; const response = await apiClient.validateTlsConfig(values); response.certificate_chain = atob(response.certificate_chain); response.private_key = atob(response.private_key); dispatch(validateTlsConfigSuccess(response)); } catch (error) {
</s> remove import { DNS_OVER_TLS_PORT, FORM_NAME, STANDARD_HTTPS_PORT } from '../../../helpers/constants'; </s> add import { DNS_OVER_QUIC_PORT, DNS_OVER_TLS_PORT, FORM_NAME, STANDARD_HTTPS_PORT, } from '../../../helpers/constants';
values.port_dns_over_quic = values.port_dns_over_quic || 0;
values.port_https = values.port_https || 0; values.port_dns_over_tls = values.port_dns_over_tls || 0; values.port_dns_over_quic = values.port_dns_over_quic || 0; const response = await apiClient.validateTlsConfig(values); response.certificate_chain = atob(response.certificate_chain); response.private_key = atob(response.private_key); dispatch(validateTlsConfigSuccess(response)); } catch (error) {
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
+ client: Add experimental DNS-over-QUIC support
https://github.com/AdguardTeam/AdGuardHome/commit/14bc5297ac6cb7c6dbc74d55239eeb16c041c048
client/src/actions/encryption.js
renderCheckboxField, renderRadioField, toNumber, } from '../../../helpers/form'; import { validateIsSafePort, validatePort, validatePortTLS } from '../../../helpers/validators'; import i18n from '../../../i18n'; import KeyStatus from './KeyStatus'; import CertificateStatus from './CertificateStatus'; import { DNS_OVER_TLS_PORT, FORM_NAME, STANDARD_HTTPS_PORT } from '../../../helpers/constants';
</s> remove import { DNS_OVER_TLS_PORT, FORM_NAME, STANDARD_HTTPS_PORT } from '../../../helpers/constants'; </s> add import { DNS_OVER_QUIC_PORT, DNS_OVER_TLS_PORT, FORM_NAME, STANDARD_HTTPS_PORT, } from '../../../helpers/constants'; </s> remove color: var(--red); </s> add color: #cd201f;
import { validateIsSafePort, validatePort, validatePortQuic, validatePortTLS, } from '../../../helpers/validators';
renderCheckboxField, renderRadioField, toNumber, } from '../../../helpers/form'; import { validateIsSafePort, validatePort, validatePortQuic, validatePortTLS, } from '../../../helpers/validators'; import i18n from '../../../i18n'; import KeyStatus from './KeyStatus'; import CertificateStatus from './CertificateStatus'; import { DNS_OVER_TLS_PORT, FORM_NAME, STANDARD_HTTPS_PORT } from '../../../helpers/constants';
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
+ client: Add experimental DNS-over-QUIC support
https://github.com/AdguardTeam/AdGuardHome/commit/14bc5297ac6cb7c6dbc74d55239eeb16c041c048
client/src/components/Settings/Encryption/Form.js
import { validateIsSafePort, validatePort, validatePortTLS } from '../../../helpers/validators'; import i18n from '../../../i18n'; import KeyStatus from './KeyStatus'; import CertificateStatus from './CertificateStatus'; import { DNS_OVER_TLS_PORT, FORM_NAME, STANDARD_HTTPS_PORT } from '../../../helpers/constants'; const validate = (values) => { const errors = {}; if (values.port_dns_over_tls && values.port_https) {
</s> remove import { validateIsSafePort, validatePort, validatePortTLS } from '../../../helpers/validators'; </s> add import { validateIsSafePort, validatePort, validatePortQuic, validatePortTLS, } from '../../../helpers/validators'; </s> remove color: var(--red); </s> add color: #cd201f;
import { DNS_OVER_QUIC_PORT, DNS_OVER_TLS_PORT, FORM_NAME, STANDARD_HTTPS_PORT, } from '../../../helpers/constants';
import { validateIsSafePort, validatePort, validatePortTLS } from '../../../helpers/validators'; import i18n from '../../../i18n'; import KeyStatus from './KeyStatus'; import CertificateStatus from './CertificateStatus'; import { DNS_OVER_QUIC_PORT, DNS_OVER_TLS_PORT, FORM_NAME, STANDARD_HTTPS_PORT, } from '../../../helpers/constants'; const validate = (values) => { const errors = {}; if (values.port_dns_over_tls && values.port_https) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
+ client: Add experimental DNS-over-QUIC support
https://github.com/AdguardTeam/AdGuardHome/commit/14bc5297ac6cb7c6dbc74d55239eeb16c041c048
client/src/components/Settings/Encryption/Form.js
port_https: STANDARD_HTTPS_PORT, port_dns_over_tls: DNS_OVER_TLS_PORT, server_name: '', force_https: false, enabled: false, };
</s> remove import { DNS_OVER_TLS_PORT, FORM_NAME, STANDARD_HTTPS_PORT } from '../../../helpers/constants'; </s> add import { DNS_OVER_QUIC_PORT, DNS_OVER_TLS_PORT, FORM_NAME, STANDARD_HTTPS_PORT, } from '../../../helpers/constants'; </s> remove import { validateIsSafePort, validatePort, validatePortTLS } from '../../../helpers/validators'; </s> add import { validateIsSafePort, validatePort, validatePortQuic, validatePortTLS, } from '../../../helpers/validators'; </s> remove color: var(--red); </s> add color: #cd201f;
port_dns_over_quic: DNS_OVER_QUIC_PORT,
port_https: STANDARD_HTTPS_PORT, port_dns_over_tls: DNS_OVER_TLS_PORT, port_dns_over_quic: DNS_OVER_QUIC_PORT, server_name: '', force_https: false, enabled: false, };
[ "keep", "add", "keep", "keep", "keep", "keep" ]
+ client: Add experimental DNS-over-QUIC support
https://github.com/AdguardTeam/AdGuardHome/commit/14bc5297ac6cb7c6dbc74d55239eeb16c041c048
client/src/components/Settings/Encryption/Form.js
force_https, port_https, port_dns_over_tls, certificate_chain, private_key, certificate_path, private_key_path, } = encryption;
</s> remove import { DNS_OVER_TLS_PORT, FORM_NAME, STANDARD_HTTPS_PORT } from '../../../helpers/constants'; </s> add import { DNS_OVER_QUIC_PORT, DNS_OVER_TLS_PORT, FORM_NAME, STANDARD_HTTPS_PORT, } from '../../../helpers/constants'; </s> remove color: var(--red); </s> add color: #cd201f; </s> remove import { validateIsSafePort, validatePort, validatePortTLS } from '../../../helpers/validators'; </s> add import { validateIsSafePort, validatePort, validatePortQuic, validatePortTLS, } from '../../../helpers/validators';
port_dns_over_quic,
force_https, port_https, port_dns_over_tls, port_dns_over_quic, certificate_chain, private_key, certificate_path, private_key_path, } = encryption;
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
+ client: Add experimental DNS-over-QUIC support
https://github.com/AdguardTeam/AdGuardHome/commit/14bc5297ac6cb7c6dbc74d55239eeb16c041c048
client/src/components/Settings/Encryption/index.js
server_name, force_https, port_https, port_dns_over_tls, certificate_chain, private_key, certificate_path, private_key_path, });
</s> remove color: var(--red); </s> add color: #cd201f;
port_dns_over_quic,
server_name, force_https, port_https, port_dns_over_tls, port_dns_over_quic, certificate_chain, private_key, certificate_path, private_key_path, });
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
+ client: Add experimental DNS-over-QUIC support
https://github.com/AdguardTeam/AdGuardHome/commit/14bc5297ac6cb7c6dbc74d55239eeb16c041c048
client/src/components/Settings/Encryption/index.js
font-size: 11px; } .form__message--error { color: var(--red); } .form__message--left-pad { padding-left: 0.85rem; }
</s> remove import { validateIsSafePort, validatePort, validatePortTLS } from '../../../helpers/validators'; </s> add import { validateIsSafePort, validatePort, validatePortQuic, validatePortTLS, } from '../../../helpers/validators'; </s> remove import { DNS_OVER_TLS_PORT, FORM_NAME, STANDARD_HTTPS_PORT } from '../../../helpers/constants'; </s> add import { DNS_OVER_QUIC_PORT, DNS_OVER_TLS_PORT, FORM_NAME, STANDARD_HTTPS_PORT, } from '../../../helpers/constants';
color: #cd201f;
font-size: 11px; } .form__message--error { color: #cd201f; } .form__message--left-pad { padding-left: 0.85rem; }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
+ client: Add experimental DNS-over-QUIC support
https://github.com/AdguardTeam/AdGuardHome/commit/14bc5297ac6cb7c6dbc74d55239eeb16c041c048
client/src/components/Settings/Settings.css
export const STANDARD_HTTPS_PORT = 443; export const DNS_OVER_TLS_PORT = 853; export const MAX_PORT = 65535; export const EMPTY_DATE = '0001-01-01T00:00:00Z';
</s> remove import { DNS_OVER_TLS_PORT, FORM_NAME, STANDARD_HTTPS_PORT } from '../../../helpers/constants'; </s> add import { DNS_OVER_QUIC_PORT, DNS_OVER_TLS_PORT, FORM_NAME, STANDARD_HTTPS_PORT, } from '../../../helpers/constants'; </s> remove import { validateIsSafePort, validatePort, validatePortTLS } from '../../../helpers/validators'; </s> add import { validateIsSafePort, validatePort, validatePortQuic, validatePortTLS, } from '../../../helpers/validators';
export const DNS_OVER_QUIC_PORT = 784;
export const STANDARD_HTTPS_PORT = 443; export const DNS_OVER_TLS_PORT = 853; export const DNS_OVER_QUIC_PORT = 784; export const MAX_PORT = 65535; export const EMPTY_DATE = '0001-01-01T00:00:00Z';
[ "keep", "add", "keep", "keep", "keep", "keep" ]
+ client: Add experimental DNS-over-QUIC support
https://github.com/AdguardTeam/AdGuardHome/commit/14bc5297ac6cb7c6dbc74d55239eeb16c041c048
client/src/helpers/constants.js
}; /** * @param value {number} * @returns {undefined|string} */ export const validateIsSafePort = (value) => { if (UNSAFE_PORTS.includes(value)) {
</s> remove import { DNS_OVER_TLS_PORT, FORM_NAME, STANDARD_HTTPS_PORT } from '../../../helpers/constants'; </s> add import { DNS_OVER_QUIC_PORT, DNS_OVER_TLS_PORT, FORM_NAME, STANDARD_HTTPS_PORT, } from '../../../helpers/constants'; </s> remove color: var(--red); </s> add color: #cd201f;
/** * @param value {number} * @returns {undefined|string} */ export const validatePortQuic = validatePortTLS;
}; /** * @param value {number} * @returns {undefined|string} */ export const validatePortQuic = validatePortTLS; /** * @param value {number} * @returns {undefined|string} */ export const validateIsSafePort = (value) => { if (UNSAFE_PORTS.includes(value)) {
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
+ client: Add experimental DNS-over-QUIC support
https://github.com/AdguardTeam/AdGuardHome/commit/14bc5297ac6cb7c6dbc74d55239eeb16c041c048
client/src/helpers/validators.js
s.processRecursion, s.processInitial, s.processDDRQuery, s.processDetermineLocal, s.processInternalHosts, s.processRestrictLocal, s.processInternalIPAddrs, s.processFilteringBeforeRequest, s.processLocalPTR, s.processUpstream,
</s> remove s.processInternalIPAddrs, </s> add s.processDHCPAddrs, </s> remove require.NoError(t, err) </s> add require.NoErrorf(t, err, "%s", addr) </s> remove lowhost := strings.ToLower(l.Hostname) </s> add lowhost := strings.ToLower(l.Hostname + "." + s.localDomainSuffix) ip := netutil.CloneIP(l.IP) </s> remove ipToHost.Set(l.IP, lowhost) ip := make(net.IP, 4) copy(ip, l.IP.To4()) </s> add ipToHost.Set(ip, lowhost) </s> remove // processInternalHosts respond to A requests if the target hostname is known to </s> add // processDHCPHosts respond to A requests if the target hostname is known to
s.processDHCPHosts,
s.processRecursion, s.processInitial, s.processDDRQuery, s.processDetermineLocal, s.processDHCPHosts, s.processRestrictLocal, s.processInternalIPAddrs, s.processFilteringBeforeRequest, s.processLocalPTR, s.processUpstream,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 4699 dhcp ptr Merge in DNS/adguard-home from 4699-dhcp-ptr to master Closes #4699. Squashed commit of the following: commit 0a8e2b3e22b7fad28a53db65031cc39d8755ecf4 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:40:53 2022 +0300 dnsforward: imp naming again commit 0b0884a8305f18f7f69560b86be8837933e220e9 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:26:58 2022 +0300 dnsforward: imp naming commit e193f53d9a1dd76d41396c06e2ec5a1e7d176557 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:26:00 2022 +0300 all: imp chlog commit 8ac9f84f086d9cb0b0f9da72bfc51f9b70a3dab7 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:18:48 2022 +0300 all: log changes commit 7cdc175d02b6eacfcb6ba62a5424d11e2561a879 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:03:52 2022 +0300 dnsforward: add tld to dhcp leased hostnames
https://github.com/AdguardTeam/AdGuardHome/commit/14d8f58592cbb192216cfe98e28e9b38e40a97c5
internal/dnsforward/dns.go
s.processDDRQuery, s.processDetermineLocal, s.processInternalHosts, s.processRestrictLocal, s.processInternalIPAddrs, s.processFilteringBeforeRequest, s.processLocalPTR, s.processUpstream, s.processFilteringAfterResponse, s.ipset.process,
</s> remove s.processInternalHosts, </s> add s.processDHCPHosts, </s> remove require.NoError(t, err) </s> add require.NoErrorf(t, err, "%s", addr) </s> remove lowhost := strings.ToLower(l.Hostname) </s> add lowhost := strings.ToLower(l.Hostname + "." + s.localDomainSuffix) ip := netutil.CloneIP(l.IP) </s> remove ipToHost.Set(l.IP, lowhost) ip := make(net.IP, 4) copy(ip, l.IP.To4()) </s> add ipToHost.Set(ip, lowhost) </s> remove // processInternalHosts respond to A requests if the target hostname is known to </s> add // processDHCPHosts respond to A requests if the target hostname is known to
s.processDHCPAddrs,
s.processDDRQuery, s.processDetermineLocal, s.processInternalHosts, s.processRestrictLocal, s.processDHCPAddrs, s.processFilteringBeforeRequest, s.processLocalPTR, s.processUpstream, s.processFilteringAfterResponse, s.ipset.process,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 4699 dhcp ptr Merge in DNS/adguard-home from 4699-dhcp-ptr to master Closes #4699. Squashed commit of the following: commit 0a8e2b3e22b7fad28a53db65031cc39d8755ecf4 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:40:53 2022 +0300 dnsforward: imp naming again commit 0b0884a8305f18f7f69560b86be8837933e220e9 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:26:58 2022 +0300 dnsforward: imp naming commit e193f53d9a1dd76d41396c06e2ec5a1e7d176557 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:26:00 2022 +0300 all: imp chlog commit 8ac9f84f086d9cb0b0f9da72bfc51f9b70a3dab7 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:18:48 2022 +0300 all: log changes commit 7cdc175d02b6eacfcb6ba62a5424d11e2561a879 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:03:52 2022 +0300 dnsforward: add tld to dhcp leased hostnames
https://github.com/AdguardTeam/AdGuardHome/commit/14d8f58592cbb192216cfe98e28e9b38e40a97c5
internal/dnsforward/dns.go
err, ) } lowhost := strings.ToLower(l.Hostname) ipToHost.Set(l.IP, lowhost) ip := make(net.IP, 4) copy(ip, l.IP.To4())
</s> remove ipToHost.Set(l.IP, lowhost) ip := make(net.IP, 4) copy(ip, l.IP.To4()) </s> add ipToHost.Set(ip, lowhost) </s> remove require.NoError(t, err) </s> add require.NoErrorf(t, err, "%s", addr) </s> remove examplelan = "example.lan" </s> add examplelan = "example." + defaultLocalDomainSuffix </s> remove func TestServer_ProcessInternalHosts(t *testing.T) { </s> add func TestServer_ProcessDHCPHosts(t *testing.T) { </s> remove dctx := &dnsContext{ proxyCtx: &proxy.DNSContext{ Req: req, }, isLocalClient: true, } </s> add dctx := &dnsContext{ proxyCtx: &proxy.DNSContext{ Req: req, }, isLocalClient: true, }
lowhost := strings.ToLower(l.Hostname + "." + s.localDomainSuffix) ip := netutil.CloneIP(l.IP)
err, ) } lowhost := strings.ToLower(l.Hostname + "." + s.localDomainSuffix) ip := netutil.CloneIP(l.IP) ipToHost.Set(l.IP, lowhost) ip := make(net.IP, 4) copy(ip, l.IP.To4())
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 4699 dhcp ptr Merge in DNS/adguard-home from 4699-dhcp-ptr to master Closes #4699. Squashed commit of the following: commit 0a8e2b3e22b7fad28a53db65031cc39d8755ecf4 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:40:53 2022 +0300 dnsforward: imp naming again commit 0b0884a8305f18f7f69560b86be8837933e220e9 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:26:58 2022 +0300 dnsforward: imp naming commit e193f53d9a1dd76d41396c06e2ec5a1e7d176557 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:26:00 2022 +0300 all: imp chlog commit 8ac9f84f086d9cb0b0f9da72bfc51f9b70a3dab7 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:18:48 2022 +0300 all: log changes commit 7cdc175d02b6eacfcb6ba62a5424d11e2561a879 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:03:52 2022 +0300 dnsforward: add tld to dhcp leased hostnames
https://github.com/AdguardTeam/AdGuardHome/commit/14d8f58592cbb192216cfe98e28e9b38e40a97c5
internal/dnsforward/dns.go
} lowhost := strings.ToLower(l.Hostname) ipToHost.Set(l.IP, lowhost) ip := make(net.IP, 4) copy(ip, l.IP.To4()) hostToIP[lowhost] = ip } log.Debug("dns: added %d A/PTR entries from DHCP", ipToHost.Len()) }
</s> remove lowhost := strings.ToLower(l.Hostname) </s> add lowhost := strings.ToLower(l.Hostname + "." + s.localDomainSuffix) ip := netutil.CloneIP(l.IP) </s> remove // don't need to be inaccessible externally. </s> add // don't need to be accessible externally. </s> remove dctx := &dnsContext{ proxyCtx: &proxy.DNSContext{ Req: req, }, isLocalClient: true, } </s> add dctx := &dnsContext{ proxyCtx: &proxy.DNSContext{ Req: req, }, isLocalClient: true, } </s> remove func TestServer_ProcessInternalHosts_localRestriction(t *testing.T) { </s> add func TestServer_ProcessDHCPHosts_localRestriction(t *testing.T) { </s> remove req := &dns.Msg{ MsgHdr: dns.MsgHdr{ Id: 1234, }, Question: []dns.Question{{ Name: dns.Fqdn(tc.host), Qtype: tc.qtyp, Qclass: dns.ClassINET, }}, } </s> add req := &dns.Msg{ MsgHdr: dns.MsgHdr{ Id: 1234, }, Question: []dns.Question{{ Name: dns.Fqdn(tc.host), Qtype: tc.qtyp, Qclass: dns.ClassINET, }}, }
ipToHost.Set(ip, lowhost)
} lowhost := strings.ToLower(l.Hostname) ipToHost.Set(ip, lowhost) ipToHost.Set(ip, lowhost) ipToHost.Set(ip, lowhost) ipToHost.Set(ip, lowhost) hostToIP[lowhost] = ip } log.Debug("dns: added %d A/PTR entries from DHCP", ipToHost.Len()) }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 4699 dhcp ptr Merge in DNS/adguard-home from 4699-dhcp-ptr to master Closes #4699. Squashed commit of the following: commit 0a8e2b3e22b7fad28a53db65031cc39d8755ecf4 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:40:53 2022 +0300 dnsforward: imp naming again commit 0b0884a8305f18f7f69560b86be8837933e220e9 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:26:58 2022 +0300 dnsforward: imp naming commit e193f53d9a1dd76d41396c06e2ec5a1e7d176557 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:26:00 2022 +0300 all: imp chlog commit 8ac9f84f086d9cb0b0f9da72bfc51f9b70a3dab7 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:18:48 2022 +0300 all: log changes commit 7cdc175d02b6eacfcb6ba62a5424d11e2561a879 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:03:52 2022 +0300 dnsforward: add tld to dhcp leased hostnames
https://github.com/AdguardTeam/AdGuardHome/commit/14d8f58592cbb192216cfe98e28e9b38e40a97c5
internal/dnsforward/dns.go
return ip, true } // processInternalHosts respond to A requests if the target hostname is known to // the server. // // TODO(a.garipov): Adapt to AAAA as well. func (s *Server) processInternalHosts(dctx *dnsContext) (rc resultCode) { if !s.dhcpServer.Enabled() {
</s> remove func (s *Server) processInternalHosts(dctx *dnsContext) (rc resultCode) { </s> add func (s *Server) processDHCPHosts(dctx *dnsContext) (rc resultCode) { </s> remove func (s *Server) processInternalIPAddrs(ctx *dnsContext) (rc resultCode) { </s> add func (s *Server) processDHCPAddrs(ctx *dnsContext) (rc resultCode) { </s> remove host := strings.TrimSuffix(reqHost, s.localDomainSuffix) if host == reqHost { </s> add if !strings.HasSuffix(reqHost, s.localDomainSuffix) { </s> remove reqHost := strings.ToLower(q.Name) </s> add reqHost := strings.ToLower(q.Name[:len(q.Name)-1]) </s> remove ip, ok := s.hostToIP(host) </s> add ip, ok := s.hostToIP(reqHost)
// processDHCPHosts respond to A requests if the target hostname is known to
return ip, true } // processDHCPHosts respond to A requests if the target hostname is known to // the server. // // TODO(a.garipov): Adapt to AAAA as well. func (s *Server) processInternalHosts(dctx *dnsContext) (rc resultCode) { if !s.dhcpServer.Enabled() {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 4699 dhcp ptr Merge in DNS/adguard-home from 4699-dhcp-ptr to master Closes #4699. Squashed commit of the following: commit 0a8e2b3e22b7fad28a53db65031cc39d8755ecf4 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:40:53 2022 +0300 dnsforward: imp naming again commit 0b0884a8305f18f7f69560b86be8837933e220e9 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:26:58 2022 +0300 dnsforward: imp naming commit e193f53d9a1dd76d41396c06e2ec5a1e7d176557 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:26:00 2022 +0300 all: imp chlog commit 8ac9f84f086d9cb0b0f9da72bfc51f9b70a3dab7 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:18:48 2022 +0300 all: log changes commit 7cdc175d02b6eacfcb6ba62a5424d11e2561a879 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:03:52 2022 +0300 dnsforward: add tld to dhcp leased hostnames
https://github.com/AdguardTeam/AdGuardHome/commit/14d8f58592cbb192216cfe98e28e9b38e40a97c5
internal/dnsforward/dns.go
// processInternalHosts respond to A requests if the target hostname is known to // the server. // // TODO(a.garipov): Adapt to AAAA as well. func (s *Server) processInternalHosts(dctx *dnsContext) (rc resultCode) { if !s.dhcpServer.Enabled() { return resultCodeSuccess } req := dctx.proxyCtx.Req
</s> remove // processInternalHosts respond to A requests if the target hostname is known to </s> add // processDHCPHosts respond to A requests if the target hostname is known to </s> remove func (s *Server) processInternalIPAddrs(ctx *dnsContext) (rc resultCode) { </s> add func (s *Server) processDHCPAddrs(ctx *dnsContext) (rc resultCode) { </s> remove host := strings.TrimSuffix(reqHost, s.localDomainSuffix) if host == reqHost { </s> add if !strings.HasSuffix(reqHost, s.localDomainSuffix) { </s> remove reqHost := strings.ToLower(q.Name) </s> add reqHost := strings.ToLower(q.Name[:len(q.Name)-1]) </s> remove // don't need to be inaccessible externally. </s> add // don't need to be accessible externally.
func (s *Server) processDHCPHosts(dctx *dnsContext) (rc resultCode) {
// processInternalHosts respond to A requests if the target hostname is known to // the server. // // TODO(a.garipov): Adapt to AAAA as well. func (s *Server) processDHCPHosts(dctx *dnsContext) (rc resultCode) { if !s.dhcpServer.Enabled() { return resultCodeSuccess } req := dctx.proxyCtx.Req
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 4699 dhcp ptr Merge in DNS/adguard-home from 4699-dhcp-ptr to master Closes #4699. Squashed commit of the following: commit 0a8e2b3e22b7fad28a53db65031cc39d8755ecf4 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:40:53 2022 +0300 dnsforward: imp naming again commit 0b0884a8305f18f7f69560b86be8837933e220e9 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:26:58 2022 +0300 dnsforward: imp naming commit e193f53d9a1dd76d41396c06e2ec5a1e7d176557 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:26:00 2022 +0300 all: imp chlog commit 8ac9f84f086d9cb0b0f9da72bfc51f9b70a3dab7 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:18:48 2022 +0300 all: log changes commit 7cdc175d02b6eacfcb6ba62a5424d11e2561a879 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:03:52 2022 +0300 dnsforward: add tld to dhcp leased hostnames
https://github.com/AdguardTeam/AdGuardHome/commit/14d8f58592cbb192216cfe98e28e9b38e40a97c5
internal/dnsforward/dns.go
if q.Qtype != dns.TypeA && q.Qtype != dns.TypeAAAA { return resultCodeSuccess } reqHost := strings.ToLower(q.Name) // TODO(a.garipov): Move everything related to DHCP local domain to the DHCP // server. host := strings.TrimSuffix(reqHost, s.localDomainSuffix) if host == reqHost { return resultCodeSuccess
</s> remove host := strings.TrimSuffix(reqHost, s.localDomainSuffix) if host == reqHost { </s> add if !strings.HasSuffix(reqHost, s.localDomainSuffix) { </s> remove func (s *Server) processInternalIPAddrs(ctx *dnsContext) (rc resultCode) { </s> add func (s *Server) processDHCPAddrs(ctx *dnsContext) (rc resultCode) { </s> remove func (s *Server) processInternalHosts(dctx *dnsContext) (rc resultCode) { </s> add func (s *Server) processDHCPHosts(dctx *dnsContext) (rc resultCode) { </s> remove // don't need to be inaccessible externally. </s> add // don't need to be accessible externally. </s> remove // processInternalHosts respond to A requests if the target hostname is known to </s> add // processDHCPHosts respond to A requests if the target hostname is known to
reqHost := strings.ToLower(q.Name[:len(q.Name)-1])
if q.Qtype != dns.TypeA && q.Qtype != dns.TypeAAAA { return resultCodeSuccess } reqHost := strings.ToLower(q.Name[:len(q.Name)-1]) // TODO(a.garipov): Move everything related to DHCP local domain to the DHCP // server. host := strings.TrimSuffix(reqHost, s.localDomainSuffix) if host == reqHost { return resultCodeSuccess
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 4699 dhcp ptr Merge in DNS/adguard-home from 4699-dhcp-ptr to master Closes #4699. Squashed commit of the following: commit 0a8e2b3e22b7fad28a53db65031cc39d8755ecf4 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:40:53 2022 +0300 dnsforward: imp naming again commit 0b0884a8305f18f7f69560b86be8837933e220e9 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:26:58 2022 +0300 dnsforward: imp naming commit e193f53d9a1dd76d41396c06e2ec5a1e7d176557 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:26:00 2022 +0300 all: imp chlog commit 8ac9f84f086d9cb0b0f9da72bfc51f9b70a3dab7 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:18:48 2022 +0300 all: log changes commit 7cdc175d02b6eacfcb6ba62a5424d11e2561a879 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:03:52 2022 +0300 dnsforward: add tld to dhcp leased hostnames
https://github.com/AdguardTeam/AdGuardHome/commit/14d8f58592cbb192216cfe98e28e9b38e40a97c5
internal/dnsforward/dns.go
reqHost := strings.ToLower(q.Name) // TODO(a.garipov): Move everything related to DHCP local domain to the DHCP // server. host := strings.TrimSuffix(reqHost, s.localDomainSuffix) if host == reqHost { return resultCodeSuccess } d := dctx.proxyCtx if !dctx.isLocalClient {
</s> remove reqHost := strings.ToLower(q.Name) </s> add reqHost := strings.ToLower(q.Name[:len(q.Name)-1]) </s> remove func (s *Server) processInternalIPAddrs(ctx *dnsContext) (rc resultCode) { </s> add func (s *Server) processDHCPAddrs(ctx *dnsContext) (rc resultCode) { </s> remove func (s *Server) processInternalHosts(dctx *dnsContext) (rc resultCode) { </s> add func (s *Server) processDHCPHosts(dctx *dnsContext) (rc resultCode) { </s> remove // don't need to be inaccessible externally. </s> add // don't need to be accessible externally. </s> remove // processInternalHosts respond to A requests if the target hostname is known to </s> add // processDHCPHosts respond to A requests if the target hostname is known to
if !strings.HasSuffix(reqHost, s.localDomainSuffix) {
reqHost := strings.ToLower(q.Name) // TODO(a.garipov): Move everything related to DHCP local domain to the DHCP // server. if !strings.HasSuffix(reqHost, s.localDomainSuffix) { if !strings.HasSuffix(reqHost, s.localDomainSuffix) { return resultCodeSuccess } d := dctx.proxyCtx if !dctx.isLocalClient {
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 4699 dhcp ptr Merge in DNS/adguard-home from 4699-dhcp-ptr to master Closes #4699. Squashed commit of the following: commit 0a8e2b3e22b7fad28a53db65031cc39d8755ecf4 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:40:53 2022 +0300 dnsforward: imp naming again commit 0b0884a8305f18f7f69560b86be8837933e220e9 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:26:58 2022 +0300 dnsforward: imp naming commit e193f53d9a1dd76d41396c06e2ec5a1e7d176557 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:26:00 2022 +0300 all: imp chlog commit 8ac9f84f086d9cb0b0f9da72bfc51f9b70a3dab7 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:18:48 2022 +0300 all: log changes commit 7cdc175d02b6eacfcb6ba62a5424d11e2561a879 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:03:52 2022 +0300 dnsforward: add tld to dhcp leased hostnames
https://github.com/AdguardTeam/AdGuardHome/commit/14d8f58592cbb192216cfe98e28e9b38e40a97c5
internal/dnsforward/dns.go
// Do not even put into query log. return resultCodeFinish } ip, ok := s.hostToIP(host) if !ok { // TODO(e.burkov): Inspect special cases when user want to apply some // rules handled by other processors to the hosts with TLD. d.Res = s.genNXDomain(req)
</s> remove func (s *Server) processInternalIPAddrs(ctx *dnsContext) (rc resultCode) { </s> add func (s *Server) processDHCPAddrs(ctx *dnsContext) (rc resultCode) { </s> remove // processInternalHosts respond to A requests if the target hostname is known to </s> add // processDHCPHosts respond to A requests if the target hostname is known to </s> remove const defaultLocalDomainSuffix = ".lan." </s> add const defaultLocalDomainSuffix = "lan" </s> remove // don't need to be inaccessible externally. </s> add // don't need to be accessible externally. </s> remove func (s *Server) processInternalHosts(dctx *dnsContext) (rc resultCode) { </s> add func (s *Server) processDHCPHosts(dctx *dnsContext) (rc resultCode) {
ip, ok := s.hostToIP(reqHost)
// Do not even put into query log. return resultCodeFinish } ip, ok := s.hostToIP(reqHost) if !ok { // TODO(e.burkov): Inspect special cases when user want to apply some // rules handled by other processors to the hosts with TLD. d.Res = s.genNXDomain(req)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 4699 dhcp ptr Merge in DNS/adguard-home from 4699-dhcp-ptr to master Closes #4699. Squashed commit of the following: commit 0a8e2b3e22b7fad28a53db65031cc39d8755ecf4 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:40:53 2022 +0300 dnsforward: imp naming again commit 0b0884a8305f18f7f69560b86be8837933e220e9 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:26:58 2022 +0300 dnsforward: imp naming commit e193f53d9a1dd76d41396c06e2ec5a1e7d176557 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:26:00 2022 +0300 all: imp chlog commit 8ac9f84f086d9cb0b0f9da72bfc51f9b70a3dab7 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:18:48 2022 +0300 all: log changes commit 7cdc175d02b6eacfcb6ba62a5424d11e2561a879 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:03:52 2022 +0300 dnsforward: add tld to dhcp leased hostnames
https://github.com/AdguardTeam/AdGuardHome/commit/14d8f58592cbb192216cfe98e28e9b38e40a97c5
internal/dnsforward/dns.go
} // Restrict an access to local addresses for external clients. We also // assume that all the DHCP leases we give are locally-served or at least // don't need to be inaccessible externally. if !s.privateNets.Contains(ip) { log.Debug("dns: addr %s is not from locally-served network", ip) return resultCodeSuccess }
</s> remove reqHost := strings.ToLower(q.Name) </s> add reqHost := strings.ToLower(q.Name[:len(q.Name)-1]) </s> remove host := strings.TrimSuffix(reqHost, s.localDomainSuffix) if host == reqHost { </s> add if !strings.HasSuffix(reqHost, s.localDomainSuffix) { </s> remove func (s *Server) processInternalIPAddrs(ctx *dnsContext) (rc resultCode) { </s> add func (s *Server) processDHCPAddrs(ctx *dnsContext) (rc resultCode) { </s> remove const defaultLocalDomainSuffix = ".lan." </s> add const defaultLocalDomainSuffix = "lan" </s> remove func (s *Server) processInternalHosts(dctx *dnsContext) (rc resultCode) { </s> add func (s *Server) processDHCPHosts(dctx *dnsContext) (rc resultCode) {
// don't need to be accessible externally.
} // Restrict an access to local addresses for external clients. We also // assume that all the DHCP leases we give are locally-served or at least // don't need to be accessible externally. if !s.privateNets.Contains(ip) { log.Debug("dns: addr %s is not from locally-served network", ip) return resultCodeSuccess }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 4699 dhcp ptr Merge in DNS/adguard-home from 4699-dhcp-ptr to master Closes #4699. Squashed commit of the following: commit 0a8e2b3e22b7fad28a53db65031cc39d8755ecf4 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:40:53 2022 +0300 dnsforward: imp naming again commit 0b0884a8305f18f7f69560b86be8837933e220e9 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:26:58 2022 +0300 dnsforward: imp naming commit e193f53d9a1dd76d41396c06e2ec5a1e7d176557 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:26:00 2022 +0300 all: imp chlog commit 8ac9f84f086d9cb0b0f9da72bfc51f9b70a3dab7 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:18:48 2022 +0300 all: log changes commit 7cdc175d02b6eacfcb6ba62a5424d11e2561a879 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:03:52 2022 +0300 dnsforward: add tld to dhcp leased hostnames
https://github.com/AdguardTeam/AdGuardHome/commit/14d8f58592cbb192216cfe98e28e9b38e40a97c5
internal/dnsforward/dns.go
} // Respond to PTR requests if the target IP is leased by our DHCP server and the // requestor is inside the local network. func (s *Server) processInternalIPAddrs(ctx *dnsContext) (rc resultCode) { d := ctx.proxyCtx if d.Res != nil { return resultCodeSuccess }
</s> remove func (s *Server) processInternalHosts(dctx *dnsContext) (rc resultCode) { </s> add func (s *Server) processDHCPHosts(dctx *dnsContext) (rc resultCode) { </s> remove // processInternalHosts respond to A requests if the target hostname is known to </s> add // processDHCPHosts respond to A requests if the target hostname is known to </s> remove reqHost := strings.ToLower(q.Name) </s> add reqHost := strings.ToLower(q.Name[:len(q.Name)-1]) </s> remove host := strings.TrimSuffix(reqHost, s.localDomainSuffix) if host == reqHost { </s> add if !strings.HasSuffix(reqHost, s.localDomainSuffix) { </s> remove // don't need to be inaccessible externally. </s> add // don't need to be accessible externally.
func (s *Server) processDHCPAddrs(ctx *dnsContext) (rc resultCode) {
} // Respond to PTR requests if the target IP is leased by our DHCP server and the // requestor is inside the local network. func (s *Server) processDHCPAddrs(ctx *dnsContext) (rc resultCode) { d := ctx.proxyCtx if d.Res != nil { return resultCodeSuccess }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 4699 dhcp ptr Merge in DNS/adguard-home from 4699-dhcp-ptr to master Closes #4699. Squashed commit of the following: commit 0a8e2b3e22b7fad28a53db65031cc39d8755ecf4 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:40:53 2022 +0300 dnsforward: imp naming again commit 0b0884a8305f18f7f69560b86be8837933e220e9 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:26:58 2022 +0300 dnsforward: imp naming commit e193f53d9a1dd76d41396c06e2ec5a1e7d176557 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:26:00 2022 +0300 all: imp chlog commit 8ac9f84f086d9cb0b0f9da72bfc51f9b70a3dab7 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:18:48 2022 +0300 all: log changes commit 7cdc175d02b6eacfcb6ba62a5424d11e2561a879 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:03:52 2022 +0300 dnsforward: add tld to dhcp leased hostnames
https://github.com/AdguardTeam/AdGuardHome/commit/14d8f58592cbb192216cfe98e28e9b38e40a97c5
internal/dnsforward/dns.go
}) } } func TestServer_ProcessInternalHosts_localRestriction(t *testing.T) { knownIP := net.IP{1, 2, 3, 4} testCases := []struct { name string host string
</s> remove examplelan = "example.lan" </s> add examplelan = "example." + defaultLocalDomainSuffix </s> remove func TestServer_ProcessInternalHosts(t *testing.T) { </s> add func TestServer_ProcessDHCPHosts(t *testing.T) { </s> remove // domainNameToSuffix converts a domain name into a local domain suffix. func domainNameToSuffix(tld string) (suffix string) { l := len(tld) + 2 b := make([]byte, l) b[0] = '.' copy(b[1:], tld) b[l-1] = '.' return string(b) } </s> add </s> remove host := strings.TrimSuffix(reqHost, s.localDomainSuffix) if host == reqHost { </s> add if !strings.HasSuffix(reqHost, s.localDomainSuffix) { </s> remove t.Run(tc.name, func(t *testing.T) { s := &Server{ dhcpServer: &testDHCP{}, localDomainSuffix: tc.suffix, tableHostToIP: hostToIPTable{ "example": knownIP, }, } </s> add s := &Server{ dhcpServer: &testDHCP{}, localDomainSuffix: tc.suffix, tableHostToIP: hostToIPTable{ "example." + tc.suffix: knownIP, }, }
func TestServer_ProcessDHCPHosts_localRestriction(t *testing.T) {
}) } } func TestServer_ProcessDHCPHosts_localRestriction(t *testing.T) { knownIP := net.IP{1, 2, 3, 4} testCases := []struct { name string host string
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 4699 dhcp ptr Merge in DNS/adguard-home from 4699-dhcp-ptr to master Closes #4699. Squashed commit of the following: commit 0a8e2b3e22b7fad28a53db65031cc39d8755ecf4 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:40:53 2022 +0300 dnsforward: imp naming again commit 0b0884a8305f18f7f69560b86be8837933e220e9 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:26:58 2022 +0300 dnsforward: imp naming commit e193f53d9a1dd76d41396c06e2ec5a1e7d176557 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:26:00 2022 +0300 all: imp chlog commit 8ac9f84f086d9cb0b0f9da72bfc51f9b70a3dab7 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:18:48 2022 +0300 all: log changes commit 7cdc175d02b6eacfcb6ba62a5424d11e2561a879 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:03:52 2022 +0300 dnsforward: add tld to dhcp leased hostnames
https://github.com/AdguardTeam/AdGuardHome/commit/14d8f58592cbb192216cfe98e28e9b38e40a97c5
internal/dnsforward/dns_test.go
s := &Server{ dhcpServer: &testDHCP{}, localDomainSuffix: defaultLocalDomainSuffix, tableHostToIP: hostToIPTable{ "example": knownIP, }, } req := &dns.Msg{ MsgHdr: dns.MsgHdr{
</s> remove t.Run(tc.name, func(t *testing.T) { s := &Server{ dhcpServer: &testDHCP{}, localDomainSuffix: tc.suffix, tableHostToIP: hostToIPTable{ "example": knownIP, }, } </s> add s := &Server{ dhcpServer: &testDHCP{}, localDomainSuffix: tc.suffix, tableHostToIP: hostToIPTable{ "example." + tc.suffix: knownIP, }, } </s> remove req := &dns.Msg{ MsgHdr: dns.MsgHdr{ Id: 1234, }, Question: []dns.Question{{ Name: dns.Fqdn(tc.host), Qtype: tc.qtyp, Qclass: dns.ClassINET, }}, } </s> add req := &dns.Msg{ MsgHdr: dns.MsgHdr{ Id: 1234, }, Question: []dns.Question{{ Name: dns.Fqdn(tc.host), Qtype: tc.qtyp, Qclass: dns.ClassINET, }}, } </s> remove dctx := &dnsContext{ proxyCtx: &proxy.DNSContext{ Req: req, }, isLocalClient: true, } </s> add dctx := &dnsContext{ proxyCtx: &proxy.DNSContext{ Req: req, }, isLocalClient: true, } </s> remove res := s.processInternalHosts(dctx) </s> add res := s.processDHCPHosts(dctx) </s> remove res := s.processInternalHosts(dctx) </s> add t.Run(tc.name, func(t *testing.T) { res := s.processDHCPHosts(dctx)
"example." + defaultLocalDomainSuffix: knownIP,
s := &Server{ dhcpServer: &testDHCP{}, localDomainSuffix: defaultLocalDomainSuffix, tableHostToIP: hostToIPTable{ "example." + defaultLocalDomainSuffix: knownIP, }, } req := &dns.Msg{ MsgHdr: dns.MsgHdr{
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 4699 dhcp ptr Merge in DNS/adguard-home from 4699-dhcp-ptr to master Closes #4699. Squashed commit of the following: commit 0a8e2b3e22b7fad28a53db65031cc39d8755ecf4 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:40:53 2022 +0300 dnsforward: imp naming again commit 0b0884a8305f18f7f69560b86be8837933e220e9 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:26:58 2022 +0300 dnsforward: imp naming commit e193f53d9a1dd76d41396c06e2ec5a1e7d176557 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:26:00 2022 +0300 all: imp chlog commit 8ac9f84f086d9cb0b0f9da72bfc51f9b70a3dab7 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:18:48 2022 +0300 all: log changes commit 7cdc175d02b6eacfcb6ba62a5424d11e2561a879 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:03:52 2022 +0300 dnsforward: add tld to dhcp leased hostnames
https://github.com/AdguardTeam/AdGuardHome/commit/14d8f58592cbb192216cfe98e28e9b38e40a97c5
internal/dnsforward/dns_test.go
}, isLocalClient: tc.isLocalCli, } res := s.processInternalHosts(dctx) require.Equal(t, tc.wantRes, res) pctx := dctx.proxyCtx if tc.wantRes == resultCodeFinish { require.NotNil(t, pctx.Res)
</s> remove res := s.processInternalHosts(dctx) </s> add t.Run(tc.name, func(t *testing.T) { res := s.processDHCPHosts(dctx) </s> remove dctx := &dnsContext{ proxyCtx: &proxy.DNSContext{ Req: req, }, isLocalClient: true, } </s> add dctx := &dnsContext{ proxyCtx: &proxy.DNSContext{ Req: req, }, isLocalClient: true, } </s> remove host := strings.TrimSuffix(reqHost, s.localDomainSuffix) if host == reqHost { </s> add if !strings.HasSuffix(reqHost, s.localDomainSuffix) { </s> remove t.Run(tc.name, func(t *testing.T) { s := &Server{ dhcpServer: &testDHCP{}, localDomainSuffix: tc.suffix, tableHostToIP: hostToIPTable{ "example": knownIP, }, } </s> add s := &Server{ dhcpServer: &testDHCP{}, localDomainSuffix: tc.suffix, tableHostToIP: hostToIPTable{ "example." + tc.suffix: knownIP, }, } </s> remove reqHost := strings.ToLower(q.Name) </s> add reqHost := strings.ToLower(q.Name[:len(q.Name)-1])
res := s.processDHCPHosts(dctx)
}, isLocalClient: tc.isLocalCli, } res := s.processDHCPHosts(dctx) require.Equal(t, tc.wantRes, res) pctx := dctx.proxyCtx if tc.wantRes == resultCodeFinish { require.NotNil(t, pctx.Res)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 4699 dhcp ptr Merge in DNS/adguard-home from 4699-dhcp-ptr to master Closes #4699. Squashed commit of the following: commit 0a8e2b3e22b7fad28a53db65031cc39d8755ecf4 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:40:53 2022 +0300 dnsforward: imp naming again commit 0b0884a8305f18f7f69560b86be8837933e220e9 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:26:58 2022 +0300 dnsforward: imp naming commit e193f53d9a1dd76d41396c06e2ec5a1e7d176557 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:26:00 2022 +0300 all: imp chlog commit 8ac9f84f086d9cb0b0f9da72bfc51f9b70a3dab7 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:18:48 2022 +0300 all: log changes commit 7cdc175d02b6eacfcb6ba62a5424d11e2561a879 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:03:52 2022 +0300 dnsforward: add tld to dhcp leased hostnames
https://github.com/AdguardTeam/AdGuardHome/commit/14d8f58592cbb192216cfe98e28e9b38e40a97c5
internal/dnsforward/dns_test.go
}) } } func TestServer_ProcessInternalHosts(t *testing.T) { const ( examplecom = "example.com" examplelan = "example.lan" )
</s> remove examplelan = "example.lan" </s> add examplelan = "example." + defaultLocalDomainSuffix </s> remove func TestServer_ProcessInternalHosts_localRestriction(t *testing.T) { </s> add func TestServer_ProcessDHCPHosts_localRestriction(t *testing.T) { </s> remove // domainNameToSuffix converts a domain name into a local domain suffix. func domainNameToSuffix(tld string) (suffix string) { l := len(tld) + 2 b := make([]byte, l) b[0] = '.' copy(b[1:], tld) b[l-1] = '.' return string(b) } </s> add </s> remove localDomainSuffix = domainNameToSuffix(p.LocalDomain) </s> add localDomainSuffix = p.LocalDomain
func TestServer_ProcessDHCPHosts(t *testing.T) {
}) } } func TestServer_ProcessDHCPHosts(t *testing.T) { const ( examplecom = "example.com" examplelan = "example.lan" )
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 4699 dhcp ptr Merge in DNS/adguard-home from 4699-dhcp-ptr to master Closes #4699. Squashed commit of the following: commit 0a8e2b3e22b7fad28a53db65031cc39d8755ecf4 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:40:53 2022 +0300 dnsforward: imp naming again commit 0b0884a8305f18f7f69560b86be8837933e220e9 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:26:58 2022 +0300 dnsforward: imp naming commit e193f53d9a1dd76d41396c06e2ec5a1e7d176557 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:26:00 2022 +0300 all: imp chlog commit 8ac9f84f086d9cb0b0f9da72bfc51f9b70a3dab7 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:18:48 2022 +0300 all: log changes commit 7cdc175d02b6eacfcb6ba62a5424d11e2561a879 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:03:52 2022 +0300 dnsforward: add tld to dhcp leased hostnames
https://github.com/AdguardTeam/AdGuardHome/commit/14d8f58592cbb192216cfe98e28e9b38e40a97c5
internal/dnsforward/dns_test.go
func TestServer_ProcessInternalHosts(t *testing.T) { const ( examplecom = "example.com" examplelan = "example.lan" ) knownIP := net.IP{1, 2, 3, 4} testCases := []struct { name string
</s> remove func TestServer_ProcessInternalHosts_localRestriction(t *testing.T) { </s> add func TestServer_ProcessDHCPHosts_localRestriction(t *testing.T) { </s> remove func TestServer_ProcessInternalHosts(t *testing.T) { </s> add func TestServer_ProcessDHCPHosts(t *testing.T) { </s> remove // domainNameToSuffix converts a domain name into a local domain suffix. func domainNameToSuffix(tld string) (suffix string) { l := len(tld) + 2 b := make([]byte, l) b[0] = '.' copy(b[1:], tld) b[l-1] = '.' return string(b) } </s> add </s> remove t.Run(tc.name, func(t *testing.T) { s := &Server{ dhcpServer: &testDHCP{}, localDomainSuffix: tc.suffix, tableHostToIP: hostToIPTable{ "example": knownIP, }, } </s> add s := &Server{ dhcpServer: &testDHCP{}, localDomainSuffix: tc.suffix, tableHostToIP: hostToIPTable{ "example." + tc.suffix: knownIP, }, }
examplelan = "example." + defaultLocalDomainSuffix
func TestServer_ProcessInternalHosts(t *testing.T) { const ( examplecom = "example.com" examplelan = "example." + defaultLocalDomainSuffix ) knownIP := net.IP{1, 2, 3, 4} testCases := []struct { name string
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 4699 dhcp ptr Merge in DNS/adguard-home from 4699-dhcp-ptr to master Closes #4699. Squashed commit of the following: commit 0a8e2b3e22b7fad28a53db65031cc39d8755ecf4 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:40:53 2022 +0300 dnsforward: imp naming again commit 0b0884a8305f18f7f69560b86be8837933e220e9 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:26:58 2022 +0300 dnsforward: imp naming commit e193f53d9a1dd76d41396c06e2ec5a1e7d176557 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:26:00 2022 +0300 all: imp chlog commit 8ac9f84f086d9cb0b0f9da72bfc51f9b70a3dab7 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:18:48 2022 +0300 all: log changes commit 7cdc175d02b6eacfcb6ba62a5424d11e2561a879 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:03:52 2022 +0300 dnsforward: add tld to dhcp leased hostnames
https://github.com/AdguardTeam/AdGuardHome/commit/14d8f58592cbb192216cfe98e28e9b38e40a97c5
internal/dnsforward/dns_test.go
qtyp: dns.TypeAAAA, }, { name: "success_custom_suffix", host: "example.custom", suffix: ".custom.", wantIP: knownIP, wantRes: resultCodeSuccess, qtyp: dns.TypeA, }}
</s> remove t.Run(tc.name, func(t *testing.T) { s := &Server{ dhcpServer: &testDHCP{}, localDomainSuffix: tc.suffix, tableHostToIP: hostToIPTable{ "example": knownIP, }, } </s> add s := &Server{ dhcpServer: &testDHCP{}, localDomainSuffix: tc.suffix, tableHostToIP: hostToIPTable{ "example." + tc.suffix: knownIP, }, } </s> remove "example": knownIP, </s> add "example." + defaultLocalDomainSuffix: knownIP, </s> remove req := &dns.Msg{ MsgHdr: dns.MsgHdr{ Id: 1234, }, Question: []dns.Question{{ Name: dns.Fqdn(tc.host), Qtype: tc.qtyp, Qclass: dns.ClassINET, }}, } </s> add req := &dns.Msg{ MsgHdr: dns.MsgHdr{ Id: 1234, }, Question: []dns.Question{{ Name: dns.Fqdn(tc.host), Qtype: tc.qtyp, Qclass: dns.ClassINET, }}, } </s> remove res := s.processInternalHosts(dctx) </s> add t.Run(tc.name, func(t *testing.T) { res := s.processDHCPHosts(dctx) </s> remove dctx := &dnsContext{ proxyCtx: &proxy.DNSContext{ Req: req, }, isLocalClient: true, } </s> add dctx := &dnsContext{ proxyCtx: &proxy.DNSContext{ Req: req, }, isLocalClient: true, }
suffix: "custom",
qtyp: dns.TypeAAAA, }, { name: "success_custom_suffix", host: "example.custom", suffix: "custom", wantIP: knownIP, wantRes: resultCodeSuccess, qtyp: dns.TypeA, }}
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 4699 dhcp ptr Merge in DNS/adguard-home from 4699-dhcp-ptr to master Closes #4699. Squashed commit of the following: commit 0a8e2b3e22b7fad28a53db65031cc39d8755ecf4 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:40:53 2022 +0300 dnsforward: imp naming again commit 0b0884a8305f18f7f69560b86be8837933e220e9 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:26:58 2022 +0300 dnsforward: imp naming commit e193f53d9a1dd76d41396c06e2ec5a1e7d176557 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:26:00 2022 +0300 all: imp chlog commit 8ac9f84f086d9cb0b0f9da72bfc51f9b70a3dab7 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:18:48 2022 +0300 all: log changes commit 7cdc175d02b6eacfcb6ba62a5424d11e2561a879 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:03:52 2022 +0300 dnsforward: add tld to dhcp leased hostnames
https://github.com/AdguardTeam/AdGuardHome/commit/14d8f58592cbb192216cfe98e28e9b38e40a97c5
internal/dnsforward/dns_test.go
qtyp: dns.TypeA, }} for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { s := &Server{ dhcpServer: &testDHCP{}, localDomainSuffix: tc.suffix, tableHostToIP: hostToIPTable{ "example": knownIP, }, } req := &dns.Msg{ MsgHdr: dns.MsgHdr{ Id: 1234, },
</s> remove "example": knownIP, </s> add "example." + defaultLocalDomainSuffix: knownIP, </s> remove req := &dns.Msg{ MsgHdr: dns.MsgHdr{ Id: 1234, }, Question: []dns.Question{{ Name: dns.Fqdn(tc.host), Qtype: tc.qtyp, Qclass: dns.ClassINET, }}, } </s> add req := &dns.Msg{ MsgHdr: dns.MsgHdr{ Id: 1234, }, Question: []dns.Question{{ Name: dns.Fqdn(tc.host), Qtype: tc.qtyp, Qclass: dns.ClassINET, }}, } </s> remove suffix: ".custom.", </s> add suffix: "custom", </s> remove res := s.processInternalHosts(dctx) </s> add t.Run(tc.name, func(t *testing.T) { res := s.processDHCPHosts(dctx) </s> remove func TestServer_ProcessInternalHosts_localRestriction(t *testing.T) { </s> add func TestServer_ProcessDHCPHosts_localRestriction(t *testing.T) {
s := &Server{ dhcpServer: &testDHCP{}, localDomainSuffix: tc.suffix, tableHostToIP: hostToIPTable{ "example." + tc.suffix: knownIP, }, }
qtyp: dns.TypeA, }} for _, tc := range testCases { s := &Server{ dhcpServer: &testDHCP{}, localDomainSuffix: tc.suffix, tableHostToIP: hostToIPTable{ "example." + tc.suffix: knownIP, }, } s := &Server{ dhcpServer: &testDHCP{}, localDomainSuffix: tc.suffix, tableHostToIP: hostToIPTable{ "example." + tc.suffix: knownIP, }, } s := &Server{ dhcpServer: &testDHCP{}, localDomainSuffix: tc.suffix, tableHostToIP: hostToIPTable{ "example." + tc.suffix: knownIP, }, } s := &Server{ dhcpServer: &testDHCP{}, localDomainSuffix: tc.suffix, tableHostToIP: hostToIPTable{ "example." + tc.suffix: knownIP, }, } s := &Server{ dhcpServer: &testDHCP{}, localDomainSuffix: tc.suffix, tableHostToIP: hostToIPTable{ "example." + tc.suffix: knownIP, }, } s := &Server{ dhcpServer: &testDHCP{}, localDomainSuffix: tc.suffix, tableHostToIP: hostToIPTable{ "example." + tc.suffix: knownIP, }, } s := &Server{ dhcpServer: &testDHCP{}, localDomainSuffix: tc.suffix, tableHostToIP: hostToIPTable{ "example." + tc.suffix: knownIP, }, } s := &Server{ dhcpServer: &testDHCP{}, localDomainSuffix: tc.suffix, tableHostToIP: hostToIPTable{ "example." + tc.suffix: knownIP, }, } req := &dns.Msg{ MsgHdr: dns.MsgHdr{ Id: 1234, },
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 4699 dhcp ptr Merge in DNS/adguard-home from 4699-dhcp-ptr to master Closes #4699. Squashed commit of the following: commit 0a8e2b3e22b7fad28a53db65031cc39d8755ecf4 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:40:53 2022 +0300 dnsforward: imp naming again commit 0b0884a8305f18f7f69560b86be8837933e220e9 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:26:58 2022 +0300 dnsforward: imp naming commit e193f53d9a1dd76d41396c06e2ec5a1e7d176557 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:26:00 2022 +0300 all: imp chlog commit 8ac9f84f086d9cb0b0f9da72bfc51f9b70a3dab7 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:18:48 2022 +0300 all: log changes commit 7cdc175d02b6eacfcb6ba62a5424d11e2561a879 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:03:52 2022 +0300 dnsforward: add tld to dhcp leased hostnames
https://github.com/AdguardTeam/AdGuardHome/commit/14d8f58592cbb192216cfe98e28e9b38e40a97c5
internal/dnsforward/dns_test.go
"example": knownIP, }, } req := &dns.Msg{ MsgHdr: dns.MsgHdr{ Id: 1234, }, Question: []dns.Question{{ Name: dns.Fqdn(tc.host), Qtype: tc.qtyp, Qclass: dns.ClassINET, }}, } dctx := &dnsContext{ proxyCtx: &proxy.DNSContext{ Req: req, },
</s> remove dctx := &dnsContext{ proxyCtx: &proxy.DNSContext{ Req: req, }, isLocalClient: true, } </s> add dctx := &dnsContext{ proxyCtx: &proxy.DNSContext{ Req: req, }, isLocalClient: true, } </s> remove t.Run(tc.name, func(t *testing.T) { s := &Server{ dhcpServer: &testDHCP{}, localDomainSuffix: tc.suffix, tableHostToIP: hostToIPTable{ "example": knownIP, }, } </s> add s := &Server{ dhcpServer: &testDHCP{}, localDomainSuffix: tc.suffix, tableHostToIP: hostToIPTable{ "example." + tc.suffix: knownIP, }, } </s> remove "example": knownIP, </s> add "example." + defaultLocalDomainSuffix: knownIP, </s> remove res := s.processInternalHosts(dctx) </s> add res := s.processDHCPHosts(dctx) </s> remove res := s.processInternalHosts(dctx) </s> add t.Run(tc.name, func(t *testing.T) { res := s.processDHCPHosts(dctx)
req := &dns.Msg{ MsgHdr: dns.MsgHdr{ Id: 1234, }, Question: []dns.Question{{ Name: dns.Fqdn(tc.host), Qtype: tc.qtyp, Qclass: dns.ClassINET, }}, }
"example": knownIP, }, } req := &dns.Msg{ MsgHdr: dns.MsgHdr{ Id: 1234, }, Question: []dns.Question{{ Name: dns.Fqdn(tc.host), Qtype: tc.qtyp, Qclass: dns.ClassINET, }}, } req := &dns.Msg{ MsgHdr: dns.MsgHdr{ Id: 1234, }, Question: []dns.Question{{ Name: dns.Fqdn(tc.host), Qtype: tc.qtyp, Qclass: dns.ClassINET, }}, } req := &dns.Msg{ MsgHdr: dns.MsgHdr{ Id: 1234, }, Question: []dns.Question{{ Name: dns.Fqdn(tc.host), Qtype: tc.qtyp, Qclass: dns.ClassINET, }}, } req := &dns.Msg{ MsgHdr: dns.MsgHdr{ Id: 1234, }, Question: []dns.Question{{ Name: dns.Fqdn(tc.host), Qtype: tc.qtyp, Qclass: dns.ClassINET, }}, } req := &dns.Msg{ MsgHdr: dns.MsgHdr{ Id: 1234, }, Question: []dns.Question{{ Name: dns.Fqdn(tc.host), Qtype: tc.qtyp, Qclass: dns.ClassINET, }}, } req := &dns.Msg{ MsgHdr: dns.MsgHdr{ Id: 1234, }, Question: []dns.Question{{ Name: dns.Fqdn(tc.host), Qtype: tc.qtyp, Qclass: dns.ClassINET, }}, } req := &dns.Msg{ MsgHdr: dns.MsgHdr{ Id: 1234, }, Question: []dns.Question{{ Name: dns.Fqdn(tc.host), Qtype: tc.qtyp, Qclass: dns.ClassINET, }}, } req := &dns.Msg{ MsgHdr: dns.MsgHdr{ Id: 1234, }, Question: []dns.Question{{ Name: dns.Fqdn(tc.host), Qtype: tc.qtyp, Qclass: dns.ClassINET, }}, } req := &dns.Msg{ MsgHdr: dns.MsgHdr{ Id: 1234, }, Question: []dns.Question{{ Name: dns.Fqdn(tc.host), Qtype: tc.qtyp, Qclass: dns.ClassINET, }}, } req := &dns.Msg{ MsgHdr: dns.MsgHdr{ Id: 1234, }, Question: []dns.Question{{ Name: dns.Fqdn(tc.host), Qtype: tc.qtyp, Qclass: dns.ClassINET, }}, } dctx := &dnsContext{ proxyCtx: &proxy.DNSContext{ Req: req, },
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 4699 dhcp ptr Merge in DNS/adguard-home from 4699-dhcp-ptr to master Closes #4699. Squashed commit of the following: commit 0a8e2b3e22b7fad28a53db65031cc39d8755ecf4 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:40:53 2022 +0300 dnsforward: imp naming again commit 0b0884a8305f18f7f69560b86be8837933e220e9 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:26:58 2022 +0300 dnsforward: imp naming commit e193f53d9a1dd76d41396c06e2ec5a1e7d176557 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:26:00 2022 +0300 all: imp chlog commit 8ac9f84f086d9cb0b0f9da72bfc51f9b70a3dab7 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:18:48 2022 +0300 all: log changes commit 7cdc175d02b6eacfcb6ba62a5424d11e2561a879 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:03:52 2022 +0300 dnsforward: add tld to dhcp leased hostnames
https://github.com/AdguardTeam/AdGuardHome/commit/14d8f58592cbb192216cfe98e28e9b38e40a97c5
internal/dnsforward/dns_test.go
Qclass: dns.ClassINET, }}, } dctx := &dnsContext{ proxyCtx: &proxy.DNSContext{ Req: req, }, isLocalClient: true, } res := s.processInternalHosts(dctx) pctx := dctx.proxyCtx assert.Equal(t, tc.wantRes, res) if tc.wantRes == resultCodeFinish {
</s> remove res := s.processInternalHosts(dctx) </s> add t.Run(tc.name, func(t *testing.T) { res := s.processDHCPHosts(dctx) </s> remove res := s.processInternalHosts(dctx) </s> add res := s.processDHCPHosts(dctx) </s> remove req := &dns.Msg{ MsgHdr: dns.MsgHdr{ Id: 1234, }, Question: []dns.Question{{ Name: dns.Fqdn(tc.host), Qtype: tc.qtyp, Qclass: dns.ClassINET, }}, } </s> add req := &dns.Msg{ MsgHdr: dns.MsgHdr{ Id: 1234, }, Question: []dns.Question{{ Name: dns.Fqdn(tc.host), Qtype: tc.qtyp, Qclass: dns.ClassINET, }}, } </s> remove host := strings.TrimSuffix(reqHost, s.localDomainSuffix) if host == reqHost { </s> add if !strings.HasSuffix(reqHost, s.localDomainSuffix) { </s> remove assert.Equal(t, "myhost.", ptr.Ptr) </s> add assert.Equal(t, dns.Fqdn("myhost."+localDomain), ptr.Ptr)
dctx := &dnsContext{ proxyCtx: &proxy.DNSContext{ Req: req, }, isLocalClient: true, }
Qclass: dns.ClassINET, }}, } dctx := &dnsContext{ proxyCtx: &proxy.DNSContext{ Req: req, }, isLocalClient: true, } dctx := &dnsContext{ proxyCtx: &proxy.DNSContext{ Req: req, }, isLocalClient: true, } dctx := &dnsContext{ proxyCtx: &proxy.DNSContext{ Req: req, }, isLocalClient: true, } dctx := &dnsContext{ proxyCtx: &proxy.DNSContext{ Req: req, }, isLocalClient: true, } dctx := &dnsContext{ proxyCtx: &proxy.DNSContext{ Req: req, }, isLocalClient: true, } dctx := &dnsContext{ proxyCtx: &proxy.DNSContext{ Req: req, }, isLocalClient: true, } res := s.processInternalHosts(dctx) pctx := dctx.proxyCtx assert.Equal(t, tc.wantRes, res) if tc.wantRes == resultCodeFinish {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 4699 dhcp ptr Merge in DNS/adguard-home from 4699-dhcp-ptr to master Closes #4699. Squashed commit of the following: commit 0a8e2b3e22b7fad28a53db65031cc39d8755ecf4 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:40:53 2022 +0300 dnsforward: imp naming again commit 0b0884a8305f18f7f69560b86be8837933e220e9 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:26:58 2022 +0300 dnsforward: imp naming commit e193f53d9a1dd76d41396c06e2ec5a1e7d176557 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:26:00 2022 +0300 all: imp chlog commit 8ac9f84f086d9cb0b0f9da72bfc51f9b70a3dab7 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:18:48 2022 +0300 all: log changes commit 7cdc175d02b6eacfcb6ba62a5424d11e2561a879 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:03:52 2022 +0300 dnsforward: add tld to dhcp leased hostnames
https://github.com/AdguardTeam/AdGuardHome/commit/14d8f58592cbb192216cfe98e28e9b38e40a97c5
internal/dnsforward/dns_test.go
}, isLocalClient: true, } res := s.processInternalHosts(dctx) pctx := dctx.proxyCtx assert.Equal(t, tc.wantRes, res) if tc.wantRes == resultCodeFinish { require.NotNil(t, pctx.Res) assert.Equal(t, dns.RcodeNameError, pctx.Res.Rcode)
</s> remove res := s.processInternalHosts(dctx) </s> add res := s.processDHCPHosts(dctx) </s> remove dctx := &dnsContext{ proxyCtx: &proxy.DNSContext{ Req: req, }, isLocalClient: true, } </s> add dctx := &dnsContext{ proxyCtx: &proxy.DNSContext{ Req: req, }, isLocalClient: true, } </s> remove assert.Equal(t, "myhost.", ptr.Ptr) </s> add assert.Equal(t, dns.Fqdn("myhost."+localDomain), ptr.Ptr) </s> remove require.NoError(t, err) </s> add require.NoErrorf(t, err, "%s", addr) </s> remove host := strings.TrimSuffix(reqHost, s.localDomainSuffix) if host == reqHost { </s> add if !strings.HasSuffix(reqHost, s.localDomainSuffix) {
t.Run(tc.name, func(t *testing.T) { res := s.processDHCPHosts(dctx)
}, isLocalClient: true, } t.Run(tc.name, func(t *testing.T) { res := s.processDHCPHosts(dctx) pctx := dctx.proxyCtx assert.Equal(t, tc.wantRes, res) if tc.wantRes == resultCodeFinish { require.NotNil(t, pctx.Res) assert.Equal(t, dns.RcodeNameError, pctx.Res.Rcode)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 4699 dhcp ptr Merge in DNS/adguard-home from 4699-dhcp-ptr to master Closes #4699. Squashed commit of the following: commit 0a8e2b3e22b7fad28a53db65031cc39d8755ecf4 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:40:53 2022 +0300 dnsforward: imp naming again commit 0b0884a8305f18f7f69560b86be8837933e220e9 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:26:58 2022 +0300 dnsforward: imp naming commit e193f53d9a1dd76d41396c06e2ec5a1e7d176557 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:26:00 2022 +0300 all: imp chlog commit 8ac9f84f086d9cb0b0f9da72bfc51f9b70a3dab7 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:18:48 2022 +0300 all: log changes commit 7cdc175d02b6eacfcb6ba62a5424d11e2561a879 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:03:52 2022 +0300 dnsforward: add tld to dhcp leased hostnames
https://github.com/AdguardTeam/AdGuardHome/commit/14d8f58592cbb192216cfe98e28e9b38e40a97c5
internal/dnsforward/dns_test.go
// defaultLocalDomainSuffix is the default suffix used to detect internal hosts // when no suffix is provided. // // See the documentation for Server.localDomainSuffix. const defaultLocalDomainSuffix = ".lan." // DNSCreateParams are parameters to create a new server. type DNSCreateParams struct { DNSFilter *filtering.DNSFilter Stats stats.Stats
</s> remove // processInternalHosts respond to A requests if the target hostname is known to </s> add // processDHCPHosts respond to A requests if the target hostname is known to </s> remove // don't need to be inaccessible externally. </s> add // don't need to be accessible externally. </s> remove // domainNameToSuffix converts a domain name into a local domain suffix. func domainNameToSuffix(tld string) (suffix string) { l := len(tld) + 2 b := make([]byte, l) b[0] = '.' copy(b[1:], tld) b[l-1] = '.' return string(b) } </s> add </s> remove func (s *Server) processInternalHosts(dctx *dnsContext) (rc resultCode) { </s> add func (s *Server) processDHCPHosts(dctx *dnsContext) (rc resultCode) { </s> remove ip, ok := s.hostToIP(host) </s> add ip, ok := s.hostToIP(reqHost)
const defaultLocalDomainSuffix = "lan"
// defaultLocalDomainSuffix is the default suffix used to detect internal hosts // when no suffix is provided. // // See the documentation for Server.localDomainSuffix. const defaultLocalDomainSuffix = "lan" // DNSCreateParams are parameters to create a new server. type DNSCreateParams struct { DNSFilter *filtering.DNSFilter Stats stats.Stats
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 4699 dhcp ptr Merge in DNS/adguard-home from 4699-dhcp-ptr to master Closes #4699. Squashed commit of the following: commit 0a8e2b3e22b7fad28a53db65031cc39d8755ecf4 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:40:53 2022 +0300 dnsforward: imp naming again commit 0b0884a8305f18f7f69560b86be8837933e220e9 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:26:58 2022 +0300 dnsforward: imp naming commit e193f53d9a1dd76d41396c06e2ec5a1e7d176557 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:26:00 2022 +0300 all: imp chlog commit 8ac9f84f086d9cb0b0f9da72bfc51f9b70a3dab7 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:18:48 2022 +0300 all: log changes commit 7cdc175d02b6eacfcb6ba62a5424d11e2561a879 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:03:52 2022 +0300 dnsforward: add tld to dhcp leased hostnames
https://github.com/AdguardTeam/AdGuardHome/commit/14d8f58592cbb192216cfe98e28e9b38e40a97c5
internal/dnsforward/dnsforward.go
Anonymizer *aghnet.IPMut LocalDomain string } // domainNameToSuffix converts a domain name into a local domain suffix. func domainNameToSuffix(tld string) (suffix string) { l := len(tld) + 2 b := make([]byte, l) b[0] = '.' copy(b[1:], tld) b[l-1] = '.' return string(b) } const ( // recursionTTL is the time recursive request is cached for. recursionTTL = 1 * time.Second // cachedRecurrentReqNum is the maximum number of cached recurrent // requests.
</s> remove const defaultLocalDomainSuffix = ".lan." </s> add const defaultLocalDomainSuffix = "lan" </s> remove examplelan = "example.lan" </s> add examplelan = "example." + defaultLocalDomainSuffix </s> remove func (s *Server) processInternalIPAddrs(ctx *dnsContext) (rc resultCode) { </s> add func (s *Server) processDHCPAddrs(ctx *dnsContext) (rc resultCode) { </s> remove host := strings.TrimSuffix(reqHost, s.localDomainSuffix) if host == reqHost { </s> add if !strings.HasSuffix(reqHost, s.localDomainSuffix) { </s> remove reqHost := strings.ToLower(q.Name) </s> add reqHost := strings.ToLower(q.Name[:len(q.Name)-1])
Anonymizer *aghnet.IPMut LocalDomain string } const ( // recursionTTL is the time recursive request is cached for. recursionTTL = 1 * time.Second // cachedRecurrentReqNum is the maximum number of cached recurrent // requests.
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 4699 dhcp ptr Merge in DNS/adguard-home from 4699-dhcp-ptr to master Closes #4699. Squashed commit of the following: commit 0a8e2b3e22b7fad28a53db65031cc39d8755ecf4 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:40:53 2022 +0300 dnsforward: imp naming again commit 0b0884a8305f18f7f69560b86be8837933e220e9 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:26:58 2022 +0300 dnsforward: imp naming commit e193f53d9a1dd76d41396c06e2ec5a1e7d176557 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:26:00 2022 +0300 all: imp chlog commit 8ac9f84f086d9cb0b0f9da72bfc51f9b70a3dab7 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:18:48 2022 +0300 all: log changes commit 7cdc175d02b6eacfcb6ba62a5424d11e2561a879 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:03:52 2022 +0300 dnsforward: add tld to dhcp leased hostnames
https://github.com/AdguardTeam/AdGuardHome/commit/14d8f58592cbb192216cfe98e28e9b38e40a97c5
internal/dnsforward/dnsforward.go
if err != nil { return nil, fmt.Errorf("local domain: %w", err) } localDomainSuffix = domainNameToSuffix(p.LocalDomain) } if p.Anonymizer == nil { p.Anonymizer = aghnet.NewIPMut(nil) }
</s> remove func (s *Server) processInternalIPAddrs(ctx *dnsContext) (rc resultCode) { </s> add func (s *Server) processDHCPAddrs(ctx *dnsContext) (rc resultCode) { </s> remove reqHost := strings.ToLower(q.Name) </s> add reqHost := strings.ToLower(q.Name[:len(q.Name)-1]) </s> remove func TestServer_ProcessInternalHosts(t *testing.T) { </s> add func TestServer_ProcessDHCPHosts(t *testing.T) { </s> remove host := strings.TrimSuffix(reqHost, s.localDomainSuffix) if host == reqHost { </s> add if !strings.HasSuffix(reqHost, s.localDomainSuffix) {
localDomainSuffix = p.LocalDomain
if err != nil { return nil, fmt.Errorf("local domain: %w", err) } localDomainSuffix = p.LocalDomain } if p.Anonymizer == nil { p.Anonymizer = aghnet.NewIPMut(nil) }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 4699 dhcp ptr Merge in DNS/adguard-home from 4699-dhcp-ptr to master Closes #4699. Squashed commit of the following: commit 0a8e2b3e22b7fad28a53db65031cc39d8755ecf4 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:40:53 2022 +0300 dnsforward: imp naming again commit 0b0884a8305f18f7f69560b86be8837933e220e9 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:26:58 2022 +0300 dnsforward: imp naming commit e193f53d9a1dd76d41396c06e2ec5a1e7d176557 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:26:00 2022 +0300 all: imp chlog commit 8ac9f84f086d9cb0b0f9da72bfc51f9b70a3dab7 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:18:48 2022 +0300 all: log changes commit 7cdc175d02b6eacfcb6ba62a5424d11e2561a879 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:03:52 2022 +0300 dnsforward: add tld to dhcp leased hostnames
https://github.com/AdguardTeam/AdGuardHome/commit/14d8f58592cbb192216cfe98e28e9b38e40a97c5
internal/dnsforward/dnsforward.go
func TestPTRResponseFromDHCPLeases(t *testing.T) { s, err := NewServer(DNSCreateParams{ DNSFilter: filtering.New(&filtering.Config{}, nil), DHCPServer: &testDHCP{}, PrivateNets: netutil.SubnetSetFunc(netutil.IsLocallyServed),
</s> remove func TestServer_ProcessInternalHosts_localRestriction(t *testing.T) { </s> add func TestServer_ProcessDHCPHosts_localRestriction(t *testing.T) { </s> remove t.Run(tc.name, func(t *testing.T) { s := &Server{ dhcpServer: &testDHCP{}, localDomainSuffix: tc.suffix, tableHostToIP: hostToIPTable{ "example": knownIP, }, } </s> add s := &Server{ dhcpServer: &testDHCP{}, localDomainSuffix: tc.suffix, tableHostToIP: hostToIPTable{ "example." + tc.suffix: knownIP, }, } </s> remove func TestServer_ProcessInternalHosts(t *testing.T) { </s> add func TestServer_ProcessDHCPHosts(t *testing.T) { </s> remove examplelan = "example.lan" </s> add examplelan = "example." + defaultLocalDomainSuffix
const localDomain = "lan"
func TestPTRResponseFromDHCPLeases(t *testing.T) { const localDomain = "lan" s, err := NewServer(DNSCreateParams{ DNSFilter: filtering.New(&filtering.Config{}, nil), DHCPServer: &testDHCP{}, PrivateNets: netutil.SubnetSetFunc(netutil.IsLocallyServed),
[ "keep", "add", "keep", "keep", "keep", "keep" ]
Pull request: 4699 dhcp ptr Merge in DNS/adguard-home from 4699-dhcp-ptr to master Closes #4699. Squashed commit of the following: commit 0a8e2b3e22b7fad28a53db65031cc39d8755ecf4 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:40:53 2022 +0300 dnsforward: imp naming again commit 0b0884a8305f18f7f69560b86be8837933e220e9 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:26:58 2022 +0300 dnsforward: imp naming commit e193f53d9a1dd76d41396c06e2ec5a1e7d176557 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:26:00 2022 +0300 all: imp chlog commit 8ac9f84f086d9cb0b0f9da72bfc51f9b70a3dab7 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:18:48 2022 +0300 all: log changes commit 7cdc175d02b6eacfcb6ba62a5424d11e2561a879 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:03:52 2022 +0300 dnsforward: add tld to dhcp leased hostnames
https://github.com/AdguardTeam/AdGuardHome/commit/14d8f58592cbb192216cfe98e28e9b38e40a97c5
internal/dnsforward/dnsforward_test.go
s, err := NewServer(DNSCreateParams{ DNSFilter: filtering.New(&filtering.Config{}, nil), DHCPServer: &testDHCP{}, PrivateNets: netutil.SubnetSetFunc(netutil.IsLocallyServed), }) require.NoError(t, err) s.conf.UDPListenAddrs = []*net.UDPAddr{{}} s.conf.TCPListenAddrs = []*net.TCPAddr{{}}
</s> remove require.NoError(t, err) </s> add require.NoErrorf(t, err, "%s", addr) </s> remove localDomainSuffix = domainNameToSuffix(p.LocalDomain) </s> add localDomainSuffix = p.LocalDomain </s> remove func TestServer_ProcessInternalHosts(t *testing.T) { </s> add func TestServer_ProcessDHCPHosts(t *testing.T) { </s> remove examplelan = "example.lan" </s> add examplelan = "example." + defaultLocalDomainSuffix
LocalDomain: localDomain,
s, err := NewServer(DNSCreateParams{ DNSFilter: filtering.New(&filtering.Config{}, nil), DHCPServer: &testDHCP{}, PrivateNets: netutil.SubnetSetFunc(netutil.IsLocallyServed), LocalDomain: localDomain, }) require.NoError(t, err) s.conf.UDPListenAddrs = []*net.UDPAddr{{}} s.conf.TCPListenAddrs = []*net.TCPAddr{{}}
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 4699 dhcp ptr Merge in DNS/adguard-home from 4699-dhcp-ptr to master Closes #4699. Squashed commit of the following: commit 0a8e2b3e22b7fad28a53db65031cc39d8755ecf4 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:40:53 2022 +0300 dnsforward: imp naming again commit 0b0884a8305f18f7f69560b86be8837933e220e9 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:26:58 2022 +0300 dnsforward: imp naming commit e193f53d9a1dd76d41396c06e2ec5a1e7d176557 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:26:00 2022 +0300 all: imp chlog commit 8ac9f84f086d9cb0b0f9da72bfc51f9b70a3dab7 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:18:48 2022 +0300 all: log changes commit 7cdc175d02b6eacfcb6ba62a5424d11e2561a879 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:03:52 2022 +0300 dnsforward: add tld to dhcp leased hostnames
https://github.com/AdguardTeam/AdGuardHome/commit/14d8f58592cbb192216cfe98e28e9b38e40a97c5
internal/dnsforward/dnsforward_test.go
addr := s.dnsProxy.Addr(proxy.ProtoUDP) req := createTestMessageWithType("34.12.168.192.in-addr.arpa.", dns.TypePTR) resp, err := dns.Exchange(req, addr.String()) require.NoError(t, err) require.Len(t, resp.Answer, 1) assert.Equal(t, dns.TypePTR, resp.Answer[0].Header().Rrtype) assert.Equal(t, "34.12.168.192.in-addr.arpa.", resp.Answer[0].Header().Name)
</s> remove assert.Equal(t, "myhost.", ptr.Ptr) </s> add assert.Equal(t, dns.Fqdn("myhost."+localDomain), ptr.Ptr) </s> remove res := s.processInternalHosts(dctx) </s> add t.Run(tc.name, func(t *testing.T) { res := s.processDHCPHosts(dctx) </s> remove dctx := &dnsContext{ proxyCtx: &proxy.DNSContext{ Req: req, }, isLocalClient: true, } </s> add dctx := &dnsContext{ proxyCtx: &proxy.DNSContext{ Req: req, }, isLocalClient: true, } </s> remove "example": knownIP, </s> add "example." + defaultLocalDomainSuffix: knownIP,
require.NoErrorf(t, err, "%s", addr)
addr := s.dnsProxy.Addr(proxy.ProtoUDP) req := createTestMessageWithType("34.12.168.192.in-addr.arpa.", dns.TypePTR) resp, err := dns.Exchange(req, addr.String()) require.NoErrorf(t, err, "%s", addr) require.Len(t, resp.Answer, 1) assert.Equal(t, dns.TypePTR, resp.Answer[0].Header().Rrtype) assert.Equal(t, "34.12.168.192.in-addr.arpa.", resp.Answer[0].Header().Name)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 4699 dhcp ptr Merge in DNS/adguard-home from 4699-dhcp-ptr to master Closes #4699. Squashed commit of the following: commit 0a8e2b3e22b7fad28a53db65031cc39d8755ecf4 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:40:53 2022 +0300 dnsforward: imp naming again commit 0b0884a8305f18f7f69560b86be8837933e220e9 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:26:58 2022 +0300 dnsforward: imp naming commit e193f53d9a1dd76d41396c06e2ec5a1e7d176557 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:26:00 2022 +0300 all: imp chlog commit 8ac9f84f086d9cb0b0f9da72bfc51f9b70a3dab7 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:18:48 2022 +0300 all: log changes commit 7cdc175d02b6eacfcb6ba62a5424d11e2561a879 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:03:52 2022 +0300 dnsforward: add tld to dhcp leased hostnames
https://github.com/AdguardTeam/AdGuardHome/commit/14d8f58592cbb192216cfe98e28e9b38e40a97c5
internal/dnsforward/dnsforward_test.go
assert.Equal(t, "34.12.168.192.in-addr.arpa.", resp.Answer[0].Header().Name) ptr, ok := resp.Answer[0].(*dns.PTR) require.True(t, ok) assert.Equal(t, "myhost.", ptr.Ptr) } func TestPTRResponseFromHosts(t *testing.T) { // Prepare test hosts file.
</s> remove require.NoError(t, err) </s> add require.NoErrorf(t, err, "%s", addr) </s> remove res := s.processInternalHosts(dctx) </s> add t.Run(tc.name, func(t *testing.T) { res := s.processDHCPHosts(dctx) </s> remove ip, ok := s.hostToIP(host) </s> add ip, ok := s.hostToIP(reqHost) </s> remove func TestServer_ProcessInternalHosts_localRestriction(t *testing.T) { </s> add func TestServer_ProcessDHCPHosts_localRestriction(t *testing.T) { </s> remove dctx := &dnsContext{ proxyCtx: &proxy.DNSContext{ Req: req, }, isLocalClient: true, } </s> add dctx := &dnsContext{ proxyCtx: &proxy.DNSContext{ Req: req, }, isLocalClient: true, }
assert.Equal(t, dns.Fqdn("myhost."+localDomain), ptr.Ptr)
assert.Equal(t, "34.12.168.192.in-addr.arpa.", resp.Answer[0].Header().Name) ptr, ok := resp.Answer[0].(*dns.PTR) require.True(t, ok) assert.Equal(t, dns.Fqdn("myhost."+localDomain), ptr.Ptr) } func TestPTRResponseFromHosts(t *testing.T) { // Prepare test hosts file.
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 4699 dhcp ptr Merge in DNS/adguard-home from 4699-dhcp-ptr to master Closes #4699. Squashed commit of the following: commit 0a8e2b3e22b7fad28a53db65031cc39d8755ecf4 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:40:53 2022 +0300 dnsforward: imp naming again commit 0b0884a8305f18f7f69560b86be8837933e220e9 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 18:26:58 2022 +0300 dnsforward: imp naming commit e193f53d9a1dd76d41396c06e2ec5a1e7d176557 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:26:00 2022 +0300 all: imp chlog commit 8ac9f84f086d9cb0b0f9da72bfc51f9b70a3dab7 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:18:48 2022 +0300 all: log changes commit 7cdc175d02b6eacfcb6ba62a5424d11e2561a879 Author: Eugene Burkov <[email protected]> Date: Tue Jun 28 17:03:52 2022 +0300 dnsforward: add tld to dhcp leased hostnames
https://github.com/AdguardTeam/AdGuardHome/commit/14d8f58592cbb192216cfe98e28e9b38e40a97c5
internal/dnsforward/dnsforward_test.go
import { LANGUAGES, BASE_LOCALE } from './helpers/twosky'; import be from './__locales/be.json'; import bg from './__locales/bg.json'; import cs from './__locales/cs.json'; import da from './__locales/da.json'; import de from './__locales/de.json'; import en from './__locales/en.json';
</s> remove func handleI18nCurrentLanguage(w http.ResponseWriter, r *http.Request) { </s> add func handleI18nCurrentLanguage(w http.ResponseWriter, _ *http.Request) {
import ar from './__locales/ar.json';
import { LANGUAGES, BASE_LOCALE } from './helpers/twosky'; import ar from './__locales/ar.json'; import be from './__locales/be.json'; import bg from './__locales/bg.json'; import cs from './__locales/cs.json'; import da from './__locales/da.json'; import de from './__locales/de.json'; import en from './__locales/en.json';
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Pull request: add-ar-i18n Merge in DNS/adguard-home from add-ar-i18n to master Squashed commit of the following: commit 6ef7c70bceb6f6ebabd81011154022a75fc91bd3 Author: Ainar Garipov <[email protected]> Date: Wed Aug 10 20:55:39 2022 +0300 client: add ar locale
https://github.com/AdguardTeam/AdGuardHome/commit/14fd995ae9a4a9f8e4a56f2d0a33aadc7bc42035
client/src/i18n.js
import { setHtmlLangAttr } from './helpers/helpers'; const resources = { be: { translation: be }, bg: { translation: bg }, cs: { translation: cs }, da: { translation: da }, de: { translation: de }, en: { translation: en },
</s> remove func handleI18nCurrentLanguage(w http.ResponseWriter, r *http.Request) { </s> add func handleI18nCurrentLanguage(w http.ResponseWriter, _ *http.Request) {
ar: { translation: ar },
import { setHtmlLangAttr } from './helpers/helpers'; const resources = { ar: { translation: ar }, be: { translation: be }, bg: { translation: bg }, cs: { translation: cs }, da: { translation: da }, de: { translation: de }, en: { translation: en },
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Pull request: add-ar-i18n Merge in DNS/adguard-home from add-ar-i18n to master Squashed commit of the following: commit 6ef7c70bceb6f6ebabd81011154022a75fc91bd3 Author: Ainar Garipov <[email protected]> Date: Wed Aug 10 20:55:39 2022 +0300 client: add ar locale
https://github.com/AdguardTeam/AdGuardHome/commit/14fd995ae9a4a9f8e4a56f2d0a33aadc7bc42035
client/src/i18n.js
// TODO(a.garipov): Get rid of a global or generate from .twosky.json. var allowedLanguages = stringutil.NewSet( "be", "bg", "cs", "da",
</s> remove func handleI18nCurrentLanguage(w http.ResponseWriter, r *http.Request) { </s> add func handleI18nCurrentLanguage(w http.ResponseWriter, _ *http.Request) {
"ar",
// TODO(a.garipov): Get rid of a global or generate from .twosky.json. var allowedLanguages = stringutil.NewSet( "ar", "be", "bg", "cs", "da",
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
Pull request: add-ar-i18n Merge in DNS/adguard-home from add-ar-i18n to master Squashed commit of the following: commit 6ef7c70bceb6f6ebabd81011154022a75fc91bd3 Author: Ainar Garipov <[email protected]> Date: Wed Aug 10 20:55:39 2022 +0300 client: add ar locale
https://github.com/AdguardTeam/AdGuardHome/commit/14fd995ae9a4a9f8e4a56f2d0a33aadc7bc42035
internal/home/i18n.go
"zh-hk", "zh-tw", ) func handleI18nCurrentLanguage(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/plain") log.Printf("config.Language is %s", config.Language) _, err := fmt.Fprintf(w, "%s\n", config.Language) if err != nil { msg := fmt.Sprintf("Unable to write response json: %s", err)
</s>
func handleI18nCurrentLanguage(w http.ResponseWriter, _ *http.Request) {
"zh-hk", "zh-tw", ) func handleI18nCurrentLanguage(w http.ResponseWriter, _ *http.Request) { w.Header().Set("Content-Type", "text/plain") log.Printf("config.Language is %s", config.Language) _, err := fmt.Fprintf(w, "%s\n", config.Language) if err != nil { msg := fmt.Sprintf("Unable to write response json: %s", err)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: add-ar-i18n Merge in DNS/adguard-home from add-ar-i18n to master Squashed commit of the following: commit 6ef7c70bceb6f6ebabd81011154022a75fc91bd3 Author: Ainar Garipov <[email protected]> Date: Wed Aug 10 20:55:39 2022 +0300 client: add ar locale
https://github.com/AdguardTeam/AdGuardHome/commit/14fd995ae9a4a9f8e4a56f2d0a33aadc7bc42035
internal/home/i18n.go
} // New creates properly initialized DNS Filter that is ready to be used func New(c *Config, blockFilters []Filter) *Dnsfilter { if c != nil { cacheConf := cache.Config{
</s> remove initBlockedServices() </s> add
// InitModule() - manually initialize blocked services map func InitModule() { initBlockedServices() }
} // InitModule() - manually initialize blocked services map func InitModule() { initBlockedServices() } // New creates properly initialized DNS Filter that is ready to be used func New(c *Config, blockFilters []Filter) *Dnsfilter { if c != nil { cacheConf := cache.Config{
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Merge: - blocked-services: settings were reset on restart Close #1624 Squashed commit of the following: commit eecc91ca1f9d062c27702a9c07da74da673bef05 Merge: ec53dbeb 26f78dcc Author: Simon Zolin <[email protected]> Date: Mon Apr 27 13:15:58 2020 +0300 Merge remote-tracking branch 'origin/master' into fix-blocked-svcs commit ec53dbebdc2fbd2ff94f939d2bd8fb07b9dd1bc8 Author: Simon Zolin <[email protected]> Date: Mon Apr 27 12:58:50 2020 +0300 minor commit 1e3c20ed02151965ebaca55ac4f25a951a772062 Author: Simon Zolin <[email protected]> Date: Mon Apr 27 12:53:37 2020 +0300 - blocked-services: settings were reset on restart broken by: 0789e4b20dea132f5d66ee18f7d1fbd05c10b014 * refactor: move blocked-services functions to dnsfilter
https://github.com/AdguardTeam/AdGuardHome/commit/14ffd1a3f52049931b21abe4ebce5bd22ece715b
dnsfilter/dnsfilter.go
bsvcs = append(bsvcs, s) } d.BlockedServices = bsvcs initBlockedServices() if blockFilters != nil { err := d.initFiltering(nil, blockFilters) if err != nil { log.Error("Can't initialize filtering subsystem: %s", err) d.Close()
</s>
bsvcs = append(bsvcs, s) } d.BlockedServices = bsvcs if blockFilters != nil { err := d.initFiltering(nil, blockFilters) if err != nil { log.Error("Can't initialize filtering subsystem: %s", err) d.Close()
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Merge: - blocked-services: settings were reset on restart Close #1624 Squashed commit of the following: commit eecc91ca1f9d062c27702a9c07da74da673bef05 Merge: ec53dbeb 26f78dcc Author: Simon Zolin <[email protected]> Date: Mon Apr 27 13:15:58 2020 +0300 Merge remote-tracking branch 'origin/master' into fix-blocked-svcs commit ec53dbebdc2fbd2ff94f939d2bd8fb07b9dd1bc8 Author: Simon Zolin <[email protected]> Date: Mon Apr 27 12:58:50 2020 +0300 minor commit 1e3c20ed02151965ebaca55ac4f25a951a772062 Author: Simon Zolin <[email protected]> Date: Mon Apr 27 12:53:37 2020 +0300 - blocked-services: settings were reset on restart broken by: 0789e4b20dea132f5d66ee18f7d1fbd05c10b014 * refactor: move blocked-services functions to dnsfilter
https://github.com/AdguardTeam/AdGuardHome/commit/14ffd1a3f52049931b21abe4ebce5bd22ece715b
dnsfilter/dnsfilter.go
} } config.DHCP.WorkDir = Context.workDir config.DHCP.HTTPRegister = httpRegister config.DHCP.ConfigModified = onConfigModified Context.dhcpServer = dhcpd.Create(config.DHCP)
</s> remove initBlockedServices() </s> add
// 'clients' module uses 'dnsfilter' module's static data (dnsfilter.BlockedSvcKnown()), // so we have to initialize dnsfilter's static data first, // but also avoid relying on automatic Go init() function dnsfilter.InitModule()
} } // 'clients' module uses 'dnsfilter' module's static data (dnsfilter.BlockedSvcKnown()), // so we have to initialize dnsfilter's static data first, // but also avoid relying on automatic Go init() function dnsfilter.InitModule() config.DHCP.WorkDir = Context.workDir config.DHCP.HTTPRegister = httpRegister config.DHCP.ConfigModified = onConfigModified Context.dhcpServer = dhcpd.Create(config.DHCP)
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
Merge: - blocked-services: settings were reset on restart Close #1624 Squashed commit of the following: commit eecc91ca1f9d062c27702a9c07da74da673bef05 Merge: ec53dbeb 26f78dcc Author: Simon Zolin <[email protected]> Date: Mon Apr 27 13:15:58 2020 +0300 Merge remote-tracking branch 'origin/master' into fix-blocked-svcs commit ec53dbebdc2fbd2ff94f939d2bd8fb07b9dd1bc8 Author: Simon Zolin <[email protected]> Date: Mon Apr 27 12:58:50 2020 +0300 minor commit 1e3c20ed02151965ebaca55ac4f25a951a772062 Author: Simon Zolin <[email protected]> Date: Mon Apr 27 12:53:37 2020 +0300 - blocked-services: settings were reset on restart broken by: 0789e4b20dea132f5d66ee18f7d1fbd05c10b014 * refactor: move blocked-services functions to dnsfilter
https://github.com/AdguardTeam/AdGuardHome/commit/14ffd1a3f52049931b21abe4ebce5bd22ece715b
home/home.go
var v interface{} v, ok = s.tableIPToHost.Get(ip) if host, ok = v.(string); !ok { log.Error("dns: bad type %T in tableIPToHost for %s", v, ip) return "", false
</s> remove return host, ok </s> add return host, true </s> remove var typOK bool if host, typOK = v.(string); !typOK { </s> add if host, ok = v.(string); !ok {
if !ok { return "", false }
var v interface{} v, ok = s.tableIPToHost.Get(ip) if !ok { return "", false } if host, ok = v.(string); !ok { log.Error("dns: bad type %T in tableIPToHost for %s", v, ip) return "", false
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Pull request #1238: dnsforward: fix panic Updates #3318. Squashed commit of the following: commit eebaa3ac3a6bfcb29e280006ead8ea9554b8a3bf Author: Ainar Garipov <[email protected]> Date: Tue Jul 6 14:59:00 2021 +0300 dnsforward: imp code commit 7591a3b183ab95f27f908267321518740cb7d4bb Author: Ainar Garipov <[email protected]> Date: Tue Jul 6 14:55:33 2021 +0300 dnsforward: fix panic
https://github.com/AdguardTeam/AdGuardHome/commit/1571609e5975be22e31d3ef7336a4ac6b1f08880
internal/dnsforward/dns.go
var v interface{} v, ok = s.tableIPToHost.Get(ip) var typOK bool if host, typOK = v.(string); !typOK { log.Error("dns: bad type %T in tableIPToHost for %s", v, ip) return "", false }
</s> remove return host, ok </s> add return host, true
if host, ok = v.(string); !ok {
var v interface{} v, ok = s.tableIPToHost.Get(ip) if host, ok = v.(string); !ok { if host, ok = v.(string); !ok { log.Error("dns: bad type %T in tableIPToHost for %s", v, ip) return "", false }
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request #1238: dnsforward: fix panic Updates #3318. Squashed commit of the following: commit eebaa3ac3a6bfcb29e280006ead8ea9554b8a3bf Author: Ainar Garipov <[email protected]> Date: Tue Jul 6 14:59:00 2021 +0300 dnsforward: imp code commit 7591a3b183ab95f27f908267321518740cb7d4bb Author: Ainar Garipov <[email protected]> Date: Tue Jul 6 14:55:33 2021 +0300 dnsforward: fix panic
https://github.com/AdguardTeam/AdGuardHome/commit/1571609e5975be22e31d3ef7336a4ac6b1f08880
internal/dnsforward/dns.go
return "", false } return host, ok } // Respond to PTR requests if the target IP is leased by our DHCP server and the // requestor is inside the local network. func (s *Server) processInternalIPAddrs(ctx *dnsContext) (rc resultCode) {
</s> remove var typOK bool if host, typOK = v.(string); !typOK { </s> add if host, ok = v.(string); !ok {
return host, true
return "", false } return host, true } // Respond to PTR requests if the target IP is leased by our DHCP server and the // requestor is inside the local network. func (s *Server) processInternalIPAddrs(ctx *dnsContext) (rc resultCode) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request #1238: dnsforward: fix panic Updates #3318. Squashed commit of the following: commit eebaa3ac3a6bfcb29e280006ead8ea9554b8a3bf Author: Ainar Garipov <[email protected]> Date: Tue Jul 6 14:59:00 2021 +0300 dnsforward: imp code commit 7591a3b183ab95f27f908267321518740cb7d4bb Author: Ainar Garipov <[email protected]> Date: Tue Jul 6 14:55:33 2021 +0300 dnsforward: fix panic
https://github.com/AdguardTeam/AdGuardHome/commit/1571609e5975be22e31d3ef7336a4ac6b1f08880
internal/dnsforward/dns.go
return safe } func UserPreferredCipherSuites(ciphers []string) (userCiphers []uint16) { for _, s := range tls.CipherSuites() { if slices.Contains(ciphers, s.Name) { userCiphers = append(userCiphers, s.ID) log.Debug("user specified cipher : %s, ID : %d", s.Name, s.ID) }
</s> remove func (web *Web) mustStartHTTP3(address string, ciphers []uint16) { </s> add func (web *Web) mustStartHTTP3(address string) { </s> remove var cipher []uint16 if len(web.conf.tlsCiphers) == 0 { cipher = aghtls.SaferCipherSuites() } else { cipher = aghtls.UserPreferredCipherSuites(web.conf.tlsCiphers) } </s> add </s> remove go web.mustStartHTTP3(addr, cipher) </s> add go web.mustStartHTTP3(addr)
// ParseCipherIDs returns a set of cipher suites with the cipher names provided func ParseCipherIDs(ciphers []string) (userCiphers []uint16) {
return safe } // ParseCipherIDs returns a set of cipher suites with the cipher names provided func ParseCipherIDs(ciphers []string) (userCiphers []uint16) { for _, s := range tls.CipherSuites() { if slices.Contains(ciphers, s.Name) { userCiphers = append(userCiphers, s.ID) log.Debug("user specified cipher : %s, ID : %d", s.Name, s.ID) }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
changes done as per review comments
https://github.com/AdguardTeam/AdGuardHome/commit/15b19ff7268da689933dd369862930afc98fcc8e
internal/aghtls/aghtls.go
userCiphers = append(userCiphers, s.ID) log.Debug("user specified cipher : %s, ID : %d", s.Name, s.ID) } } return userCiphers }
</s> remove func UserPreferredCipherSuites(ciphers []string) (userCiphers []uint16) { </s> add // ParseCipherIDs returns a set of cipher suites with the cipher names provided func ParseCipherIDs(ciphers []string) (userCiphers []uint16) { </s> remove var cipher []uint16 if len(web.conf.tlsCiphers) == 0 { cipher = aghtls.SaferCipherSuites() } else { cipher = aghtls.UserPreferredCipherSuites(web.conf.tlsCiphers) } </s> add </s> remove tlsCiphers: config.TLS.TLSCiphers, </s> add tlsCiphers: getTLSCiphers(), </s> remove func (web *Web) mustStartHTTP3(address string, ciphers []uint16) { </s> add func (web *Web) mustStartHTTP3(address string) {
} else { log.Error("unknown cipher : %s ", s)
userCiphers = append(userCiphers, s.ID) log.Debug("user specified cipher : %s, ID : %d", s.Name, s.ID) } else { log.Error("unknown cipher : %s ", s) } } return userCiphers }
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
changes done as per review comments
https://github.com/AdguardTeam/AdGuardHome/commit/15b19ff7268da689933dd369862930afc98fcc8e
internal/aghtls/aghtls.go
cert tls.Certificate // DNS names from certificate (SAN) or CN value from Subject dnsNames []string // ciphers specified by user TLSCiphers []string `yaml:"tls_ciphers" json:"-"` } // DNSCryptConfig is the DNSCrypt server configuration struct. type DNSCryptConfig struct { ResolverCert *dnscrypt.Cert
</s> remove // ciphers specified by user tlsCiphers []string </s> add </s> remove func UserPreferredCipherSuites(ciphers []string) (userCiphers []uint16) { </s> add // ParseCipherIDs returns a set of cipher suites with the cipher names provided func ParseCipherIDs(ciphers []string) (userCiphers []uint16) { </s> remove func (web *Web) mustStartHTTP3(address string, ciphers []uint16) { </s> add func (web *Web) mustStartHTTP3(address string) {
// OverrideTLSCiphers holds the cipher names. If the slice is empty // default set of ciphers are used for https listener, else this is // considered. OverrideTLSCiphers []string `yaml:"override_tls_ciphers" json:"-"`
cert tls.Certificate // DNS names from certificate (SAN) or CN value from Subject dnsNames []string // OverrideTLSCiphers holds the cipher names. If the slice is empty // default set of ciphers are used for https listener, else this is // considered. OverrideTLSCiphers []string `yaml:"override_tls_ciphers" json:"-"` // OverrideTLSCiphers holds the cipher names. If the slice is empty // default set of ciphers are used for https listener, else this is // considered. OverrideTLSCiphers []string `yaml:"override_tls_ciphers" json:"-"` } // DNSCryptConfig is the DNSCrypt server configuration struct. type DNSCryptConfig struct { ResolverCert *dnscrypt.Cert
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
changes done as per review comments
https://github.com/AdguardTeam/AdGuardHome/commit/15b19ff7268da689933dd369862930afc98fcc8e
internal/dnsforward/config.go
clientFS: clientFS, clientBetaFS: clientBetaFS, serveHTTP3: config.DNS.ServeHTTP3, tlsCiphers: config.TLS.TLSCiphers, } web = newWeb(&webConf) if web == nil { return nil, fmt.Errorf("initializing web: %w", err)
</s> remove var cipher []uint16 if len(web.conf.tlsCiphers) == 0 { cipher = aghtls.SaferCipherSuites() } else { cipher = aghtls.UserPreferredCipherSuites(web.conf.tlsCiphers) } </s> add </s> remove func UserPreferredCipherSuites(ciphers []string) (userCiphers []uint16) { </s> add // ParseCipherIDs returns a set of cipher suites with the cipher names provided func ParseCipherIDs(ciphers []string) (userCiphers []uint16) { </s> remove func (web *Web) mustStartHTTP3(address string, ciphers []uint16) { </s> add func (web *Web) mustStartHTTP3(address string) {
tlsCiphers: getTLSCiphers(),
clientFS: clientFS, clientBetaFS: clientBetaFS, serveHTTP3: config.DNS.ServeHTTP3, tlsCiphers: getTLSCiphers(), } web = newWeb(&webConf) if web == nil { return nil, fmt.Errorf("initializing web: %w", err)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
changes done as per review comments
https://github.com/AdguardTeam/AdGuardHome/commit/15b19ff7268da689933dd369862930afc98fcc8e
internal/home/home.go
type jsonError struct { // Message is the error message, an opaque string. Message string `json:"message"` }
</s> remove // ciphers specified by user tlsCiphers []string </s> add </s> remove func (web *Web) mustStartHTTP3(address string, ciphers []uint16) { </s> add func (web *Web) mustStartHTTP3(address string) { </s> remove // ciphers specified by user TLSCiphers []string `yaml:"tls_ciphers" json:"-"` </s> add // OverrideTLSCiphers holds the cipher names. If the slice is empty // default set of ciphers are used for https listener, else this is // considered. OverrideTLSCiphers []string `yaml:"override_tls_ciphers" json:"-"` </s> remove func UserPreferredCipherSuites(ciphers []string) (userCiphers []uint16) { </s> add // ParseCipherIDs returns a set of cipher suites with the cipher names provided func ParseCipherIDs(ciphers []string) (userCiphers []uint16) {
// getTLSCiphers check for overriden tls ciphers, if the slice is // empty, then default safe ciphers are used func getTLSCiphers() []uint16 { var cipher []uint16 if len(config.TLS.OverrideTLSCiphers) == 0 { cipher = aghtls.SaferCipherSuites() } else { cipher = aghtls.ParseCipherIDs(config.TLS.OverrideTLSCiphers) } return cipher }
type jsonError struct { // Message is the error message, an opaque string. Message string `json:"message"` } // getTLSCiphers check for overriden tls ciphers, if the slice is // empty, then default safe ciphers are used func getTLSCiphers() []uint16 { var cipher []uint16 if len(config.TLS.OverrideTLSCiphers) == 0 { cipher = aghtls.SaferCipherSuites() } else { cipher = aghtls.ParseCipherIDs(config.TLS.OverrideTLSCiphers) } return cipher }
[ "keep", "keep", "keep", "add" ]
changes done as per review comments
https://github.com/AdguardTeam/AdGuardHome/commit/15b19ff7268da689933dd369862930afc98fcc8e
internal/home/home.go
"time" "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" "github.com/AdguardTeam/AdGuardHome/internal/aghnet" "github.com/AdguardTeam/AdGuardHome/internal/aghtls" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log" "github.com/AdguardTeam/golibs/netutil" "github.com/NYTimes/gziphandler" "github.com/lucas-clemente/quic-go"
</s> remove CipherSuites: ciphers, </s> add CipherSuites: web.conf.tlsCiphers, </s> remove func (web *Web) mustStartHTTP3(address string, ciphers []uint16) { </s> add func (web *Web) mustStartHTTP3(address string) { </s> remove go web.mustStartHTTP3(addr, cipher) </s> add go web.mustStartHTTP3(addr) </s> remove CipherSuites: cipher, </s> add CipherSuites: web.conf.tlsCiphers, </s> remove var cipher []uint16 if len(web.conf.tlsCiphers) == 0 { cipher = aghtls.SaferCipherSuites() } else { cipher = aghtls.UserPreferredCipherSuites(web.conf.tlsCiphers) } </s> add
"time" "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" "github.com/AdguardTeam/AdGuardHome/internal/aghnet" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log" "github.com/AdguardTeam/golibs/netutil" "github.com/NYTimes/gziphandler" "github.com/lucas-clemente/quic-go"
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
changes done as per review comments
https://github.com/AdguardTeam/AdGuardHome/commit/15b19ff7268da689933dd369862930afc98fcc8e
internal/home/web.go
writeTimeout = 60 * time.Second ) type webConfig struct { clientFS fs.FS clientBetaFS fs.FS BindHost net.IP
</s> remove // ciphers specified by user tlsCiphers []string </s> add </s> remove var cipher []uint16 if len(web.conf.tlsCiphers) == 0 { cipher = aghtls.SaferCipherSuites() } else { cipher = aghtls.UserPreferredCipherSuites(web.conf.tlsCiphers) } </s> add </s> remove // ciphers specified by user TLSCiphers []string `yaml:"tls_ciphers" json:"-"` </s> add // OverrideTLSCiphers holds the cipher names. If the slice is empty // default set of ciphers are used for https listener, else this is // considered. OverrideTLSCiphers []string `yaml:"override_tls_ciphers" json:"-"` </s> remove func UserPreferredCipherSuites(ciphers []string) (userCiphers []uint16) { </s> add // ParseCipherIDs returns a set of cipher suites with the cipher names provided func ParseCipherIDs(ciphers []string) (userCiphers []uint16) {
// Ciphers that are used for https listener tlsCiphers []uint16
writeTimeout = 60 * time.Second ) type webConfig struct { // Ciphers that are used for https listener tlsCiphers []uint16 clientFS fs.FS clientBetaFS fs.FS BindHost net.IP
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
changes done as per review comments
https://github.com/AdguardTeam/AdGuardHome/commit/15b19ff7268da689933dd369862930afc98fcc8e
internal/home/web.go
firstRun bool serveHTTP3 bool // ciphers specified by user tlsCiphers []string } // httpsServer contains the data for the HTTPS server. type httpsServer struct { // server is the pre-HTTP/3 HTTPS server.
</s> remove // ciphers specified by user TLSCiphers []string `yaml:"tls_ciphers" json:"-"` </s> add // OverrideTLSCiphers holds the cipher names. If the slice is empty // default set of ciphers are used for https listener, else this is // considered. OverrideTLSCiphers []string `yaml:"override_tls_ciphers" json:"-"` </s> remove func (web *Web) mustStartHTTP3(address string, ciphers []uint16) { </s> add func (web *Web) mustStartHTTP3(address string) { </s> remove func UserPreferredCipherSuites(ciphers []string) (userCiphers []uint16) { </s> add // ParseCipherIDs returns a set of cipher suites with the cipher names provided func ParseCipherIDs(ciphers []string) (userCiphers []uint16) {
firstRun bool serveHTTP3 bool } // httpsServer contains the data for the HTTPS server. type httpsServer struct { // server is the pre-HTTP/3 HTTPS server.
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
changes done as per review comments
https://github.com/AdguardTeam/AdGuardHome/commit/15b19ff7268da689933dd369862930afc98fcc8e
internal/home/web.go
} web.httpsServer.cond.L.Unlock() var cipher []uint16 if len(web.conf.tlsCiphers) == 0 { cipher = aghtls.SaferCipherSuites() } else { cipher = aghtls.UserPreferredCipherSuites(web.conf.tlsCiphers) } addr := netutil.JoinHostPort(web.conf.BindHost.String(), web.conf.PortHTTPS) web.httpsServer.server = &http.Server{ ErrorLog: log.StdLog("web: https", log.DEBUG), Addr: addr, TLSConfig: &tls.Config{
</s> remove func UserPreferredCipherSuites(ciphers []string) (userCiphers []uint16) { </s> add // ParseCipherIDs returns a set of cipher suites with the cipher names provided func ParseCipherIDs(ciphers []string) (userCiphers []uint16) { </s> remove CipherSuites: ciphers, </s> add CipherSuites: web.conf.tlsCiphers, </s> remove CipherSuites: cipher, </s> add CipherSuites: web.conf.tlsCiphers,
} web.httpsServer.cond.L.Unlock() addr := netutil.JoinHostPort(web.conf.BindHost.String(), web.conf.PortHTTPS) web.httpsServer.server = &http.Server{ ErrorLog: log.StdLog("web: https", log.DEBUG), Addr: addr, TLSConfig: &tls.Config{
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
changes done as per review comments
https://github.com/AdguardTeam/AdGuardHome/commit/15b19ff7268da689933dd369862930afc98fcc8e
internal/home/web.go
Addr: addr, TLSConfig: &tls.Config{ Certificates: []tls.Certificate{web.httpsServer.cert}, RootCAs: Context.tlsRoots, CipherSuites: cipher, MinVersion: tls.VersionTLS12, }, Handler: withMiddlewares(Context.mux, limitRequestBody), ReadTimeout: web.conf.ReadTimeout, ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
</s> remove CipherSuites: ciphers, </s> add CipherSuites: web.conf.tlsCiphers, </s> remove var cipher []uint16 if len(web.conf.tlsCiphers) == 0 { cipher = aghtls.SaferCipherSuites() } else { cipher = aghtls.UserPreferredCipherSuites(web.conf.tlsCiphers) } </s> add </s> remove func (web *Web) mustStartHTTP3(address string, ciphers []uint16) { </s> add func (web *Web) mustStartHTTP3(address string) { </s> remove go web.mustStartHTTP3(addr, cipher) </s> add go web.mustStartHTTP3(addr) </s> remove // ciphers specified by user tlsCiphers []string </s> add
CipherSuites: web.conf.tlsCiphers,
Addr: addr, TLSConfig: &tls.Config{ Certificates: []tls.Certificate{web.httpsServer.cert}, RootCAs: Context.tlsRoots, CipherSuites: web.conf.tlsCiphers, MinVersion: tls.VersionTLS12, }, Handler: withMiddlewares(Context.mux, limitRequestBody), ReadTimeout: web.conf.ReadTimeout, ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
changes done as per review comments
https://github.com/AdguardTeam/AdGuardHome/commit/15b19ff7268da689933dd369862930afc98fcc8e
internal/home/web.go
printHTTPAddresses(aghhttp.SchemeHTTPS) if web.conf.serveHTTP3 { go web.mustStartHTTP3(addr, cipher) } log.Debug("web: starting https server") err := web.httpsServer.server.ListenAndServeTLS("", "") if !errors.Is(err, http.ErrServerClosed) {
</s> remove var cipher []uint16 if len(web.conf.tlsCiphers) == 0 { cipher = aghtls.SaferCipherSuites() } else { cipher = aghtls.UserPreferredCipherSuites(web.conf.tlsCiphers) } </s> add </s> remove func UserPreferredCipherSuites(ciphers []string) (userCiphers []uint16) { </s> add // ParseCipherIDs returns a set of cipher suites with the cipher names provided func ParseCipherIDs(ciphers []string) (userCiphers []uint16) { </s> remove func (web *Web) mustStartHTTP3(address string, ciphers []uint16) { </s> add func (web *Web) mustStartHTTP3(address string) {
go web.mustStartHTTP3(addr)
printHTTPAddresses(aghhttp.SchemeHTTPS) if web.conf.serveHTTP3 { go web.mustStartHTTP3(addr) } log.Debug("web: starting https server") err := web.httpsServer.server.ListenAndServeTLS("", "") if !errors.Is(err, http.ErrServerClosed) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
changes done as per review comments
https://github.com/AdguardTeam/AdGuardHome/commit/15b19ff7268da689933dd369862930afc98fcc8e
internal/home/web.go
} } } func (web *Web) mustStartHTTP3(address string, ciphers []uint16) { defer log.OnPanic("web: http3") web.httpsServer.server3 = &http3.Server{ // TODO(a.garipov): See if there is a way to use the error log as // well as timeouts here.
</s> remove func UserPreferredCipherSuites(ciphers []string) (userCiphers []uint16) { </s> add // ParseCipherIDs returns a set of cipher suites with the cipher names provided func ParseCipherIDs(ciphers []string) (userCiphers []uint16) { </s> remove // ciphers specified by user tlsCiphers []string </s> add </s> remove // ciphers specified by user TLSCiphers []string `yaml:"tls_ciphers" json:"-"` </s> add // OverrideTLSCiphers holds the cipher names. If the slice is empty // default set of ciphers are used for https listener, else this is // considered. OverrideTLSCiphers []string `yaml:"override_tls_ciphers" json:"-"` </s> remove var cipher []uint16 if len(web.conf.tlsCiphers) == 0 { cipher = aghtls.SaferCipherSuites() } else { cipher = aghtls.UserPreferredCipherSuites(web.conf.tlsCiphers) } </s> add
func (web *Web) mustStartHTTP3(address string) {
} } } func (web *Web) mustStartHTTP3(address string) { defer log.OnPanic("web: http3") web.httpsServer.server3 = &http3.Server{ // TODO(a.garipov): See if there is a way to use the error log as // well as timeouts here.
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
changes done as per review comments
https://github.com/AdguardTeam/AdGuardHome/commit/15b19ff7268da689933dd369862930afc98fcc8e
internal/home/web.go
Addr: address, TLSConfig: &tls.Config{ Certificates: []tls.Certificate{web.httpsServer.cert}, RootCAs: Context.tlsRoots, CipherSuites: ciphers, MinVersion: tls.VersionTLS12, }, Handler: withMiddlewares(Context.mux, limitRequestBody), }
</s> remove CipherSuites: cipher, </s> add CipherSuites: web.conf.tlsCiphers, </s> remove var cipher []uint16 if len(web.conf.tlsCiphers) == 0 { cipher = aghtls.SaferCipherSuites() } else { cipher = aghtls.UserPreferredCipherSuites(web.conf.tlsCiphers) } </s> add </s> remove func (web *Web) mustStartHTTP3(address string, ciphers []uint16) { </s> add func (web *Web) mustStartHTTP3(address string) {
CipherSuites: web.conf.tlsCiphers,
Addr: address, TLSConfig: &tls.Config{ Certificates: []tls.Certificate{web.httpsServer.cert}, RootCAs: Context.tlsRoots, CipherSuites: web.conf.tlsCiphers, MinVersion: tls.VersionTLS12, }, Handler: withMiddlewares(Context.mux, limitRequestBody), }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
changes done as per review comments
https://github.com/AdguardTeam/AdGuardHome/commit/15b19ff7268da689933dd369862930afc98fcc8e
internal/home/web.go
go 1.19 require ( github.com/AdguardTeam/dnsproxy v0.48.3 github.com/AdguardTeam/golibs v0.13.1 github.com/AdguardTeam/urlfilter v0.16.1 github.com/NYTimes/gziphandler v1.1.1 github.com/ameshkov/dnscrypt/v2 v2.2.6 github.com/digineo/go-ipset/v2 v2.2.1 github.com/dimfeld/httptreemux/v5 v5.5.0
</s> remove github.com/AdguardTeam/golibs v0.13.1 h1:x6ChoXk2jborbCWJ01TyBAEY3SilHts0SCG7yjnf6Sc= github.com/AdguardTeam/golibs v0.13.1/go.mod h1:7ylQLv2Lqsc3UW3jHoITynYk6Y1tYtgEMkR09ppfsN8= </s> add github.com/AdguardTeam/golibs v0.13.2 h1:BPASsyQKmb+b8VnvsNOHp7bKfcZl9Z+Z2UhPjOiupSc= github.com/AdguardTeam/golibs v0.13.2/go.mod h1:7ylQLv2Lqsc3UW3jHoITynYk6Y1tYtgEMkR09ppfsN8= </s> remove loginURL := w.hdr.Get("Location") </s> add loginURL := w.hdr.Get(httphdr.Location) </s> remove assert.NotEmpty(t, w.hdr.Get("Location")) </s> add assert.NotEmpty(t, w.hdr.Get(httphdr.Location))
github.com/AdguardTeam/golibs v0.13.2
go 1.19 require ( github.com/AdguardTeam/dnsproxy v0.48.3 github.com/AdguardTeam/golibs v0.13.2 github.com/AdguardTeam/urlfilter v0.16.1 github.com/NYTimes/gziphandler v1.1.1 github.com/ameshkov/dnscrypt/v2 v2.2.6 github.com/digineo/go-ipset/v2 v2.2.1 github.com/dimfeld/httptreemux/v5 v5.5.0
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
go.mod
github.com/AdguardTeam/dnsproxy v0.48.3 h1:h9xgDSmd1MqsPFNApyaPVXolmSTtzOWOcfWvPeDEP6s= github.com/AdguardTeam/dnsproxy v0.48.3/go.mod h1:Y7g7jRTd/u7+KJ/QvnGI2PCE8vnisp6EsW47/Sz0DZw= github.com/AdguardTeam/golibs v0.4.0/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= github.com/AdguardTeam/golibs v0.10.4/go.mod h1:rSfQRGHIdgfxriDDNgNJ7HmE5zRoURq8R+VdR81Zuzw= github.com/AdguardTeam/golibs v0.13.1 h1:x6ChoXk2jborbCWJ01TyBAEY3SilHts0SCG7yjnf6Sc= github.com/AdguardTeam/golibs v0.13.1/go.mod h1:7ylQLv2Lqsc3UW3jHoITynYk6Y1tYtgEMkR09ppfsN8= github.com/AdguardTeam/gomitmproxy v0.2.0/go.mod h1:Qdv0Mktnzer5zpdpi5rAwixNJzW2FN91LjKJCkVbYGU= github.com/AdguardTeam/urlfilter v0.16.1 h1:ZPi0rjqo8cQf2FVdzo6cqumNoHZx2KPXj2yZa1A5BBw= github.com/AdguardTeam/urlfilter v0.16.1/go.mod h1:46YZDOV1+qtdRDuhZKVPSSp7JWWes0KayqHrKAFBdEI= github.com/NYTimes/gziphandler v1.1.1 h1:ZUDjpQae29j0ryrS0u/B8HZfJBtBQHjqw2rQ2cqUQ3I= github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c=
</s> remove github.com/AdguardTeam/golibs v0.13.1 </s> add github.com/AdguardTeam/golibs v0.13.2 </s> remove w.Header().Set("Retry-After", strconv.Itoa(int(left.Seconds()))) </s> add w.Header().Set(httphdr.RetryAfter, strconv.Itoa(int(left.Seconds()))) </s> remove r.Header.Set("Cookie", cookie.String()) </s> add r.Header.Set(httphdr.Cookie, cookie.String()) </s> remove loginURL := w.hdr.Get("Location") </s> add loginURL := w.hdr.Get(httphdr.Location) </s> remove assert.NotEmpty(t, w.hdr.Get("Location")) </s> add assert.NotEmpty(t, w.hdr.Get(httphdr.Location))
github.com/AdguardTeam/golibs v0.13.2 h1:BPASsyQKmb+b8VnvsNOHp7bKfcZl9Z+Z2UhPjOiupSc= github.com/AdguardTeam/golibs v0.13.2/go.mod h1:7ylQLv2Lqsc3UW3jHoITynYk6Y1tYtgEMkR09ppfsN8=
github.com/AdguardTeam/dnsproxy v0.48.3 h1:h9xgDSmd1MqsPFNApyaPVXolmSTtzOWOcfWvPeDEP6s= github.com/AdguardTeam/dnsproxy v0.48.3/go.mod h1:Y7g7jRTd/u7+KJ/QvnGI2PCE8vnisp6EsW47/Sz0DZw= github.com/AdguardTeam/golibs v0.4.0/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= github.com/AdguardTeam/golibs v0.10.4/go.mod h1:rSfQRGHIdgfxriDDNgNJ7HmE5zRoURq8R+VdR81Zuzw= github.com/AdguardTeam/golibs v0.13.2 h1:BPASsyQKmb+b8VnvsNOHp7bKfcZl9Z+Z2UhPjOiupSc= github.com/AdguardTeam/golibs v0.13.2/go.mod h1:7ylQLv2Lqsc3UW3jHoITynYk6Y1tYtgEMkR09ppfsN8= github.com/AdguardTeam/golibs v0.13.2 h1:BPASsyQKmb+b8VnvsNOHp7bKfcZl9Z+Z2UhPjOiupSc= github.com/AdguardTeam/golibs v0.13.2/go.mod h1:7ylQLv2Lqsc3UW3jHoITynYk6Y1tYtgEMkR09ppfsN8= github.com/AdguardTeam/gomitmproxy v0.2.0/go.mod h1:Qdv0Mktnzer5zpdpi5rAwixNJzW2FN91LjKJCkVbYGU= github.com/AdguardTeam/urlfilter v0.16.1 h1:ZPi0rjqo8cQf2FVdzo6cqumNoHZx2KPXj2yZa1A5BBw= github.com/AdguardTeam/urlfilter v0.16.1/go.mod h1:46YZDOV1+qtdRDuhZKVPSSp7JWWes0KayqHrKAFBdEI= github.com/NYTimes/gziphandler v1.1.1 h1:ZUDjpQae29j0ryrS0u/B8HZfJBtBQHjqw2rQ2cqUQ3I= github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c=
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
go.sum
"net/http" "github.com/AdguardTeam/AdGuardHome/internal/version" "github.com/AdguardTeam/golibs/log" ) // HTTP scheme constants. const ( SchemeHTTP = "http"
</s> remove // HTTP Headers // HTTP header name constants. // // TODO(a.garipov): Remove unused. const ( HdrNameAcceptEncoding = "Accept-Encoding" HdrNameAccessControlAllowOrigin = "Access-Control-Allow-Origin" HdrNameAltSvc = "Alt-Svc" HdrNameContentEncoding = "Content-Encoding" HdrNameContentType = "Content-Type" HdrNameOrigin = "Origin" HdrNameServer = "Server" HdrNameTrailer = "Trailer" HdrNameUserAgent = "User-Agent" HdrNameVary = "Vary" ) </s> add // HTTP headers </s> remove import "net/http" </s> add import ( "net/http" "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" "github.com/AdguardTeam/golibs/httphdr" ) </s> remove w.Header().Set("Content-Type", "application/xml") </s> add w.Header().Set(httphdr.ContentType, "application/xml")
"github.com/AdguardTeam/golibs/httphdr"
"net/http" "github.com/AdguardTeam/AdGuardHome/internal/version" "github.com/AdguardTeam/golibs/httphdr" "github.com/AdguardTeam/golibs/log" ) // HTTP scheme constants. const ( SchemeHTTP = "http"
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/aghhttp/aghhttp.go
// WriteTextPlainDeprecated responds to the request with a message about // deprecation and removal of a plain-text API if the request is made with the // "text/plain" content-type. func WriteTextPlainDeprecated(w http.ResponseWriter, r *http.Request) (isPlainText bool) { if r.Header.Get(HdrNameContentType) != HdrValTextPlain { return false } Error(r, w, http.StatusUnsupportedMediaType, textPlainDeprMsg)
</s> remove cType := r.Header.Get(aghhttp.HdrNameContentType) </s> add cType := r.Header.Get(httphdr.ContentType) </s> remove w.Header().Set(HdrNameContentType, HdrValApplicationJSON) </s> add w.Header().Set(httphdr.ContentType, HdrValApplicationJSON) </s> remove w.Header().Set("Content-Type", "application/json") </s> add w.Header().Set(httphdr.ContentType, aghhttp.HdrValApplicationJSON) </s> remove respHdr.Set(aghhttp.HdrNameAltSvc, altSvc) </s> add respHdr.Set(httphdr.AltSvc, altSvc) </s> remove h.Set(aghhttp.HdrNameContentType, aghhttp.HdrValApplicationJSON) h.Set(aghhttp.HdrNameServer, aghhttp.UserAgent()) </s> add h.Set(httphdr.ContentType, aghhttp.HdrValApplicationJSON) h.Set(httphdr.Server, aghhttp.UserAgent())
if r.Header.Get(httphdr.ContentType) != HdrValTextPlain {
// WriteTextPlainDeprecated responds to the request with a message about // deprecation and removal of a plain-text API if the request is made with the // "text/plain" content-type. func WriteTextPlainDeprecated(w http.ResponseWriter, r *http.Request) (isPlainText bool) { if r.Header.Get(httphdr.ContentType) != HdrValTextPlain { return false } Error(r, w, http.StatusUnsupportedMediaType, textPlainDeprMsg)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/aghhttp/aghhttp.go
// WriteJSONResponseCode is like [WriteJSONResponse] but adds the ability to // redefine the status code. func WriteJSONResponseCode(w http.ResponseWriter, r *http.Request, code int, resp any) (err error) { w.WriteHeader(code) w.Header().Set(HdrNameContentType, HdrValApplicationJSON) err = json.NewEncoder(w).Encode(resp) if err != nil { Error(r, w, http.StatusInternalServerError, "encoding resp: %s", err) }
</s> remove h.Set(aghhttp.HdrNameContentType, aghhttp.HdrValApplicationJSON) h.Set(aghhttp.HdrNameServer, aghhttp.UserAgent()) </s> add h.Set(httphdr.ContentType, aghhttp.HdrValApplicationJSON) h.Set(httphdr.Server, aghhttp.UserAgent()) </s> remove if r.Header.Get(HdrNameContentType) != HdrValTextPlain { </s> add if r.Header.Get(httphdr.ContentType) != HdrValTextPlain { </s> remove req.Header.Set("Content-Type", cType) </s> add req.Header.Set(httphdr.ContentType, cType) </s> remove respHdr.Set("Location", "/login.html") </s> add respHdr.Set(httphdr.Location, "/login.html") </s> remove w.Header().Set("Location", "/") </s> add w.Header().Set(httphdr.Location, "/")
w.Header().Set(httphdr.ContentType, HdrValApplicationJSON)
// WriteJSONResponseCode is like [WriteJSONResponse] but adds the ability to // redefine the status code. func WriteJSONResponseCode(w http.ResponseWriter, r *http.Request, code int, resp any) (err error) { w.WriteHeader(code) w.Header().Set(httphdr.ContentType, HdrValApplicationJSON) err = json.NewEncoder(w).Encode(resp) if err != nil { Error(r, w, http.StatusInternalServerError, "encoding resp: %s", err) }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/aghhttp/aghhttp.go
package aghhttp // HTTP Headers // HTTP header name constants. // // TODO(a.garipov): Remove unused. const ( HdrNameAcceptEncoding = "Accept-Encoding" HdrNameAccessControlAllowOrigin = "Access-Control-Allow-Origin" HdrNameAltSvc = "Alt-Svc" HdrNameContentEncoding = "Content-Encoding" HdrNameContentType = "Content-Type" HdrNameOrigin = "Origin" HdrNameServer = "Server" HdrNameTrailer = "Trailer" HdrNameUserAgent = "User-Agent" HdrNameVary = "Vary" ) // HTTP header value constants. const ( HdrValApplicationJSON = "application/json" HdrValTextPlain = "text/plain"
</s> remove w.Header().Set("Content-Type", "application/xml") </s> add w.Header().Set(httphdr.ContentType, "application/xml") </s> remove "CF-Connecting-IP", "True-Client-IP", "X-Real-IP", </s> add httphdr.CFConnectingIP, httphdr.TrueClientIP, httphdr.XRealIP, </s> remove import "net/http" </s> add import ( "net/http" "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" "github.com/AdguardTeam/golibs/httphdr" )
// HTTP headers
package aghhttp // HTTP headers // HTTP headers // HTTP headers // HTTP headers // HTTP headers // HTTP headers // HTTP headers // HTTP headers // HTTP headers // HTTP headers // HTTP headers // HTTP headers // HTTP headers // HTTP headers // HTTP headers // HTTP headers // HTTP headers // HTTP header value constants. const ( HdrValApplicationJSON = "application/json" HdrValTextPlain = "text/plain"
[ "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/aghhttp/header.go
"github.com/AdguardTeam/AdGuardHome/internal/aghnet" "github.com/AdguardTeam/AdGuardHome/internal/filtering" "github.com/AdguardTeam/golibs/netutil" "github.com/AdguardTeam/golibs/testutil" "github.com/miekg/dns" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" )
</s>
"github.com/AdguardTeam/golibs/httphdr"
"github.com/AdguardTeam/AdGuardHome/internal/aghnet" "github.com/AdguardTeam/AdGuardHome/internal/filtering" "github.com/AdguardTeam/golibs/httphdr" "github.com/AdguardTeam/golibs/netutil" "github.com/AdguardTeam/golibs/testutil" "github.com/miekg/dns" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" )
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/dnsforward/http_test.go
s.conf = tc.conf() s.handleGetConfig(w, nil) cType := w.Header().Get(aghhttp.HdrNameContentType) assert.Equal(t, aghhttp.HdrValApplicationJSON, cType) assert.JSONEq(t, string(caseWant), w.Body.String()) }) } }
</s> remove cType := r.Header.Get(aghhttp.HdrNameContentType) </s> add cType := r.Header.Get(httphdr.ContentType) </s> remove req.Header.Set("Content-Type", cType) </s> add req.Header.Set(httphdr.ContentType, cType) </s> remove assert.NotEmpty(t, w.hdr.Get("Location")) </s> add assert.NotEmpty(t, w.hdr.Get(httphdr.Location)) </s> remove w.Header().Set("Retry-After", strconv.Itoa(int(left.Seconds()))) </s> add w.Header().Set(httphdr.RetryAfter, strconv.Itoa(int(left.Seconds()))) </s> remove s := r.Header.Get("X-Forwarded-For") </s> add s := r.Header.Get(httphdr.XForwardedFor)
cType := w.Header().Get(httphdr.ContentType)
s.conf = tc.conf() s.handleGetConfig(w, nil) cType := w.Header().Get(httphdr.ContentType) assert.Equal(t, aghhttp.HdrValApplicationJSON, cType) assert.JSONEq(t, string(caseWant), w.Body.String()) }) } }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/dnsforward/http_test.go
"github.com/AdguardTeam/AdGuardHome/internal/aghhttp" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log" "github.com/AdguardTeam/golibs/netutil" "github.com/AdguardTeam/golibs/timeutil" "go.etcd.io/bbolt"
</s>
"github.com/AdguardTeam/golibs/httphdr"
"github.com/AdguardTeam/AdGuardHome/internal/aghhttp" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/httphdr" "github.com/AdguardTeam/golibs/log" "github.com/AdguardTeam/golibs/netutil" "github.com/AdguardTeam/golibs/timeutil" "go.etcd.io/bbolt"
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/home/auth.go
// // TODO(a.garipov): Support header Forwarded from RFC 7329. func realIP(r *http.Request) (ip net.IP, err error) { proxyHeaders := []string{ "CF-Connecting-IP", "True-Client-IP", "X-Real-IP", } for _, h := range proxyHeaders { v := r.Header.Get(h) ip = net.ParseIP(v)
</s> remove h.Set(aghhttp.HdrNameContentType, aghhttp.HdrValApplicationJSON) h.Set(aghhttp.HdrNameServer, aghhttp.UserAgent()) </s> add h.Set(httphdr.ContentType, aghhttp.HdrValApplicationJSON) h.Set(httphdr.Server, aghhttp.UserAgent()) </s> remove s := r.Header.Get("X-Forwarded-For") </s> add s := r.Header.Get(httphdr.XForwardedFor) </s> remove respHdr.Set("Location", "/login.html") </s> add respHdr.Set(httphdr.Location, "/login.html") </s> remove w.Header().Set("Content-Disposition", contDisp) </s> add w.Header().Set(httphdr.ContentDisposition, contDisp) </s> remove h.Set("Content-Type", "application/json") </s> add h.Set(httphdr.ContentType, aghhttp.HdrValApplicationJSON)
httphdr.CFConnectingIP, httphdr.TrueClientIP, httphdr.XRealIP,
// // TODO(a.garipov): Support header Forwarded from RFC 7329. func realIP(r *http.Request) (ip net.IP, err error) { proxyHeaders := []string{ httphdr.CFConnectingIP, httphdr.TrueClientIP, httphdr.XRealIP, httphdr.CFConnectingIP, httphdr.TrueClientIP, httphdr.XRealIP, httphdr.CFConnectingIP, httphdr.TrueClientIP, httphdr.XRealIP, } for _, h := range proxyHeaders { v := r.Header.Get(h) ip = net.ParseIP(v)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/home/auth.go
} // If none of the above yielded any results, get the leftmost IP address // from the X-Forwarded-For header. s := r.Header.Get("X-Forwarded-For") ipStrs := strings.SplitN(s, ", ", 2) ip = net.ParseIP(ipStrs[0]) if ip != nil { return ip, nil }
</s> remove if r.Header.Get(HdrNameContentType) != HdrValTextPlain { </s> add if r.Header.Get(httphdr.ContentType) != HdrValTextPlain { </s> remove w.Header().Set("Location", "/") </s> add w.Header().Set(httphdr.Location, "/") </s> remove respHdr.Set(aghhttp.HdrNameAltSvc, altSvc) </s> add respHdr.Set(httphdr.AltSvc, altSvc) </s> remove w.Header().Set("Content-Type", "application/json") </s> add w.Header().Set(httphdr.ContentType, aghhttp.HdrValApplicationJSON) </s> remove respHdr.Set("Location", "/login.html") </s> add respHdr.Set(httphdr.Location, "/login.html")
s := r.Header.Get(httphdr.XForwardedFor)
} // If none of the above yielded any results, get the leftmost IP address // from the X-Forwarded-For header. s := r.Header.Get(httphdr.XForwardedFor) ipStrs := strings.SplitN(s, ", ", 2) ip = net.ParseIP(ipStrs[0]) if ip != nil { return ip, nil }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/home/auth.go
} if rateLimiter := Context.auth.raleLimiter; rateLimiter != nil { if left := rateLimiter.check(remoteAddr); left > 0 { w.Header().Set("Retry-After", strconv.Itoa(int(left.Seconds()))) aghhttp.Error(r, w, http.StatusTooManyRequests, "auth: blocked for %s", left) return } }
</s> remove req.Header.Set("Content-Type", cType) </s> add req.Header.Set(httphdr.ContentType, cType) </s> remove cType := r.Header.Get(aghhttp.HdrNameContentType) </s> add cType := r.Header.Get(httphdr.ContentType) </s> remove s := r.Header.Get("X-Forwarded-For") </s> add s := r.Header.Get(httphdr.XForwardedFor) </s> remove w.Header().Set(HdrNameContentType, HdrValApplicationJSON) </s> add w.Header().Set(httphdr.ContentType, HdrValApplicationJSON) </s> remove h.Set("Content-Disposition", d) </s> add h.Set(httphdr.ContentDisposition, d)
w.Header().Set(httphdr.RetryAfter, strconv.Itoa(int(left.Seconds())))
} if rateLimiter := Context.auth.raleLimiter; rateLimiter != nil { if left := rateLimiter.check(remoteAddr); left > 0 { w.Header().Set(httphdr.RetryAfter, strconv.Itoa(int(left.Seconds()))) aghhttp.Error(r, w, http.StatusTooManyRequests, "auth: blocked for %s", left) return } }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/home/auth.go
http.SetCookie(w, cookie) h := w.Header() h.Set("Cache-Control", "no-store, no-cache, must-revalidate, proxy-revalidate") h.Set("Pragma", "no-cache") h.Set("Expires", "0") aghhttp.OK(w) } func handleLogout(w http.ResponseWriter, r *http.Request) {
</s> remove h.Set(aghhttp.HdrNameContentType, aghhttp.HdrValApplicationJSON) h.Set(aghhttp.HdrNameServer, aghhttp.UserAgent()) </s> add h.Set(httphdr.ContentType, aghhttp.HdrValApplicationJSON) h.Set(httphdr.Server, aghhttp.UserAgent()) </s> remove w.Header().Set("Content-Disposition", contDisp) </s> add w.Header().Set(httphdr.ContentDisposition, contDisp) </s> remove w.Header().Set("Content-Type", "application/json") </s> add w.Header().Set(httphdr.ContentType, aghhttp.HdrValApplicationJSON) </s> remove cType := r.Header.Get(aghhttp.HdrNameContentType) </s> add cType := r.Header.Get(httphdr.ContentType) </s> remove "CF-Connecting-IP", "True-Client-IP", "X-Real-IP", </s> add httphdr.CFConnectingIP, httphdr.TrueClientIP, httphdr.XRealIP,
h.Set(httphdr.CacheControl, "no-store, no-cache, must-revalidate, proxy-revalidate") h.Set(httphdr.Pragma, "no-cache") h.Set(httphdr.Expires, "0")
http.SetCookie(w, cookie) h := w.Header() h.Set(httphdr.CacheControl, "no-store, no-cache, must-revalidate, proxy-revalidate") h.Set(httphdr.Pragma, "no-cache") h.Set(httphdr.Expires, "0") h.Set(httphdr.CacheControl, "no-store, no-cache, must-revalidate, proxy-revalidate") h.Set(httphdr.Pragma, "no-cache") h.Set(httphdr.Expires, "0") h.Set(httphdr.CacheControl, "no-store, no-cache, must-revalidate, proxy-revalidate") h.Set(httphdr.Pragma, "no-cache") h.Set(httphdr.Expires, "0") aghhttp.OK(w) } func handleLogout(w http.ResponseWriter, r *http.Request) {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/home/auth.go
c, err := r.Cookie(sessionCookieName) if err != nil { // The only error that is returned from r.Cookie is [http.ErrNoCookie]. // The user is already logged out. respHdr.Set("Location", "/login.html") w.WriteHeader(http.StatusFound) return }
</s> remove w.Header().Set("Location", "/") </s> add w.Header().Set(httphdr.Location, "/") </s> remove req.Header.Set("Content-Type", cType) </s> add req.Header.Set(httphdr.ContentType, cType) </s> remove w.Header().Set(HdrNameContentType, HdrValApplicationJSON) </s> add w.Header().Set(httphdr.ContentType, HdrValApplicationJSON) </s> remove respHdr.Set("Location", "/login.html") respHdr.Set("Set-Cookie", c.String()) </s> add respHdr.Set(httphdr.Location, "/login.html") respHdr.Set(httphdr.SetCookie, c.String()) </s> remove respHdr.Set(aghhttp.HdrNameAccessControlAllowOrigin, originURL.String()) respHdr.Set(aghhttp.HdrNameVary, aghhttp.HdrNameOrigin) </s> add respHdr.Set(httphdr.AccessControlAllowOrigin, originURL.String()) respHdr.Set(httphdr.Vary, httphdr.Origin)
respHdr.Set(httphdr.Location, "/login.html")
c, err := r.Cookie(sessionCookieName) if err != nil { // The only error that is returned from r.Cookie is [http.ErrNoCookie]. // The user is already logged out. respHdr.Set(httphdr.Location, "/login.html") w.WriteHeader(http.StatusFound) return }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/home/auth.go
HttpOnly: true, SameSite: http.SameSiteLaxMode, } respHdr.Set("Location", "/login.html") respHdr.Set("Set-Cookie", c.String()) w.WriteHeader(http.StatusFound) } // RegisterAuthHandlers - register handlers func RegisterAuthHandlers() {
</s> remove respHdr.Set("Location", "/login.html") </s> add respHdr.Set(httphdr.Location, "/login.html") </s> remove w.Header().Set("Location", "/login.html") </s> add w.Header().Set(httphdr.Location, "/login.html") </s> remove w.Header().Set("Location", "/") </s> add w.Header().Set(httphdr.Location, "/") </s> remove r.Header.Del("Authorization") </s> add r.Header.Del(httphdr.Authorization) </s> remove r.Header.Set("Cookie", cookie.String()) </s> add r.Header.Set(httphdr.Cookie, cookie.String())
respHdr.Set(httphdr.Location, "/login.html") respHdr.Set(httphdr.SetCookie, c.String())
HttpOnly: true, SameSite: http.SameSiteLaxMode, } respHdr.Set(httphdr.Location, "/login.html") respHdr.Set(httphdr.SetCookie, c.String()) respHdr.Set(httphdr.Location, "/login.html") respHdr.Set(httphdr.SetCookie, c.String()) w.WriteHeader(http.StatusFound) } // RegisterAuthHandlers - register handlers func RegisterAuthHandlers() {
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/home/auth.go
if glProcessRedirect(w, r) { log.Debug("auth: redirected to login page by GL-Inet submodule") } else { log.Debug("auth: redirected to login page") w.Header().Set("Location", "/login.html") w.WriteHeader(http.StatusFound) } } else { log.Debug("auth: responded with forbidden to %s %s", r.Method, p) w.WriteHeader(http.StatusForbidden)
</s> remove r.Header.Del("Authorization") </s> add r.Header.Del(httphdr.Authorization) </s> remove r.Header.Set("Cookie", cookie.String()) </s> add r.Header.Set(httphdr.Cookie, cookie.String()) </s> remove w.Header().Set("Location", "/") </s> add w.Header().Set(httphdr.Location, "/") </s> remove respHdr.Set("Location", "/login.html") respHdr.Set("Set-Cookie", c.String()) </s> add respHdr.Set(httphdr.Location, "/login.html") respHdr.Set(httphdr.SetCookie, c.String()) </s> remove loginURL := w.hdr.Get("Location") </s> add loginURL := w.hdr.Get(httphdr.Location)
w.Header().Set(httphdr.Location, "/login.html")
if glProcessRedirect(w, r) { log.Debug("auth: redirected to login page by GL-Inet submodule") } else { log.Debug("auth: redirected to login page") w.Header().Set(httphdr.Location, "/login.html") w.WriteHeader(http.StatusFound) } } else { log.Debug("auth: responded with forbidden to %s %s", r.Method, p) w.WriteHeader(http.StatusForbidden)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/home/auth.go
if authRequired && err == nil { // Redirect to the dashboard if already authenticated. res := Context.auth.checkSession(cookie.Value) if res == checkSessionOK { w.Header().Set("Location", "/") w.WriteHeader(http.StatusFound) return }
</s> remove respHdr.Set(aghhttp.HdrNameAltSvc, altSvc) </s> add respHdr.Set(httphdr.AltSvc, altSvc) </s> remove respHdr.Set("Location", "/login.html") </s> add respHdr.Set(httphdr.Location, "/login.html") </s> remove cType := r.Header.Get(aghhttp.HdrNameContentType) </s> add cType := r.Header.Get(httphdr.ContentType) </s> remove req.Header.Set("Content-Type", cType) </s> add req.Header.Set(httphdr.ContentType, cType) </s> remove s := r.Header.Get("X-Forwarded-For") </s> add s := r.Header.Get(httphdr.XForwardedFor)
w.Header().Set(httphdr.Location, "/")
if authRequired && err == nil { // Redirect to the dashboard if already authenticated. res := Context.auth.checkSession(cookie.Value) if res == checkSessionOK { w.Header().Set(httphdr.Location, "/") w.WriteHeader(http.StatusFound) return }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/home/auth.go
"testing" "time" "github.com/AdguardTeam/golibs/testutil" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" )
</s>
"github.com/AdguardTeam/golibs/httphdr"
"testing" "time" "github.com/AdguardTeam/golibs/httphdr" "github.com/AdguardTeam/golibs/testutil" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" )
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/home/auth_test.go
r.URL = &url.URL{Path: "/"} handlerCalled = false handler2(&w, &r) assert.Equal(t, http.StatusFound, w.statusCode) assert.NotEmpty(t, w.hdr.Get("Location")) assert.False(t, handlerCalled) // go to login page loginURL := w.hdr.Get("Location") r.URL = &url.URL{Path: loginURL}
</s> remove loginURL := w.hdr.Get("Location") </s> add loginURL := w.hdr.Get(httphdr.Location) </s> remove assert.NotEmpty(t, w.hdr.Get("Location")) </s> add assert.NotEmpty(t, w.hdr.Get(httphdr.Location)) </s> remove r.Header.Set("Cookie", cookie.String()) </s> add r.Header.Set(httphdr.Cookie, cookie.String()) </s> remove r.Header.Set("Cookie", "bad") </s> add r.Header.Set(httphdr.Cookie, "bad") </s> remove r.Header.Set("Cookie", cookie.String()) </s> add r.Header.Set(httphdr.Cookie, cookie.String())
assert.NotEmpty(t, w.hdr.Get(httphdr.Location))
r.URL = &url.URL{Path: "/"} handlerCalled = false handler2(&w, &r) assert.Equal(t, http.StatusFound, w.statusCode) assert.NotEmpty(t, w.hdr.Get(httphdr.Location)) assert.False(t, handlerCalled) // go to login page loginURL := w.hdr.Get("Location") r.URL = &url.URL{Path: loginURL}
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/home/auth_test.go
assert.NotEmpty(t, w.hdr.Get("Location")) assert.False(t, handlerCalled) // go to login page loginURL := w.hdr.Get("Location") r.URL = &url.URL{Path: loginURL} handlerCalled = false handler2(&w, &r) assert.True(t, handlerCalled)
</s> remove assert.NotEmpty(t, w.hdr.Get("Location")) </s> add assert.NotEmpty(t, w.hdr.Get(httphdr.Location)) </s> remove assert.NotEmpty(t, w.hdr.Get("Location")) </s> add assert.NotEmpty(t, w.hdr.Get(httphdr.Location)) </s> remove r.Header.Set("Cookie", cookie.String()) </s> add r.Header.Set(httphdr.Cookie, cookie.String()) </s> remove r.Header.Del("Cookie") </s> add r.Header.Del(httphdr.Cookie) </s> remove r.Header.Set("Cookie", "bad") </s> add r.Header.Set(httphdr.Cookie, "bad")
loginURL := w.hdr.Get(httphdr.Location)
assert.NotEmpty(t, w.hdr.Get("Location")) assert.False(t, handlerCalled) // go to login page loginURL := w.hdr.Get(httphdr.Location) r.URL = &url.URL{Path: loginURL} handlerCalled = false handler2(&w, &r) assert.True(t, handlerCalled)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/home/auth_test.go
// get / handler2 = optionalAuth(handler) w.hdr = make(http.Header) r.Header.Set("Cookie", cookie.String()) r.URL = &url.URL{Path: "/"} handlerCalled = false handler2(&w, &r) assert.True(t, handlerCalled)
</s> remove r.Header.Del("Cookie") </s> add r.Header.Del(httphdr.Cookie) </s> remove r.Header.Set("Cookie", cookie.String()) </s> add r.Header.Set(httphdr.Cookie, cookie.String()) </s> remove r.Header.Del("Authorization") </s> add r.Header.Del(httphdr.Authorization) </s> remove r.Header.Set("Cookie", "bad") </s> add r.Header.Set(httphdr.Cookie, "bad") </s> remove assert.NotEmpty(t, w.hdr.Get("Location")) </s> add assert.NotEmpty(t, w.hdr.Get(httphdr.Location))
r.Header.Set(httphdr.Cookie, cookie.String())
// get / handler2 = optionalAuth(handler) w.hdr = make(http.Header) r.Header.Set(httphdr.Cookie, cookie.String()) r.URL = &url.URL{Path: "/"} handlerCalled = false handler2(&w, &r) assert.True(t, handlerCalled)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/home/auth_test.go
handlerCalled = false handler2(&w, &r) assert.True(t, handlerCalled) r.Header.Del("Cookie") // get / with basic auth handler2 = optionalAuth(handler) w.hdr = make(http.Header) r.URL = &url.URL{Path: "/"}
</s> remove r.Header.Set("Cookie", cookie.String()) </s> add r.Header.Set(httphdr.Cookie, cookie.String()) </s> remove r.Header.Set("Cookie", "bad") </s> add r.Header.Set(httphdr.Cookie, "bad") </s> remove r.Header.Set("Cookie", cookie.String()) </s> add r.Header.Set(httphdr.Cookie, cookie.String()) </s> remove r.Header.Del("Authorization") </s> add r.Header.Del(httphdr.Authorization) </s> remove r.Header.Del("Cookie") </s> add r.Header.Del(httphdr.Cookie)
r.Header.Del(httphdr.Cookie)
handlerCalled = false handler2(&w, &r) assert.True(t, handlerCalled) r.Header.Del(httphdr.Cookie) // get / with basic auth handler2 = optionalAuth(handler) w.hdr = make(http.Header) r.URL = &url.URL{Path: "/"}
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/home/auth_test.go
r.SetBasicAuth("name", "password") handlerCalled = false handler2(&w, &r) assert.True(t, handlerCalled) r.Header.Del("Authorization") // get login page with a valid cookie - we're redirected to / handler2 = optionalAuth(handler) w.hdr = make(http.Header) r.Header.Set("Cookie", cookie.String())
</s> remove r.Header.Set("Cookie", cookie.String()) </s> add r.Header.Set(httphdr.Cookie, cookie.String()) </s> remove r.Header.Set("Cookie", cookie.String()) </s> add r.Header.Set(httphdr.Cookie, cookie.String()) </s> remove r.Header.Set("Cookie", "bad") </s> add r.Header.Set(httphdr.Cookie, "bad") </s> remove r.Header.Del("Cookie") </s> add r.Header.Del(httphdr.Cookie) </s> remove r.Header.Del("Cookie") </s> add r.Header.Del(httphdr.Cookie)
r.Header.Del(httphdr.Authorization)
r.SetBasicAuth("name", "password") handlerCalled = false handler2(&w, &r) assert.True(t, handlerCalled) r.Header.Del(httphdr.Authorization) // get login page with a valid cookie - we're redirected to / handler2 = optionalAuth(handler) w.hdr = make(http.Header) r.Header.Set("Cookie", cookie.String())
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/home/auth_test.go
// get login page with a valid cookie - we're redirected to / handler2 = optionalAuth(handler) w.hdr = make(http.Header) r.Header.Set("Cookie", cookie.String()) r.URL = &url.URL{Path: loginURL} handlerCalled = false handler2(&w, &r) assert.NotEmpty(t, w.hdr.Get("Location")) assert.False(t, handlerCalled)
</s> remove r.Header.Del("Authorization") </s> add r.Header.Del(httphdr.Authorization) </s> remove assert.NotEmpty(t, w.hdr.Get("Location")) </s> add assert.NotEmpty(t, w.hdr.Get(httphdr.Location)) </s> remove r.Header.Del("Cookie") </s> add r.Header.Del(httphdr.Cookie) </s> remove r.Header.Set("Cookie", "bad") </s> add r.Header.Set(httphdr.Cookie, "bad") </s> remove r.Header.Set("Cookie", cookie.String()) </s> add r.Header.Set(httphdr.Cookie, cookie.String())
r.Header.Set(httphdr.Cookie, cookie.String())
// get login page with a valid cookie - we're redirected to / handler2 = optionalAuth(handler) w.hdr = make(http.Header) r.Header.Set(httphdr.Cookie, cookie.String()) r.URL = &url.URL{Path: loginURL} handlerCalled = false handler2(&w, &r) assert.NotEmpty(t, w.hdr.Get("Location")) assert.False(t, handlerCalled)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/home/auth_test.go
r.Header.Set("Cookie", cookie.String()) r.URL = &url.URL{Path: loginURL} handlerCalled = false handler2(&w, &r) assert.NotEmpty(t, w.hdr.Get("Location")) assert.False(t, handlerCalled) r.Header.Del("Cookie") // get login page with an invalid cookie handler2 = optionalAuth(handler)
</s> remove r.Header.Del("Cookie") </s> add r.Header.Del(httphdr.Cookie) </s> remove r.Header.Set("Cookie", "bad") </s> add r.Header.Set(httphdr.Cookie, "bad") </s> remove r.Header.Set("Cookie", cookie.String()) </s> add r.Header.Set(httphdr.Cookie, cookie.String()) </s> remove assert.NotEmpty(t, w.hdr.Get("Location")) </s> add assert.NotEmpty(t, w.hdr.Get(httphdr.Location)) </s> remove loginURL := w.hdr.Get("Location") </s> add loginURL := w.hdr.Get(httphdr.Location)
assert.NotEmpty(t, w.hdr.Get(httphdr.Location))
r.Header.Set("Cookie", cookie.String()) r.URL = &url.URL{Path: loginURL} handlerCalled = false handler2(&w, &r) assert.NotEmpty(t, w.hdr.Get(httphdr.Location)) assert.False(t, handlerCalled) r.Header.Del("Cookie") // get login page with an invalid cookie handler2 = optionalAuth(handler)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/home/auth_test.go
handlerCalled = false handler2(&w, &r) assert.NotEmpty(t, w.hdr.Get("Location")) assert.False(t, handlerCalled) r.Header.Del("Cookie") // get login page with an invalid cookie handler2 = optionalAuth(handler) w.hdr = make(http.Header) r.Header.Set("Cookie", "bad")
</s> remove r.Header.Set("Cookie", "bad") </s> add r.Header.Set(httphdr.Cookie, "bad") </s> remove assert.NotEmpty(t, w.hdr.Get("Location")) </s> add assert.NotEmpty(t, w.hdr.Get(httphdr.Location)) </s> remove r.Header.Set("Cookie", cookie.String()) </s> add r.Header.Set(httphdr.Cookie, cookie.String()) </s> remove r.Header.Del("Authorization") </s> add r.Header.Del(httphdr.Authorization) </s> remove r.Header.Del("Cookie") </s> add r.Header.Del(httphdr.Cookie)
r.Header.Del(httphdr.Cookie)
handlerCalled = false handler2(&w, &r) assert.NotEmpty(t, w.hdr.Get("Location")) assert.False(t, handlerCalled) r.Header.Del(httphdr.Cookie) // get login page with an invalid cookie handler2 = optionalAuth(handler) w.hdr = make(http.Header) r.Header.Set("Cookie", "bad")
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/home/auth_test.go
// get login page with an invalid cookie handler2 = optionalAuth(handler) w.hdr = make(http.Header) r.Header.Set("Cookie", "bad") r.URL = &url.URL{Path: loginURL} handlerCalled = false handler2(&w, &r) assert.True(t, handlerCalled) r.Header.Del("Cookie")
</s> remove r.Header.Del("Cookie") </s> add r.Header.Del(httphdr.Cookie) </s> remove assert.NotEmpty(t, w.hdr.Get("Location")) </s> add assert.NotEmpty(t, w.hdr.Get(httphdr.Location)) </s> remove r.Header.Set("Cookie", cookie.String()) </s> add r.Header.Set(httphdr.Cookie, cookie.String()) </s> remove r.Header.Del("Cookie") </s> add r.Header.Del(httphdr.Cookie) </s> remove r.Header.Del("Authorization") </s> add r.Header.Del(httphdr.Authorization)
r.Header.Set(httphdr.Cookie, "bad")
// get login page with an invalid cookie handler2 = optionalAuth(handler) w.hdr = make(http.Header) r.Header.Set(httphdr.Cookie, "bad") r.URL = &url.URL{Path: loginURL} handlerCalled = false handler2(&w, &r) assert.True(t, handlerCalled) r.Header.Del("Cookie")
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/home/auth_test.go