-
Notifications
You must be signed in to change notification settings - Fork 96
Use resolvectl when no other DNS provider is available #158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
|
|
||
| import argparse | ||
| import os | ||
| import subprocess | ||
| from enum import Enum | ||
| from ipaddress import IPv4Address, IPv4Network, IPv6Address, IPv6Interface, IPv6Network, ip_address, ip_network | ||
| from itertools import chain, zip_longest | ||
|
|
@@ -250,7 +251,10 @@ def do_connect(env, args): | |
| # Use vpn dns for provided domains | ||
| if args.vpn_domains is not None: | ||
| if 'domain_vpn_dns' not in providers: | ||
| print("WARNING: no split dns provider available; can't split dns", file=stderr) | ||
| print("WARNING: no split dns provider available; trying resolvectl...", file=stderr) | ||
| print(subprocess.run(['resolvectl', 'dns', 'tun0', *map(str, env.dns)]), file=stderr) | ||
| for domain in args.vpn_domains: | ||
| print(subprocess.run(['resolvectl', 'domain', 'tun0', domain]), file=stderr) | ||
|
Comment on lines
+255
to
+257
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't hardcode
Comment on lines
+256
to
+257
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this also does the wrong thing when you provide multiple domains. by calling the command repeatedly, you overwrite the previous domain rather than appending more domains to the list. instead of looping, just set all the domains at once in a single step. |
||
| else: | ||
| providers.domain_vpn_dns.configure_domain_vpn_dns(args.vpn_domains, env.dns) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolvectlonly exists and works on Linux systems runningsystemd-resolved.It should not be used as a catch-all/fallback. Instead, please create a
SplitDnsProvidersubclass, and plug in that provider on systems where it makes sense. The availability check might consist of runningresolvectl statusand parsing its output.