mirror of
https://git.disroot.org/pranav/pybatmesh.git
synced 2025-01-01 12:41:52 +05:30
almost ready for merge
* Improved CHANGELOG, README, HACKING * Added naxalnet.conf containing default values. This will be installed along with the package.
This commit is contained in:
parent
d7a9edc1e8
commit
397269823d
12
CHANGELOG.md
12
CHANGELOG.md
@ -5,15 +5,15 @@
|
||||
### Added
|
||||
|
||||
- Support for arguments
|
||||
- Configuration file support
|
||||
- New versioning scheme that conforms to PEP 440
|
||||
- Configuration file support with fallback values
|
||||
- Made messages more readable
|
||||
- Improved documentation in docstrings
|
||||
|
||||
### Changed
|
||||
|
||||
- Changed default name of mesh network. This will make naxalnet
|
||||
incompatible with previous versions.
|
||||
- Changed default name of mesh network. **This will make naxalnet
|
||||
incompatible with previous versions.**
|
||||
- New versioning scheme that conforms to PEP 440
|
||||
|
||||
## [v0.2.0][] - 2021-07-26
|
||||
|
||||
@ -27,7 +27,9 @@
|
||||
|
||||
## [v0.1.0][] - 2021-06-19
|
||||
|
||||
Initial version
|
||||
Initial version. At first, this was a shell script. Than it was converted
|
||||
into a single python file that did just what the shell script used to do.
|
||||
The shell script was not given a version.
|
||||
|
||||
[unreleased]: https://git.disroot.org/pranav/naxalnet/compare/v0.2.0...HEAD
|
||||
[v0.2.0]: https://git.disroot.org/pranav/naxalnet/compare/v0.1.0...v0.2.0
|
||||
|
12
HACKING.md
12
HACKING.md
@ -10,17 +10,21 @@ relevant label.
|
||||
|
||||
## Improving documentation
|
||||
|
||||
See section below
|
||||
The README and HACKING.md needs to be more beginner friendly.
|
||||
See section below.
|
||||
|
||||
## Contribute code
|
||||
|
||||
To push to this repo, you need your username to be in the
|
||||
contributors list. See issue #8. Before each commit, update
|
||||
the CHANGELOG and `__version__` in `naxalnet/__init__.py`
|
||||
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`
|
||||
|
||||
## Packaging
|
||||
|
||||
naxalnet needs distro packages in Debian, Fedora, openSUSE,
|
||||
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 to issue #6.
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
include LICENSE
|
||||
include README.md
|
||||
include naxalnet.service
|
||||
include naxalnet.conf
|
||||
include systemd-networkd/*
|
||||
|
4
Makefile
4
Makefile
@ -1,6 +1,6 @@
|
||||
# This makefile uses setup.py under the hood.
|
||||
# In ubuntu, python and pip are symlinks to python2 and pip2.
|
||||
# So we have to specify python as python3 by default.
|
||||
# In ubuntu, python and pip are symlinks to python2 and pip2, not
|
||||
# python3. So we have to specify python as python3 by default.
|
||||
PYTHON := python3
|
||||
PIP := pip3
|
||||
DESTDIR:= /
|
||||
|
107
README.md
107
README.md
@ -12,20 +12,19 @@ West Bengal.
|
||||
|
||||
WARNING:
|
||||
This program uses an **unencrypted** network. This means
|
||||
you do not get any more privacy or security than with an open wifi
|
||||
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
|
||||
Running this program in the world's largest partly-free democracy
|
||||
may result in you getting arrested under the UAPA, and not
|
||||
getting bail because of false evidence planted in your phone by
|
||||
Pegasus, or by a forensic lab in Gujarat.
|
||||
|
||||
The author, not unlike the Government of India, does not wish
|
||||
The author, much like the Government of India, does not wish
|
||||
to take responsibility in your well-being if you get arrested under
|
||||
a draconian national security law, which was once used to arrest
|
||||
a person involved in the freedom struggle against British Raj.
|
||||
a draconian national security law.
|
||||
|
||||
-->
|
||||
<!-- UNCOMMENT WHEN NECESSARY
|
||||
@ -45,16 +44,19 @@ with anyone currently at risk of death in overcrowded prisons.
|
||||
- [systemd v248 or more][batman-systemd]
|
||||
- Linux kernel with batman-adv module
|
||||
- [iwd][]
|
||||
- python3
|
||||
- python
|
||||
- python-setuptools (for building)
|
||||
- [python-dasbus][]
|
||||
- wifi adapter with ad-hoc support
|
||||
- two or more computers, or laptops with wifi adapter, called nodes
|
||||
- [dasbus][]
|
||||
- WiFi adapter with ad-hoc support
|
||||
- two or more computers, or laptops with WiFi adapter, called nodes
|
||||
- systemd-resolved (optional, for DNS)
|
||||
- batctl (optional, for debugging)
|
||||
|
||||
## Installing
|
||||
|
||||
This program is available in the AUR for Arch users. Building
|
||||
manually for other distributions may not always work.
|
||||
|
||||
### Arch Linux
|
||||
|
||||
Install [naxalnet][aur] (or [naxalnet-git][aur-devel] for the
|
||||
@ -65,7 +67,8 @@ yay -S naxalnet
|
||||
```
|
||||
|
||||
Optionally, [setup systemd-resolved][arch-resolved] for DNS if any
|
||||
of the nodes have internet access.
|
||||
of the nodes have internet access. [Start naxalnet][startnx] when
|
||||
you need it.
|
||||
|
||||
### Manually
|
||||
|
||||
@ -82,9 +85,14 @@ Or, if you have an [IPFS client][ipfs] running, try:
|
||||
git clone http://k51qzi5uqu5dlye74be0n9iihwk6sm54vexo7bf7pdr4w811y6mmrcp25djozv.ipns.localhost:8080/naxalnet.git
|
||||
```
|
||||
|
||||
Run `sudo make install` to install naxalnet.
|
||||
After installing, reload systemd so that you can enable `naxalnet.service`
|
||||
without rebooting:
|
||||
Now, install naxalnet:
|
||||
|
||||
```sh
|
||||
sudo make install
|
||||
```
|
||||
|
||||
After installing, reload systemd so that it detects the new
|
||||
service files:
|
||||
|
||||
```sh
|
||||
sudo systemctl daemon-reload
|
||||
@ -92,25 +100,24 @@ sudo systemctl daemon-reload
|
||||
|
||||
## How to use
|
||||
|
||||
You need more than one computer running for the connection to work.
|
||||
You need more than one machine running naxalnet for the connection to work.
|
||||
|
||||
### Start naxalnet
|
||||
|
||||
Though naxalnet can run from the commandline, it was designed to be
|
||||
run as a systemd service.
|
||||
To start naxalnet, do the command on all the nodes:
|
||||
|
||||
```sh
|
||||
sudo systemctl start naxalnet.service
|
||||
```
|
||||
|
||||
To test if it works, run `ip -c addr` to find out your address.
|
||||
Note the `inet` address of `bridge0`. If there isn't one, try again
|
||||
after a few seconds. If the address starts with 169.254, it has
|
||||
got a link-local address. Otherwise, it has got an IP address
|
||||
from DHCP.
|
||||
To test if it works, run `sudo batctl n -w` and check for
|
||||
nodes. If there are any nodes, your network is up.
|
||||
|
||||
### Getting internet access
|
||||
|
||||
Connect an ethernet cable to any of the peers and
|
||||
Connect an ethernet cable from a router to any of the peers and
|
||||
[start naxalnet][startnx]. If it was already started, you should
|
||||
renew the DHCP connection of all peers. To do this, type
|
||||
`sudo networkctl renew bridge0` on all peers.
|
||||
@ -118,28 +125,24 @@ renew the DHCP connection of all peers. To do this, type
|
||||
### Tethering via WiFi AP
|
||||
|
||||
If there are two adapters in a peer, naxalnet 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 device and [start naxalnet][startnx].
|
||||
Now an ap will be created on one of the adapters.
|
||||
Type `naxalnet --print-wifi` to get the WiFi SSID and password.
|
||||
Connect two WiFi adapters on a device and [start naxalnet][startnx].
|
||||
Now an ap will be started on one of the adapters.
|
||||
Type `naxalnet --print-WiFi` to get the WiFi SSID and password.
|
||||
|
||||
If you had set up internet access on one of the peers, internet
|
||||
can be accessed from the AP.
|
||||
|
||||
### Running at boot
|
||||
|
||||
Starting the service will stop `NetworkManager.service` and
|
||||
`wpa_supplicant.service` if it is running. If you start either of these
|
||||
services after naxalnet was started, systemd will stop naxalnet.
|
||||
|
||||
To run naxalnet at boot, enable the service on all the nodes:
|
||||
|
||||
```sh
|
||||
sudo systemctl enable naxalnet.service
|
||||
```
|
||||
|
||||
Now naxalnet will configure a batman interface on every boot.
|
||||
Now naxalnet will start a mesh on every boot.
|
||||
Disable the service to stop running at boot:
|
||||
|
||||
```sh
|
||||
@ -162,24 +165,46 @@ will have stopped it. Start NetworkManager again:
|
||||
sudo systemctl start NetworkManager.service
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
naxalnet stores its default configuration file in
|
||||
`/usr/share/naxalnet/naxalnet.conf`. To change how the program
|
||||
behaves, copy it to /etc/naxalnet/naxalnet.conf and edit it:
|
||||
|
||||
```sh
|
||||
# Create the directory
|
||||
sudo mkdir /etc/naxalnet
|
||||
# Now copy the file
|
||||
sudo cp /usr/share/naxalnet/naxalnet.conf /etc/naxalnet
|
||||
# Edit the file with your favourite editor as root
|
||||
gedit admin:/etc/naxalnet/naxalnet.conf
|
||||
```
|
||||
|
||||
Also, you can change its behaviour every time you run it using
|
||||
arguments:
|
||||
|
||||
```sh
|
||||
naxalnet --help
|
||||
```
|
||||
|
||||
## How it works
|
||||
|
||||
There are three modes commonly supported by wifi adapters -
|
||||
`ap` (wifi hotspot), `station` (for joining wifi networks) and `ad-hoc`
|
||||
There are three modes commonly supported by WiFi adapters -
|
||||
`ap` (WiFi hotspot), `station` (for joining WiFi networks) and `ad-hoc`
|
||||
(for decentralised networks). There are some other modes too,
|
||||
like `p2p` (wifi direct), but we won't go into the details.
|
||||
like `p2p` (WiFi direct), but we won't go into the details.
|
||||
|
||||
naxalnet uses two mode -- ad-hoc and ap, for connecting to the mesh.
|
||||
naxalnet uses iwd to start an `ad-hoc` network and configures
|
||||
naxalnet uses two modes - `ad-hoc` and `ap`, for connecting to the
|
||||
mesh. naxalnet 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,
|
||||
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.
|
||||
You can use the ap for connecting mobile phones and other devices
|
||||
to the mesh network.
|
||||
|
||||
Read the code to learn the details.
|
||||
See [systemd-networkd](systemd-networkd) to see how systemd-networkd
|
||||
configures the network.
|
||||
See [systemd-networkd](systemd-networkd) to see how
|
||||
systemd-networkd configures the network.
|
||||
|
||||
## Use cases
|
||||
|
||||
@ -193,7 +218,7 @@ You need at least one device with internet access.
|
||||
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 need to be installed on your device _before_ your friendly
|
||||
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]
|
||||
@ -216,7 +241,7 @@ See [HACKING.md](HACKING.md)
|
||||
## Similar projects
|
||||
|
||||
The following projects are similar to naxalnet, but are not designed
|
||||
to be used in a machine with wifi adapter. If you live in
|
||||
to be used in a machine with WiFi adapter. If you live in
|
||||
an area where the materials required for any of them are easily
|
||||
available, consider using them instead of naxalnet.
|
||||
|
||||
@ -237,7 +262,7 @@ 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"
|
||||
[python-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-devel]: https://aur.archlinux.org/packages/naxalnet-git
|
||||
[arch-resolved]: https://wiki.archlinux.org/title/Systemd-resolved#DNS "systemd-resolved on ArchWiki"
|
||||
@ -245,6 +270,6 @@ See [LICENSE](LICENSE) for the complete version of the license.
|
||||
[libremesh]: https://libremesh.org
|
||||
[disaster.radio]: https://disaster.radio
|
||||
[startnx]: #start-naxalnet
|
||||
[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?"
|
||||
[enablenx]: #running-at-boot
|
||||
|
22
naxalnet.conf
Normal file
22
naxalnet.conf
Normal file
@ -0,0 +1,22 @@
|
||||
# This configuration file is part of naxalnet.
|
||||
# To configure this program, copy this file
|
||||
# to /etc/naxalnet/ (create it if it doesn't exist) and
|
||||
# edit it to your liking.
|
||||
|
||||
[networkd]
|
||||
# systemd-networkd configuration files bundled with naxalnet.
|
||||
# THese will be copied to runtimedir at runtime.
|
||||
confdir = /usr/share/naxalnet/networkd
|
||||
# systemd-networkd runtime configuration directory.
|
||||
# See man:systemd.network(5)
|
||||
runtimedir = /run/systemd/network
|
||||
|
||||
[adhoc]
|
||||
# All your nodes should have the same name
|
||||
name = NxMesh
|
||||
|
||||
[ap]
|
||||
# An AP is started if your machine has more than one WiFi adapter.
|
||||
ssid = MeshWiFi
|
||||
passwd = naxalnet256
|
||||
|
@ -7,7 +7,9 @@ Requires=systemd-networkd.service
|
||||
Requires=iwd.service
|
||||
Wants=systemd-resolved.service
|
||||
# naxalnet does not reload networkd, so networkd
|
||||
# should be started only afer naxalnet exits
|
||||
# should be started only afer naxalnet exits.
|
||||
# This should be changed when naxalnet becomes
|
||||
# a daemon.
|
||||
Before=systemd-networkd.service
|
||||
After=iwd.service
|
||||
# Stops NetworkManager and wpa_supplicant if already running
|
||||
@ -23,8 +25,11 @@ Restart=on-failure
|
||||
# Probably not needed now
|
||||
RestartSec=2sec
|
||||
# IWD takes some time to find devices.
|
||||
# If naxalnet is run before iwd finds devices,
|
||||
# naxalnet cannot start a mesh network.
|
||||
# Without the delay, naxalnet could not detect the second
|
||||
# device while testing.
|
||||
# TODO: Remove this line when naxalnet becomes a daemon.
|
||||
ExecStartPre=/usr/bin/sleep 2
|
||||
ExecStart=/usr/bin/naxalnet
|
||||
|
||||
|
@ -36,4 +36,4 @@ See README.md for documentation.
|
||||
#
|
||||
# In case you forgot to add a version, put the next number
|
||||
# in the next commit
|
||||
__version__ = "0.2.0a3.dev3"
|
||||
__version__ = "0.2.0a3.dev4"
|
||||
|
Loading…
Reference in New Issue
Block a user