|
@@ -171,6 +171,12 @@ _allowedparameters = { |
|
|
'host': str, |
|
|
'host': str, |
|
|
'port': int, |
|
|
'port': int, |
|
|
}, |
|
|
}, |
|
|
|
|
|
'udp': { |
|
|
|
|
|
'host': str, |
|
|
|
|
|
'port': int, |
|
|
|
|
|
'lclhost': str, |
|
|
|
|
|
'lclport': int, |
|
|
|
|
|
}, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
def parsesockstr(sockstr): |
|
|
def parsesockstr(sockstr): |
|
@@ -199,6 +205,21 @@ def parsesockstr(sockstr): |
|
|
The host parameter specifies the host, and the |
|
|
The host parameter specifies the host, and the |
|
|
port parameter specifies the port of the |
|
|
port parameter specifies the port of the |
|
|
connection. |
|
|
connection. |
|
|
|
|
|
|
|
|
|
|
|
udp: |
|
|
|
|
|
Default parameter is host[:port]. |
|
|
|
|
|
Note that the meaning depends upon if it is used |
|
|
|
|
|
in a server context vs a client context. In the |
|
|
|
|
|
server context, host and port specify the host to |
|
|
|
|
|
bind to, and in the client context, specify the |
|
|
|
|
|
remote host and port to connect to. In the case |
|
|
|
|
|
of a client, there are also the lclhost and lclport |
|
|
|
|
|
that can be specified to bind the local side of |
|
|
|
|
|
the socket. |
|
|
|
|
|
|
|
|
|
|
|
The host parameter specifies the host, and the |
|
|
|
|
|
port parameter specifies the port of the |
|
|
|
|
|
connection. |
|
|
''' |
|
|
''' |
|
|
|
|
|
|
|
|
proto, rem = sockstr.split(':', 1) |
|
|
proto, rem = sockstr.split(':', 1) |
|
@@ -209,6 +230,10 @@ def parsesockstr(sockstr): |
|
|
|
|
|
|
|
|
if proto == 'unix': |
|
|
if proto == 'unix': |
|
|
args = { 'path': rem } |
|
|
args = { 'path': rem } |
|
|
|
|
|
|
|
|
|
|
|
if proto == 'udp': |
|
|
|
|
|
h, p = rem.split(':') |
|
|
|
|
|
args = { 'host': h, 'port': p } |
|
|
else: |
|
|
else: |
|
|
args = dict(i.split('=', 1) for i in rem.split(',')) |
|
|
args = dict(i.split('=', 1) for i in rem.split(',')) |
|
|
|
|
|
|
|
@@ -535,6 +560,15 @@ class Tests_misc(unittest.TestCase): |
|
|
'tcp:host=apath': ('tcp', { 'host': 'apath' }), |
|
|
'tcp:host=apath': ('tcp', { 'host': 'apath' }), |
|
|
'tcp:host=apath,port=5': ('tcp', { 'host': 'apath', |
|
|
'tcp:host=apath,port=5': ('tcp', { 'host': 'apath', |
|
|
'port': 5 }), |
|
|
'port': 5 }), |
|
|
|
|
|
'udp:host=apath,port=5': ('udp', { 'host': 'apath', |
|
|
|
|
|
'port': 5 }), |
|
|
|
|
|
'udp:port=5': ('udp', { 'port': 5 }), |
|
|
|
|
|
'udp:port=5,lclport=10,lclhost=foo': ('udp', |
|
|
|
|
|
{ 'port': 5, 'lclport': 10, 'lclhost': 'foo' }), |
|
|
|
|
|
'udp:apath:5': ('udp', { 'host': 'apath', |
|
|
|
|
|
'port': 5 }), |
|
|
|
|
|
'udp::5': ('udp', { 'host': '', |
|
|
|
|
|
'port': 5 }), |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
for s, r in results.items(): |
|
|
for s, r in results.items(): |
|
|