Skip to content

Commit 9c4a356

Browse files
committed
more tweaks, cleaned up socketutil module some more. Python 3.5 is now required!
1 parent 8ef87a3 commit 9c4a356

File tree

10 files changed

+146
-149
lines changed

10 files changed

+146
-149
lines changed

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# travis CI config
22
language: python
33
python:
4-
- 3.4
54
- 3.5
65
- 3.6
76
- 3.7-dev

Pyro5/compatibility/Pyro4.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
# from Pyro4.futures import Future
2626

2727
import sys
28+
import ipaddress
29+
2830
from .. import api
2931
from .. import errors
3032
from .. import serializers
@@ -141,25 +143,25 @@ def excepthook(self, *args, **kwargs):
141143
class SocketUtilModule:
142144
@staticmethod
143145
def getIpVersion(hostnameOrAddress):
144-
return socketutil_pyro5.get_ip_version(hostnameOrAddress)
146+
return ipaddress.ip_address(hostnameOrAddress).version
145147

146148
@staticmethod
147149
def getIpAddress(hostname, workaround127=False, ipVersion=None):
148-
return socketutil_pyro5.get_ip_address(hostname, workaround127, ipVersion)
150+
return str(socketutil_pyro5.get_ip_address(hostname, workaround127, ipVersion))
149151

150152
@staticmethod
151153
def getInterfaceAddress(ip_address):
152-
return socketutil_pyro5.get_interface_address(ip_address)
154+
return str(socketutil_pyro5.get_interface(ip_address).ip)
153155

154156
@staticmethod
155157
def createSocket(bind=None, connect=None, reuseaddr=False, keepalive=True,
156-
timeout=socketutil_pyro5._GLOBAL_DEFAULT_TIMEOUT, noinherit=False,
158+
timeout=-1, noinherit=False,
157159
ipv6=False, nodelay=True, sslContext=None):
158160
return socketutil_pyro5.create_socket(bind, connect, reuseaddr, keepalive,
159161
timeout, noinherit, ipv6, nodelay, sslContext)
160162

161163
@staticmethod
162-
def createBroadcastSocket(bind=None, reuseaddr=False, timeout=socketutil_pyro5._GLOBAL_DEFAULT_TIMEOUT, ipv6=False):
164+
def createBroadcastSocket(bind=None, reuseaddr=False, timeout=-1, ipv6=False):
163165
return socketutil_pyro5.create_bc_socket(bind, reuseaddr, timeout, ipv6)
164166

165167
@staticmethod

Pyro5/nameserver.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
try:
1515
import sqlite3
1616
except ImportError:
17-
sqlite3 = None
17+
pass
1818
from . import config, core, socketutil, server, errors
1919
from .errors import NamingError, PyroError, ProtocolError
2020

@@ -631,8 +631,8 @@ def processRequest(self):
631631
if responsedata.host == "0.0.0.0":
632632
# replace INADDR_ANY address by the interface IP address that connects to the requesting client
633633
try:
634-
interface_ip = socketutil.get_interface_address(addr[0])
635-
responsedata.host = interface_ip
634+
interface_ip = socketutil.get_interface(addr[0]).ip
635+
responsedata.host = str(interface_ip)
636636
except socket.error:
637637
pass
638638
log.debug("responding to broadcast request from %s: interface %s", addr[0], responsedata.host)

0 commit comments

Comments
 (0)