Skip to content

Commit 4f130c1

Browse files
committed
fix: use stdlib ipaddress for is_local_address, remove netaddr dependency
1 parent 1d5fa5c commit 4f130c1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

octoprint_obico/printer_discovery.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import random
1010
import string
1111
import flask
12+
import octoprint
13+
import ipaddress
1214

1315
try:
1416
from secrets import token_hex
@@ -17,7 +19,6 @@ def token_hex(n):
1719
letters = string.ascii_letters + string.digits
1820
return "".join([random.choice(letters) for i in range(n)])
1921

20-
import netaddr.ip
2122
from octoprint.util.net import sanitize_address
2223
from octoprint.util.platform import (
2324
get_os as octoprint_get_os,
@@ -317,8 +318,8 @@ def get_local_ip(plugin):
317318
def is_local_address(plugin, address):
318319
try:
319320
address = sanitize_address(address)
320-
ip = netaddr.IPAddress(address)
321-
return ip.is_private() or ip.is_loopback()
321+
ip = ipaddress.ip_address(address)
322+
return ip.is_private or ip.is_loopback
322323
except Exception as exc:
323324
_logger.error(
324325
'could not determine whether {} is local address ({})'.format(

0 commit comments

Comments
 (0)