]> source.dussan.org Git - rspamd.git/commitdiff
[Test] Add dummy ssl echo server
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 31 May 2019 14:19:29 +0000 (15:19 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 31 May 2019 14:19:29 +0000 (15:19 +0100)
test/functional/util/dummy_ssl.py [new file with mode: 0755]
test/functional/util/server.pem [new file with mode: 0644]

diff --git a/test/functional/util/dummy_ssl.py b/test/functional/util/dummy_ssl.py
new file mode 100755 (executable)
index 0000000..7928446
--- /dev/null
@@ -0,0 +1,69 @@
+#!/usr/bin/env python
+
+import SocketServer
+import dummy_killer
+
+import time
+import os
+import sys
+import socket
+import ssl
+
+PORT = 14433
+HOST_NAME = '127.0.0.1'
+
+PID = "/tmp/dummy_ssl.pid"
+
+class SSLTCPHandler(SocketServer.BaseRequestHandler):
+    def handle(self):
+        data = self.request.recv(1024)
+        while data:
+            print "{} wrote:".format(self.client_address[0])
+            print data
+            self.request.sendall(data)
+            data = self.request.recv(1024)
+
+class SSL_TCP_Server(SocketServer.TCPServer):
+    def __init__(self,
+                 server_address,
+                 RequestHandlerClass,
+                 certfile,
+                 keyfile,
+                 ssl_version=ssl.PROTOCOL_TLSv1,
+                 bind_and_activate=True):
+        self.allow_reuse_address = True
+        SocketServer.TCPServer.__init__(self, server_address,
+                                        RequestHandlerClass, bind_and_activate)
+        self.certfile = certfile
+        self.keyfile = keyfile
+        self.ssl_version = ssl_version
+        #self.timeout = 1
+
+    def get_request(self):
+        newsocket, fromaddr = self.socket.accept()
+        connstream = ssl.wrap_socket(newsocket,
+                                     server_side=True,
+                                     certfile = self.certfile,
+                                     keyfile = self.keyfile,
+                                     ssl_version = self.ssl_version)
+        return connstream, fromaddr
+
+    def run(self):
+        dummy_killer.write_pid(PID)
+        try:
+            self.serve_forever()
+        except KeyboardInterrupt:
+            print "Interrupt"
+        except socket.error as e:
+            print "Socket closed {}".format(e)
+
+    def stop(self):
+        self.keep_running = False
+        self.server_close()
+
+class SSL_ThreadingTCPServer(SocketServer.ThreadingMixIn, SSL_TCP_Server): pass
+
+if __name__ == '__main__':
+    server = SSL_ThreadingTCPServer((HOST_NAME, PORT), SSLTCPHandler, sys.argv[1], sys.argv[1])
+    dummy_killer.setup_killer(server, server.stop)
+    server.run()
diff --git a/test/functional/util/server.pem b/test/functional/util/server.pem
new file mode 100644 (file)
index 0000000..b5ec4c3
--- /dev/null
@@ -0,0 +1,46 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIEpAIBAAKCAQEA1nROqQC9tDLdnC2o1246g1T/oDq5Szbktof7TPHm/wDmWG47
+pwD22UkyEXthlq9kT9BZEgN6E2XF9UeA/7tZw7S4nbDUY/gWoGu7KlGLIIb5YXBW
+CzSHAwlJtW/Pg5Muk7vJldHOufBJXP99PjJVzZZuYvv9+JJfSWHEeuY+RysWnTX5
+saq4cwDG8fCKqKEwy8PKatr8eJFL1/cPnC/0SAB77mIEdYHV5hBDUoNTpPWQrB2s
+SgTqLa2pYTCWGUAvu4TiZKx00f6Z7soLa8RXddhEj6Qu5zLl+t5Llc8iSr7MgWTZ
+0PD/lChOUg7H9STM4KiQ/qtBvSyGB0Cz71aWdQIDAQABAoIBAQDVAuG+7IWBn6SP
+pKq4kTx9hsgCF1JFa1jyFU9/tieD0xj5bUTDNSn72cBprOvaCIzS2lgelGWFLuna
+IBP579XRlohp2WKdiaav4VIfTq+qt2atai+NIbeZRHh6R30Pa/ovs68fqS51cj7s
+qLl2NfkUI/+xQiuZ44nSEdJfYKMre8d/sF2zWg5sO5DaJWYsKdAqclRR4q8ZrEQY
+6AZ8hsAlsyczpvU1A7Y/XWnyg7jr2towxeAbey13phFdukrZnRq2pRaprvwA1KqC
+AtO0jx7L3MP3eamwQaNyaBD/PE+wnGpbPr36oU1ewhUTSZUlx3aYzaUDPrqMWwMk
+7cb/gnsBAoGBAO9OQCnVE4D8r3DCRtmFfgqasWIakEs591+lzVSnHrLDsiaPk/5Q
+Rv6FAyxU8T78SJN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