Adguardhome: [Feature Request] Temporarily disable with API

Created on 5 Jan 2020  Â·  26Comments  Â·  Source: AdguardTeam/AdGuardHome

Hello -- I'm trying to figure out if there's a way to disable AdGuard Home temporarily within the API. For example, Pi-hole allows disabling for some number of seconds through theirs (http://pi.hole/admin/api.php?disable=300). Unless I'm missing something, I've only figured out how to switch on vs off or make a script that switches it off, sleeps for a certain number of seconds, and then switches it back on.

Thanks!

Medium feature request

Most helpful comment

I'd like this feature too

All 26 comments

Yeah, there's no such API method at the moment, start-sleep-stop is the only way.

Thanks!

Can we close this issue? I doubt that we really need a new API method to temporarily disable the filtering.

It depends on the users. If there will be upvotes, we'll consider it.

Generally, I'd better keep all feature requests open until we are 100% sure that we won't do it.

i would like to see this feature too!

I'd like this feature too

I would really like this feature too. The scenario is like this: I can easily turn on/off AdGuard Home from the web interface, but my wife/kids are not so technical. I could then just make a shortcut on their iphone to turn off the filtering for a short time (say 5 minutes) to test if AdGuard is blocking the website they want to visit.
What do you think?

Guys, please add upvotes then (upvote reaction on the issue)

Alternative UI solution https://github.com/AdguardTeam/AdGuardHome/issues/997 https://github.com/AdguardTeam/AdGuardHome/issues/1203 https://github.com/AdguardTeam/AdGuardHome/issues/1450

but my wife/kids are not so technical.

@danielp123 I understand but you may able to create account for them and add a timed allow list with single rule to unblock all domains for 5min. In this cause; i'm not prefer to see AGH become too simple tool.

@ameshkov Along with this feature request to temporarily disable filtering via API, and a good reason for making this feature, would be to integrate this "Temporarily disable AdGuard Home DNS filtering protection" API feature into AdGuard for Windows, AdGuard browser extensions, etc.

I am a long time user of AdGuard for Windows. Quite often, I have to temporarily disable the AGH DNS filtering because it causes problems on kids iPad games and certain things that other users may need to do from time to time.

This may be a tricky request though, in that regard.

@ameshkov – I know this issue has gone to a bunch of different places, but I've been using:

curl -X POST "http://[URL]/control/dns_config" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"protection_enabled\": false}"

to enable and disable filtering. Unfortunately, I've noticed that even though filtering is now disabled, the domain is cached as blocked so you have to wait for the cache to clear before the domain will work again. Is this a separate issue that I should file or is there a different API call to turn AdGuard Home off?

Thanks for everything, it's a great piece of software.

domain is cached as blocked

@shapiro125 Do you mean browser's cache? Please try requesting the host name via nslookup or dig - what are the results?

@szolin – dig is showing it correctly each time, it appears to be a browser cache issue. If the request is blocked, my browser will continue to block it even after disable adguard. Once it's disabled, the browser will still resolve the domain even after adguard is re-enabled.

I know it's working as expected (according to the dig results), so don't know what to do about it. I'm coming from Pi-hole, where their disable seemed to work instantly in browser without cache problems. Thanks!

. I'm coming from Pi-hole, where their disable seemed to work instantly in browser without cache problems

Maybe they just set small TTL values.
You may set cache_ttl_max: 10 in AGH yaml config, and your browser will "forget" it after 10 seconds.

@szolin you mean blocked_response_ttl?

or blocked_response_ttl, yes
Note: cache_ttl_max is available only in beta

Oh, interesting. I noticed blocked_response_ttl is set for 10 seconds and, yup, disabling and waiting 10 seconds works.

What are the performance implications for making that shorter?

What are the performance implications for making that shorter?

Your devices will make DNS queries for blocked resources more often. Tbh, there are no really serious performance implications, especially if we're talking about AGH that's hosted in the local network and not on some public server.

I'd love this too. Just noticed that Adguard was disabled for the past day or so because I had forgotten to re-enable it. It would be great to have an option in the UI as well.

@hoshsadiq #1879

I would love to have an API or any kind of remote controllability that is not having issues right now.
https://github.com/home-assistant/core/issues/36197
https://github.com/home-assistant/core/issues/38112

How is that AdGuard related? You're having issues with HA, not AdGuard. Try this to see whether your API is working.
curl -X POST -H "Content-Type:application/json" -d '{"protection_enabled":false}' http://[IP_ADGUARD]/control/dns_config

It should disable AdGuard

HTTP auth header may be necessary as well, plz see the openapi folder in AGH sources

Would love to see such feature also. Preferable on a per cliënt basis but a temp disable option in general would be great to start with.

This was a GREAT feature in Pi-Hole, dissapointed to not see a similar feature in AdGuard Home

So I recently found out I had this disabled again and had forgotten to re-enable it. I wrote a small script to disable and re-enable AGH. It's not ideal, as this won't run if you put your computer to sleep and/or shut it down or something.

#!/usr/bin/env bash

username="<set>"
password="<set>"
url="<set>"

urlRegex='^(([^:/?#]+):)?(//((([^:/?#]+)@)?([^:/?#]+)(:([0-9]+))?))?(/([^?#]*))(\?([^#]*))?(#(.*))?'

if [[ "$url" =~ $urlRegex ]]; then
  targetUri="$(printf "%s://%s%s/%s" "${BASH_REMATCH[2]}" "${BASH_REMATCH[4]}" "${BASH_REMATCH[5]}" "control/dns_config")"
  curl -X POST -u "$username:$password" -H "Content-Type:application/json" -d '{"protection_enabled":false}' "$targetUri"
  ( sleep 300; curl -X POST -u "$username:$password" -H "Content-Type:application/json" -d '{"protection_enabled":true}' "$targetUri" ) &
  disown
else
  >&2 printf "unable to get AdGuard Home URL. Got %s" "$url"
fi

In my case I get the details from my password manager, but you can simply set in the script or make the change to retrieve the data from your password manager too. I suggest you edit it to your needs.

Would love it if this can be prioritised higher as leaving it accidentally disabled is a pretty big privacy risk.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ajongsma picture ajongsma  Â·  3Comments

alexpovel picture alexpovel  Â·  3Comments

hl2guide picture hl2guide  Â·  3Comments

ammnt picture ammnt  Â·  3Comments

xenio picture xenio  Â·  4Comments