diff options
author | erkin <e.altunbas@vyos.io> | 2021-06-08 14:14:26 +0300 |
---|---|---|
committer | erkin <e.altunbas@vyos.io> | 2021-06-08 14:15:02 +0300 |
commit | 5bf0f7d818b353c0ad583e5c1d0835d510132958 (patch) | |
tree | c9069aeceb1c5ad0565e80c4ae3233c41872fbeb /python | |
parent | df8043dcbee22ec8d9d45b24d9e1fc07daeabf64 (diff) | |
download | vyos-1x-5bf0f7d818b353c0ad583e5c1d0835d510132958.tar.gz vyos-1x-5bf0f7d818b353c0ad583e5c1d0835d510132958.zip |
remote: Use `is_ipv6()` instead of ad hoc IPv6 check
Diffstat (limited to 'python')
-rw-r--r-- | python/vyos/remote.py | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/python/vyos/remote.py b/python/vyos/remote.py index f1768aa4f..81ea23c71 100644 --- a/python/vyos/remote.py +++ b/python/vyos/remote.py @@ -14,7 +14,6 @@ # License along with this library. If not, see <http://www.gnu.org/licenses/>. from ftplib import FTP -import ipaddress import math import os import shutil @@ -25,6 +24,7 @@ import urllib.parse import urllib.request as urlreq from vyos.util import cmd, ask_yes_no +from vyos.validate import is_ipv6 from vyos.version import get_version from paramiko import SSHClient, SSHException, MissingHostKeyPolicy @@ -182,12 +182,7 @@ def transfer_sftp(mode, local_path, hostname, remote_path,\ sock = None if source: # Check if the given string is an IPv6 address. - try: - ipaddress.IPv6Address(source) - except ipaddress.AddressValueError: - address_family = socket.AF_INET - else: - address_family = socket.AF_INET6 + address_family = socket.AF_INET6 if is_ipv6(source) else socket.AF_INET sock = socket.socket(address_family, socket.SOCK_STREAM) sock.bind((source, 0)) sock.connect((hostname, port)) |