mirror of
https://git.disroot.org/pranav/pybatmesh.git
synced 2025-04-08 12:09:18 +05:30
Compare commits
39 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
566f562d33 | ||
1106945732 | |||
|
d45ac72442 | ||
3354584045 | |||
0c6bdea4a8 | |||
|
9123224de0 | ||
396fe9af7e | |||
72dda12d7b | |||
38d0aa8ab5 | |||
fad2591b9f | |||
|
05b91e7721 | ||
4d4e5e15d7 | |||
6bca6149b7 | |||
710da18af9 | |||
888fdf3856 | |||
fc1f3d4216 | |||
5e58df0b71 | |||
d7a84d8ccc | |||
183ce16eca | |||
caeb042612 | |||
f657146eb3 | |||
cd44357496 | |||
fbf518e14c | |||
28de9570b5 | |||
009f6364cd | |||
a09ababd06 | |||
9749cf0c00 | |||
|
542347eac7 | ||
a5ba99ca2a | |||
|
0d5d3c5cc6 | ||
26a907d907 | |||
704fe646f8 | |||
aa079c7c29 | |||
295fde3f0b | |||
270db3cf90 | |||
6fbebc51bb | |||
1f8be50dd6 | |||
c4933378ff | |||
0a85c465ee |
39
CHANGELOG.md
39
CHANGELOG.md
@ -1,5 +1,29 @@
|
||||
# Changelog
|
||||
|
||||
## [v0.5.3][] - 2022-08-03
|
||||
|
||||
- Renamed to pybatmesh, to be more clear what the program does
|
||||
- code cleanup
|
||||
|
||||
To update via the repo, do the following:
|
||||
|
||||
```sh
|
||||
git remote set-url origin git@git.disroot.org:pranav/pybatmesh.git
|
||||
# or
|
||||
git remote set-url origin https://git.disroot.org/pranav/pybatmesh.git
|
||||
# remove naxlnet and install pybatmesh
|
||||
git pull && git checkout 38d0aa8ab5dd60f2febffda335df6df1ea143ab3 && make clean && sudo make purge && git checkout main && make && sudo make install
|
||||
```
|
||||
|
||||
## [v0.5.2][] - 2021-12-10
|
||||
|
||||
- Optimised auto gateway mode selection (#25)
|
||||
|
||||
## [v0.5.1][] - 2021-10-22
|
||||
|
||||
- Fixed stopping at boot when GNOME starts location service (#21)
|
||||
- Changes in directory structure
|
||||
|
||||
## [v0.5.0][] - 2021-10-10
|
||||
|
||||
- Better error messages
|
||||
@ -42,9 +66,12 @@ 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.0...HEAD
|
||||
[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.3...HEAD
|
||||
[v0.5.3]: https://git.disroot.org/pranav/pybatmesh/compare/v0.5.2...v0.5.3
|
||||
[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
|
||||
|
29
HACKING.md
29
HACKING.md
@ -1,30 +1,33 @@
|
||||
# Hacking
|
||||
|
||||
Everyone can [hack][] naxalnet. See below for how to hack.
|
||||
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 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
|
||||
|
||||
The README and HACKING.md needs to be more beginner friendly.
|
||||
See #20.
|
||||
The README and HACKING.md needs to be more beginner friendly. See #20.
|
||||
|
||||
## Contribute code
|
||||
|
||||
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`
|
||||
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
|
||||
`pybatmesh/__init__.py`
|
||||
|
||||
## Packaging
|
||||
|
||||
Currently this program is only packaged for Arch Linux.
|
||||
naxalnet 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.
|
||||
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.
|
||||
|
||||
[hack]: https://catb.org/jargon/html/H/hack.html
|
||||
|
14
Makefile
14
Makefile
@ -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
|
||||
|
184
README.md
184
README.md
@ -1,47 +1,30 @@
|
||||
# naxalnet
|
||||
# pybatmesh
|
||||
|
||||
**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
|
||||
## Features
|
||||
|
||||
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.
|
||||
|
||||
-->
|
||||
<!-- 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. .
|
||||
|
||||
-->
|
||||
- Select best network when multiple nodes have internet access (gateway
|
||||
mode)
|
||||
- Detect insertion and removal of wifi adapters and reconfigure them
|
||||
- Readable logs
|
||||
- Supports rfkill
|
||||
|
||||
## 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 only on 3.9)
|
||||
- python setuptools, for building and installing naxalnet
|
||||
- python (tested on 3.9 and 3.10)
|
||||
- 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
|
||||
@ -56,30 +39,29 @@ 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
|
||||
and install it manually. Currently, only Debian experimental and Ubuntu
|
||||
21.10 comes with the required version of systemd. Therefore, naxalnet
|
||||
requires **Debian experimental** or **Ubuntu 21.10 or greater** to work.
|
||||
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,
|
||||
pybatmesh requires **Debian testing** or **Ubuntu 21.10 or greater** to
|
||||
work.
|
||||
|
||||
Install the requirements from the repositories:
|
||||
|
||||
```sh
|
||||
# batctl is optional
|
||||
sudo apt install python3-pip python3-systemd iwd batctl build-essential
|
||||
# Now, install dasbus with pip
|
||||
sudo pip3 install dasbus
|
||||
sudo apt install python3-pip python3-systemd python3-dasbus iwd batctl
|
||||
```
|
||||
|
||||
Now follow the instructions in the
|
||||
@ -87,25 +69,25 @@ Now follow the instructions in the
|
||||
|
||||
### Fedora
|
||||
|
||||
naxalnet is not packaged for Fedora, so it should be installed manually.
|
||||
naxalnet requires atleast 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:
|
||||
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 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
|
||||
@ -126,17 +108,17 @@ uname -r
|
||||
python3 --version
|
||||
|
||||
# Check for IBSS (ad-hoc) support in your WiFi firmware or driver
|
||||
iw phy | grep -iq 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
|
||||
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
|
||||
@ -164,16 +146,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
|
||||
@ -183,32 +165,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:
|
||||
@ -217,10 +199,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:
|
||||
@ -232,10 +214,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
|
||||
@ -244,21 +226,21 @@ 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
|
||||
@ -272,47 +254,40 @@ 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.
|
||||
|
||||
Read the code and the documentation in the code to learn the details.
|
||||
See the directory [systemd-networkd](systemd-networkd) to see how
|
||||
See the directory [network](network) to see how
|
||||
systemd-networkd configures the network.
|
||||
|
||||
## Use cases
|
||||
|
||||
### Online class
|
||||
|
||||
naxalnet can be used to share connections to join online classes.
|
||||
You need at least one device with internet access.
|
||||
|
||||
<!--
|
||||
|
||||
### Malign democracies and well-established institutions
|
||||
|
||||
Withheld due to national security reasons.
|
||||
|
||||
-->
|
||||
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).
|
||||
|
||||
### Internet shutdown
|
||||
|
||||
You can communicate with neighbouring devices running naxalnet, using
|
||||
services like [IPFS][], [Jami][], [Secure Scuttlebutt][ssb] and others
|
||||
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 installed
|
||||
software to communicate with anyone within range.
|
||||
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 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
|
||||
@ -325,24 +300,24 @@ 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.
|
||||
either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
See [LICENSE](LICENSE) for the complete version of the license.
|
||||
|
||||
@ -351,17 +326,18 @@ See [LICENSE](LICENSE) for the complete version of the license.
|
||||
[ipfs]: https://ipfs.io "InterPlanetary File System"
|
||||
[jami]: https://jami.net "Peer to peer video calls"
|
||||
[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
|
||||
|
@ -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]
|
@ -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
|
@ -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]
|
||||
@ -9,21 +9,19 @@ Wants=systemd-resolved.service
|
||||
After=iwd.service
|
||||
After=systemd-networkd.service
|
||||
After=systemd-resolved.service
|
||||
# Stops NetworkManager and wpa_supplicant if already running
|
||||
# Stops NetworkManager if already running
|
||||
Conflicts=NetworkManager.service
|
||||
Conflicts=wpa_supplicant.service
|
||||
# This stops networkmanager and wpa_supplicant when naxalnet is enabled
|
||||
# This stops NetworkManager when pybatmesh is enabled
|
||||
After=NetworkManager.service
|
||||
After=wpa_supplicant.service
|
||||
|
||||
[Service]
|
||||
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
|
@ -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.0"
|
||||
__version__ = "0.5.3"
|
@ -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()
|
@ -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()
|
@ -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:
|
@ -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,26 +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 behaviour of pybatmesh,
|
||||
# but affect the meaning of Life, the Universe and Everthing
|
||||
ANSWER = 42
|
@ -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 = "/"
|
@ -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,22 +19,22 @@ log.py
|
||||
------
|
||||
|
||||
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
|
||||
"""
|
||||
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
|
@ -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
|
||||
@ -30,6 +30,7 @@ examples.
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from dasbus.connection import SystemMessageBus
|
||||
from dasbus.loop import EventLoop, GLib
|
||||
|
||||
|
||||
NETWORKD_BUS = "org.freedesktop.network1"
|
||||
@ -39,11 +40,12 @@ 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()):
|
||||
print("NetworkD init")
|
||||
self._bus = bus
|
||||
self.proxy_reload()
|
||||
|
||||
@ -118,3 +120,68 @@ class NetworkD:
|
||||
"""
|
||||
for i in self.runtime_path.iterdir():
|
||||
self.remove_config(i.name)
|
||||
|
||||
|
||||
class NetworkLoop(NetworkD):
|
||||
"""Used to wait until a condition is met
|
||||
|
||||
Available methods:
|
||||
|
||||
NetworkLoop.wait_until_routable(timeout=0):
|
||||
return true when the network is routable, or false when timed out
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
# first, initialise the parent object
|
||||
super().__init__(*args, **kwargs)
|
||||
self.waitfor = None
|
||||
self.wait_function = None
|
||||
self.loop = EventLoop()
|
||||
|
||||
def start_loop(self):
|
||||
"""start the dasbus loop"""
|
||||
self.proxy.PropertiesChanged.connect(self.on_properties_changed)
|
||||
self.loop.run()
|
||||
|
||||
def wait_until_routable(self, timeout=0):
|
||||
"""
|
||||
Wait until timeout in milliseconds and returns True when any
|
||||
network interface is shown routable by networkd. Does not wait
|
||||
for timeout if timeout==0
|
||||
"""
|
||||
self.setup_timeout(timeout)
|
||||
self.wait_for_change("AddressState", self.on_addressstate_change)
|
||||
|
||||
return self.is_routable()
|
||||
|
||||
def wait_for_change(self, name, function):
|
||||
"""
|
||||
Wait until the given property is changed and stop. If setup_timeout()
|
||||
is called before calling this function, the loop stops after the timeout
|
||||
or after the property is changed, whichever occurs first.
|
||||
"""
|
||||
self.waitfor = name
|
||||
self.wait_function = function
|
||||
self.start_loop()
|
||||
|
||||
def on_addressstate_change(self):
|
||||
"""quit the loop if the network is routable"""
|
||||
if self.is_routable():
|
||||
self.loop.quit()
|
||||
|
||||
def on_properties_changed(self, bus_interface, data, blah):
|
||||
"""called by dasbus everytime the configured property is changed"""
|
||||
if self.waitfor in data:
|
||||
return self.wait_function()
|
||||
# Just to shut up pylint
|
||||
return None
|
||||
|
||||
def setup_timeout(self, timeout):
|
||||
"""setup a timeout"""
|
||||
if timeout != 0:
|
||||
GLib.timeout_add(timeout, self.on_timeout)
|
||||
|
||||
def on_timeout(self):
|
||||
"""called by dasbus when a timeout occurs"""
|
||||
self.loop.quit()
|
@ -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,22 +22,21 @@ 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.
|
||||
"""
|
||||
|
||||
import sys
|
||||
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
|
||||
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:
|
||||
@ -56,17 +55,15 @@ def get_sorted_glob(directory: str, glob: str) -> list:
|
||||
|
||||
def any_interface_is_routable():
|
||||
"""returns true if any of the interfaces is routable"""
|
||||
networkd = NetworkD(runtime_dir=args.networkd_runtime_dir)
|
||||
networkd = NetworkLoop(runtime_dir=args.networkd_runtime_dir)
|
||||
|
||||
# First, add the temporary configs to networkd.
|
||||
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.
|
||||
# This can probably be replaced by a d-bus wait-for-signal
|
||||
# function that timeouts after 10 seconds.
|
||||
time.sleep(10)
|
||||
routable = networkd.is_routable()
|
||||
|
||||
# timeout = 10 seconds
|
||||
routable = networkd.wait_until_routable(10 * 1000)
|
||||
networkd.remove_all_configs()
|
||||
|
||||
return routable
|
||||
@ -161,7 +158,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)
|
||||
@ -224,7 +221,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:
|
||||
@ -234,20 +231,22 @@ 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")
|
||||
notify("STATUS=Checking for internet")
|
||||
# If any interface is routable, set gateway mode to server
|
||||
if any_interface_is_routable():
|
||||
logger.info("Network is routable. Setting gw_mode to server")
|
||||
gateway_mode = "server"
|
||||
else:
|
||||
logger.info("Network is not routable. Setting gw_mode to client")
|
||||
gateway_mode = "client"
|
||||
logger.info("gateway_mode set to %s", gateway_mode)
|
||||
elif args.gateway_mode in ["server", "client", "off"]:
|
@ -1,3 +1,4 @@
|
||||
[build-system]
|
||||
# I don't know what this means, I just copied it from some setuptools tutorial
|
||||
requires = ["setuptools", "wheel"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
37
setup.cfg
37
setup.cfg
@ -1,10 +1,13 @@
|
||||
# This program is not meant to be distributed through PyPi
|
||||
# This file is loosely based on the setup.cfg used in django.
|
||||
# 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
|
||||
@ -29,21 +32,21 @@ 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 =
|
||||
systemd-networkd/mesh.01-batman.netdev
|
||||
systemd-networkd/mesh.02-bridge.netdev
|
||||
systemd-networkd/mesh.03-wireless-ad-hoc.network
|
||||
systemd-networkd/mesh.04-batman.network
|
||||
systemd-networkd/mesh.05-wireless-ap.network
|
||||
systemd-networkd/mesh.06-eth.network
|
||||
systemd-networkd/mesh.07-bridge.network
|
||||
systemd-networkd/tmp.01-eth.network
|
||||
/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
|
||||
network/mesh.04-batman.network
|
||||
network/mesh.05-wireless-ap.network
|
||||
network/mesh.06-eth.network
|
||||
network/mesh.07-bridge.network
|
||||
network/tmp.01-eth.network
|
||||
|
Loading…
x
Reference in New Issue
Block a user