Пример #1
0
 def test_start_ovpn(self):
     client = RPCClient("tcp://%s:%s" % (host, port))
     if client.start_ovpn('demo.bitmask.net', 'log.txt') == 0:
         ovpn = OpenVPNLauncher()
         while ovpn.get_status().get('ovpn_state') != "CONNECTED":
             print ovpn.get_status()
             sleep(1)
Пример #2
0
    class Endpoint(object):
        def __init__(self, port):
            self._port = port
            self._process_hdl = None
            self._connector = None

        def __start_endpoint(self):
            cmd = [endpoint_start_cmd, "--port", str(self._port)]
            env = os.environ.copy()
            env["PYTHONPATH"] = os.curdir
            p = Popen(cmd, env=env)
            print("* Starting Endpoint listener on port : " + str(self._port) +
                  ", pid(" + str(p.pid) + ")")
            return p

        def Start(self):
            self._process_hdl = self.__start_endpoint()
            self._connector = RPCClient('tcp://localhost:{}'.format(
                self._port),
                                        timeout=600000)

        def Run(self, name, cmd, timeout=None, background=False):
            return self._connector.process_run(name, cmd, timeout, background)

        def CopyFile(self, name, file):
            with open(file, 'r') as data_file:
                return self._connector.copy_file(name, os.path.basename(file),
                                                 data_file.read())

        def CleanUp(self, name):
            return self._connector.cleanup(name)

        def AddArpEntry(self, name, ip, mac):
            self._connector.add_arp_entry(name, ip, mac)

        def Stop(self):
            self._connector.reset()
            self._process_hdl.kill()
Пример #3
0
 def Start(self):
     self._process_hdl = self.__start_endpoint()
     self._connector = RPCClient('tcp://localhost:{}'.format(
         self._port),
                                 timeout=600000)
Пример #4
0
 def test_firewall_start(self):
     client = RPCClient("tcp://%s:%s" % (host, port))
     client.start_firewall()
Пример #5
0
 def test_stop_ovpn(self):
     client = RPCClient("tcp://%s:%s" % (host, port))
     client.stop_ovpn()
Пример #6
0
import time
from jsonrpc2_zeromq import RPCClient

c = RPCClient("tcp://127.0.0.1:57570", logger = None)
N = 10000

while True:
	t_0 = time.time()

	for i in xrange(100):
		c.echo("Echo?")
	t_1 = time.time()
	print N / (t_1 - t_0)