예제 #1
0
    def __init__(self, version=VERSION_TLS12, server=None):
        self.server = server
        if not self.server:
            self.server = socket.TCPServer()

        key = SSLPrivateKey.generate()
        cert = SSLCertificate.generate(key)
        self.context = SSLContext(version)
        self.context.set_certificate(cert, key)
예제 #2
0
    def __init__(self, use_ssl, server=None):
        self.ssl = use_ssl
        self.server = server

        if not self.server:
            if use_ssl:
                self.server = ssl.SSLServer()
            else:
                self.server = socket.TCPServer()
예제 #3
0
    def __init__(self, settings, server=None):
        self.settings = settings
        self.server = server

        if not self.server:
            transport_type = settings.get("prudp.transport")
            if transport_type == settings.TRANSPORT_UDP:
                self.server = socket.UDPServer()
            elif transport_type == settings.TRANSPORT_TCP:
                self.server = socket.TCPServer()
            else:
                self.server = websocket.WebSocketServer(True)

        self.sockets = []
예제 #4
0
 def start(self, host, port):
     sock = self.context.wrap(self.server.fd())
     wrapper = socket.SocketWrapper(sock)
     self.server = socket.TCPServer(wrapper)
     self.server.start(host, port)