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