示例#1
0
def verify(repeated, operational, non_operational, unverified):
    """Verify if the servers are operational."""
    if operational:
        operational = True
    elif non_operational:
        operational = False

    try:
        verify_all(repeated, operational, unverified)
    except KeyboardInterrupt:
        log.warning("CTRL+C detected! exiting.")
        sys.exit(0)
示例#2
0
文件: main.py 项目: RicoVZ/socks5man
def verify(repeated, operational, non_operational, unverified):
    """Verify if the servers are operational."""
    if operational:
        operational = True
    elif non_operational:
        operational = False

    try:
        verify_all(repeated, operational, unverified)
    except KeyboardInterrupt:
        log.warning("CTRL+C detected! exiting.")
        sys.exit(0)
示例#3
0
    def test_success(self, ms):
        create_cwd(cwd())
        socks5 = mock.MagicMock()
        socks5.host = "8.8.8.8"
        socks5.port = 4242
        ms.return_value = socks5
        self.db.add_socks5("8.8.8.8", 4242, "Germany", "DE")

        verify_all()
        socks5.verify.assert_called_once()
        socks5.measure_connection_time.assert_called_once()
        socks5.approx_bandwidth.assert_not_called()
示例#4
0
    def test_bandwidth(self, ms):
        create_cwd(cwd())
        socks5 = mock.MagicMock()
        socks5.host = "8.8.8.8"
        socks5.port = 4242
        ms.return_value = socks5
        self.db.add_socks5("8.8.8.8", 4242, "Germany", "DE")
        Config._cache["bandwidth"]["enabled"] = True

        verify_all()
        socks5.verify.assert_called_once()
        socks5.measure_connection_time.assert_called_once()
        socks5.approx_bandwidth.assert_called_once()
        Config._cache["bandwidth"]["enabled"] = False
示例#5
0
    def test_download_verify_fail(self, ms, mu):
        create_cwd(cwd())
        socks5 = mock.MagicMock()
        socks5.host = "8.8.8.8"
        socks5.port = 4242
        ms.return_value = socks5
        mu.side_effect = socket.error
        self.db.add_socks5("8.8.8.8", 4242, "Germany", "DE")
        Config._cache["bandwidth"]["enabled"] = True

        verify_all()
        socks5.verify.assert_called_once()
        socks5.measure_connection_time.assert_called_once()
        mu.assert_called_once_with(mock.ANY, timeout=5)
        socks5.approx_bandwidth.assert_not_called()
        Config._cache["bandwidth"]["enabled"] = False