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


Python IPRoute.serve方法代码示例

本文整理汇总了Python中pyroute2.IPRoute.serve方法的典型用法代码示例。如果您正苦于以下问题:Python IPRoute.serve方法的具体用法?Python IPRoute.serve怎么用?Python IPRoute.serve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyroute2.IPRoute的用法示例。


在下文中一共展示了IPRoute.serve方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestProxyData

# 需要导入模块: from pyroute2 import IPRoute [as 别名]
# 或者: from pyroute2.IPRoute import serve [as 别名]
class TestProxyData(TestData):

    def setup(self):
        create_link('dummyX', 'dummy')
        t_url = 'unix://\0%s' % (uuid.uuid4())
        p_url = 'unix://\0%s' % (uuid.uuid4())

        self.uplink = IPRoute()
        self.uplink.serve(t_url)

        self.proxy = IPRoute(host=t_url)
        self.proxy.serve(p_url)

        self.ip = IPRoute(host=p_url)
        service = self.ip.discover(self.ip.default_target,
                                   addr=self.proxy.default_peer)

        self.ip.default_peer = self.proxy.default_peer
        self.ip.default_dport = service

        self.dev = self.ip.link_lookup(ifname='dummyX')

    def teardown(self):
        TestData.teardown(self)
        self.proxy.release()
        self.uplink.release()
开发者ID:hegusung,项目名称:pyroute2,代码行数:28,代码来源:test_ipr.py

示例2: _run_remote_uplink

# 需要导入模块: from pyroute2 import IPRoute [as 别名]
# 或者: from pyroute2.IPRoute import serve [as 别名]
def _run_remote_uplink(url, connect, release,
                       key=None, cert=None, ca=None):
    ip = IPRoute()
    ip.serve(url, key=key, cert=cert, ca=ca)
    ip.iothread.secret = 'bala'
    connect.set()
    release.wait()
    ip.release()
开发者ID:chantra,项目名称:pyroute2,代码行数:10,代码来源:test_ipr.py

示例3: _test_remote

# 需要导入模块: from pyroute2 import IPRoute [as 别名]
# 或者: from pyroute2.IPRoute import serve [as 别名]
    def _test_remote(self, url):

        uplink = IPRoute()
        uplink.serve(url)

        ip = IPRoute(host=url)
        ip.release()
        uplink.release()
开发者ID:hegusung,项目名称:pyroute2,代码行数:10,代码来源:test_ipr.py

示例4: testServer

# 需要导入模块: from pyroute2 import IPRoute [as 别名]
# 或者: from pyroute2.IPRoute import serve [as 别名]
 def testServer(self):
     url = 'unix://\0%s' % (uuid.uuid4())
     ip = IPRoute()
     ip.serve(url)
     target = Process(target=_run_remote_client,
                      args=(url, 'get_links'))
     target.start()
     target.join()
     ip.release()
开发者ID:chantra,项目名称:pyroute2,代码行数:11,代码来源:test_ipr.py

示例5: test_server

# 需要导入模块: from pyroute2 import IPRoute [as 别名]
# 或者: from pyroute2.IPRoute import serve [as 别名]
    def test_server(self):
        url = 'unix://\0%s' % (uuid.uuid4())
        ip = IPRoute()
        ip.serve(url)

        client = IPRoute(host=url)

        client.release()
        ip.release()
开发者ID:hegusung,项目名称:pyroute2,代码行数:11,代码来源:test_ipr.py

示例6: test_ssl_fail

# 需要导入模块: from pyroute2 import IPRoute [as 别名]
# 或者: from pyroute2.IPRoute import serve [as 别名]
    def test_ssl_fail(self):
        url = 'localhost:9824'
        uplink = IPRoute()
        uplink.serve('ssl://%s' % (url),
                     key='server.key',
                     cert='server.crt',
                     ca='ca.crt')

        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.connect(('localhost', 9824))
        s.send(b'test')
        s.close()
        uplink.release()
开发者ID:hegusung,项目名称:pyroute2,代码行数:15,代码来源:test_ipr.py

示例7: TestRemoteData

# 需要导入模块: from pyroute2 import IPRoute [as 别名]
# 或者: from pyroute2.IPRoute import serve [as 别名]
class TestRemoteData(TestData):

    def setup(self):
        create_link('dummyX', 'dummy')
        url = 'unix://\0%s' % (uuid.uuid4())

        self.uplink = IPRoute()
        self.uplink.serve(url)

        self.ip = IPRoute(host=url)
        self.dev = self.ip.link_lookup(ifname='dummyX')

    def teardown(self):
        TestData.teardown(self)
        self.uplink.release()
开发者ID:hegusung,项目名称:pyroute2,代码行数:17,代码来源:test_ipr.py

示例8: TestSSLData

# 需要导入模块: from pyroute2 import IPRoute [as 别名]
# 或者: from pyroute2.IPRoute import serve [as 别名]
class TestSSLData(TestData):
    ssl_proto = 'ssl'

    def setup(self):
        create_link('dummyX', 'dummy')
        url = 'unix+%s://\0%s' % (self.ssl_proto, uuid.uuid4())
        self.uplink = IPRoute()
        self.uplink.serve(url,
                          key='server.key',
                          cert='server.crt',
                          ca='ca.crt')
        self.ip = IPRoute(host=url,
                          key='client.key',
                          cert='client.crt',
                          ca='ca.crt')
        self.dev = self.ip.link_lookup(ifname='dummyX')

    def teardown(self):
        TestData.teardown(self)
        self.uplink.release()
开发者ID:hegusung,项目名称:pyroute2,代码行数:22,代码来源:test_ipr.py

示例9: test_serve

# 需要导入模块: from pyroute2 import IPRoute [as 别名]
# 或者: from pyroute2.IPRoute import serve [as 别名]
 def test_serve(self, url=None, key=None, cert=None, ca=None):
     url = url or 'unix://\0nose_tests_socket'
     ip = IPRoute()
     ip.serve(url, key=key, cert=cert, ca=ca)
     ip.shutdown(url)
     ip.release()
开发者ID:chantra,项目名称:pyroute2,代码行数:8,代码来源:test_ipr.py

示例10: IPRoute

# 需要导入模块: from pyroute2 import IPRoute [as 别名]
# 或者: from pyroute2.IPRoute import serve [as 别名]
#!/usr/bin/python
'''
Sample server script.

Start netlink proxy on the port 7000 and use TLS client/server
authentication. Clients w/o known certificates will be rejected.

You have to generate keys prior to start it. The easiest way is
to use OpnVPN's pkitool
'''
from pyroute2 import IPRoute

ip = IPRoute()

ip.serve('tls://localhost:7000',
         key='server.key',
         cert='server.crt',
         ca='ca.crt')

try:
    raw_input("return >> ")
except NameError:
    input("return >> ")

ip.release()
开发者ID:bouttier,项目名称:pyroute2,代码行数:27,代码来源:server.py


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