| 1 |
#!/usr/bin/env python |
| 2 |
# Copyright (c) Twisted Matrix Laboratories. |
| 3 |
# See LICENSE for details. |
| 4 |
|
| 5 |
import sys |
| 6 |
|
| 7 |
import echoserv |
| 8 |
|
| 9 |
from twisted.internet import defer, protocol, ssl, task |
| 10 |
from twisted.internet.endpoints import TCP6ServerEndpoint, wrapServerTLS |
| 11 |
from twisted.python import log |
| 12 |
from twisted.python.modules import getModule |
| 13 |
|
| 14 |
|
| 15 |
def main(reactor): |
| 16 |
log.startLogging(sys.stdout) |
| 17 |
certData = getModule(__name__).filePath.sibling("server.pem").getContent() |
| 18 |
certificate = ssl.PrivateCertificate.loadPEM(certData) |
| 19 |
factory = protocol.Factory.forProtocol(echoserv.Echo) |
| 20 |
tcpEndpoint = TCP6ServerEndpoint(reactor, 8000) |
| 21 |
endpoint = wrapServerTLS(certificate.options(), tcpEndpoint, reactor) |
| 22 |
endpoint.listen(factory) |
| 23 |
return defer.Deferred() |
| 24 |
|
| 25 |
|
| 26 |
if __name__ == "__main__": |
| 27 |
import echoserv_ssl |
| 28 |
|
| 29 |
task.react(echoserv_ssl.main) |