mirror of
https://git.disroot.org/pranav/pybatmesh.git
synced 2024-11-26 16:52:07 +05:30
turn off all wifi devices at exit
This makes things easier to maintain, or so I hope. Added more comments in files in systemd-networkd, made CHANGELOG.md better, and updated the README.
This commit is contained in:
parent
32e9559e6e
commit
a7304a986b
22
CHANGELOG.md
22
CHANGELOG.md
@ -1,25 +1,27 @@
|
||||
# Changelog
|
||||
|
||||
## [Unreleased][] - 2021-09-27
|
||||
## [Unreleased][] - 2021-09-29
|
||||
|
||||
- Better error messages
|
||||
- Sets gateway mode automatically. **This might cause problems with nodes running previous version of naxalnet**
|
||||
- Sets gateway mode automatically. **This might cause problems with nodes
|
||||
running previous version of naxalnet** (#15)
|
||||
- Cleanup before exit
|
||||
- Closed #19
|
||||
|
||||
## [v0.4.0][] - 2021-09-20
|
||||
|
||||
- naxalnet is now a daemon! naxalnet will reconfigure the WiFi network
|
||||
every time a WiFi adapter is plugged in or removed
|
||||
every time a WiFi adapter is plugged in or removed (#14)
|
||||
- **Logging**: logs to systemd journal when run from systemd, stderr
|
||||
otherwise
|
||||
otherwise (#13)
|
||||
- New dependency `python-systemd`
|
||||
- Fixed dependency order in systemd service
|
||||
- Added `--verbose` argument
|
||||
|
||||
## [v0.3.0][] - 2021-08-19
|
||||
|
||||
- Support for arguments
|
||||
- Configuration file support with fallback values
|
||||
- Support for arguments (#11)
|
||||
- Configuration file support with fallback values (#11)
|
||||
- Made messages more readable
|
||||
- Improved documentation in docstrings
|
||||
- Changed default name of mesh network. **This will make naxalnet
|
||||
@ -28,15 +30,17 @@
|
||||
|
||||
## [v0.2.0][] - 2021-07-26
|
||||
|
||||
- rfkill support
|
||||
- rewrite into python module
|
||||
- rfkill support (#9)
|
||||
- rewrite into python module (#5)
|
||||
|
||||
## [v0.1.0][] - 2021-06-19
|
||||
|
||||
Initial python version. At first, this was a shell script. Than it was
|
||||
Rewrite to python. At first, this was a shell script. Than it was
|
||||
converted into a single python file that did just what the shell script
|
||||
used to do. The shell script was not given a version.
|
||||
|
||||
- Closed #1 and #3
|
||||
|
||||
[unreleased]: https://git.disroot.org/pranav/naxalnet/compare/v0.4.0...HEAD
|
||||
[v0.4.0]: https://git.disroot.org/pranav/naxalnet/compare/v0.3.0...v0.4.0
|
||||
[v0.3.0]: https://git.disroot.org/pranav/naxalnet/compare/v0.2.0...v0.3.0
|
||||
|
@ -5,8 +5,7 @@ Everyone can [hack][] naxalnet. See below for how to hack.
|
||||
## Reporting issues and suggesting ideas
|
||||
|
||||
To report a bug or suggest an idea, create a new issue at
|
||||
<https://git.disroot.org/pranav/naxalnet/issues> with a
|
||||
relevant label.
|
||||
<https://git.disroot.org/pranav/naxalnet/issues>
|
||||
|
||||
## Improving documentation
|
||||
|
||||
|
13
README.md
13
README.md
@ -154,15 +154,16 @@ To start naxalnet, do the command on all the nodes:
|
||||
sudo systemctl start naxalnet.service
|
||||
```
|
||||
|
||||
This will start a mesh network and connect to all nodes.
|
||||
To test if it works, run `sudo batctl n -w` and check for
|
||||
nodes. If there are any nodes, your network is up. Press
|
||||
Ctrl+C to stop `batctl`.
|
||||
This will start a mesh network and connect to all nodes. To test if it
|
||||
works, run `sudo batctl n -w` and check for nodes. If there are any nodes,
|
||||
your network is up. Press Ctrl+C to stop `batctl`.
|
||||
|
||||
### Getting internet access
|
||||
|
||||
Connect an ethernet cable from a router to any of the nodes and
|
||||
renew the DHCP connection of all peers. To do this, type
|
||||
Connect an ethernet cable from a router to any of the nodes. Now restart
|
||||
naxalnet on the node to set `gateway_mode` to `server`. Other nodes will
|
||||
take a minute or more to renew DHCP. You can optionally do this manually
|
||||
if you don't want the delay. To do this, type
|
||||
`sudo networkctl renew bridge0` on all nodes.
|
||||
|
||||
### Tethering via WiFi AP
|
||||
|
@ -35,4 +35,4 @@ See README.md for documentation.
|
||||
#
|
||||
# In case you forgot to change the version, skip the number
|
||||
# and put the next number in the next commit.
|
||||
__version__ = "0.4.0a5.dev6"
|
||||
__version__ = "0.4.0a5.dev8"
|
||||
|
@ -39,12 +39,6 @@ from naxalnet.config import args
|
||||
from naxalnet.daemon import Daemon
|
||||
from naxalnet.network import NetworkD
|
||||
|
||||
# List of wireless devices used as part of the mesh.
|
||||
# Used to poweroff devices during cleanup.
|
||||
# Though used as a variable, thi e name is
|
||||
# capitalised to shut up pylint and co.
|
||||
USED_DEVICES = []
|
||||
|
||||
|
||||
def get_sorted_glob(directory: str, glob: str) -> list:
|
||||
"""return sorted list of filenames matching glob"""
|
||||
@ -68,7 +62,9 @@ def any_interface_is_routable():
|
||||
for i in get_sorted_glob(args.networkd_config_dir, TMP_NET_GLOB):
|
||||
logger.debug("Adding temporary config %s", i)
|
||||
networkd.add_config(i)
|
||||
# Then, wait for some time to setup the network
|
||||
# Then, wait for some time to setup the network.
|
||||
# This should be replaced by a d-bus wait-for-signal
|
||||
# function that timeouts after 10 seconds.
|
||||
time.sleep(10)
|
||||
routable = networkd.is_routable()
|
||||
networkd.remove_all_configs()
|
||||
@ -122,9 +118,6 @@ def setup_devices():
|
||||
adhoc_devices = []
|
||||
ap_devices = []
|
||||
|
||||
global USED_DEVICES
|
||||
USED_DEVICES = []
|
||||
|
||||
# Find devices supporting ad-hoc and ap
|
||||
for i in devices:
|
||||
# For each device, check if its adapter supports
|
||||
@ -158,7 +151,6 @@ def setup_devices():
|
||||
|
||||
logger.info("Starting mesh on %s", adhoc_device.name)
|
||||
adhoc_device.start_adhoc_open(args.adhoc_name)
|
||||
USED_DEVICES.append(adhoc_device.name)
|
||||
|
||||
# Start Access point if ap_device is not empty,
|
||||
# ie, we have more devices
|
||||
@ -173,7 +165,6 @@ def setup_devices():
|
||||
logger.debug("Adapter %s is off. Turning on", ap_adapter.name)
|
||||
ap_adapter.power_on()
|
||||
ap_device.start_ap(args.ap_ssid, args.ap_passwd)
|
||||
USED_DEVICES.append(ap_device.name)
|
||||
else:
|
||||
logger.warning("Not setting up WiFi AP.")
|
||||
else:
|
||||
@ -199,7 +190,7 @@ def cleanup():
|
||||
networkd = NetworkD(runtime_dir=args.networkd_runtime_dir)
|
||||
logger.info("Exiting gracefully")
|
||||
networkd.remove_all_configs()
|
||||
for i in USED_DEVICES:
|
||||
for i in IWD().get_devices():
|
||||
logger.debug("Turning off %s", i)
|
||||
device = Device(i)
|
||||
# device.set_mode("station")
|
||||
@ -243,6 +234,9 @@ def main():
|
||||
# see man:sd_notify(3)
|
||||
notify("READY=1")
|
||||
|
||||
# Gateway mode comes in handy when many nodes have a DHCP server
|
||||
# and you want to prevent conflicts.
|
||||
# https://www.open-mesh.org/projects/batman-adv/wiki/Gateways
|
||||
if args.gateway_mode == "auto":
|
||||
logger.info("Checking for internet connection")
|
||||
notify("STATUS=Checking for internet")
|
||||
|
@ -1,10 +1,13 @@
|
||||
# Create the BATMAN interface
|
||||
# See 04-batman.network for configuration details
|
||||
# See mesh.04-batman.network for configuration details
|
||||
[NetDev]
|
||||
Name={batdev}
|
||||
Description=BATMAN interface
|
||||
Kind=batadv
|
||||
|
||||
# see man:systemd.netdev(5) § [BATMANADVANCED] SECTION OPTIONS
|
||||
# See man:systemd.netdev(5) § [BATMANADVANCED] SECTION OPTIONS
|
||||
[BatmanAdvanced]
|
||||
# This helps choose the best network when many nodes have a DHCP
|
||||
# server. See the B.A.T.M.A.N. documentation at
|
||||
# https://www.open-mesh.org/projects/batman-adv/wiki/Gateways
|
||||
GatewayMode={gateway_mode}
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Create a bridge interface
|
||||
# The batman interface be will later linked to this bridge.
|
||||
# See 07-bridge.network to see how this bridge is configured
|
||||
# See mesh.07-bridge.network to see how this bridge is configured
|
||||
[NetDev]
|
||||
Name={bridgedev}
|
||||
Description=Bridge
|
||||
|
@ -5,7 +5,7 @@ Name={batdev}
|
||||
Description=Configuration for the BATMAN interface
|
||||
Bridge={bridgedev}
|
||||
|
||||
# like in 03-wireless-ad-hoc.network, this interface
|
||||
# like in mesh.03-wireless-ad-hoc.network, this interface
|
||||
# also shouldn't have IP address the address will
|
||||
# be assigned to the bridge
|
||||
DHCP=no
|
||||
|
@ -1,5 +1,5 @@
|
||||
# This file bridges any ethernet device found
|
||||
# to the bridge made in 02-bridge.netdev
|
||||
# to the bridge made in mesh.02-bridge.netdev
|
||||
[Match]
|
||||
Name=en*
|
||||
Name=eth*
|
||||
|
Loading…
Reference in New Issue
Block a user