Add https experience
Signed-off-by: Benjamin Hesmans <benjamin.hesmans@uclouvain.be>
This commit is contained in:
parent
3fa6fcb19f
commit
dd56e490d6
5
src/conf/https/topo
Normal file
5
src/conf/https/topo
Normal file
@ -0,0 +1,5 @@
|
||||
leftSubnet:10.0.
|
||||
rightSubnet:10.1.
|
||||
path_0:100,20,4
|
||||
path_1:1,20,4
|
||||
topoType:MultiIf
|
5
src/conf/https/xp
Normal file
5
src/conf/https/xp
Normal file
@ -0,0 +1,5 @@
|
||||
xpType:https
|
||||
clientPcap:yes
|
||||
kpms:fullmesh
|
||||
kpmc:fullmesh
|
||||
rmem:300000 300000 300000
|
54
src/https.py
Normal file
54
src/https.py
Normal file
@ -0,0 +1,54 @@
|
||||
'''
|
||||
From :
|
||||
http://code.activestate.com/recipes/442473-simple-http-server-supporting-ssl-secure-communica/
|
||||
|
||||
SimpleSecureHTTPServer.py - simple HTTP server supporting SSL.
|
||||
|
||||
- replace fpem with the location of your .pem server file.
|
||||
- the default port is 443.
|
||||
|
||||
usage: python SimpleSecureHTTPServer.py
|
||||
'''
|
||||
|
||||
import socket, os
|
||||
from SocketServer import BaseServer
|
||||
from BaseHTTPServer import HTTPServer
|
||||
from SimpleHTTPServer import SimpleHTTPRequestHandler
|
||||
from OpenSSL import SSL
|
||||
|
||||
|
||||
class SecureHTTPServer(HTTPServer):
|
||||
def __init__(self, server_address, HandlerClass):
|
||||
BaseServer.__init__(self, server_address, HandlerClass)
|
||||
ctx = SSL.Context(SSL.SSLv23_METHOD)
|
||||
#server.pem's location (containing the server private key and
|
||||
#the server certificate).
|
||||
fpem = os.path.dirname(os.path.abspath(__file__)) + "/server.pem"
|
||||
ctx.use_privatekey_file (fpem)
|
||||
ctx.use_certificate_file(fpem)
|
||||
self.socket = SSL.Connection(ctx, socket.socket(self.address_family,
|
||||
self.socket_type))
|
||||
self.server_bind()
|
||||
self.server_activate()
|
||||
|
||||
def shutdown_request(self,request):
|
||||
request.shutdown()
|
||||
|
||||
class SecureHTTPRequestHandler(SimpleHTTPRequestHandler):
|
||||
def setup(self):
|
||||
self.connection = self.request
|
||||
self.rfile = socket._fileobject(self.request, "rb", self.rbufsize)
|
||||
self.wfile = socket._fileobject(self.request, "wb", self.wbufsize)
|
||||
|
||||
|
||||
def test(HandlerClass = SecureHTTPRequestHandler,
|
||||
ServerClass = SecureHTTPServer):
|
||||
server_address = ('', 443) # (address, port)
|
||||
httpd = ServerClass(server_address, HandlerClass)
|
||||
sa = httpd.socket.getsockname()
|
||||
print("Serving HTTPS on", sa[0], "port", sa[1], "...")
|
||||
httpd.serve_forever()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
test()
|
@ -5,6 +5,7 @@ class MpExperience:
|
||||
NCPV = "ncpv"
|
||||
NC = "nc"
|
||||
NONE = "none"
|
||||
HTTPS = "https"
|
||||
|
||||
def __init__(self, xpParam, mpTopo, mpConfig):
|
||||
self.xpParam = xpParam
|
||||
|
78
src/mpExperienceHTTPS.py
Normal file
78
src/mpExperienceHTTPS.py
Normal file
@ -0,0 +1,78 @@
|
||||
from mpExperience import MpExperience
|
||||
from mpParamXp import MpParamXp
|
||||
from mpPvAt import MpPvAt
|
||||
import os
|
||||
|
||||
class MpExperienceHTTPS(MpExperience):
|
||||
SERVER_LOG = "https_server.log"
|
||||
CLIENT_LOG = "https_client.log"
|
||||
WGET_BIN = "wget"
|
||||
PING_OUTPUT = "ping.log"
|
||||
|
||||
def __init__(self, xpParamFile, mpTopo, mpConfig):
|
||||
MpExperience.__init__(self, xpParamFile, mpTopo, mpConfig)
|
||||
self.loadParam()
|
||||
self.ping()
|
||||
MpExperience.classicRun(self)
|
||||
|
||||
def ping(self):
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \
|
||||
MpExperienceHTTPS.PING_OUTPUT )
|
||||
count = self.xpParam.getParam(MpParamXp.PINGCOUNT)
|
||||
for i in range(0, self.mpConfig.getClientInterfaceCount()):
|
||||
cmd = self.pingCommand(self.mpConfig.getClientIP(i),
|
||||
self.mpConfig.getServerIP(), n = count)
|
||||
self.mpTopo.commandTo(self.mpConfig.client, cmd)
|
||||
|
||||
def pingCommand(self, fromIP, toIP, n=5):
|
||||
s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \
|
||||
" >> " + MpExperienceHTTPS.PING_OUTPUT
|
||||
print(s)
|
||||
return s
|
||||
|
||||
def loadParam(self):
|
||||
"""
|
||||
todo : param LD_PRELOAD ??
|
||||
"""
|
||||
self.file = self.xpParam.getParam(MpParamXp.HTTPSFILE)
|
||||
self.random_size = self.xpParam.getParam(MpParamXp.HTTPSRANDOMSIZE)
|
||||
|
||||
def prepare(self):
|
||||
MpExperience.prepare(self)
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \
|
||||
MpExperienceHTTPS.CLIENT_LOG )
|
||||
self.mpTopo.commandTo(self.mpConfig.server, "rm " + \
|
||||
MpExperienceHTTPS.SERVER_LOG )
|
||||
if self.file == "random":
|
||||
self.mpTopo.commandTo(self.mpConfig.client,
|
||||
"dd if=/dev/urandom of=random bs=1K count=" + \
|
||||
self.random_size)
|
||||
|
||||
def getHTTPSServerCmd(self):
|
||||
s = "python " + os.path.dirname(os.path.abspath(__file__)) + \
|
||||
"/https.py &>" + MpExperienceHTTPS.SERVER_LOG + "&"
|
||||
print(s)
|
||||
return s
|
||||
|
||||
def getHTTPSClientCmd(self):
|
||||
s = MpExperienceHTTPS.WGET_BIN + " https://" + self.mpConfig.getServerIP() + \
|
||||
"/" + self.file + " --no-check-certificate &>" + MpExperienceHTTPS.CLIENT_LOG
|
||||
print(s)
|
||||
return s
|
||||
|
||||
def clean(self):
|
||||
MpExperience.clean(self)
|
||||
if self.file == "random":
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "rm random*")
|
||||
#todo use cst
|
||||
#self.mpTopo.commandTo(self.mpConfig.server, "killall netcat")
|
||||
|
||||
|
||||
def run(self):
|
||||
cmd = self.getHTTPSServerCmd()
|
||||
self.mpTopo.commandTo(self.mpConfig.server, cmd)
|
||||
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2")
|
||||
cmd = self.getHTTPSClientCmd()
|
||||
self.mpTopo.commandTo(self.mpConfig.client, cmd)
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2")
|
@ -26,6 +26,9 @@ class MpParamXp(MpParam):
|
||||
NCCLIENTPORT = "ncClientPort"
|
||||
CHANGEPV = "changePv"
|
||||
CHANGEPVAT = "changePvAt"
|
||||
HTTPSFILE = "file" # file to wget, if random : we create a file with random data called random.
|
||||
HTTPSRANDOMSIZE = "file_size" # if file is set to random, define the size of the random file
|
||||
|
||||
|
||||
# global sysctl
|
||||
sysctlKey = {}
|
||||
@ -65,6 +68,8 @@ class MpParamXp(MpParam):
|
||||
defaultValue[NCSERVERPORT] = "33666"
|
||||
defaultValue[NCCLIENTPORT] = "33555"
|
||||
defaultValue[CHANGEPV] = "no"
|
||||
defaultValue[HTTPSFILE] = "random"
|
||||
defaultValue[HTTPSRANDOMSIZE] = "1024"
|
||||
|
||||
def __init__(self, paramFile):
|
||||
MpParam.__init__(self, paramFile)
|
||||
|
@ -8,6 +8,7 @@ from mpMininetBuilder import MpMininetBuilder
|
||||
from mpExperiencePing import MpExperiencePing
|
||||
from mpExperienceNCPV import MpExperienceNCPV
|
||||
from mpExperienceNC import MpExperienceNC
|
||||
from mpExperienceHTTPS import MpExperienceHTTPS
|
||||
from mpExperienceNone import MpExperienceNone
|
||||
from mpExperience import MpExperience
|
||||
from mpECMPSingleInterfaceTopo import MpECMPSingleInterfaceTopo
|
||||
@ -75,6 +76,9 @@ class MpXpRunner:
|
||||
elif xp == MpExperience.NONE:
|
||||
MpExperienceNone(self.xpParam, self.mpTopo,
|
||||
self.mpTopoConfig)
|
||||
elif xp == MpExperience.HTTPS:
|
||||
MpExperienceHTTPS(self.xpParam, self.mpTopo,
|
||||
self.mpTopoConfig)
|
||||
else:
|
||||
print("Unfound xp type..." + xp)
|
||||
|
||||
|
48
src/server.pem
Normal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oMGEludGVybmV0IFdpZGdpdHMg
|
||||
UHR5IEx0ZDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMnpjhkgjuXv
|
||||
uI0dpRsmNg38XDl3su5JeyBpK2lJvVjlPsQ/3dF0eNCL0u3AEnimREfkqZCybkgG
|
||||
Qu+A6SxtWayzqpc/G7CsyNNr5NlVBmcMpweo2ESK8EKY3XeNQbM9+ZU9de0uM9R8
|
||||
/TLvF4gXyTndBknGGaviEEveQpJVwb4arrbb1wSpEZAmbKq401KsM3V2JmVcgepH
|
||||
KDXxAEqc4PkRM3XMtblbZ3qYvozvVWb3PanOJV+KFaGbG4fjI7zcsizAyryktkSt
|
||||
pKEW7zkGg6LH3D5M4rVLQz5Tbg6xHICZsg0hZvGHHXUrAtcJN/8st8RTWddN3Pwd
|
||||
iMJDM+72q0kCAwEAAaNQME4wHQYDVR0OBBYEFJl1YmlCXxlJIur6n4XUx+vJ+LxY
|
||||
MB8GA1UdIwQYMBaAFJl1YmlCXxlJIur6n4XUx+vJ+LxYMAwGA1UdEwQFMAMBAf8w
|
||||
DQYJKoZIhvcNAQELBQADggEBAFqNf6XzHI5tEdZPZC9CB+WjxtSroH4z31XOSKQG
|
||||
aHqZKozx51mD911nqsOD286yCslpoA7ZI9YDC/juanVUDA/vmv8WgpjlLqfD4fK/
|
||||
V1lvXLb1x4mhyXXV8++1+EcktgGk4G8Z/5Bs8zR5UF2mIXBK/FwcDJt/esWunEse
|
||||
7KrvtHb9ESZ4mEDfQ6bcYdVg/l+3h7B/4kpP+fC/c7LA632/Z6U+/jYHhj2C2Uhv
|
||||
6KicgQ6ANB5CkvvJj3wD0eabqlhTL4oXrrpITXHB5MgBMAQWEvh2Dr6FKYe9Te/H
|
||||
4183fX7arMCQGmzexoreS9mntq55wLPMHoQzHIxh+A/PXmk=
|
||||
-----END CERTIFICATE-----
|
Loading…
Reference in New Issue
Block a user