fauxapi_apisecret = sys.argv[3] rule_category = sys.argv[4] rule_action = sys.argv[5] FauxapiLib = FauxapiLib(fauxapi_host, fauxapi_apikey, fauxapi_apisecret, debug=False) # Get the current set of filters filters = FauxapiLib.config_get('filter') # Iterate through and find 'KinderControl' rules, find enable/disable i = 0 for rule in filters['rule']: if (rule['descr'].startswith(rule_prefix)): if (rule_category in rule['descr']): if (rule_action == "enable"): del filters['rule'][i]['disabled'] print("Rule {} enabled.".format(rule['descr'])) elif (rule_action == "disable"): filters['rule'][i]['disabled'] = "" print("Rule {} disabled.".format(rule['descr'])) i = i + 1 # Push the config back to pfSense filters = FauxapiLib.config_set(filters, 'filter') # Reload the config FauxapiLib.send_event("filter reload")
# system_stats # ============================================================================= print(json.dumps(FauxapiLib.system_stats())) # interface_stats - NB: the real interface name, not an interface alias such as "WAN" or "LAN" # ============================================================================= print(json.dumps(FauxapiLib.interface_stats('em0'))) # gateway_status # ============================================================================= print(json.dumps(FauxapiLib.gateway_status())) # send_event - filter reload # ============================================================================= print(json.dumps(FauxapiLib.send_event('filter reload'))) # send_event - interface all reload # ============================================================================= print(json.dumps(FauxapiLib.send_event('interface all reload'))) # rule_get - get all rules # ============================================================================= print(json.dumps(FauxapiLib.rule_get())) # rule_get - get rule number 5 # ============================================================================= print(json.dumps(FauxapiLib.rule_get(5))) # alias_update_urltables # =============================================================================