equal
deleted
inserted
replaced
1 from __future__ import absolute_import |
1 from __future__ import absolute_import |
2 from __future__ import print_function |
2 from __future__ import print_function |
3 |
3 |
4 import socket |
4 import socket |
|
5 import re |
5 import sslpsk |
6 import sslpsk |
6 import Pyro |
7 import Pyro |
|
8 from Pyro.core import PyroURI |
7 from Pyro.protocol import _connect_socket,TCPConnection,PYROAdapter |
9 from Pyro.protocol import _connect_socket,TCPConnection,PYROAdapter |
8 from Pyro.errors import ConnectionDeniedError, ProtocolError |
10 from Pyro.errors import ConnectionDeniedError, ProtocolError |
9 from Pyro.util import Log |
11 from Pyro.util import Log |
10 |
12 |
11 # |
13 # |
43 msg = self._sendConnect(sock,self.newConnValidator.createAuthToken(self.ident, authChallenge, conn.addr, self.URI, None) ) |
45 msg = self._sendConnect(sock,self.newConnValidator.createAuthToken(self.ident, authChallenge, conn.addr, self.URI, None) ) |
44 if msg==self.acceptMSG: |
46 if msg==self.acceptMSG: |
45 self.conn=conn |
47 self.conn=conn |
46 self.conn.connected=1 |
48 self.conn.connected=1 |
47 Log.msg('PYROAdapter','connected to',str(URI)) |
49 Log.msg('PYROAdapter','connected to',str(URI)) |
48 if URI.protocol=='PYROLOC': |
50 if URI.protocol=='PYROLOCPSK': |
49 self.resolvePYROLOC_URI("PYRO") # updates self.URI |
51 self.resolvePYROLOC_URI("PYROPSK") # updates self.URI |
50 elif msg[:len(self.denyMSG)]==self.denyMSG: |
52 elif msg[:len(self.denyMSG)]==self.denyMSG: |
51 try: |
53 try: |
52 raise ConnectionDeniedError(Pyro.constants.deniedReasons[int(msg[-1])]) |
54 raise ConnectionDeniedError(Pyro.constants.deniedReasons[int(msg[-1])]) |
53 except (KeyError,ValueError): |
55 except (KeyError,ValueError): |
54 raise ConnectionDeniedError('invalid response') |
56 raise ConnectionDeniedError('invalid response') |
62 return PYROPSKAdapter() |
64 return PYROPSKAdapter() |
63 _getProtocolAdapter(protocol) |
65 _getProtocolAdapter(protocol) |
64 |
66 |
65 Pyro.protocol.getProtocolAdapter = getProtocolAdapter |
67 Pyro.protocol.getProtocolAdapter = getProtocolAdapter |
66 |
68 |
|
69 _processStringURI = Pyro.core.processStringURI |
|
70 def processStringURI(URI): |
|
71 x=re.match(r'(?P<protocol>PYROLOCPSK)://(?P<hostname>[^\s:]+):?(?P<port>\d+)?/(?P<name>\S*)',URI) |
|
72 if x: |
|
73 protocol=x.group('protocol') |
|
74 hostname=x.group('hostname') |
|
75 port=x.group('port') |
|
76 if port: |
|
77 port=int(port) |
|
78 else: |
|
79 port=0 |
|
80 name=x.group('name') |
|
81 return PyroURI(hostname,name,port,protocol) |
|
82 return _processStringURI(URI) |
|
83 Pyro.core.processStringURI = processStringURI |