connectors/PYRO/PSK_Adapter.py
author Edouard Tisserant
Thu, 04 Apr 2019 13:59:22 +0200
branchrename_on_location_change
changeset 2575 aee08bd135d8
parent 2544 640d639d9bd8
child 2588 25f19b76c7b6
permissions -rw-r--r--
Rename checkbox and immediately apply.
Added a checkbox in Location selection dialog (saved as user settings) to let user choose if variable is being renamed.
Also forced closing celle editor once new location is selected.
2544
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
     1
#!/usr/bin/env python
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
     2
# -*- coding: utf-8 -*-
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
     3
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
     4
# This file is part of Beremiz, a Integrated Development Environment for
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
     5
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival.
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
     6
#
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
     7
# Copyright (C) 2019: Edouard TISSERANT
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
     8
#
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
     9
# See COPYING file for copyrights details.
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
    10
#
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
    11
# This program is free software; you can redistribute it and/or
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
    12
# modify it under the terms of the GNU General Public License
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
    13
# as published by the Free Software Foundation; either version 2
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
    14
# of the License, or (at your option) any later version.
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
    15
#
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
    16
# This program is distributed in the hope that it will be useful,
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
    17
# but WITHOUT ANY WARRANTY; without even the implied warranty of
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
    18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
    19
# GNU General Public License for more details.
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
    20
#
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
    21
# You should have received a copy of the GNU General Public License
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
    22
# along with this program; if not, write to the Free Software
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
    23
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
    24
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
    25
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
    26
"""
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
    27
The TLS-PSK adapter that handles SSL connections instead of regular sockets,
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
    28
but using Pre Shared Keys instead of Certificates
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
    29
"""
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
    30
