renaming to pybatmesh

pybatmesh better describes the project and does not attract the
attention of caged investigation agencies, like it probably would have
before. I probably left traces of the original name somewhere, so this
commit will likely be followed by other commits to erase all traces of
the previous name
This commit is contained in:
Pranav Jerry 2022-07-23 15:58:32 +05:30
parent 38d0aa8ab5
commit 72dda12d7b
Signed by: pranav
GPG Key ID: F1DCDC4FED0A0C5B
17 changed files with 168 additions and 214 deletions

View File

@ -1,5 +1,9 @@
# Changelog
## Renamed to pybatmesh
- Renamed to pybatmesh, to be more clear what the program does
## [v0.5.2][] - 2021-12-10
- Optimised auto gateway mode selection (#25)
@ -51,11 +55,11 @@ used to do. The shell script was not given a version.
- Closed #1 and #3
[unreleased]: https://git.disroot.org/pranav/naxalnet/compare/v0.5.2...HEAD
[v0.5.2]: https://git.disroot.org/pranav/naxalnet/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.0]: https://git.disroot.org/pranav/naxalnet/compare/v0.4.0...v0.5.0
[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
[v0.2.0]: https://git.disroot.org/pranav/naxalnet/compare/v0.1.0...v0.2.0
[v0.1.0]: https://git.disroot.org/pranav/naxalnet/releases/tag/v0.1.0
[unreleased]: https://git.disroot.org/pranav/pybatmesh/compare/v0.5.2...HEAD
[v0.5.2]: https://git.disroot.org/pranav/pybatmesh/compare/v0.5.1...v0.5.2
[v0.5.1]: https://git.disroot.org/pranav/pybatmesh/compare/v0.5.0...v0.5.1
[v0.5.0]: https://git.disroot.org/pranav/pybatmesh/compare/v0.4.0...v0.5.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/pybatmesh/compare/v0.2.0...v0.3.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/pybatmesh/releases/tag/v0.1.0

View File

@ -1,22 +1,15 @@
# Hacking
Everyone can [hack][] naxalnet. 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 -->
Everyone can [hack][] pybatmesh. 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>
<https://git.disroot.org/pranav/pybatmesh/issues>
While reporting a bug, you can add the debug messages to provide more
data. Run `journalctl -fu naxalnet` 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
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 pybatmesh.service` or whatever caused the error. Now copy the error
messages and paste it in the issue body along with the description.
## 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
list. Add your username to issue #8 to add you as a contributor. Before
each commit, update the CHANGELOG.md and `__version__` in
`naxalnet/__init__.py`
`pybatmesh/__init__.py`
## 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,
openSUSE, and nixos. If you know/like to package it in your distro, post a
message to issue #6.

View File

@ -10,19 +10,19 @@ DESTDIR:= /
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
# naxalnet/__init__.py
build: naxalnet/__init__.py
# pybatmesh/__init__.py
build: pybatmesh/__init__.py
$(PYTHON) setup.py build
install:
$(PYTHON) setup.py install --root="$(DESTDIR)" --optimize=1 --skip-build
uninstall:
$(PIP) uninstall -y naxalnet
rm -rf /usr/share/naxalnet /usr/lib/systemd/system/naxalnet.service
@echo "make uninstall will not remove anything in /etc/naxalnet" && \
$(PIP) uninstall -y pybatmesh
rm -rf /usr/share/pybatmesh /usr/lib/systemd/system/pybatmesh.service
@echo "make uninstall will not remove anything in /etc/pybatmesh" && \
echo "Do 'sudo make purge' to remove it."
rpm:
@ -31,7 +31,7 @@ rpm:
# Remove config files, like apt purge. Purge should first do what
# uninstall does, so we add uninstall as a dependency to this rule.
purge: uninstall
rm -rf /etc/naxalnet
rm -rf /etc/pybatmesh
clean:
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
10, 2021. See issue #8
**naxalnet** is a program to create a wireless mesh network for
**pybatmesh** is a program to create a wireless mesh network for
communicating with each other. It can be useful during an [internet
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
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
Bengal.
peers.
**WARNING**: This program uses an **unencrypted** network. This means you do
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
- 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
- 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
- [systemd-networkd v248 or greater][batman-systemd]
- Linux kernel with [batman-adv v2021.0][batman-systemd] or greater
- [iwd][] for controlling the WiFi adapter
- 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
- [dasbus][], for communicating with iwd
- two or more machines with a WiFi adapter having ibss support, called
@ -68,22 +39,22 @@ distributions will have to build manually.
### 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:
```sh
yay -S naxalnet
yay -S pybatmesh
```
Optionally, [setup systemd-resolved][arch-resolved] for DNS. [Start
naxalnet][startnx] when you need it.
pybatmesh][startnx] when you need it.
### 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
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.
Install the requirements from the repositories:
@ -100,25 +71,25 @@ Now follow the instructions in the
### Fedora
naxalnet is not packaged for Fedora, so it should be installed manually.
naxalnet requires at least systemd v248, which is only available on
pybatmesh is not packaged for Fedora, so it should be installed manually.
pybatmesh requires at least systemd v248, which is only available on
**Fedora 34 and above**. python-setuptools support building rpms, which
are the preferred way of installing software in Fedora. Follow the steps
to install naxalnet on Fedora:
to install pybatmesh on Fedora:
```sh
# Install the build requirements
sudo dnf install python3-setuptools make git
# Clone the repo
git clone https://git.disroot.org/pranav/naxalnet.git
cd naxalnet
git clone https://git.disroot.org/pranav/pybatmesh.git
cd pybatmesh
# Create an installable rpm from the source code
make rpm
# 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
@ -142,14 +113,14 @@ python3 --version
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
git clone https://git.disroot.org/pranav/naxalnet.git
cd naxalnet
git clone https://git.disroot.org/pranav/pybatmesh.git
cd pybatmesh
```
Now, build and install naxalnet:
Now, build and install pybatmesh:
```sh
make
@ -177,16 +148,16 @@ This will keep the configuration files.
## 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.
To start naxalnet, do the command on all the nodes:
To start pybatmesh, do the command on all the nodes:
```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
@ -196,32 +167,32 @@ 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. 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
if you don't want the delay. To do this, type
`sudo networkctl renew bridge0` on all nodes.
### 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.
Connect two WiFi adapters on a node.
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
can be accessed from the AP.
### 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
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
Fedora, it should be disabled:
@ -230,10 +201,10 @@ Fedora, it should be disabled:
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
sudo systemctl disable naxalnet.service
sudo systemctl disable pybatmesh.service
```
If you had disabled `NetworkManager` before, enable it:
@ -245,10 +216,10 @@ sudo systemctl enable NetworkManager.service
### Stopping the service
```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:
```sh
@ -257,28 +228,26 @@ sudo systemctl start NetworkManager.service
### Configuration
naxalnet comes with a sample configuration file
`/etc/naxalnet/naxalnet.conf.example`. To change how the program
behaves, copy it to /etc/naxalnet/naxalnet.conf and edit it:
pybatmesh comes with a sample configuration file
`/etc/pybatmesh/pybatmesh.conf.example`. To change how the program
behaves, copy it to /etc/pybatmesh/pybatmesh.conf and edit it:
```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
gedit admin:/etc/naxalnet/naxalnet.conf
gedit admin:/etc/pybatmesh/pybatmesh.conf
```
Also, you can change its behaviour every time you run it using
arguments:
```sh
naxalnet --help
pybatmesh --help
```
## Contributing or reporting bugs
Join the XMPP channel <xmpp:naxalnet@chat.disroot.org> to talk about
anything related to this program or about mesh networks in general. See
[HACKING.md](HACKING.md) to contribute to the repo.
See [HACKING.md](HACKING.md)
## 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
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
mesh. naxalnet uses iwd to start an `ad-hoc` network and configures
pybatmesh uses two modes - `ad-hoc` and `ap`, for connecting to the
mesh. pybatmesh uses iwd to start an `ad-hoc` network and configures
systemd-networkd to setup a BATMAN Advanced network.
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
to the mesh network.
@ -303,32 +272,24 @@ systemd-networkd configures the network.
### 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
like [Jami][] (see below).
<!--
### Malign democracies and well-established institutions
Withheld due to national security reasons.
-->
### 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
similar software which can work on an intranet. They should be installed
on your machine _before_ your friendly democratic government announces an
[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.
## Uninstalling
If you installed naxalnet manually, use make uninstall to remove
naxalnet and its data files. This requires python pip to be installed.
If you installed pybatmesh manually, use make uninstall to remove
pybatmesh and its data files. This requires python pip to be installed.
```sh
# 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
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
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
where the materials are easily available, consider using them instead
of naxalnet.
of pybatmesh.
- [LibreMesh][]: framework for OpenWrt-based firmwares
- [disaster.radio][]: solar-powered communications network
## 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
General Public License as published by the Free Software Foundation,
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"
[briar]: https://briarproject.org/
[dasbus]: https://github.com/rhinstaller/dasbus "A python D-Bus library"
[aur]: https://aur.archlinux.org/packages/naxalnet
[aur-devel]: https://aur.archlinux.org/packages/naxalnet-git
[aur]: https://aur.archlinux.org/packages/pybatmesh
[aur-devel]: https://aur.archlinux.org/packages/pybatmesh-git
[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"
[libremesh]: https://libremesh.org
[disaster.radio]: https://disaster.radio
[startnx]: #start-naxalnet
[startnx]: #start-pybatmesh
[iwd]: https://iwd.wiki.kernel.org "WiFi daemon"
[free-sw]: https://gnu.org/philosophy/free-sw.html "What is free software?"
[enablenx]: #running-at-boot
[enable-pybatmesh]: #running-at-boot
[requirements]: #requirements
[install-manual]: #manually
[python-systemd]: https://github.com/systemd/python-systemd

View File

@ -1,7 +1,7 @@
# This file links any interface in ap mode
# to the bridge we created earlier.
# 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.
[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 naxalnet.conf and edit it.
# to pybatmesh.conf and edit it.
# The values given here are defaults.
[networkd]
# systemd-networkd configuration files bundled with naxalnet.
# systemd-networkd configuration files bundled with pybatmesh.
# THese will be copied to runtimedir at runtime.
confdir = /usr/share/naxalnet/networkd
confdir = /usr/share/pybatmesh/networkd
# systemd-networkd runtime configuration directory.
# See man:systemd.network(5)
runtimedir = /run/systemd/network
@ -26,10 +26,10 @@ mode=auto
[adhoc]
# All your nodes should have the same name
name = NxMesh
name = pybatmesh
[ap]
# 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.
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)
# before editing this file.
[Unit]
@ -11,7 +11,7 @@ After=systemd-networkd.service
After=systemd-resolved.service
# Stops NetworkManager if already running
Conflicts=NetworkManager.service
# This stops networkmanager and wpa_supplicant when naxalnet is enabled
# This stops NetworkManager when pybatmesh is enabled
After=NetworkManager.service
[Service]
@ -19,9 +19,9 @@ Type=notify
NotifyAccess=all
Restart=on-failure
RestartSec=2sec
ExecStart=naxalnet --systemd
ExecStart=pybatmesh --systemd
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.
StandardOutput=null
StandardError=null

View File

@ -1,5 +1,5 @@
# This file is part of naxalnet.
# Copyright (C) 2021 The naxalnet Authors
# This file is part of pybatmesh.
# Copyright (C) 2021 The pybatmesh Authors
# 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
@ -15,7 +15,7 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
"""
naxalnet
pybatmesh
========
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
given below.
>>> help("naxalnet")
>>> help("naxalnet.config")
>>> help("pybatmesh")
>>> help("pybatmesh.config")
"""
@ -42,4 +42,4 @@ given below.
#
# In case you forgot to change the version, skip the number
# and put the next number in the next commit.
__version__ = "0.5.2"
__version__ = "0.5.2a1.dev1"

View File

@ -1,5 +1,5 @@
# This file is part of naxalnet.
# Copyright (C) 2021 The naxalnet Authors
# This file is part of pybatmesh.
# Copyright (C) 2021 The pybatmesh Authors
# 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
@ -19,16 +19,12 @@
__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:
python -m naxalnet --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.
python -m pybatmesh --help
"""
from naxalnet.scripts import main
from pybatmesh.scripts import main
if __name__ == "__main__":
main()

View File

@ -1,5 +1,5 @@
# This file is part of naxalnet.
# Copyright (C) 2021 The naxalnet Authors
# This file is part of pybatmesh.
# Copyright (C) 2021 The pybatmesh Authors
# 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
@ -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,
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
is taken. Then, key-value pairs from the configuration files are read, if
they exist, in the following order:
- First it reads /usr/share/naxalnet/naxalnet.conf and then from
/usr/share/naxalnet/naxalnet.conf.d/*.conf where *.conf means any file
- First it reads /usr/share/pybatmesh/pybatmesh.conf and then from
/usr/share/pybatmesh/pybatmesh.conf.d/*.conf where *.conf means any file
with the name ending with ".conf". The files in this directory are
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
from the directory /etc/naxalnet, like it did up above. This directory
- Then, it looks for the files pybatmesh.conf and pybatmesh.conf.d/*.conf
from the directory /etc/pybatmesh, like it did up above. This directory
is where the user creates and stores the config file.
- Then it parses the arguments from the commandline, storing the values in
@ -56,7 +56,7 @@ is used.
from pathlib import Path
from configparser import ConfigParser
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():
@ -96,7 +96,7 @@ def parse_args() -> Namespace:
"""
Parse all arguments and return ArgumentParser.parse_args(),
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.
"""
config = parse_config()

View File

@ -1,5 +1,5 @@
# This file is part of naxalnet.
# Copyright (C) 2021 The naxalnet Authors
# This file is part of pybatmesh.
# Copyright (C) 2021 The pybatmesh Authors
# 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
@ -23,8 +23,8 @@ is plugged in, or it is removed.
"""
from dasbus.loop import EventLoop
from naxalnet.iwd import IWD, IWD_DEVICE_INTERFACE
from naxalnet.log import logger
from pybatmesh.iwd import IWD, IWD_DEVICE_INTERFACE
from pybatmesh.log import logger
class Daemon:

View File

@ -1,5 +1,5 @@
# This file is part of naxalnet.
# Copyright (C) 2021 The naxalnet Authors
# This file is part of pybatmesh.
# Copyright (C) 2021 The pybatmesh Authors
# 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
@ -21,30 +21,30 @@ default.py
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
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.
"""
CONFIG = {
"networkd": {
"confdir": "/usr/share/naxalnet/networkd",
"confdir": "/usr/share/pybatmesh/networkd",
"runtimedir": "/run/systemd/network",
},
"device": {"batman": "bat0", "bridge": "bridge0"},
"adhoc": {"name": "NxMesh"},
"ap": {"ssid": "MeshWiFi", "passwd": "naxalnet256"},
"adhoc": {"name": "pybatmesh"},
"ap": {"ssid": "BatWiFi", "passwd": "pybatmesh256"},
"gateway": {"mode": "auto"},
}
# glob
CONFIG_FILES = ["naxalnet.conf", "naxalnet.conf.d/*.conf"]
CONFIG_DIRS = ["/usr/share/naxalnet", "/usr/local/share/naxalnet", "/etc/naxalnet"]
CONFIG_FILES = ["pybatmesh.conf", "pybatmesh.conf.d/*.conf"]
CONFIG_DIRS = ["/usr/share/pybatmesh", "/usr/local/share/pybatmesh", "/etc/pybatmesh"]
MESH_GLOB = "mesh.*"
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
# Changing this constant will alter not just the behavoiur of naxalnet,
# Changing this constant will alter not just the behavoiur of pybatmesh,
# but affect the meaning of Life, the Universe and Everthing
ANSWER = 42

View File

@ -1,5 +1,5 @@
# This file is part of naxalnet.
# Copyright (C) 2021 The naxalnet Authors
# This file is part of pybatmesh.
# Copyright (C) 2021 The pybatmesh Authors
# 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
@ -29,11 +29,11 @@ terms and what they mean:
network, where there is no central point of failure.
- 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.
- 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
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
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.
"""
from dasbus.connection import SystemMessageBus
from naxalnet.log import logger
from pybatmesh.log import logger
IWD_BUS = "net.connman.iwd"
IWD_ROOT_PATH = "/"

View File

@ -1,5 +1,5 @@
# This file is part of naxalnet.
# Copyright (C) 2021 The naxalnet Authors
# This file is part of pybatmesh.
# Copyright (C) 2021 The pybatmesh Authors
# 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
@ -24,17 +24,17 @@ loglevel and to add the systemd journal handler
"""
import logging
from systemd.journal import JournalHandler
from naxalnet.config import args
from pybatmesh.config import args
def get_logger():
"""
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:
from naxalnet.log import logger
from pybatmesh.log import logger
"""
log = logging.getLogger("naxalnet")
log = logging.getLogger("pybatmesh")
# --verbose
if args.verbose >= 2:
loglevel = logging.DEBUG

View File

@ -1,5 +1,5 @@
# This file is part of naxalnet.
# Copyright (C) 2021 The naxalnet Authors
# This file is part of pybatmesh.
# Copyright (C) 2021 The pybatmesh Authors
# 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
@ -40,8 +40,8 @@ NETWORKD_PATH = "/org/freedesktop/network1"
class NetworkD:
"""
Control systemd-networkd using configuration files. Since these
were made for use by naxalnet only, the class is not suitable for
importing outside naxalnet.
were made for use by pybatmesh only, the class is not suitable for
importing outside pybatmesh.
"""
def __init__(self, runtime_dir="/run/systemd/network", bus=SystemMessageBus()):

View File

@ -1,5 +1,5 @@
# This file is part of naxalnet.
# Copyright (C) 2021 The naxalnet Authors
# This file is part of pybatmesh.
# Copyright (C) 2021 The pybatmesh Authors
# 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
@ -22,7 +22,7 @@ The functions in this file is used for reading configs, args
and doing the things this program is supposed to do.
This file is named scripts.py because the original developer
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.
"""
@ -31,13 +31,13 @@ import time
from pathlib import Path
from dasbus.error import DBusError
from systemd.daemon import notify
from naxalnet import __version__
from naxalnet.default import REPORT_BUG_INFO, MESH_GLOB, TMP_NET_GLOB
from naxalnet.log import logger
from naxalnet.iwd import Adapter, Device, IWD
from naxalnet.config import args
from naxalnet.daemon import Daemon
from naxalnet.network import NetworkD, NetworkLoop
from pybatmesh import __version__
from pybatmesh.default import REPORT_BUG_INFO, MESH_GLOB, TMP_NET_GLOB
from pybatmesh.log import logger
from pybatmesh.iwd import Adapter, Device, IWD
from pybatmesh.config import args
from pybatmesh.daemon import Daemon
from pybatmesh.network import NetworkD, NetworkLoop
def get_sorted_glob(directory: str, glob: str) -> list:
@ -159,7 +159,7 @@ def setup_devices():
if len(ap_devices) != 0:
ap_device = Device(ap_devices.pop())
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
# See issue #9
ap_adapter = Adapter(ap_device.adapter)
@ -222,7 +222,7 @@ def main():
"""
This is where the magic happens!
This function is run every time you
execute naxalnet from the commandline
execute pybatmesh from the commandline
"""
if args.print_wifi:
@ -232,12 +232,12 @@ def main():
print_version()
sys.exit(0)
# Notify systemd that naxalnet is ready.
# Notify systemd that pybatmesh is ready.
# 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. 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
if args.gateway_mode == "auto":
logger.info("Checking for internet connection")

View File

@ -1,13 +1,13 @@
# 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
# module.
[metadata]
name = naxalnet
version = attr: naxalnet.__version__
name = pybatmesh
version = attr: pybatmesh.__version__
description = create mesh networks with batman-adv and systemd
long_description = file: README.md
url = https://git.disroot.org/pranav/naxalnet
url = https://git.disroot.org/pranav/pybatmesh
author = Pranav Jerry
author_email = libreinator@disroot.org
license = GPLv3
@ -32,16 +32,16 @@ install_requires =
[options.entry_points]
console_scripts =
naxalnet = naxalnet.scripts:main
pybatmesh = pybatmesh.scripts:main
[options.data_files]
lib/systemd/system =
naxalnet.service
pybatmesh.service
# 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.
/etc/naxalnet =
naxalnet.conf.example
share/naxalnet/networkd =
/etc/pybatmesh =
pybatmesh.conf.example
share/pybatmesh/networkd =
network/mesh.01-batman.netdev
network/mesh.02-bridge.netdev
network/mesh.03-wireless-ad-hoc.network