Version 0.3.1, rev238, Connection encryption using TLS, One click site clone feature, Encryption stats, Disable encryption startup parameter, Disable ssl compression startup parameter, Exchange supported encryption methods at handshake, Alternative open port checker, Option to store site privatekey in users.json, Torrent tracker swap, Test for bip32 based site creation, cloning and sslcert creation, Fix for Chrome plugin on OSX, Separate siteSign websocket command, Update pybitcointools to major speedup, Re-add sslwrap for python 0.2.9+, Disable SSL compression to save memory and better performance
2015-06-10 00:29:30 +02:00
|
|
|
#!/usr/bin/python2
|
2015-07-12 20:36:46 +02:00
|
|
|
from gevent import monkey
|
|
|
|
monkey.patch_all()
|
|
|
|
import os
|
|
|
|
import time
|
|
|
|
import sys
|
|
|
|
import socket
|
|
|
|
import ssl
|
|
|
|
sys.path.append(os.path.abspath("src")) # Imports relative to src dir
|
Version 0.3.1, rev238, Connection encryption using TLS, One click site clone feature, Encryption stats, Disable encryption startup parameter, Disable ssl compression startup parameter, Exchange supported encryption methods at handshake, Alternative open port checker, Option to store site privatekey in users.json, Torrent tracker swap, Test for bip32 based site creation, cloning and sslcert creation, Fix for Chrome plugin on OSX, Separate siteSign websocket command, Update pybitcointools to major speedup, Re-add sslwrap for python 0.2.9+, Disable SSL compression to save memory and better performance
2015-06-10 00:29:30 +02:00
|
|
|
|
|
|
|
import cStringIO as StringIO
|
|
|
|
import gevent
|
2015-07-12 20:36:46 +02:00
|
|
|
|
Version 0.3.1, rev238, Connection encryption using TLS, One click site clone feature, Encryption stats, Disable encryption startup parameter, Disable ssl compression startup parameter, Exchange supported encryption methods at handshake, Alternative open port checker, Option to store site privatekey in users.json, Torrent tracker swap, Test for bip32 based site creation, cloning and sslcert creation, Fix for Chrome plugin on OSX, Separate siteSign websocket command, Update pybitcointools to major speedup, Re-add sslwrap for python 0.2.9+, Disable SSL compression to save memory and better performance
2015-06-10 00:29:30 +02:00
|
|
|
from gevent.server import StreamServer
|
|
|
|
from gevent.pool import Pool
|
|
|
|
from util import SslPatch
|
|
|
|
|
|
|
|
|
|
|
|
# Server
|
|
|
|
socks = []
|
2015-07-12 20:36:46 +02:00
|
|
|
data = os.urandom(1024 * 100)
|
Version 0.3.1, rev238, Connection encryption using TLS, One click site clone feature, Encryption stats, Disable encryption startup parameter, Disable ssl compression startup parameter, Exchange supported encryption methods at handshake, Alternative open port checker, Option to store site privatekey in users.json, Torrent tracker swap, Test for bip32 based site creation, cloning and sslcert creation, Fix for Chrome plugin on OSX, Separate siteSign websocket command, Update pybitcointools to major speedup, Re-add sslwrap for python 0.2.9+, Disable SSL compression to save memory and better performance
2015-06-10 00:29:30 +02:00
|
|
|
data += "\n"
|
|
|
|
|
2015-07-12 20:36:46 +02:00
|
|
|
|
Version 0.3.1, rev238, Connection encryption using TLS, One click site clone feature, Encryption stats, Disable encryption startup parameter, Disable ssl compression startup parameter, Exchange supported encryption methods at handshake, Alternative open port checker, Option to store site privatekey in users.json, Torrent tracker swap, Test for bip32 based site creation, cloning and sslcert creation, Fix for Chrome plugin on OSX, Separate siteSign websocket command, Update pybitcointools to major speedup, Re-add sslwrap for python 0.2.9+, Disable SSL compression to save memory and better performance
2015-06-10 00:29:30 +02:00
|
|
|
def handle(sock_raw, addr):
|
2015-07-12 20:36:46 +02:00
|
|
|
socks.append(sock_raw)
|
|
|
|
sock = sock_raw
|
|
|
|
# sock = ctx.wrap_socket(sock, server_side=True)
|
|
|
|
# if sock_raw.recv( 1, gevent.socket.MSG_PEEK ) == "\x16":
|
|
|
|
# sock = gevent.ssl.wrap_socket(sock_raw, server_side=True, keyfile='key-cz.pem',
|
|
|
|
# certfile='cert-cz.pem', ciphers=ciphers, ssl_version=ssl.PROTOCOL_TLSv1)
|
|
|
|
# fp = os.fdopen(sock.fileno(), 'rb', 1024*512)
|
|
|
|
try:
|
|
|
|
while True:
|
|
|
|
line = sock.recv(16 * 1024)
|
|
|
|
if not line:
|
|
|
|
break
|
|
|
|
if line == "bye\n":
|
|
|
|
break
|
|
|
|
elif line == "gotssl\n":
|
|
|
|
sock.sendall("yes\n")
|
|
|
|
sock = gevent.ssl.wrap_socket(
|
|
|
|
sock_raw, server_side=True, keyfile='data/key-rsa.pem', certfile='data/cert-rsa.pem',
|
|
|
|
ciphers=ciphers, ssl_version=ssl.PROTOCOL_TLSv1
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
sock.sendall(data)
|
|
|
|
except Exception, err:
|
|
|
|
print err
|
|
|
|
try:
|
|
|
|
sock.shutdown(gevent.socket.SHUT_WR)
|
|
|
|
sock.close()
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
socks.remove(sock_raw)
|
|
|
|
|
|
|
|
pool = Pool(1000) # do not accept more than 10000 connections
|
|
|
|
server = StreamServer(('127.0.0.1', 1234), handle)
|
|
|
|
server.start()
|
Version 0.3.1, rev238, Connection encryption using TLS, One click site clone feature, Encryption stats, Disable encryption startup parameter, Disable ssl compression startup parameter, Exchange supported encryption methods at handshake, Alternative open port checker, Option to store site privatekey in users.json, Torrent tracker swap, Test for bip32 based site creation, cloning and sslcert creation, Fix for Chrome plugin on OSX, Separate siteSign websocket command, Update pybitcointools to major speedup, Re-add sslwrap for python 0.2.9+, Disable SSL compression to save memory and better performance
2015-06-10 00:29:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
# Client
|
|
|
|
|
|
|
|
|
|
|
|
total_num = 0
|
|
|
|
total_bytes = 0
|
|
|
|
clipher = None
|
2015-07-12 20:36:46 +02:00
|
|
|
ciphers = "ECDHE-ECDSA-AES128-GCM-SHA256:ECDH+AES128:ECDHE-RSA-AES128-GCM-SHA256:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:HIGH:" + \
|
|
|
|
"!aNULL:!eNULL:!EXPORT:!DSS:!DES:!RC4:!3DES:!MD5:!PSK"
|
Version 0.3.1, rev238, Connection encryption using TLS, One click site clone feature, Encryption stats, Disable encryption startup parameter, Disable ssl compression startup parameter, Exchange supported encryption methods at handshake, Alternative open port checker, Option to store site privatekey in users.json, Torrent tracker swap, Test for bip32 based site creation, cloning and sslcert creation, Fix for Chrome plugin on OSX, Separate siteSign websocket command, Update pybitcointools to major speedup, Re-add sslwrap for python 0.2.9+, Disable SSL compression to save memory and better performance
2015-06-10 00:29:30 +02:00
|
|
|
|
|
|
|
# ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
|
|
|
|
|
2015-07-12 20:36:46 +02:00
|
|
|
|
Version 0.3.1, rev238, Connection encryption using TLS, One click site clone feature, Encryption stats, Disable encryption startup parameter, Disable ssl compression startup parameter, Exchange supported encryption methods at handshake, Alternative open port checker, Option to store site privatekey in users.json, Torrent tracker swap, Test for bip32 based site creation, cloning and sslcert creation, Fix for Chrome plugin on OSX, Separate siteSign websocket command, Update pybitcointools to major speedup, Re-add sslwrap for python 0.2.9+, Disable SSL compression to save memory and better performance
2015-06-10 00:29:30 +02:00
|
|
|
def getData():
|
2015-07-12 20:36:46 +02:00
|
|
|
global total_num, total_bytes, clipher
|
|
|
|
data = None
|
|
|
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
|
|
# sock = socket.ssl(s)
|
|
|
|
# sock = ssl.wrap_socket(sock)
|
|
|
|
sock.connect(("127.0.0.1", 1234))
|
|
|
|
# sock.do_handshake()
|
|
|
|
# clipher = sock.cipher()
|
|
|
|
sock.send("gotssl\n")
|
|
|
|
if sock.recv(128) == "yes\n":
|
|
|
|
sock = ssl.wrap_socket(sock, ciphers=ciphers, ssl_version=ssl.PROTOCOL_TLSv1)
|
|
|
|
sock.do_handshake()
|
|
|
|
clipher = sock.cipher()
|
|
|
|
|
|
|
|
for req in range(100):
|
|
|
|
sock.sendall("req\n")
|
|
|
|
buff = StringIO.StringIO()
|
|
|
|
data = sock.recv(16 * 1024)
|
|
|
|
buff.write(data)
|
|
|
|
if not data:
|
|
|
|
break
|
|
|
|
while not data.endswith("\n"):
|
|
|
|
data = sock.recv(16 * 1024)
|
|
|
|
if not data:
|
|
|
|
break
|
|
|
|
buff.write(data)
|
|
|
|
total_num += 1
|
|
|
|
total_bytes += buff.tell()
|
|
|
|
if not data:
|
|
|
|
print "No data"
|
|
|
|
|
|
|
|
sock.shutdown(gevent.socket.SHUT_WR)
|
|
|
|
sock.close()
|
Version 0.3.1, rev238, Connection encryption using TLS, One click site clone feature, Encryption stats, Disable encryption startup parameter, Disable ssl compression startup parameter, Exchange supported encryption methods at handshake, Alternative open port checker, Option to store site privatekey in users.json, Torrent tracker swap, Test for bip32 based site creation, cloning and sslcert creation, Fix for Chrome plugin on OSX, Separate siteSign websocket command, Update pybitcointools to major speedup, Re-add sslwrap for python 0.2.9+, Disable SSL compression to save memory and better performance
2015-06-10 00:29:30 +02:00
|
|
|
|
|
|
|
s = time.time()
|
|
|
|
|
2015-07-12 20:36:46 +02:00
|
|
|
|
Version 0.3.1, rev238, Connection encryption using TLS, One click site clone feature, Encryption stats, Disable encryption startup parameter, Disable ssl compression startup parameter, Exchange supported encryption methods at handshake, Alternative open port checker, Option to store site privatekey in users.json, Torrent tracker swap, Test for bip32 based site creation, cloning and sslcert creation, Fix for Chrome plugin on OSX, Separate siteSign websocket command, Update pybitcointools to major speedup, Re-add sslwrap for python 0.2.9+, Disable SSL compression to save memory and better performance
2015-06-10 00:29:30 +02:00
|
|
|
def info():
|
2015-07-12 20:36:46 +02:00
|
|
|
import psutil
|
|
|
|
import os
|
|
|
|
process = psutil.Process(os.getpid())
|
|
|
|
if "memory_info" in dir(process):
|
|
|
|
memory_info = process.memory_info
|
|
|
|
else:
|
|
|
|
memory_info = process.get_memory_info
|
|
|
|
while 1:
|
|
|
|
print total_num, "req", (total_bytes / 1024), "kbytes", "transfered in", time.time() - s,
|
|
|
|
print "using", clipher, "Mem:", memory_info()[0] / float(2 ** 20)
|
|
|
|
time.sleep(1)
|
Version 0.3.1, rev238, Connection encryption using TLS, One click site clone feature, Encryption stats, Disable encryption startup parameter, Disable ssl compression startup parameter, Exchange supported encryption methods at handshake, Alternative open port checker, Option to store site privatekey in users.json, Torrent tracker swap, Test for bip32 based site creation, cloning and sslcert creation, Fix for Chrome plugin on OSX, Separate siteSign websocket command, Update pybitcointools to major speedup, Re-add sslwrap for python 0.2.9+, Disable SSL compression to save memory and better performance
2015-06-10 00:29:30 +02:00
|
|
|
|
|
|
|
gevent.spawn(info)
|
|
|
|
|
|
|
|
for test in range(10):
|
2015-07-12 20:36:46 +02:00
|
|
|
clients = []
|
|
|
|
for i in range(10): # Thread
|
|
|
|
clients.append(gevent.spawn(getData))
|
|
|
|
gevent.joinall(clients)
|
Version 0.3.1, rev238, Connection encryption using TLS, One click site clone feature, Encryption stats, Disable encryption startup parameter, Disable ssl compression startup parameter, Exchange supported encryption methods at handshake, Alternative open port checker, Option to store site privatekey in users.json, Torrent tracker swap, Test for bip32 based site creation, cloning and sslcert creation, Fix for Chrome plugin on OSX, Separate siteSign websocket command, Update pybitcointools to major speedup, Re-add sslwrap for python 0.2.9+, Disable SSL compression to save memory and better performance
2015-06-10 00:29:30 +02:00
|
|
|
|
|
|
|
|
2015-07-12 20:36:46 +02:00
|
|
|
print total_num, "req", (total_bytes / 1024), "kbytes", "transfered in", time.time() - s
|
Version 0.3.1, rev238, Connection encryption using TLS, One click site clone feature, Encryption stats, Disable encryption startup parameter, Disable ssl compression startup parameter, Exchange supported encryption methods at handshake, Alternative open port checker, Option to store site privatekey in users.json, Torrent tracker swap, Test for bip32 based site creation, cloning and sslcert creation, Fix for Chrome plugin on OSX, Separate siteSign websocket command, Update pybitcointools to major speedup, Re-add sslwrap for python 0.2.9+, Disable SSL compression to save memory and better performance
2015-06-10 00:29:30 +02:00
|
|
|
|
|
|
|
# Separate client/server process:
|
|
|
|
# 10*10*100:
|
2015-07-12 20:36:46 +02:00
|
|
|
# Raw: 10000 req 1000009 kbytes transfered in 5.39999985695
|
Version 0.3.1, rev238, Connection encryption using TLS, One click site clone feature, Encryption stats, Disable encryption startup parameter, Disable ssl compression startup parameter, Exchange supported encryption methods at handshake, Alternative open port checker, Option to store site privatekey in users.json, Torrent tracker swap, Test for bip32 based site creation, cloning and sslcert creation, Fix for Chrome plugin on OSX, Separate siteSign websocket command, Update pybitcointools to major speedup, Re-add sslwrap for python 0.2.9+, Disable SSL compression to save memory and better performance
2015-06-10 00:29:30 +02:00
|
|
|
# RSA 2048: 10000 req 1000009 kbytes transfered in 27.7890000343 using ('ECDHE-RSA-AES256-SHA', 'TLSv1/SSLv3', 256)
|
2015-07-12 20:36:46 +02:00
|
|
|
# ECC: 10000 req 1000009 kbytes transfered in 26.1959998608 using ('ECDHE-ECDSA-AES256-SHA', 'TLSv1/SSLv3', 256)
|
|
|
|
# ECC: 10000 req 1000009 kbytes transfered in 28.2410001755 using ('ECDHE-ECDSA-AES256-GCM-SHA384', 'TLSv1/SSLv3', 256) Mem: 13.3828125
|
Version 0.3.1, rev238, Connection encryption using TLS, One click site clone feature, Encryption stats, Disable encryption startup parameter, Disable ssl compression startup parameter, Exchange supported encryption methods at handshake, Alternative open port checker, Option to store site privatekey in users.json, Torrent tracker swap, Test for bip32 based site creation, cloning and sslcert creation, Fix for Chrome plugin on OSX, Separate siteSign websocket command, Update pybitcointools to major speedup, Re-add sslwrap for python 0.2.9+, Disable SSL compression to save memory and better performance
2015-06-10 00:29:30 +02:00
|
|
|
#
|
|
|
|
# 10*100*10:
|
2015-07-12 20:36:46 +02:00
|
|
|
# Raw: 10000 req 1000009 kbytes transfered in 7.02700018883 Mem: 14.328125
|
|
|
|
# RSA 2048: 10000 req 1000009 kbytes transfered in 44.8860001564 using ('ECDHE-RSA-AES256-GCM-SHA384', 'TLSv1/SSLv3', 256) Mem: 20.078125
|
|
|
|
# ECC: 10000 req 1000009 kbytes transfered in 37.9430000782 using ('ECDHE-ECDSA-AES256-GCM-SHA384', 'TLSv1/SSLv3', 256) Mem: 20.0234375
|
Version 0.3.1, rev238, Connection encryption using TLS, One click site clone feature, Encryption stats, Disable encryption startup parameter, Disable ssl compression startup parameter, Exchange supported encryption methods at handshake, Alternative open port checker, Option to store site privatekey in users.json, Torrent tracker swap, Test for bip32 based site creation, cloning and sslcert creation, Fix for Chrome plugin on OSX, Separate siteSign websocket command, Update pybitcointools to major speedup, Re-add sslwrap for python 0.2.9+, Disable SSL compression to save memory and better performance
2015-06-10 00:29:30 +02:00
|
|
|
#
|
|
|
|
# 1*100*100:
|
2015-07-12 20:36:46 +02:00
|
|
|
# Raw: 10000 req 1000009 kbytes transfered in 4.64400005341 Mem: 14.06640625
|
|
|
|
# RSA: 10000 req 1000009 kbytes transfered in 24.2300000191 using ('ECDHE-RSA-AES256-GCM-SHA384', 'TLSv1/SSLv3', 256) Mem: 19.7734375
|
|
|
|
# ECC: 10000 req 1000009 kbytes transfered in 22.8849999905 using ('ECDHE-ECDSA-AES256-GCM-SHA384', 'TLSv1/SSLv3', 256) Mem: 17.8125
|
|
|
|
# AES128: 10000 req 1000009 kbytes transfered in 21.2839999199 using ('AES128-GCM-SHA256', 'TLSv1/SSLv3', 128) Mem: 14.1328125
|
|
|
|
# ECC+128: 10000 req 1000009 kbytes transfered in 20.496999979 using ('ECDHE-ECDSA-AES128-GCM-SHA256', 'TLSv1/SSLv3', 128) Mem: 14.40234375
|
Version 0.3.1, rev238, Connection encryption using TLS, One click site clone feature, Encryption stats, Disable encryption startup parameter, Disable ssl compression startup parameter, Exchange supported encryption methods at handshake, Alternative open port checker, Option to store site privatekey in users.json, Torrent tracker swap, Test for bip32 based site creation, cloning and sslcert creation, Fix for Chrome plugin on OSX, Separate siteSign websocket command, Update pybitcointools to major speedup, Re-add sslwrap for python 0.2.9+, Disable SSL compression to save memory and better performance
2015-06-10 00:29:30 +02:00
|
|
|
#
|
|
|
|
#
|
|
|
|
# Single process:
|
|
|
|
# 1*100*100
|
2015-07-12 20:36:46 +02:00
|
|
|
# RSA: 10000 req 1000009 kbytes transfered in 41.7899999619 using ('ECDHE-RSA-AES128-GCM-SHA256', 'TLSv1/SSLv3', 128) Mem: 26.91015625
|
Version 0.3.1, rev238, Connection encryption using TLS, One click site clone feature, Encryption stats, Disable encryption startup parameter, Disable ssl compression startup parameter, Exchange supported encryption methods at handshake, Alternative open port checker, Option to store site privatekey in users.json, Torrent tracker swap, Test for bip32 based site creation, cloning and sslcert creation, Fix for Chrome plugin on OSX, Separate siteSign websocket command, Update pybitcointools to major speedup, Re-add sslwrap for python 0.2.9+, Disable SSL compression to save memory and better performance
2015-06-10 00:29:30 +02:00
|
|
|
#
|
|
|
|
# 10*10*100
|
2015-07-12 20:36:46 +02:00
|
|
|
# RSA: 10000 req 1000009 kbytes transfered in 40.1640000343 using ('ECDHE-RSA-AES128-GCM-SHA256', 'TLSv1/SSLv3', 128) Mem: 14.94921875
|