Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion client/src/components/ui/Guide/Guide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,11 @@ export const Guide = ({ dnsAddresses }: GuideProps) => {
const serverName = useSelector((state: RootState) => state.encryption?.server_name);

const portHttps = useSelector((state: RootState) => state.encryption?.port_https);
const dnsPrivacyAvailable = useSelector((state: RootState) => state.dashboard?.dnsPrivacyAvailable);
const tlsAddress = dnsAddresses?.filter((item: any) => item.includes('tls://')) ?? '';
const httpsAddress = dnsAddresses?.filter((item: any) => item.includes('https://')) ?? '';
const showDnsPrivacyNotice = httpsAddress.length < 1 && tlsAddress.length < 1;
const hasDnsPrivacyAddresses = httpsAddress.length > 0 || tlsAddress.length > 0;
const showDnsPrivacyNotice = !hasDnsPrivacyAddresses && !dnsPrivacyAvailable;

const [activeTabLabel, setActiveTabLabel] = useState('Router');

Expand Down
2 changes: 2 additions & 0 deletions client/src/initialState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export type DashboardData = {
httpPort: number;
dnsPort: number;
dnsAddresses: string[];
dnsPrivacyAvailable: boolean;
dnsVersion: string;
dnsStartTime: number | null;
clients: Client[];
Expand Down Expand Up @@ -448,6 +449,7 @@ export const initialState: RootState = {
httpPort: STANDARD_WEB_PORT,
dnsPort: STANDARD_DNS_PORT,
dnsAddresses: [],
dnsPrivacyAvailable: false,
dnsVersion: '',
dnsStartTime: null,
clients: [],
Expand Down
2 changes: 2 additions & 0 deletions client/src/reducers/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const dashboard = handleActions(
start_time: dnsStartTime,
dns_port: dnsPort,
dns_addresses: dnsAddresses,
dns_privacy_available: dnsPrivacyAvailable,
protection_enabled: protectionEnabled,
protection_disabled_duration: protectionDisabledDuration,
http_port: httpPort,
Expand All @@ -37,6 +38,7 @@ const dashboard = handleActions(
dnsStartTime,
dnsPort,
dnsAddresses,
dnsPrivacyAvailable: dnsPrivacyAvailable ?? state.dnsPrivacyAvailable,
protectionEnabled,
protectionDisabledDuration,
language,
Expand Down
18 changes: 18 additions & 0 deletions internal/home/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,30 @@ func collectDNSAddresses(tlsMgr *tlsManager) (addrs []string, err error) {
return addrs, nil
}

// isDNSPrivacyAvailable returns true if at least one DNS privacy protocol is
// configured to be available. tlsMgr must not be nil.
func isDNSPrivacyAvailable(tlsMgr *tlsManager) (ok bool) {
if tlsMgr == nil {
return false
}

tlsConf := tlsMgr.config()
dohAvailable := tlsConf.PortHTTPS != 0 && (tlsConf.Enabled || tlsConf.AllowUnencryptedDoH)
dotAvailable := tlsConf.Enabled && tlsConf.PortDNSOverTLS != 0
doqAvailable := tlsConf.Enabled && tlsConf.PortDNSOverQUIC != 0

return dohAvailable || dotAvailable || doqAvailable
}

// statusResponse is a response for /control/status endpoint.
type statusResponse struct {
Version string `json:"version"`
Language string `json:"language"`
DNSAddrs []string `json:"dns_addresses"`
DNSPort uint16 `json:"dns_port"`
HTTPPort uint16 `json:"http_port"`
// DNSPrivacyAvailable indicates whether DNS privacy features are available.
DNSPrivacyAvailable bool `json:"dns_privacy_available"`

// ProtectionDisabledDuration is the duration of the protection pause in
// milliseconds.
Expand Down Expand Up @@ -160,6 +177,7 @@ func (web *webAPI) handleStatus(w http.ResponseWriter, r *http.Request) {
DNSAddrs: dnsAddrs,
DNSPort: config.DNS.Port,
HTTPPort: config.HTTPConfig.Address.Port(),
DNSPrivacyAvailable: isDNSPrivacyAvailable(web.tlsManager),
ProtectionDisabledDuration: protectionDisabledDuration,
StartTime: aghhttp.JSONTime(web.startTime),
ProtectionEnabled: protEnabled,
Expand Down
4 changes: 4 additions & 0 deletions openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1462,6 +1462,7 @@
- 'dns_addresses'
- 'dns_port'
- 'http_port'
- 'dns_privacy_available'
- 'protection_enabled'
- 'protection_disabled_until'
- 'running'
Expand All @@ -1485,6 +1486,9 @@
'example': 80
'minimum': 1
'maximum': 65535
'dns_privacy_available':
'type': 'boolean'
'description': 'Whether at least one DNS privacy protocol is available.'
'protection_enabled':
'type': 'boolean'
'protection_disabled_duration':
Expand Down