本文整理匯總了Python中twisted.application.internet.StreamServerEndpointService.setServiceParent方法的典型用法代碼示例。如果您正苦於以下問題:Python StreamServerEndpointService.setServiceParent方法的具體用法?Python StreamServerEndpointService.setServiceParent怎麽用?Python StreamServerEndpointService.setServiceParent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類twisted.application.internet.StreamServerEndpointService
的用法示例。
在下文中一共展示了StreamServerEndpointService.setServiceParent方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: makeService
# 需要導入模塊: from twisted.application.internet import StreamServerEndpointService [as 別名]
# 或者: from twisted.application.internet.StreamServerEndpointService import setServiceParent [as 別名]
def makeService(options):
"""
Construct a Pantheon SSH service.
"""
from twisted.internet import reactor
factory = SSHFactory()
key = options["host-key"]
factory.privateKeys = {key.sshType(): key}
factory.publicKeys = {key.sshType(): key.public()}
realm = PantheonRealm(
reactor,
options['auth-host'], options['auth-port'],
options['client-key'].path, options['client-cert'].path)
checker = PantheonHTTPChecker(
reactor,
options['auth-host'], options['auth-port'],
options['client-key'].path, options['client-cert'].path)
factory.portal = Portal(realm, [checker])
service = MultiService()
for endpoint in options["listen"]:
child = StreamServerEndpointService(endpoint, factory)
child.setServiceParent(service)
return service
示例2: makeService
# 需要導入模塊: from twisted.application.internet import StreamServerEndpointService [as 別名]
# 或者: from twisted.application.internet.StreamServerEndpointService import setServiceParent [as 別名]
def makeService(self, options):
greatPath = FilePath(great.__file__).parent()
staticPath = greatPath.child("static")
templatesPath = greatPath.child("templates")
rootResource = Resource()
rootResource.putChild("", File(staticPath.child("index.html").path))
rootResource.putChild("static", File(staticPath.path))
rootResource.putChild("templates", File(templatesPath.path))
rootResource.putChild("great", MinionResource(create_app()))
greatService = StreamServerEndpointService(
endpoint=options["endpoint"],
factory=server.Site(rootResource),
)
redirects = options["redirects"]
if not redirects:
return greatService
service = MultiService()
greatService.setServiceParent(service)
for redirect in redirects:
redirectService = StreamServerEndpointService(
endpoint=redirect,
factory=server.Site(Redirect(options["canonical_url"])),
)
redirectService.setServiceParent(service)
return service
示例3: startService
# 需要導入模塊: from twisted.application.internet import StreamServerEndpointService [as 別名]
# 或者: from twisted.application.internet.StreamServerEndpointService import setServiceParent [as 別名]
def startService(self):
MultiService.startService(self)
staticPath = FilePath(__file__).sibling("static")
root = NoListDirFile(staticPath.path)
root.putChild('api', SockJSResource(
Factory.forProtocol(DaneDoctorProtocol))
)
webService = StreamServerEndpointService(
serverFromString(self._reactor, "tcp:8080"),
Site(root)
)
webService.setServiceParent(self)
示例4: makeService
# 需要導入模塊: from twisted.application.internet import StreamServerEndpointService [as 別名]
# 或者: from twisted.application.internet.StreamServerEndpointService import setServiceParent [as 別名]
def makeService(self, options):
reactor = self.reactor
if reactor is None:
from twisted.internet import reactor
resolver = self.resolver
if resolver is None:
resolver = getResolver()
with open(options.config) as infile:
config = yaml.safe_load(infile)
multiService = MultiService()
for proxy in config['proxies']:
client = endpoints.clientFromString(reactor, str(proxy['client']))
server = endpoints.serverFromString(reactor, str(proxy['server']))
fac = ProxyFactory(client, resolver, proxy)
service = StreamServerEndpointService(server, fac)
service.setServiceParent(multiService)
return multiService
示例5: getContext
# 需要導入模塊: from twisted.application.internet import StreamServerEndpointService [as 別名]
# 或者: from twisted.application.internet.StreamServerEndpointService import setServiceParent [as 別名]
self.setContextFactory(name, connection)
else:
log.msg('SNI not provided, closing SSL connection')
connection.shutdown()
def getContext(self):
return self._context
sslContext = SNIContextFactory(depl, config)
ports = [
endpoints.TCP4ServerEndpoint(reactor, config.getint('master', 'port')),
endpoints.SSL4ServerEndpoint(reactor, config.getint('master', 'sslport'),
sslContext),
]
logfile = filepath.FilePath(config.get('master', 'http_logfile'))
if not logfile.parent().exists():
logfile.parent().makedirs()
depl.root.putChild('_admin', resources.VhostListing(depl))
site = server.Site(depl.root, logPath=logfile.path)
application = service.Application('appserver')
depl.setServiceParent(application)
for port in ports:
svc = StreamServerEndpointService(port, site)
svc.setServiceParent(application)