Skip to content
Open
Changes from all commits
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
6 changes: 5 additions & 1 deletion vpn_slice/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolvectl only exists and works on Linux systems running systemd-resolved.

It should not be used as a catch-all/fallback. Instead, please create a SplitDnsProvider subclass, and plug in that provider on systems where it makes sense. The availability check might consist of running resolvectl status and parsing its output.

for domain in args.vpn_domains:
print(subprocess.run(['resolvectl', 'domain', 'tun0', domain]), file=stderr)
Comment on lines +255 to +257
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't hardcode tun0. Use env.tundev

Comment on lines +256 to +257

Choose a reason for hiding this comment

The 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)

Expand Down