def stop_hotspot(): try: try: iptables.delete_rules(RULES) except: LOGGER.exception('failed to delete rules') try: shell_execute('%s dnsmasq' % KILLALL_PATH) except: LOGGER.exception('failed to killall dnsmasq') try: shell_execute('%s hostapd' % KILLALL_PATH) except: LOGGER.exception('failed to killall hostapd') try: working_hotspot_iface = get_working_hotspot_iface() if working_hotspot_iface: stop_hotspot_interface(working_hotspot_iface) return 'hotspot stopped successfully' else: return 'hotspot has not been started yet' finally: try: control_socket_dir = get_wpa_supplicant_control_socket_dir() delete_existing_p2p_persistent_networks(WIFI_INTERFACE, control_socket_dir) except: LOGGER.exception('failed to delete existing p2p persistent networks') except: LOGGER.exception('failed to stop hotspot') return 'failed to stop hotspot'
def start_hotspot(): try: iptables.delete_rules(RULES) working_hotspot_iface = get_working_hotspot_iface() if working_hotspot_iface: return True, 'hotspot is already working, start skipped' else: LOGGER.info('=== Before Starting Hotspot ===') dump_wifi_status() LOGGER.info('=== Start Hotspot ===') wifi_chipset = get_wifi_chipset() hotspot_interface = start_hotspot_interface(wifi_chipset) setup_networking(hotspot_interface) LOGGER.info('=== Started Hotspot ===') dump_wifi_status() if on_wifi_hotspot_started: on_wifi_hotspot_started() return True, 'hotspot started successfully' except: LOGGER.exception('failed to start hotspot') try: LOGGER.error('=== Failed to Start Hotspot ===') dump_wifi_status() finally: stop_hotspot() return False, 'failed to start hotspot'
def stop_hotspot_interface(iface): iptables.delete_rules(RULES) netd_execute('tether stop') try: shell_execute('%s dev %s del' % (IW_PATH, iface)) except: LOGGER.exception('failed to delete wifi interface') netd_execute('softap fwreload %s STA' % network_interface.WIFI_INTERFACE) shell_execute('netcfg %s down' % network_interface.WIFI_INTERFACE) shell_execute('netcfg %s up' % network_interface.WIFI_INTERFACE) try: shell_execute('killall hostapd') except: LOGGER.exception('failed to killall hostapd')
def stop_hotspot(iface): iptables.delete_rules(RULES) netd_execute('tether stop') try: stop_p2p_persistent_network(get_wpa_supplicant_control_socket_dir(), iface) except: LOGGER.exception('failed to stop p2p persistent network') try: shell_execute('%s dev %s del' % (IW_PATH, iface)) except: LOGGER.exception('failed to delete wifi interface') netd_execute('softap fwreload wlan0 STA') shell_execute('netcfg wlan0 down') shell_execute('netcfg wlan0 up') try: shell_execute('killall hostapd') except: LOGGER.exception('failed to killall hostapd')
def stop_hotspot(): try: working_hotspot_iface = get_working_hotspot_iface() try: iptables.delete_rules(RULES) except: LOGGER.exception('failed to delete rules') try: shell_execute('%s dnsmasq' % KILLALL_PATH) except: LOGGER.exception('failed to killall dnsmasq') try: shell_execute('%s hostapd' % KILLALL_PATH) except: LOGGER.exception('failed to killall hostapd') try: netd_execute('softap fwreload %s STA' % WIFI_INTERFACE) shell_execute('netcfg %s down' % WIFI_INTERFACE) shell_execute('netcfg %s up' % WIFI_INTERFACE) except: LOGGER.exception('failed to reload STA firmware') try: control_socket_dir = get_wpa_supplicant_control_socket_dir() delete_existing_p2p_persistent_networks(WIFI_INTERFACE, control_socket_dir) shell_execute('%s -p %s -i %s save_config' % (P2P_CLI_PATH, control_socket_dir, WIFI_INTERFACE)) except: LOGGER.exception('failed to delete existing p2p persistent networks') if working_hotspot_iface: try: shell_execute('%s dev %s del' % (IW_PATH, working_hotspot_iface)) except: LOGGER.exception('failed to delete wifi interface') return 'hotspot stopped successfully' else: return 'hotspot has not been started yet' except: LOGGER.exception('failed to stop hotspot') return 'failed to stop hotspot'
def delete_iptables_rules(): iptables.delete_nfqueue_rules(1) iptables.delete_rules(RULES)
def delete_iptables_rules(): iptables.delete_rules(RULES)
def delete_iptables_rules(): iptables.delete_nfqueue_rules(2) iptables.delete_rules(RULES) iptables.delete_chain('fq_INPUT') iptables.delete_chain('fq_OUTPUT') iptables.delete_chain('fq_FORWARD')
def delete_iptables_rules(): iptables.delete_rules(RULES) iptables.delete_nfqueue_rules(2) iptables.delete_chain('scramble_INPUT') iptables.delete_chain('scramble_OUTPUT') iptables.delete_chain('scramble_FORWARD')
def delete_iptables_rules(): iptables.delete_rules(RULES) iptables.delete_chain('fp_PREROUTING') iptables.delete_chain('fp_OUTPUT')