mirror of https://github.com/D4-project/d4-core
chg: [server] twisted, get socat data
parent
4ddca99f93
commit
dd68f7472d
|
@ -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
|
|
@ -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)
|
Loading…
Reference in New Issue