Example #1
0
def apply_setting(setting, value):
    '''
    Sets the setting to the value given

    :param setting: The speedify setting to set.
    :type setting: str
    :param value: The value to set the setting to.
    :type value: str/int
    '''
    success = True
    try:
        adapterguids = []
        logging.debug("setting: " + str(setting) + ", value:" + str(value))
        if setting.startswith("adapter_"):
            setting_split = setting.split("_")
            adaptertype = setting_split[-1]
            adapterguids = _find_adapterids(adaptertype)
            _apply_setting_to_adapters(setting, value, adapterguids)
        elif setting == "connectmethod":
            speedify.connectmethod(value)
        elif setting == "directory":
            speedify.directory(value)
        elif setting == "encryption":
            speedify.encryption(value)
        elif setting == "packet_aggregation":
            speedify.packetaggregation(value)
        elif setting == "jumbo":
            speedify.jumbo(value)
        # dnsleak and killswitch not available on all platforms
        elif setting == "privacy_dnsleak":
            if os.name == 'nt':
                speedify.dnsleak(value)
            else:
                logging.info("dnsleak not supported on this platform")
        elif setting == "privacy_killswitch":
            if os.name == 'nt':
                speedify.killswitch(value)
            else:
                logging.info("killswitch not supported on this platform")
        elif setting == "privacy_crashreports":
            speedify.crashreports(value)
        elif setting == "mode":
            speedify.mode(value)
        elif setting == "overflow_threshold":
            speedify.overflow(float(value))
        elif setting == "route_default":
            speedify.routedefault(value)
        elif setting == "startupconnect":
            speedify.startupconnect(value)
        elif setting == "transport":
            speedify.transport(value)
        else:
            logging.warning("unknown setting " + str(setting))
            success = False
    except SpeedifyError as se:
        logging.error("Speedify error on setting:" + str(setting) + " value:" +
                      str(value) + ", exception:" + str(se))
        success = False
    return success
Example #2
0
 def test_set_defaults(self):
     speedify.encryption(False)
     speedify.transport("tcp")
     self.assertTrue(speedifysettings.apply_speedify_settings(speedifysettings.speedify_defaults))
     settings = speedify.show_settings()
     self.assertTrue(settings["encrypted"])
     self.assertTrue(settings["jumboPackets"])
     self.assertEqual( settings["transportMode"] , "auto")
Example #3
0
 def setUp(self):
     speedify.encryption(True)
     speedify.transport("auto")
     speedify.jumbo(True)
     speedify.crashreports(True)
     speedify.packetaggregation(True)
     speedify.routedefault(True)
     speedify.connectmethod("closest")
     speedify.disconnect()
Example #4
0
def apply_value(name, value):
    if name == "transport":
        transport = "tcp" if value else "udp"
        speedify.transport(transport)
    elif name == "mode":
        mode = "redundant" if value else "speed"
        speedify.mode(mode)
    else:
        apply_setting(name, value)
Example #5
0
 def test_read_settings(self):
     speedify.encryption(False)
     speedify.transport("tcp")
     speedify.packetaggregation(False)
     mysettings = speedifysettings.get_speedify_settings()
     self.assertIn("encryption", mysettings)
     self.assertFalse(mysettings["encryption"])
     self.assertFalse(mysettings["packet_aggregation"])
     self.assertIn("transport", mysettings)
     self.assertEqual("tcp", mysettings["transport"])
     self.assertIn("jumbo", mysettings)
     self.assertTrue(mysettings["jumbo"])
Example #6
0
    def test_transport(self):
        mysettings = speedify.transport("https")
        serverinfo = speedify.connect()
        mysettings = speedify.show_settings()
        self.assertEqual(mysettings["transportMode"], "https")

        # to make sure runtime changed, could check stats and look for connectionstats : connections[] : protocol
        mysettings = speedify.transport("tcp")
        self.assertEqual(mysettings["transportMode"], "tcp")
        serverinfo = speedify.connect()
        mysettings = speedify.show_settings()
        self.assertEqual(mysettings["transportMode"], "tcp")
Example #7
0
 def setUp(self):
     speedify.encryption(True)
     speedify.transport("auto")
     speedify.jumbo(True)
     speedify.packetaggregation(True)
     speedify.routedefault(True)