Skip to content
Snippets Groups Projects
Commit b32102ec authored by atrax's avatar atrax Committed by Moul
Browse files

[mod] #226: Use DuniterPy's regex instead of ipaddress

parent bea8f9d0
No related branches found
No related tags found
1 merge request!158[dep] #226 : Get rid of ipaddress dependency
...@@ -16,13 +16,14 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. ...@@ -16,13 +16,14 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>.
""" """
from __future__ import unicode_literals from __future__ import unicode_literals
from ipaddress import ip_address import re
import socket import socket
import logging import logging
from sys import exit, stderr from sys import exit, stderr
from asyncio import sleep from asyncio import sleep
from duniterpy.api.client import Client from duniterpy.api.client import Client
from duniterpy.api.bma import network from duniterpy.api.bma import network
from duniterpy.constants import IPV4_REGEX, IPV6_REGEX
from silkaj.constants import ( from silkaj.constants import (
G1_DEFAULT_ENDPOINT, G1_DEFAULT_ENDPOINT,
...@@ -198,10 +199,11 @@ def endpoint_type(sep, ep): ...@@ -198,10 +199,11 @@ def endpoint_type(sep, ep):
def check_ip(address): def check_ip(address):
try: if re.match(IPV4_REGEX, address) != None:
return ip_address(address).version return 4
except: elif re.match(IPV6_REGEX, address) != None:
return 0 return 6
return 0
def best_endpoint_address(ep, main): def best_endpoint_address(ep, main):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment