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
Merged
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
9 changes: 6 additions & 3 deletions vpn_slice/mac.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ def _route(self, *args):
def _ifconfig(self, *args):
return subprocess.check_output([self.ifconfig] + list(map(str, args)), universal_newlines=True)

def _family_option(self, destination):
return '-inet6' if destination.version == 6 else '-inet'

def add_route(self, destination, *, via=None, dev=None, src=None, mtu=None):
args = ['add']
args = ['add', self._family_option(destination)]
if mtu is not None:
args.extend(('-mtu', str(mtu)))
if via is not None:
Expand All @@ -53,10 +56,10 @@ def add_route(self, destination, *, via=None, dev=None, src=None, mtu=None):
replace_route = add_route

def remove_route(self, destination):
self._route('delete', destination)
self._route('delete', self._family_option(destination), destination)

def get_route(self, destination):
info = self._route('get', destination)
info = self._route('get', self._family_option(destination), destination)
lines = iter(info.splitlines())
info_d = {}
for line in lines:
Expand Down