MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / _start_ap_services

Method _start_ap_services

wifi_manager.py:2698–2789  ·  view source on GitHub ↗

Start hostapd and dnsmasq services

(self)

Source from the content-addressed store, hash-verified

2696 if self._wardrive_ap_prev_interface:
2697 self.ap_interface = self._wardrive_ap_prev_interface
2698 self._wardrive_ap_prev_interface = None
2699 self.shared_data.wardrive_ap_active = False
2700 self.shared_data.wardrive_ap_url = ''
2701 self.shared_data.wardrive_ap_iface = ''
2702 engine = self._wardriving_engine()
2703 if engine is not None and iface:
2704 engine.reclaim_interface_from_ap(iface)
2705 self._wardrive_ap_lent_iface = None
2706 self.logger.info("Wardrive AP stopped")
2707 return True
2708
2709 def _create_hostapd_config(self):
2710 """Create hostapd configuration file"""
2711 try:
2712 self.ap_logger.debug("Creating hostapd configuration file...")
2713 config_content = f"""interface={self.ap_interface}
2714driver=nl80211
2715ssid={self.ap_ssid}
2716hw_mode=g
2717channel=7
2718wmm_enabled=0
2719macaddr_acl=0
2720auth_algs=1
2721ignore_broadcast_ssid=0
2722wpa=2
2723wpa_passphrase={self.ap_password}
2724wpa_key_mgmt=WPA-PSK
2725wpa_pairwise=TKIP
2726rsn_pairwise=CCMP
2727"""
2728
2729 os.makedirs('/tmp/ragnar', exist_ok=True)
2730 with open('/tmp/ragnar/hostapd.conf', 'w') as f:
2731 f.write(config_content)
2732
2733 self.logger.info("Created hostapd configuration")
2734 self.ap_logger.info("Created hostapd configuration at /tmp/ragnar/hostapd.conf")
2735 self.ap_logger.debug(f"Hostapd config content:\n{config_content}")
2736 return True
2737
2738 except Exception as e:
2739 self.logger.error(f"Error creating hostapd config: {e}")
2740 self.ap_logger.error(f"Error creating hostapd config: {e}")
2741 return False
2742
2743 def _dnsmasq_config_no_internet(self):
2744 """dnsmasq profile for an accessory AP that must NOT become the client's
2745 internet path — used by the wardriving phone-access AP.
2746
2747 Ragnar never routes for AP clients (there is no NAT, no ip_forward, and
2748 while wardriving the radio is usually borrowed so there's no uplink at
2749 all). Handing out a default route and a DNS server anyway is what made
2750 phones blackhole: iOS would put its default route on Wi-Fi, send every
2751 request at 192.168.4.1, get nothing back, and show "No Internet".
2752
2753 So we hand out an address and deliberately nothing else:
2754 * `dhcp-option=3` with an empty value suppresses the router option, so
2755 the client installs only the on-link 192.168.4.0/24 route. The

Callers 1

start_ap_modeMethod · 0.95

Calls 8

infoMethod · 0.80
debugMethod · 0.80
errorMethod · 0.80
warningMethod · 0.80
runMethod · 0.45
sleepMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected