Skip to content

Commit

Permalink
Merge pull request #55 from gmacon/issue-54-ip-interfaces
Browse files Browse the repository at this point in the history
handle IPv6Interface objects consistently and gracefully (fix for #54)
  • Loading branch information
dlenski committed Jun 11, 2020
2 parents 7ea4c5e + e03de6a commit 6c173e1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

########################################

setup(name="vpn_slice",
setup(name="vpn-slice",
version=version_pep,
description=("vpnc-script replacement for easy split-tunnel VPN setup"),
long_description=open('description.rst').read(),
Expand Down
2 changes: 1 addition & 1 deletion vpn_slice/dnspython.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from sys import stderr
from ipaddress import ip_address
from ipaddress import ip_address, ip_interface
from dns.resolver import Resolver, NXDOMAIN, NoAnswer, Timeout
from dns.name import root, from_text

Expand Down
8 changes: 4 additions & 4 deletions vpn_slice/mac.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import re
import subprocess
from ipaddress import ip_network
from ipaddress import ip_network, ip_interface

from .posix import PosixProcessProvider
from .provider import RouteProvider
Expand Down Expand Up @@ -102,8 +102,8 @@ def set_link_info(self, device, state, mtu=None):
self._ifconfig(*args)

def add_address(self, device, address):
address = ip_interface(address)
if address.version == 6:
family = 'inet6'
self._ifconfig(device, 'inet6', address)
else:
family = 'inet'
self._ifconfig(device, family, ip_network(address), address)
self._ifconfig(device, 'inet', address.ip, address.ip, 'netmask', '255.255.255.255')
3 changes: 2 additions & 1 deletion vpn_slice/provider.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from abc import ABCMeta, abstractmethod
from ipaddress import ip_interface


class ProcessProvider(metaclass=ABCMeta):
Expand Down Expand Up @@ -102,7 +103,7 @@ class DNSProvider(metaclass=ABCMeta):
def configure(self, dns_servers, *, bind_addresses=None, search_domains=()):
"""Configure provider to use the specified DNS servers, bind addresses, and search domains."""
self.dns_servers = dns_servers
self.bind_addresses = bind_addresses
self.bind_addresses = [ip_interface(a).ip for a in bind_addresses]
self.search_domains = search_domains

@abstractmethod
Expand Down

0 comments on commit 6c173e1

Please sign in to comment.