Windows: Fix IPV6 for Windows 10+

Fixes #9326
This commit is contained in:
Philipp Hörist 2018-09-05 02:14:51 +02:00 committed by Philipp Hörist
parent dd267359be
commit 7a8892f021
2 changed files with 4 additions and 4 deletions

View File

@ -27,6 +27,7 @@ import struct
import hashlib import hashlib
import os import os
import time import time
import platform
from errno import EWOULDBLOCK from errno import EWOULDBLOCK
from errno import ENOBUFS from errno import ENOBUFS
from errno import EINTR from errno import EINTR
@ -1424,8 +1425,7 @@ class Socks5Listener(IdleObject):
# Under windows Vista, we need that to listen on ipv6 AND ipv4 # Under windows Vista, we need that to listen on ipv6 AND ipv4
# Doesn't work under windows XP # Doesn't work under windows XP
if os.name == 'nt': if os.name == 'nt':
ver = os.sys.getwindowsversion() if int(platform.win32_ver()[0]) >= 6: # Win Vista +
if (ver[3], ver[0]) == (2, 6): # Win Vista +
# 47 is socket.IPPROTO_IPV6 # 47 is socket.IPPROTO_IPV6
# 27 is socket.IPV6_V6ONLY under windows, but not defined ... # 27 is socket.IPV6_V6ONLY under windows, but not defined ...
self._serv.setsockopt(41, 27, 0) self._serv.setsockopt(41, 27, 0)

View File

@ -27,6 +27,7 @@ from gajim.common.zeroconf import zeroconf
from nbxmpp.protocol import * from nbxmpp.protocol import *
import socket import socket
import platform
import ssl import ssl
import errno import errno
import sys import sys
@ -73,8 +74,7 @@ class ZeroconfListener(IdleObject):
self._serv.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) self._serv.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
self._serv.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) self._serv.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
if os.name == 'nt': if os.name == 'nt':
ver = os.sys.getwindowsversion() if int(platform.win32_ver()[0]) >= 6: # Win Vista +
if (ver[3], ver[0]) == (2, 6): # Win Vista +
# 47 is socket.IPPROTO_IPV6 # 47 is socket.IPPROTO_IPV6
# 27 is socket.IPV6_V6ONLY under windows, but not defined ... # 27 is socket.IPV6_V6ONLY under windows, but not defined ...
self._serv.setsockopt(41, 27, 0) self._serv.setsockopt(41, 27, 0)