2313
2eaf235270f8 PYRO/TLSPSK : fixed typos, used appropriate ciphers (https://github.com/drbild/sslpsk/issues/3), use PYROPSK instead of unresolvable PYROLOCPSK.
Edouard Tisserant
parents: 2312
diff changeset
    31
from __future__ import absolute_import
2eaf235270f8 PYRO/TLSPSK : fixed typos, used appropriate ciphers (https://github.com/drbild/sslpsk/issues/3), use PYROPSK instead of unresolvable PYROLOCPSK.
Edouard Tisserant
parents: 2312
diff changeset
    32
from __future__ import print_function
2312
84b3cc18893b Replaced PYROSSL with PYROPSK.
Edouard Tisserant
parents:
diff changeset
    33
2313
2eaf235270f8 PYRO/TLSPSK : fixed typos, used appropriate ciphers (https://github.com/drbild/sslpsk/issues/3), use PYROPSK instead of unresolvable PYROLOCPSK.
Edouard Tisserant
parents: 2312
diff changeset
    34
import socket
2314
e927c101ce6d PYRO/TLSPSK : must use PYROLOC* protocol scheme in pyro URI, otherwise object ID is missing. Had to use more persuasive pyro3 monkey patching to have PYROLOCPSK resolved properly
Edouard Tisserant
parents: 2313
diff changeset
    35
import re
2537
eb4a4cc41914 Fix various pylint and pep8 errors
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2536
diff changeset
    36
import ssl
2312
84b3cc18893b Replaced PYROSSL with PYROPSK.
Edouard Tisserant
parents:
diff changeset
    37
import sslpsk
84b3cc18893b Replaced PYROSSL with PYROPSK.
Edouard Tisserant
parents:
diff changeset
    38
import Pyro
2314
e927c101ce6d PYRO/TLSPSK : must use PYROLOC* protocol scheme in pyro URI, otherwise object ID is missing. Had to use more persuasive pyro3 monkey patching to have PYROLOCPSK resolved properly
Edouard Tisserant
parents: 2313
diff changeset
    39
from Pyro.core import PyroURI
2492
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
    40
from Pyro.protocol import _connect_socket, TCPConnection, PYROAdapter
2312
84b3cc18893b Replaced PYROSSL with PYROPSK.
Edouard Tisserant
parents:
diff changeset
    41
from Pyro.errors import ConnectionDeniedError, ProtocolError
84b3cc18893b Replaced PYROSSL with PYROPSK.
Edouard Tisserant
parents:
diff changeset
    42
from Pyro.util import Log
84b3cc18893b Replaced PYROSSL with PYROPSK.
Edouard Tisserant
parents:
diff changeset
    43
2492
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
    44
2312
84b3cc18893b Replaced PYROSSL with PYROPSK.
Edouard Tisserant
parents:
diff changeset
    45
class PYROPSKAdapter(PYROAdapter):
2544
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
    46
    """
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
    47
    This is essentialy the same as in Pyro/protocol.py
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
    48
    only raw_sock wrapping into sock through sslpsk.wrap_socket was added
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
    49
    Pyro unfortunately doesn't allow cleaner customization
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
    50
    """
640d639d9bd8 Fix header and convert comments to docstrings in PSK_Adapter
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2543
diff changeset
    51
2492
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
    52
    def bindToURI(self, URI):
2312
84b3cc18893b Replaced PYROSSL with PYROPSK.
Edouard Tisserant
parents:
diff changeset
    53
        with self.lock:   # only 1 thread at a time can bind the URI
84b3cc18893b Replaced PYROSSL with PYROPSK.
Edouard Tisserant
parents:
diff changeset
    54
            try:
2492
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
    55
                self.URI = URI
2312
84b3cc18893b Replaced PYROSSL with PYROPSK.
Edouard Tisserant
parents:
diff changeset
    56
84b3cc18893b Replaced PYROSSL with PYROPSK.
Edouard Tisserant
parents:
diff changeset
    57
                # This are the statements that differ from Pyro/protocol.py
84b3cc18893b Replaced PYROSSL with PYROPSK.
Edouard Tisserant
parents:
diff changeset
    58
                raw_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
84b3cc18893b Replaced PYROSSL with PYROPSK.
Edouard Tisserant
parents:
diff changeset
    59
                _connect_socket(raw_sock, URI.address, URI.port, self.timeout)
84b3cc18893b Replaced PYROSSL with PYROPSK.
Edouard Tisserant
parents:
diff changeset
    60
                sock = sslpsk.wrap_socket(
2313
2eaf235270f8 PYRO/TLSPSK : fixed typos, used appropriate ciphers (https://github.com/drbild/sslpsk/issues/3), use PYROPSK instead of unresolvable PYROLOCPSK.
Edouard Tisserant
parents: 2312
diff changeset
    61
                    raw_sock, psk=Pyro.config.PYROPSK, server_side=False,
2492
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
    62
                    ciphers="PSK-AES256-CBC-SHA",  # available in openssl 1.0.2
2316
5416c76df9e2 Fix PYROPSK protocol configuration. After a few iteration of trial and error it appears that TSLv1 and PSK ciphers needs to be specified
Edouard Tisserant
parents: 2314
diff changeset
    63
                    ssl_version=ssl.PROTOCOL_TLSv1)
2492
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
    64
                # all the rest is the same as in Pyro/protocol.py
2312
84b3cc18893b Replaced PYROSSL with PYROPSK.
Edouard Tisserant
parents:
diff changeset
    65
2492
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
    66
                conn = TCPConnection(sock, sock.getpeername())
2312
84b3cc18893b Replaced PYROSSL with PYROPSK.
Edouard Tisserant
parents:
diff changeset
    67
                # receive the authentication challenge string, and use that to build the actual identification string.
84b3cc18893b Replaced PYROSSL with PYROPSK.
Edouard Tisserant
parents:
diff changeset
    68
                try:
2492
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
    69
                    authChallenge = self.recvAuthChallenge(conn)
2536
2747d6e72eb8 Fix invalid python3 syntax
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2492
diff changeset
    70
                except ProtocolError as x:
2312
84b3cc18893b Replaced PYROSSL with PYROPSK.
Edouard Tisserant
parents:
diff changeset
    71
                    # check if we were denied
2492
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
    72
                    if hasattr(x, "partialMsg") and x.partialMsg[:len(self.denyMSG)] == self.denyMSG:
2312
84b3cc18893b Replaced PYROSSL with PYROPSK.
Edouard Tisserant
parents:
diff changeset
    73
                        raise ConnectionDeniedError(Pyro.constants.deniedReasons[int(x.partialMsg[-1])])
84b3cc18893b Replaced PYROSSL with PYROPSK.
Edouard Tisserant
parents:
diff changeset
    74
                    else:
84b3cc18893b Replaced PYROSSL with PYROPSK.
Edouard Tisserant
parents:
diff changeset
    75
                        raise
84b3cc18893b Replaced PYROSSL with PYROPSK.
Edouard Tisserant
parents:
diff changeset
    76
                # reply with our ident token, generated from the ident passphrase and the challenge
2492
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
    77
                msg = self._sendConnect(sock, self.newConnValidator.createAuthToken(self.ident, authChallenge, conn.addr, self.URI, None))
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
    78
                if msg == self.acceptMSG:
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
    79
                    self.conn = conn
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
    80
                    self.conn.connected = 1
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
    81
                    Log.msg('PYROAdapter', 'connected to', str(URI))
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
    82
                    if URI.protocol == 'PYROLOCPSK':
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
    83
                        self.resolvePYROLOC_URI("PYROPSK")  # updates self.URI
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
    84
                elif msg[:len(self.denyMSG)] == self.denyMSG:
2312
84b3cc18893b Replaced PYROSSL with PYROPSK.
Edouard Tisserant
parents:
diff changeset
    85
                    try:
84b3cc18893b Replaced PYROSSL with PYROPSK.
Edouard Tisserant
parents:
diff changeset
    86
                        raise ConnectionDeniedError(Pyro.constants.deniedReasons[int(msg[-1])])
2492
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
    87
                    except (KeyError, ValueError):
2312
84b3cc18893b Replaced PYROSSL with PYROPSK.
Edouard Tisserant
parents:
diff changeset
    88
                        raise ConnectionDeniedError('invalid response')
84b3cc18893b Replaced PYROSSL with PYROPSK.
Edouard Tisserant
parents:
diff changeset
    89
            except socket.error:
2492
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
    90
                Log.msg('PYROAdapter', 'connection failed to URI', str(URI))
2312
84b3cc18893b Replaced PYROSSL with PYROPSK.
Edouard Tisserant
parents:
diff changeset
    91
                raise ProtocolError('connection failed')
84b3cc18893b Replaced PYROSSL with PYROPSK.
Edouard Tisserant
parents:
diff changeset
    92
2492
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
    93
2312
84b3cc18893b Replaced PYROSSL with PYROPSK.
Edouard Tisserant
parents:
diff changeset
    94
_getProtocolAdapter = Pyro.protocol.getProtocolAdapter
2492
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
    95
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
    96
2312
84b3cc18893b Replaced PYROSSL with PYROPSK.
Edouard Tisserant
parents:
diff changeset
    97
def getProtocolAdapter(protocol):
84b3cc18893b Replaced PYROSSL with PYROPSK.
Edouard Tisserant
parents:
diff changeset
    98
    if protocol in ('PYROPSK', 'PYROLOCPSK'):
84b3cc18893b Replaced PYROSSL with PYROPSK.
Edouard Tisserant
parents:
diff changeset
    99
        return PYROPSKAdapter()
2318
8925d487605a Fixed PYRO's PSK_Adapter : monkey patching was breaking non-PSK protocol, and import ssl was missing.
Edouard Tisserant
parents: 2316
diff changeset
   100
    return _getProtocolAdapter(protocol)
2312
84b3cc18893b Replaced PYROSSL with PYROPSK.
Edouard Tisserant
parents:
diff changeset
   101
2492
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
   102
2314
e927c101ce6d PYRO/TLSPSK : must use PYROLOC* protocol scheme in pyro URI, otherwise object ID is missing. Had to use more persuasive pyro3 monkey patching to have PYROLOCPSK resolved properly
Edouard Tisserant
parents: 2313
diff changeset
   103
_processStringURI = Pyro.core.processStringURI
2492
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
   104
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
   105
2314
e927c101ce6d PYRO/TLSPSK : must use PYROLOC* protocol scheme in pyro URI, otherwise object ID is missing. Had to use more persuasive pyro3 monkey patching to have PYROLOCPSK resolved properly
Edouard Tisserant
parents: 2313
diff changeset
   106
def processStringURI(URI):
2492
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
   107
    x = re.match(r'(?P<protocol>PYROLOCPSK)://(?P<hostname>[^\s:]+):?(?P<port>\d+)?/(?P<name>\S*)', URI)
2314
e927c101ce6d PYRO/TLSPSK : must use PYROLOC* protocol scheme in pyro URI, otherwise object ID is missing. Had to use more persuasive pyro3 monkey patching to have PYROLOCPSK resolved properly
Edouard Tisserant
parents: 2313
diff changeset
   108
    if x:
2492
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
   109
        protocol = x.group('protocol')
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
   110
        hostname = x.group('hostname')
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
   111
        port = x.group('port')
2314
e927c101ce6d PYRO/TLSPSK : must use PYROLOC* protocol scheme in pyro URI, otherwise object ID is missing. Had to use more persuasive pyro3 monkey patching to have PYROLOCPSK resolved properly
Edouard Tisserant
parents: 2313
diff changeset
   112
        if port:
2492
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
   113
            port = int(port)
2314
e927c101ce6d PYRO/TLSPSK : must use PYROLOC* protocol scheme in pyro URI, otherwise object ID is missing. Had to use more persuasive pyro3 monkey patching to have PYROLOCPSK resolved properly
Edouard Tisserant
parents: 2313
diff changeset
   114
        else:
2492
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
   115
            port = 0
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
   116
        name = x.group('name')
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
   117
        return PyroURI(hostname, name, port, protocol)
2314
e927c101ce6d PYRO/TLSPSK : must use PYROLOC* protocol scheme in pyro URI, otherwise object ID is missing. Had to use more persuasive pyro3 monkey patching to have PYROLOCPSK resolved properly
Edouard Tisserant
parents: 2313
diff changeset
   118
    return _processStringURI(URI)
2492
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
   119
7dd551ac2fa0 check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2325
diff changeset
   120
2543
2befed4d6ca8 Fix Pyro work with SSL wrapper (sslpsk)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2537
diff changeset
   121
def setupPSKAdapter():
2befed4d6ca8 Fix Pyro work with SSL wrapper (sslpsk)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2537
diff changeset
   122
    """
2befed4d6ca8 Fix Pyro work with SSL wrapper (sslpsk)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2537
diff changeset
   123
    Add PyroAdapter to the list of available in
2befed4d6ca8 Fix Pyro work with SSL wrapper (sslpsk)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2537
diff changeset
   124
    Pyro adapters and handle new supported protocols
2befed4d6ca8 Fix Pyro work with SSL wrapper (sslpsk)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2537
diff changeset
   125
2befed4d6ca8 Fix Pyro work with SSL wrapper (sslpsk)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2537
diff changeset
   126
    This function should be called after
2befed4d6ca8 Fix Pyro work with SSL wrapper (sslpsk)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2537
diff changeset
   127
    reimport of Pyro module to enable PYROS:// again.
2befed4d6ca8 Fix Pyro work with SSL wrapper (sslpsk)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2537
diff changeset
   128
    """
2befed4d6ca8 Fix Pyro work with SSL wrapper (sslpsk)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2537
diff changeset
   129
    Pyro.protocol.getProtocolAdapter = getProtocolAdapter
2befed4d6ca8 Fix Pyro work with SSL wrapper (sslpsk)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2537
diff changeset
   130
    Pyro.core.processStringURI = processStringURI