Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/python-nbxmpp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/nbxmpp
diff options
context:
space:
mode:
authorlovetox <philipp@hoerist.com>2020-08-16 21:49:55 +0300
committerlovetox <philipp@hoerist.com>2020-08-16 21:50:40 +0300
commite5f5effc3065d1f6942915b6ab2a5a2a5584ffed (patch)
tree460ff1cf6cac204f2ee6d38ab105973bd190bd99 /nbxmpp
parentef105bd0ee9f5df3cc0057d8d043f6c4cf6637bd (diff)
Simplify domainpart check
Diffstat (limited to 'nbxmpp')
-rw-r--r--nbxmpp/protocol.py17
1 files changed, 3 insertions, 14 deletions
diff --git a/nbxmpp/protocol.py b/nbxmpp/protocol.py
index 41fa0b2..e802595 100644
--- a/nbxmpp/protocol.py
+++ b/nbxmpp/protocol.py
@@ -20,10 +20,11 @@ sub- stanzas) handling routines
import time
import hashlib
-import socket
import functools
from base64 import b64encode
+from gi.repository import GLib
+
import idna
from precis_i18n import get_profile
from nbxmpp.simplexml import Node
@@ -716,20 +717,8 @@ def validate_domainpart(domainpart):
if not domainpart:
raise DomainpartByteLimit
- # Check if this is a IPV4 address
- try:
- socket.inet_aton(domainpart)
+ if GLib.hostname_is_ip_address(domainpart):
return domainpart
- except Exception:
- pass
-
- # Check if this is a IPV6 address
- if domainpart.startswith('[') and domainpart.endswith(']'):
- try:
- socket.inet_pton(socket.AF_INET6, domainpart.strip('[]'))
- return domainpart
- except Exception:
- pass
if domainpart.endswith('.'): # RFC7622, 3.2
domainpart = domainpart[:-1]