Skip to content
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

Use -inet6 flag for BSD route where needed #39

Merged
merged 1 commit into from
Mar 16, 2020

Conversation

gmacon
Copy link
Collaborator

@gmacon gmacon commented Mar 16, 2020

My company started providing IPv6 addresses, and I got this error on macOS:

route: bad address: xxxx:xxx:xxx:xxxx::xxx
Traceback (most recent call last):
  File "/usr/local/bin/vpn-slice", line 11, in <module>
    load_entry_point('vpn-slice', 'console_scripts', 'vpn-slice')()
  File "vpn-slice/vpn_slice/__main__.py", line 462, in main
    do_connect(env, args)
  File "vpn-slice/vpn_slice/__main__.py", line 171, in do_connect
    providers.route.replace_route(dest, dev=env.tundev)
  File "vpn-slice/vpn_slice/mac.py", line 51, in add_route
    self._route(*args)
  File "vpn-slice/vpn_slice/mac.py", line 38, in _route
    return subprocess.check_output([self.route, '-n'] + list(map(str, args)), universal_newlines=True)
  File "python3.7/subprocess.py", line 411, in check_output
    **kwargs).stdout
  File "python3.7/subprocess.py", line 512, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['/sbin/route', '-n', 'add', '-interface', 'xxxx:xxx:xxx:xxxx::xxx', 'utun1']' returned non-zero exit status 68.

This PR adds the -inet6 flag that BSD route expects in this case.

vpn_slice/mac.py Outdated
@@ -42,6 +42,8 @@ def _ifconfig(self, *args):

def add_route(self, destination, *, via=None, dev=None, src=None, mtu=None):
args = ['add']
Copy link
Owner

Choose a reason for hiding this comment

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

Perhaps we can make this a bit less verbose on the Python side, and a bit more explicit on the route side, by using something like this instead?

args = ['add', ('-inet6' if destination.version == 6 else '-inet')]

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure. I'll make that modification.

Copy link
Owner

Choose a reason for hiding this comment

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

👍 👍 👍

@dlenski dlenski merged commit e4dcb90 into dlenski:master Mar 16, 2020
@gmacon
Copy link
Collaborator Author

gmacon commented Mar 18, 2020

Thanks for the quick response!

@gmacon gmacon deleted the bsd-route-inet6 branch March 18, 2020 14:25
@dlenski dlenski mentioned this pull request Apr 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants