Merge pull request 'Rename to pybatmesh' (#27) from rename-to-pybatmesh into main

Reviewed-on: https://git.disroot.org/pranav/naxalnet/pulls/27
This commit is contained in:
Pranav Jerry 2022-08-03 05:23:03 +00:00
commit 9123224de0
17 changed files with 170 additions and 216 deletions

View File

@ -1,5 +1,10 @@
# Changelog # Changelog
## [unreleased][] - 2022-08-03
- Renamed to pybatmesh, to be more clear what the program does
- code cleanup
## [v0.5.2][] - 2021-12-10 ## [v0.5.2][] - 2021-12-10
- Optimised auto gateway mode selection (#25) - Optimised auto gateway mode selection (#25)
@ -51,11 +56,11 @@ used to do. The shell script was not given a version.
- Closed #1 and #3 - Closed #1 and #3
[unreleased]: https://git.disroot.org/pranav/naxalnet/compare/v0.5.2...HEAD [unreleased]: https://git.disroot.org/pranav/pybatmesh/compare/v0.5.2...HEAD
[v0.5.2]: https://git.disroot.org/pranav/naxalnet/compare/v0.5.1...v0.5.2 [v0.5.2]: https://git.disroot.org/pranav/pybatmesh/compare/v0.5.1...v0.5.2
[v0.5.1]: https://git.disroot.org/pranav/naxalnet/compare/v0.5.0...v0.5.1 [v0.5.1]: https://git.disroot.org/pranav/pybatmesh/compare/v0.5.0...v0.5.1
[v0.5.0]: https://git.disroot.org/pranav/naxalnet/compare/v0.4.0...v0.5.0 [v0.5.0]: https://git.disroot.org/pranav/pybatmesh/compare/v0.4.0...v0.5.0
[v0.4.0]: https://git.disroot.org/pranav/naxalnet/compare/v0.3.0...v0.4.0 [v0.4.0]: https://git.disroot.org/pranav/pybatmesh/compare/v0.3.0...v0.4.0
[v0.3.0]: https://git.disroot.org/pranav/naxalnet/compare/v0.2.0...v0.3.0 [v0.3.0]: https://git.disroot.org/pranav/pybatmesh/compare/v0.2.0...v0.3.0
[v0.2.0]: https://git.disroot.org/pranav/naxalnet/compare/v0.1.0...v0.2.0 [v0.2.0]: https://git.disroot.org/pranav/pybatmesh/compare/v0.1.0...v0.2.0
[v0.1.0]: https://git.disroot.org/pranav/naxalnet/releases/tag/v0.1.0 [v0.1.0]: https://git.disroot.org/pranav/pybatmesh/releases/tag/v0.1.0

View File

@ -1,22 +1,15 @@
# Hacking # Hacking
Everyone can [hack][] naxalnet. See below for how to hack. Everyone can [hack][] pybatmesh. See below for how to hack.
## Questions and answers
Join the XMPP channel <xmpp:naxalnet@chat.disroot.org> to talk about
anything related to this program or about mesh networks in general.
<!-- And send your hate to /dev/null -->
## Reporting issues and suggesting ideas ## Reporting issues and suggesting ideas
To report a bug or suggest an idea, create a new issue at To report a bug or suggest an idea, create a new issue at
<https://git.disroot.org/pranav/naxalnet/issues> <https://git.disroot.org/pranav/pybatmesh/issues>
While reporting a bug, you can add the debug messages to provide more While reporting a bug, you can add the debug messages to provide more
data. Run `journalctl -fu naxalnet` on a terminal emulator (this could data. Run `journalctl -fu pybatmesh` on a terminal emulator (this could
take some time on some machines). Now on another one, type `sudo systemctl start naxalnet.service` or whatever caused the error. Now copy the error take some time on some machines). Now on another one, type `sudo systemctl start pybatmesh.service` or whatever caused the error. Now copy the error
messages and paste it in the issue body along with the description. messages and paste it in the issue body along with the description.
## Improving documentation ## Improving documentation
@ -28,11 +21,11 @@ The README and HACKING.md needs to be more beginner friendly. See #20.
To push to this repo, you need your username to be in the contributors To push to this repo, you need your username to be in the contributors
list. Add your username to issue #8 to add you as a contributor. Before list. Add your username to issue #8 to add you as a contributor. Before
each commit, update the CHANGELOG.md and `__version__` in each commit, update the CHANGELOG.md and `__version__` in
`naxalnet/__init__.py` `pybatmesh/__init__.py`
## Packaging ## Packaging
Currently this program is only packaged for Arch Linux. naxalnet needs Currently this program is only packaged for Arch Linux. pybatmesh needs
packages in GNU+Linux+systemd distributions such as Debian, Fedora, packages in GNU+Linux+systemd distributions such as Debian, Fedora,
openSUSE, and nixos. If you know/like to package it in your distro, post a openSUSE, and nixos. If you know/like to package it in your distro, post a
message to issue #6. message to issue #6.

View File

@ -10,19 +10,19 @@ DESTDIR:= /
all: build all: build
# Build only when naxalnet/__init__.py changes. We assume here that anyone # Build only when pybatmesh/__init__.py changes. We assume here that anyone
# creating a new commit will first update the __version__ in # creating a new commit will first update the __version__ in
# naxalnet/__init__.py # pybatmesh/__init__.py
build: naxalnet/__init__.py build: pybatmesh/__init__.py
$(PYTHON) setup.py build $(PYTHON) setup.py build
install: install:
$(PYTHON) setup.py install --root="$(DESTDIR)" --optimize=1 --skip-build $(PYTHON) setup.py install --root="$(DESTDIR)" --optimize=1 --skip-build
uninstall: uninstall:
$(PIP) uninstall -y naxalnet $(PIP) uninstall -y pybatmesh
rm -rf /usr/share/naxalnet /usr/lib/systemd/system/naxalnet.service rm -rf /usr/share/pybatmesh /usr/lib/systemd/system/pybatmesh.service
@echo "make uninstall will not remove anything in /etc/naxalnet" && \ @echo "make uninstall will not remove anything in /etc/pybatmesh" && \
echo "Do 'sudo make purge' to remove it." echo "Do 'sudo make purge' to remove it."
rpm: rpm:
@ -31,7 +31,7 @@ rpm:
# Remove config files, like apt purge. Purge should first do what # Remove config files, like apt purge. Purge should first do what
# uninstall does, so we add uninstall as a dependency to this rule. # uninstall does, so we add uninstall as a dependency to this rule.
purge: uninstall purge: uninstall
rm -rf /etc/naxalnet rm -rf /etc/pybatmesh
clean: clean:
rm -rf build *.egg-info **/__pycache__ dist rm -rf build *.egg-info **/__pycache__ dist

153
README.md
View File

@ -1,31 +1,15 @@
# naxalnet # pybatmesh
I no longer maintain this project. The last commit was on December **pybatmesh** is a program to create a wireless mesh network for
10, 2021. See issue #8
**naxalnet** is a program to create a wireless mesh network for
communicating with each other. It can be useful during an [internet communicating with each other. It can be useful during an [internet
shutdown](#internet-shutdown), or to join [online classes](#online-class) shutdown](#internet-shutdown), or to join [online classes](#online-class)
with a group of laptops. It uses [B.A.T.M.A.N. Advanced][batman-adv], an with a group of laptops. It uses [B.A.T.M.A.N. Advanced][batman-adv], an
implementation of the B.A.T.M.A.N. routing protocol to communicate with implementation of the B.A.T.M.A.N. routing protocol to communicate with
peers. The name naxal comes from Naxalbari, a village in Darjeeling, West peers.
Bengal.
**WARNING**: This program uses an **unencrypted** network. This means you do **WARNING**: This program uses an **unencrypted** network. This means you do
not get any more privacy or security than with an open WiFi network. not get any more privacy or security than with an open WiFi network.
<!-- NOTE TO ACTIVISTS
Running this program in the world's largest (partly-free) democracy
may result in you getting arrested under the Act Which Must Not Be Named,
and not getting bail because of false evidence planted in your phone by
Pegasus, or by a forensic lab in Gujarat.
The author, much like the GoI, does not wish to take responsibility in your
well-being if you get arrested under a draconian national security law.
-->
## Features ## Features
- Select best network when multiple nodes have internet access (gateway - Select best network when multiple nodes have internet access (gateway
@ -34,26 +18,13 @@ well-being if you get arrested under a draconian national security law.
- Readable logs - Readable logs
- Supports rfkill - Supports rfkill
<!-- UNCOMMENT WHEN NECESSARY
**Disclaimer**: In case you are either 1: a complete idiot; or 2: a member
of the saffron brigade; or 3: both, please be aware that this project is
not affiliated with any human rights defenders or with anyone currently at
risk of death in overcrowded prisons.
Using the name naxal in a program will not shake the foundations of
democracy nor affect the soverignty, unity or integrity of any
nation-state. .
-->
## Requirements ## Requirements
- [systemd-networkd v248 or greater][batman-systemd] - [systemd-networkd v248 or greater][batman-systemd]
- Linux kernel with [batman-adv v2021.0][batman-systemd] or greater - Linux kernel with [batman-adv v2021.0][batman-systemd] or greater
- [iwd][] for controlling the WiFi adapter - [iwd][] for controlling the WiFi adapter
- python (tested on 3.9 and 3.10) - python (tested on 3.9 and 3.10)
- python setuptools, for building and installing naxalnet - python setuptools, for building and installing pybatmesh
- [python-systemd][], for logging to systemd journal - [python-systemd][], for logging to systemd journal
- [dasbus][], for communicating with iwd - [dasbus][], for communicating with iwd
- two or more machines with a WiFi adapter having ibss support, called - two or more machines with a WiFi adapter having ibss support, called
@ -68,22 +39,22 @@ distributions will have to build manually.
### Arch Linux ### Arch Linux
Install [naxalnet][aur] (or [naxalnet-git][aur-devel] for the Install [pybatmesh][aur] (or [pybatmesh-git][aur-devel] for the
development version) from the AUR with your favourite helper: development version) from the AUR with your favourite helper:
```sh ```sh
yay -S naxalnet yay -S pybatmesh
``` ```
Optionally, [setup systemd-resolved][arch-resolved] for DNS. [Start Optionally, [setup systemd-resolved][arch-resolved] for DNS. [Start
naxalnet][startnx] when you need it. pybatmesh][startnx] when you need it.
### Debian or Ubuntu ### Debian or Ubuntu
naxalnet is not packaged for Debian or Ubuntu, so you will have to build pybatmesh is not packaged for Debian or Ubuntu, so you will have to build
and install it manually. Currently, only Debian bookworm (testing) and and install it manually. Currently, only Debian bookworm (testing) and
Ubuntu 21.10 comes with the required version of systemd. Therefore, Ubuntu 21.10 comes with the required version of systemd. Therefore,
naxalnet requires **Debian testing** or **Ubuntu 21.10 or greater** to pybatmesh requires **Debian testing** or **Ubuntu 21.10 or greater** to
work. work.
Install the requirements from the repositories: Install the requirements from the repositories:
@ -100,25 +71,25 @@ Now follow the instructions in the
### Fedora ### Fedora
naxalnet is not packaged for Fedora, so it should be installed manually. pybatmesh is not packaged for Fedora, so it should be installed manually.
naxalnet requires at least systemd v248, which is only available on pybatmesh requires at least systemd v248, which is only available on
**Fedora 34 and above**. python-setuptools support building rpms, which **Fedora 34 and above**. python-setuptools support building rpms, which
are the preferred way of installing software in Fedora. Follow the steps are the preferred way of installing software in Fedora. Follow the steps
to install naxalnet on Fedora: to install pybatmesh on Fedora:
```sh ```sh
# Install the build requirements # Install the build requirements
sudo dnf install python3-setuptools make git sudo dnf install python3-setuptools make git
# Clone the repo # Clone the repo
git clone https://git.disroot.org/pranav/naxalnet.git git clone https://git.disroot.org/pranav/pybatmesh.git
cd naxalnet cd pybatmesh
# Create an installable rpm from the source code # Create an installable rpm from the source code
make rpm make rpm
# Now install it. This will also install the requirements # Now install it. This will also install the requirements
sudo dnf install dist/naxalnet-$(python3 -m setup --version)-1.noarch.rpm sudo dnf install dist/pybatmesh-$(python3 -m setup --version)-1.noarch.rpm
``` ```
### Manually ### Manually
@ -142,14 +113,14 @@ python3 --version
iw phy | grep -q join_ibss && echo "IBSS is supported" || echo "IBSS not supported" iw phy | grep -q join_ibss && echo "IBSS is supported" || echo "IBSS not supported"
``` ```
Clone the naxalnet repo and cd into it. Clone the pybatmesh repo and cd into it.
```sh ```sh
git clone https://git.disroot.org/pranav/naxalnet.git git clone https://git.disroot.org/pranav/pybatmesh.git
cd naxalnet cd pybatmesh
``` ```
Now, build and install naxalnet: Now, build and install pybatmesh:
```sh ```sh
make make
@ -177,16 +148,16 @@ This will keep the configuration files.
## How to use ## How to use
You need more than one machine running naxalnet for the connection to work. You need more than one machine running pybatmesh for the connection to work.
### Start naxalnet ### Start pybatmesh
Though naxalnet can run from the command line, it was designed to be Though pybatmesh can run from the command line, it was designed to be
run as a systemd service. run as a systemd service.
To start naxalnet, do the command on all the nodes: To start pybatmesh, do the command on all the nodes:
```sh ```sh
sudo systemctl start naxalnet.service sudo systemctl start pybatmesh.service
``` ```
This will start a mesh network and connect to all nodes. To test if it This will start a mesh network and connect to all nodes. To test if it
@ -196,32 +167,32 @@ your network is up. Press Ctrl+C to stop `batctl`.
### Getting internet access ### Getting internet access
Connect an ethernet cable from a router to any of the nodes. Now restart 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 pybatmesh 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 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 if you don't want the delay. To do this, type
`sudo networkctl renew bridge0` on all nodes. `sudo networkctl renew bridge0` on all nodes.
### Tethering via WiFi AP ### Tethering via WiFi AP
If there are two adapters in a peer, naxalnet will start a If there are two adapters in a peer, pybatmesh will start a
WiFi ap (also called WiFi hotspot) on one of them. WiFi ap (also called WiFi hotspot) on one of them.
Connect two WiFi adapters on a node. Connect two WiFi adapters on a node.
Now an AP will be started on one of the adapters. Now an AP will be started on one of the adapters.
Type `naxalnet --print-wifi` to get the WiFi SSID and password. Type `pybatmesh --print-wifi` to get the WiFi SSID and password.
If you had set up internet access on one of the nodes, internet If you had set up internet access on one of the nodes, internet
can be accessed from the AP. can be accessed from the AP.
### Running at boot ### Running at boot
To run naxalnet at boot, enable the service on all the nodes: To run pybatmesh at boot, enable the service on all the nodes:
```sh ```sh
sudo systemctl enable naxalnet.service sudo systemctl enable pybatmesh.service
``` ```
Now naxalnet will start a mesh on every boot. Now pybatmesh will start a mesh on every boot.
If you have NetworkManager enabled, which is the default in Ubuntu and If you have NetworkManager enabled, which is the default in Ubuntu and
Fedora, it should be disabled: Fedora, it should be disabled:
@ -230,10 +201,10 @@ Fedora, it should be disabled:
sudo systemctl disable NetworkManager.service sudo systemctl disable NetworkManager.service
``` ```
To stop running at boot, you should disable `naxalnet.service`: To stop running at boot, you should disable `pybatmesh.service`:
```sh ```sh
sudo systemctl disable naxalnet.service sudo systemctl disable pybatmesh.service
``` ```
If you had disabled `NetworkManager` before, enable it: If you had disabled `NetworkManager` before, enable it:
@ -245,10 +216,10 @@ sudo systemctl enable NetworkManager.service
### Stopping the service ### Stopping the service
```sh ```sh
sudo systemctl stop naxalnet iwd systemd-networkd systemd-resolved sudo systemctl stop pybatmesh iwd systemd-networkd systemd-resolved
``` ```
If your distribution uses NetworkManager, starting `naxalnet.service` If your distribution uses NetworkManager, starting `pybatmesh.service`
will have stopped it. Start NetworkManager again: will have stopped it. Start NetworkManager again:
```sh ```sh
@ -257,28 +228,26 @@ sudo systemctl start NetworkManager.service
### Configuration ### Configuration
naxalnet comes with a sample configuration file pybatmesh comes with a sample configuration file
`/etc/naxalnet/naxalnet.conf.example`. To change how the program `/etc/pybatmesh/pybatmesh.conf.example`. To change how the program
behaves, copy it to /etc/naxalnet/naxalnet.conf and edit it: behaves, copy it to /etc/pybatmesh/pybatmesh.conf and edit it:
```sh ```sh
sudo cp /etc/naxalnet/naxalnet.conf{.example,} sudo cp /etc/pybatmesh/pybatmesh.conf{.example,}
# Now edit the file with your favourite editor as root # Now edit the file with your favourite editor as root
gedit admin:/etc/naxalnet/naxalnet.conf gedit admin:/etc/pybatmesh/pybatmesh.conf
``` ```
Also, you can change its behaviour every time you run it using Also, you can change its behaviour every time you run it using
arguments: arguments:
```sh ```sh
naxalnet --help pybatmesh --help
``` ```
## Contributing or reporting bugs ## Contributing or reporting bugs
Join the XMPP channel <xmpp:naxalnet@chat.disroot.org> to talk about See [HACKING.md](HACKING.md)
anything related to this program or about mesh networks in general. See
[HACKING.md](HACKING.md) to contribute to the repo.
## How it works ## How it works
@ -287,11 +256,11 @@ hotspot), `station` (for joining WiFi networks) and `ad-hoc` (or ibss, for
decentralised networks). There are other modes supported by some WiFi decentralised networks). There are other modes supported by some WiFi
adapters too, like `p2p` (WiFi direct), but this program doesn't use them. adapters too, like `p2p` (WiFi direct), but this program doesn't use them.
naxalnet uses two modes - `ad-hoc` and `ap`, for connecting to the pybatmesh uses two modes - `ad-hoc` and `ap`, for connecting to the
mesh. naxalnet uses iwd to start an `ad-hoc` network and configures mesh. pybatmesh uses iwd to start an `ad-hoc` network and configures
systemd-networkd to setup a BATMAN Advanced network. systemd-networkd to setup a BATMAN Advanced network.
If there are two WiFi adapters connected to the machine, If there are two WiFi adapters connected to the machine,
naxalnet starts an ad-hoc on one of them and an ap on the other. pybatmesh starts an ad-hoc on one of them and an ap on the other.
You can use the ap for connecting mobile phones and other devices You can use the ap for connecting mobile phones and other devices
to the mesh network. to the mesh network.
@ -303,32 +272,24 @@ systemd-networkd configures the network.
### Online class ### Online class
naxalnet can be used to share connections to join online classes. You need pybatmesh can be used to share connections to join online classes. You need
at least one device with internet access if you are not using a program at least one device with internet access if you are not using a program
like [Jami][] (see below). like [Jami][] (see below).
<!--
### Malign democracies and well-established institutions
Withheld due to national security reasons.
-->
### Internet shutdown ### Internet shutdown
You can communicate with neighbouring devices running naxalnet, using You can communicate with neighbouring devices running pybatmesh, using
services like [IPFS][], [Jami][], [Briar][] [Secure Scuttlebutt][ssb] or services like [IPFS][], [Jami][], [Briar][] [Secure Scuttlebutt][ssb] or
similar software which can work on an intranet. They should be installed similar software which can work on an intranet. They should be installed
on your machine _before_ your friendly democratic government announces an on your machine _before_ your friendly democratic government announces an
[internet shutdown][], since you cannot download and install them during a [internet shutdown][], since you cannot download and install them during a
shutdown. When a shutdown occurs, [enable naxalnet][enablenx] and use the shutdown. When a shutdown occurs, [enable pybatmesh][enable-pybatmesh] and use the
installed software to communicate with anyone within range. installed software to communicate with anyone within range.
## Uninstalling ## Uninstalling
If you installed naxalnet manually, use make uninstall to remove If you installed pybatmesh manually, use make uninstall to remove
naxalnet and its data files. This requires python pip to be installed. pybatmesh and its data files. This requires python pip to be installed.
```sh ```sh
# Uninstall the program, keeping the config files # Uninstall the program, keeping the config files
@ -341,21 +302,21 @@ sudo make purge
Many projects make setting up B.A.T.M.A.N. Advanced mesh networks with Many projects make setting up B.A.T.M.A.N. Advanced mesh networks with
WiFi routers easier. They are easier to setup and are more WiFi routers easier. They are easier to setup and are more
configurable. But naxalnet is different from them. It simplifies configurable. But pybatmesh is different from them. It simplifies
setting up mesh networks with _laptops or computers_, and was not setting up mesh networks with _laptops or computers_, and was not
made to work with routers. made to work with routers.
The following projects does something similar to naxalnet, but The following projects does something similar to pybatmesh, but
requires special devices or routers to work. If you live in an area requires special devices or routers to work. If you live in an area
where the materials are easily available, consider using them instead where the materials are easily available, consider using them instead
of naxalnet. of pybatmesh.
- [LibreMesh][]: framework for OpenWrt-based firmwares - [LibreMesh][]: framework for OpenWrt-based firmwares
- [disaster.radio][]: solar-powered communications network - [disaster.radio][]: solar-powered communications network
## License ## License
naxalnet is [free/libre/swatantra][free-sw] and open source software; pybatmesh is [free/libre/swatantra][free-sw] and open source software;
you can redistribute it and/or modify it under the terms of the GNU you can redistribute it and/or modify it under the terms of the GNU
General Public License as published by the Free Software Foundation, General Public License as published by the Free Software Foundation,
eitherversion 3 of the License, or (at your option) any later version. eitherversion 3 of the License, or (at your option) any later version.
@ -369,16 +330,16 @@ See [LICENSE](LICENSE) for the complete version of the license.
[ssb]: https://scuttlebutt.nz "Secure Scuttlebutt" [ssb]: https://scuttlebutt.nz "Secure Scuttlebutt"
[briar]: https://briarproject.org/ [briar]: https://briarproject.org/
[dasbus]: https://github.com/rhinstaller/dasbus "A python D-Bus library" [dasbus]: https://github.com/rhinstaller/dasbus "A python D-Bus library"
[aur]: https://aur.archlinux.org/packages/naxalnet [aur]: https://aur.archlinux.org/packages/pybatmesh
[aur-devel]: https://aur.archlinux.org/packages/naxalnet-git [aur-devel]: https://aur.archlinux.org/packages/pybatmesh-git
[arch-resolved]: https://wiki.archlinux.org/title/Systemd-resolved#DNS "systemd-resolved on ArchWiki" [arch-resolved]: https://wiki.archlinux.org/title/Systemd-resolved#DNS "systemd-resolved on ArchWiki"
[batman-systemd]: https://www.open-mesh.org/news/101 "systemd v248 brings support for batman advanced" [batman-systemd]: https://www.open-mesh.org/news/101 "systemd v248 brings support for batman advanced"
[libremesh]: https://libremesh.org [libremesh]: https://libremesh.org
[disaster.radio]: https://disaster.radio [disaster.radio]: https://disaster.radio
[startnx]: #start-naxalnet [startnx]: #start-pybatmesh
[iwd]: https://iwd.wiki.kernel.org "WiFi daemon" [iwd]: https://iwd.wiki.kernel.org "WiFi daemon"
[free-sw]: https://gnu.org/philosophy/free-sw.html "What is free software?" [free-sw]: https://gnu.org/philosophy/free-sw.html "What is free software?"
[enablenx]: #running-at-boot [enable-pybatmesh]: #running-at-boot
[requirements]: #requirements [requirements]: #requirements
[install-manual]: #manually [install-manual]: #manually
[python-systemd]: https://github.com/systemd/python-systemd [python-systemd]: https://github.com/systemd/python-systemd

View File

@ -1,7 +1,7 @@
# This file links any interface in ap mode # This file links any interface in ap mode
# to the bridge we created earlier. # to the bridge we created earlier.
# To start an AP, connect two adapters to the computer # To start an AP, connect two adapters to the computer
# before starting naxalnet.service # before starting pybatmesh.service
# This file won't do anything if an ap interface is not found. # This file won't do anything if an ap interface is not found.
[Match] [Match]

View File

@ -1,12 +1,12 @@
# This configuration file is part of naxalnet. # This configuration file is part of pybatmesh.
# To configure this program, rename this file # To configure this program, rename this file
# to naxalnet.conf and edit it. # to pybatmesh.conf and edit it.
# The values given here are defaults. # The values given here are defaults.
[networkd] [networkd]
# systemd-networkd configuration files bundled with naxalnet. # systemd-networkd configuration files bundled with pybatmesh.
# THese will be copied to runtimedir at runtime. # THese will be copied to runtimedir at runtime.
confdir = /usr/share/naxalnet/networkd confdir = /usr/share/pybatmesh/networkd
# systemd-networkd runtime configuration directory. # systemd-networkd runtime configuration directory.
# See man:systemd.network(5) # See man:systemd.network(5)
runtimedir = /run/systemd/network runtimedir = /run/systemd/network
@ -26,10 +26,10 @@ mode=auto
[adhoc] [adhoc]
# All your nodes should have the same name # All your nodes should have the same name
name = NxMesh name = pybatmesh
[ap] [ap]
# An AP is started if your machine has more than one WiFi adapter. # An AP is started if your machine has more than one WiFi adapter.
ssid = MeshWiFi ssid = BatWiFi
# Note the spelling. It's passwd, not password. # Note the spelling. It's passwd, not password.
passwd = naxalnet256 passwd = pybatmesh256

View File

@ -1,4 +1,4 @@
# The naxalnet systemd service # The pybatmesh systemd service
# See man:systemd.service(5) and man:systemd.unit(5) # See man:systemd.service(5) and man:systemd.unit(5)
# before editing this file. # before editing this file.
[Unit] [Unit]
@ -11,7 +11,7 @@ After=systemd-networkd.service
After=systemd-resolved.service After=systemd-resolved.service
# Stops NetworkManager if already running # Stops NetworkManager if already running
Conflicts=NetworkManager.service Conflicts=NetworkManager.service
# This stops networkmanager and wpa_supplicant when naxalnet is enabled # This stops NetworkManager when pybatmesh is enabled
After=NetworkManager.service After=NetworkManager.service
[Service] [Service]
@ -19,9 +19,9 @@ Type=notify
NotifyAccess=all NotifyAccess=all
Restart=on-failure Restart=on-failure
RestartSec=2sec RestartSec=2sec
ExecStart=naxalnet --systemd ExecStart=pybatmesh --systemd
KillSignal=SIGINT KillSignal=SIGINT
# naxalnet already logs to systemd journal so we don't need # pybatmesh already logs to systemd journal so we don't need
# stdout and stderr. # stdout and stderr.
StandardOutput=null StandardOutput=null
StandardError=null StandardError=null

View File

@ -1,5 +1,5 @@
# This file is part of naxalnet. # This file is part of pybatmesh.
# Copyright (C) 2021 The naxalnet Authors # Copyright (C) 2021 The pybatmesh Authors
# This program is free software: you can redistribute it and/or modify it # This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the # under the terms of the GNU General Public License as published by the
@ -15,7 +15,7 @@
# with this program. If not, see <http://www.gnu.org/licenses/>. # with this program. If not, see <http://www.gnu.org/licenses/>.
""" """
naxalnet pybatmesh
======== ========
Create mesh networks with batman-adv, systemd-networkd and iwd. Create mesh networks with batman-adv, systemd-networkd and iwd.
@ -24,8 +24,8 @@ See README.md and the docstrings for documentation. You can read
documentaion in the python interpretor using something like the example documentaion in the python interpretor using something like the example
given below. given below.
>>> help("naxalnet") >>> help("pybatmesh")
>>> help("naxalnet.config") >>> help("pybatmesh.config")
""" """
@ -42,4 +42,4 @@ given below.
# #
# In case you forgot to change the version, skip the number # In case you forgot to change the version, skip the number
# and put the next number in the next commit. # and put the next number in the next commit.
__version__ = "0.5.2" __version__ = "0.5.2a2"

View File

@ -1,5 +1,5 @@
# This file is part of naxalnet. # This file is part of pybatmesh.
# Copyright (C) 2021 The naxalnet Authors # Copyright (C) 2021 The pybatmesh Authors
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -19,16 +19,12 @@
__main__.py __main__.py
----------- -----------
If called as python -m naxalnet, this file makes naxalnet run like If called as python -m pybatmesh, this file makes pybatmesh run like
it was called from the commandline. Try: it was called from the commandline. Try:
python -m naxalnet --help python -m pybatmesh --help
WARNING: Using naxalnet might threaten the soverignity and integrity of
your nation-state. The authors are not responsible for any damage caused
while using this software.
""" """
from naxalnet.scripts import main from pybatmesh.scripts import main
if __name__ == "__main__": if __name__ == "__main__":
main() main()

View File

@ -1,5 +1,5 @@
# This file is part of naxalnet. # This file is part of pybatmesh.
# Copyright (C) 2021 The naxalnet Authors # Copyright (C) 2021 The pybatmesh Authors
# This program is free software: you can redistribute it and/or modify it # This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the # under the terms of the GNU General Public License as published by the
@ -22,20 +22,20 @@ This file contains functions to parse configuration files and arguments.
Most of these functions are meant to be used by parse_args() internally, Most of these functions are meant to be used by parse_args() internally,
so only parse_args() should be imported outside this file. so only parse_args() should be imported outside this file.
Some parts of naxalnet can be configured by configuration files and Some parts of pybatmesh can be configured by configuration files and
arguments in a specific order. First, the default values from default.py arguments in a specific order. First, the default values from default.py
is taken. Then, key-value pairs from the configuration files are read, if is taken. Then, key-value pairs from the configuration files are read, if
they exist, in the following order: they exist, in the following order:
- First it reads /usr/share/naxalnet/naxalnet.conf and then from - First it reads /usr/share/pybatmesh/pybatmesh.conf and then from
/usr/share/naxalnet/naxalnet.conf.d/*.conf where *.conf means any file /usr/share/pybatmesh/pybatmesh.conf.d/*.conf where *.conf means any file
with the name ending with ".conf". The files in this directory are with the name ending with ".conf". The files in this directory are
intended to be used by distribution and package maintainers. intended to be used by distribution and package maintainers.
- Next, it does the same with /usr/local/share/naxalnet - Next, it does the same with /usr/local/share/pybatmesh
- Then, it looks for the files naxalnet.conf and naxalnet.conf.d/*.conf - Then, it looks for the files pybatmesh.conf and pybatmesh.conf.d/*.conf
from the directory /etc/naxalnet, like it did up above. This directory from the directory /etc/pybatmesh, like it did up above. This directory
is where the user creates and stores the config file. is where the user creates and stores the config file.
- Then it parses the arguments from the commandline, storing the values in - Then it parses the arguments from the commandline, storing the values in
@ -56,7 +56,7 @@ is used.
from pathlib import Path from pathlib import Path
from configparser import ConfigParser from configparser import ConfigParser
from argparse import ArgumentParser, Namespace from argparse import ArgumentParser, Namespace
from naxalnet.default import CONFIG, CONFIG_FILES, CONFIG_DIRS from pybatmesh.default import CONFIG, CONFIG_FILES, CONFIG_DIRS
def get_config_files(): def get_config_files():
@ -96,7 +96,7 @@ def parse_args() -> Namespace:
""" """
Parse all arguments and return ArgumentParser.parse_args(), Parse all arguments and return ArgumentParser.parse_args(),
with values in config files as fallback. Ideally, only this with values in config files as fallback. Ideally, only this
function should be used by naxalnet to get arguments and function should be used by pybatmesh to get arguments and
configuration. configuration.
""" """
config = parse_config() config = parse_config()

View File

@ -1,5 +1,5 @@
# This file is part of naxalnet. # This file is part of pybatmesh.
# Copyright (C) 2021 The naxalnet Authors # Copyright (C) 2021 The pybatmesh Authors
# This program is free software: you can redistribute it and/or modify it # This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the # under the terms of the GNU General Public License as published by the
@ -23,8 +23,8 @@ is plugged in, or it is removed.
""" """
from dasbus.loop import EventLoop from dasbus.loop import EventLoop
from naxalnet.iwd import IWD, IWD_DEVICE_INTERFACE from pybatmesh.iwd import IWD, IWD_DEVICE_INTERFACE
from naxalnet.log import logger from pybatmesh.log import logger
class Daemon: class Daemon:

View File

@ -1,5 +1,5 @@
# This file is part of naxalnet. # This file is part of pybatmesh.
# Copyright (C) 2021 The naxalnet Authors # Copyright (C) 2021 The pybatmesh Authors
# This program is free software: you can redistribute it and/or modify it # This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the # under the terms of the GNU General Public License as published by the
@ -21,30 +21,30 @@ default.py
This file contains default values for configuration. This is taken as This file contains default values for configuration. This is taken as
fallback data by config.py if no configuration files were found, or if a fallback data by config.py if no configuration files were found, or if a
key-value pair was not present in the config file. The data will be key-value pair was not present in the config file. The data will be
further changed by arguments if naxalnet is called from the commandline. further changed by arguments if pybatmesh is called from the commandline.
See config.py for more info. See config.py for more info.
""" """
CONFIG = { CONFIG = {
"networkd": { "networkd": {
"confdir": "/usr/share/naxalnet/networkd", "confdir": "/usr/share/pybatmesh/networkd",
"runtimedir": "/run/systemd/network", "runtimedir": "/run/systemd/network",
}, },
"device": {"batman": "bat0", "bridge": "bridge0"}, "device": {"batman": "bat0", "bridge": "bridge0"},
"adhoc": {"name": "NxMesh"}, "adhoc": {"name": "pybatmesh"},
"ap": {"ssid": "MeshWiFi", "passwd": "naxalnet256"}, "ap": {"ssid": "BatWiFi", "passwd": "pybatmesh256"},
"gateway": {"mode": "auto"}, "gateway": {"mode": "auto"},
} }
# glob # glob
CONFIG_FILES = ["naxalnet.conf", "naxalnet.conf.d/*.conf"] CONFIG_FILES = ["pybatmesh.conf", "pybatmesh.conf.d/*.conf"]
CONFIG_DIRS = ["/usr/share/naxalnet", "/usr/local/share/naxalnet", "/etc/naxalnet"] CONFIG_DIRS = ["/usr/share/pybatmesh", "/usr/local/share/pybatmesh", "/etc/pybatmesh"]
MESH_GLOB = "mesh.*" MESH_GLOB = "mesh.*"
TMP_NET_GLOB = "tmp.*" TMP_NET_GLOB = "tmp.*"
ISSUE_URL = "https://git.disroot.org/pranav/naxalnet/issues" ISSUE_URL = "https://git.disroot.org/pranav/pybatmesh/issues"
REPORT_BUG_INFO = "If you think this is a bug, report it to " + ISSUE_URL REPORT_BUG_INFO = "If you think this is a bug, report it to " + ISSUE_URL
# Changing this constant will alter not just the behavoiur of naxalnet, # Changing this constant will alter not just the behaviour of pybatmesh,
# but affect the meaning of Life, the Universe and Everthing # but affect the meaning of Life, the Universe and Everthing
ANSWER = 42 ANSWER = 42

View File

@ -1,5 +1,5 @@
# This file is part of naxalnet. # This file is part of pybatmesh.
# Copyright (C) 2021 The naxalnet Authors # Copyright (C) 2021 The pybatmesh Authors
# This program is free software: you can redistribute it and/or modify it # This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the # under the terms of the GNU General Public License as published by the
@ -29,11 +29,11 @@ terms and what they mean:
network, where there is no central point of failure. network, where there is no central point of failure.
- ap: a mode used to start a central access point so that other machines - ap: a mode used to start a central access point so that other machines
without naxalnet can connect to the mesh. AP is also known as WiFi without pybatmesh can connect to the mesh. AP is also known as WiFi
hotspot. hotspot.
- station: this is the mode most WiFi adapters use by default. This mode - station: this is the mode most WiFi adapters use by default. This mode
is used to connect to an ap. naxalnet DOES NOT use this mode. is used to connect to an ap. pybatmesh DOES NOT use this mode.
- adapter: a physical WiFi chip or something similar that is present - adapter: a physical WiFi chip or something similar that is present
inside most laptops and phones or can be connected via USB to a inside most laptops and phones or can be connected via USB to a
@ -47,12 +47,12 @@ terms and what they mean:
- machine: Since iwd uses the term device for a WiFi interface, we use the - machine: Since iwd uses the term device for a WiFi interface, we use the
word machine to refer to a computer, or a laptop, or a phone. word machine to refer to a computer, or a laptop, or a phone.
- node: a machine that runs naxalnet and is therefore connected to the - node: a machine that runs pybatmesh and is therefore connected to the
mesh. mesh.
""" """
from dasbus.connection import SystemMessageBus from dasbus.connection import SystemMessageBus
from naxalnet.log import logger from pybatmesh.log import logger
IWD_BUS = "net.connman.iwd" IWD_BUS = "net.connman.iwd"
IWD_ROOT_PATH = "/" IWD_ROOT_PATH = "/"

View File

@ -1,5 +1,5 @@
# This file is part of naxalnet. # This file is part of pybatmesh.
# Copyright (C) 2021 The naxalnet Authors # Copyright (C) 2021 The pybatmesh Authors
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -19,22 +19,22 @@ log.py
------ ------
Initialise the logger for other submodules to import. Do not import any Initialise the logger for other submodules to import. Do not import any
submodules here other than naxallnet.config, which is needed to set the submodules here other than pybatmesh.config, which is needed to set the
loglevel and to add the systemd journal handler loglevel and to add the systemd journal handler
""" """
import logging import logging
from systemd.journal import JournalHandler from systemd.journal import JournalHandler
from naxalnet.config import args from pybatmesh.config import args
def get_logger(): def get_logger():
""" """
Initialise the logger and return it. Initialise the logger and return it.
This function is meant to be used only by naxalnet.log. This function is meant to be used only by pybatmesh.log.
If you want to import the logger, use: If you want to import the logger, use:
from naxalnet.log import logger from pybatmesh.log import logger
""" """
log = logging.getLogger("naxalnet") log = logging.getLogger("pybatmesh")
# --verbose # --verbose
if args.verbose >= 2: if args.verbose >= 2:
loglevel = logging.DEBUG loglevel = logging.DEBUG

View File

@ -1,5 +1,5 @@
# This file is part of naxalnet. # This file is part of pybatmesh.
# Copyright (C) 2021 The naxalnet Authors # Copyright (C) 2021 The pybatmesh Authors
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -40,8 +40,8 @@ NETWORKD_PATH = "/org/freedesktop/network1"
class NetworkD: class NetworkD:
""" """
Control systemd-networkd using configuration files. Since these Control systemd-networkd using configuration files. Since these
were made for use by naxalnet only, the class is not suitable for were made for use by pybatmesh only, the class is not suitable for
importing outside naxalnet. importing outside pybatmesh.
""" """
def __init__(self, runtime_dir="/run/systemd/network", bus=SystemMessageBus()): def __init__(self, runtime_dir="/run/systemd/network", bus=SystemMessageBus()):

View File

@ -1,5 +1,5 @@
# This file is part of naxalnet. # This file is part of pybatmesh.
# Copyright (C) 2021 The naxalnet Authors # Copyright (C) 2021 The pybatmesh Authors
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -22,22 +22,21 @@ The functions in this file is used for reading configs, args
and doing the things this program is supposed to do. and doing the things this program is supposed to do.
This file is named scripts.py because the original developer This file is named scripts.py because the original developer
of this program could not think of a better name that suits this file. of this program could not think of a better name that suits this file.
If you want to hack naxalnet, this is the right place to start. If you want to hack pybatmesh, this is the right place to start.
When run from the commandline, the function main() is called. When run from the commandline, the function main() is called.
""" """
import sys import sys
import time
from pathlib import Path from pathlib import Path
from dasbus.error import DBusError from dasbus.error import DBusError
from systemd.daemon import notify from systemd.daemon import notify
from naxalnet import __version__ from pybatmesh import __version__
from naxalnet.default import REPORT_BUG_INFO, MESH_GLOB, TMP_NET_GLOB from pybatmesh.default import REPORT_BUG_INFO, MESH_GLOB, TMP_NET_GLOB
from naxalnet.log import logger from pybatmesh.log import logger
from naxalnet.iwd import Adapter, Device, IWD from pybatmesh.iwd import Adapter, Device, IWD
from naxalnet.config import args from pybatmesh.config import args
from naxalnet.daemon import Daemon from pybatmesh.daemon import Daemon
from naxalnet.network import NetworkD, NetworkLoop from pybatmesh.network import NetworkD, NetworkLoop
def get_sorted_glob(directory: str, glob: str) -> list: def get_sorted_glob(directory: str, glob: str) -> list:
@ -159,7 +158,7 @@ def setup_devices():
if len(ap_devices) != 0: if len(ap_devices) != 0:
ap_device = Device(ap_devices.pop()) ap_device = Device(ap_devices.pop())
logger.info("Starting WiFi Access Point on %s", ap_device.name) logger.info("Starting WiFi Access Point on %s", ap_device.name)
logger.info("Use naxalnet --print-wifi to get password") logger.info("Use pybatmesh --print-wifi to get password")
# Turn on adapter if it is off # Turn on adapter if it is off
# See issue #9 # See issue #9
ap_adapter = Adapter(ap_device.adapter) ap_adapter = Adapter(ap_device.adapter)
@ -222,7 +221,7 @@ def main():
""" """
This is where the magic happens! This is where the magic happens!
This function is run every time you This function is run every time you
execute naxalnet from the commandline execute pybatmesh from the commandline
""" """
if args.print_wifi: if args.print_wifi:
@ -232,12 +231,12 @@ def main():
print_version() print_version()
sys.exit(0) sys.exit(0)
# Notify systemd that naxalnet is ready. # Notify systemd that pybatmesh is ready.
# see man:sd_notify(3) # see man:sd_notify(3)
notify("READY=1") notify("READY=1")
# Gateway mode comes in handy when many nodes have a DHCP server and # Gateway mode comes in handy when many nodes have a DHCP server and
# you want to prevent conflicts. It defaults to "auto" in naxalnet. # you want to prevent conflicts. It defaults to "auto" in pybatmesh.
# https://www.open-mesh.org/projects/batman-adv/wiki/Gateways # https://www.open-mesh.org/projects/batman-adv/wiki/Gateways
if args.gateway_mode == "auto": if args.gateway_mode == "auto":
logger.info("Checking for internet connection") logger.info("Checking for internet connection")

View File

@ -1,13 +1,13 @@
# This file is loosely based on the setup.cfg used in django. # This file is loosely based on the setup.cfg used in django.
# naxalnet is not meant to be distributed through PyPi. This program uses # pybatmesh is not meant to be distributed through PyPi. This program uses
# a systemd service, and some other files whose path is hardcoded into the # a systemd service, and some other files whose path is hardcoded into the
# module. # module.
[metadata] [metadata]
name = naxalnet name = pybatmesh
version = attr: naxalnet.__version__ version = attr: pybatmesh.__version__
description = create mesh networks with batman-adv and systemd description = create mesh networks with batman-adv and systemd
long_description = file: README.md long_description = file: README.md
url = https://git.disroot.org/pranav/naxalnet url = https://git.disroot.org/pranav/pybatmesh
author = Pranav Jerry author = Pranav Jerry
author_email = libreinator@disroot.org author_email = libreinator@disroot.org
license = GPLv3 license = GPLv3
@ -32,16 +32,16 @@ install_requires =
[options.entry_points] [options.entry_points]
console_scripts = console_scripts =
naxalnet = naxalnet.scripts:main pybatmesh = pybatmesh.scripts:main
[options.data_files] [options.data_files]
lib/systemd/system = lib/systemd/system =
naxalnet.service pybatmesh.service
# If installing with pip, this file will be copied to some other place. # If installing with pip, this file will be copied to some other place.
# This is the reason we use setup.py instead of pip in the Makefile. # This is the reason we use setup.py instead of pip in the Makefile.
/etc/naxalnet = /etc/pybatmesh =
naxalnet.conf.example pybatmesh.conf.example
share/naxalnet/networkd = share/pybatmesh/networkd =
network/mesh.01-batman.netdev network/mesh.01-batman.netdev
network/mesh.02-bridge.netdev network/mesh.02-bridge.netdev
network/mesh.03-wireless-ad-hoc.network network/mesh.03-wireless-ad-hoc.network