示例#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
示例#2
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()
示例#3
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"])
示例#4
0
 def test_settings(self):
     # test some basic settings
     speedify.packetaggregation(False)
     speedify.jumbo(False)
     my_settings = speedify.show_settings()
     self.assertFalse(my_settings["packetAggregation"])
     self.assertFalse(my_settings["jumboPackets"])
     speedify.packetaggregation(True)
     speedify.jumbo(True)
     my_settings = speedify.show_settings()
     self.assertTrue(my_settings["packetAggregation"])
     self.assertTrue(my_settings["jumboPackets"])
示例#5
0
 def setUp(self):
     speedify.encryption(True)
     speedify.transport("auto")
     speedify.jumbo(True)
     speedify.packetaggregation(True)
     speedify.routedefault(True)