当前位置: 首页>>代码示例>>Python>>正文


Python StreamServerEndpointService.setServiceParent方法代码示例

本文整理汇总了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
开发者ID:exarkun,项目名称:Pantheon-SSH,代码行数:27,代码来源:tap.py

示例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
开发者ID:Julian,项目名称:Great,代码行数:34,代码来源:great.py

示例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)
开发者ID:hynek,项目名称:tnw,代码行数:16,代码来源:tap.py

示例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
开发者ID:weykent,项目名称:zangoose,代码行数:24,代码来源:zangoose.py

示例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)
开发者ID:simbha,项目名称:appserver,代码行数:32,代码来源:server.py


注:本文中的twisted.application.internet.StreamServerEndpointService.setServiceParent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。