chg: [server] twisted, get socat data

pull/23/head
Terrtia 2018-12-05 16:24:10 +01:00
parent 4ddca99f93
commit dd68f7472d
No known key found for this signature in database
GPG Key ID: 1E1B1F50D84613D0
2 changed files with 37 additions and 0 deletions

7
server/requirement.txt Normal file
View File

@ -0,0 +1,7 @@
twisted[tls]
sudo python3 -m pip install --upgrade service_identity
client:
cat /proc/cpuinfo | ./d4 -c conf.sample | socat - OPENSSL-CONNECT:127.178.0.1:4443,verify=0

30
server/server.py Executable file
View File

@ -0,0 +1,30 @@
#!/usr/bin/env python3
import sys
from twisted.internet import ssl, task, protocol, endpoints, defer
from twisted.python import log
from twisted.python.modules import getModule
from twisted.internet.protocol import Protocol
class Echo(Protocol):
#def __init__(self, factory):
# self.factory = factory
def dataReceived(self, data):
print(data)
self.transport.write(data)
def main(reactor):
log.startLogging(sys.stdout)
certData = getModule(__name__).filePath.sibling('server.pem').getContent()
certificate = ssl.PrivateCertificate.loadPEM(certData)
factory = protocol.Factory.forProtocol(Echo)
reactor.listenSSL(4443, factory, certificate.options())
return defer.Deferred()
if __name__ == "__main__":
task.react(main)