本文整理汇总了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)