Skip to main content

pyhostapdconf

This package contains a library for working with hostapd configuration file in Python. It is intended for configuring simple access points and supports the folowing configuration:

  • Interface selection

  • Driver selection (nl80211 and rtl871xdrv, as supported)

  • SSID

  • Country code

  • Channel

  • WPA configuration (passphrase, WPA mode)

  • Maximum client limit

  • Hidden SSID

Configuration class

To load the configuration file, use the HostapdConf class:

>>> from hostapdconf.parser import HostapdConf
>>> conf = HostapdConf('example/hostapd_example.conf')

This class is a generic configuration parser/writer and doesn’t know much about how configuration options work. It behaves like a dictionary, and you can look up keys using subscript notation. For example:

>>> conf['interface']
'wlan0'

If a key is not found, a KeyError is raised.

>>> conf['driver']
KeyError: '<HostapdConf "interface=wlan0...">' has no key 'driver'

You can set any key by assigning:

>>> conf['driver'] = 'nl80211'

You can update multiple values by calling the update() method with a dictionary as its argument, just like with Python dictionaries. Finally, if you want to save the configuration file, you can use the write() method:

>>> conf.write()

If you wish to save the file to another location, simply pass the path to the write() method. To reload the configuration, you can use the reload() method.

HostapdConf class will preserve the order of the configuration keys as much as possible, but it does not offer methods for inserting configuration options at random locations.

Helper functions

To help with common configuration tasks, there is a number of helper methods.

Helpers are found in the hosapdconf.helpers module.

>>> from hostapdconf import helpers as ha

Each helper function takes the configuration object as first argument followed by arguments specific to the setting. Here is a quick overview of the helper methods:

>>> ha.set_ssid(conf, 'Foobar')
>>> ha.hide_ssid(conf)
>>> ha.reveal_ssid(conf)
>>> ha.set_iface(conf, 'wlan2')
>>> ha.set_driver(conf, ha.REALTEK)  # or ha.STANDARD
>>> ha.set_channel(conf, 2)
# wpa_modes supported: ha.WPA1_ONLY, ha.WPA2_ONLY, ha.WPA_BOTH
>>> ha.enable_wpa(conf, passphrase='SECRET', wpa_mode=ha.WPA2_ONLY)
>>> ha.disable_wpa(conf)
>>> ha.set_country(conf, 'de')

License

pyhostapdconf is released under GPLv3. Please see the COPYING file in the source tree.

Metadata

Release files for pyhostapdconf 1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distributions (sdists)

Source distribution for pyhostapdconf 1.0
File Size Uploaded Provenance Actions
pyhostapdconf-1.0.zip 21.5 kB Without provenance Details for pyhostapdconf-1.0.zip
pyhostapdconf-1.0.tar.gz 18.0 kB Without provenance Details for pyhostapdconf-1.0.tar.gz

Release files / pyhostapdconf-1.0.zip

Download URL pyhostapdconf-1.0.zip
Size 21.5 kB
Tags Source
SHA-256 checksum
How to use checksums
3e3c8f85b58f8d889285a7249fb28d57b840efdf8f45b9ac81b1b43840f59f33
BLAKE2b-256 checksum
How to use checksums
193ffbcb1ee42944ca36d4597c11dad52e15730e9e33b88b28fa6921c56d8535
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pyhostapdconf-1.0.tar.gz

Download URL pyhostapdconf-1.0.tar.gz
Size 18.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a889d06e7d141f325b6c8be328cf2a30d40559ae24a88e0d571229e217488a83
BLAKE2b-256 checksum
How to use checksums
595cb1c9069f1f6a72dcfb7b6e10c46a9eaa74e99e9a2b287a7f687e36e2db4f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for pyhostapdconf 1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page