mirror of
https://git.disroot.org/pranav/pybatmesh.git
synced 2024-11-10 07:21:59 +05:30
Merge branch 'fix-rfkill'
Added rfkill support, among other things. See pull request #10 for more info.
This commit is contained in:
commit
b3710633cc
@ -12,11 +12,7 @@ relevant label.
|
|||||||
## Contribute code
|
## Contribute code
|
||||||
|
|
||||||
To push to this repo, you need your username to be in the
|
To push to this repo, you need your username to be in the
|
||||||
contributors list.
|
contributors list. See issue #8.
|
||||||
To add you as a contributor, email any of the authors with
|
|
||||||
your username:
|
|
||||||
|
|
||||||
- `echo yvoervangbe cyhf akyarg ng qvfebbg qbg bet | tr 'A-Za-z' 'N-ZA-Mn-za-m' | sed 's/plus/+/' | sed 's/ at /@/' | sed 's/dot/./' | tr -d ' '`
|
|
||||||
|
|
||||||
## Packaging
|
## Packaging
|
||||||
|
|
||||||
|
3
Makefile
3
Makefile
@ -6,3 +6,6 @@ build:
|
|||||||
|
|
||||||
install: build
|
install: build
|
||||||
python setup.py install --root="$(DESTDIR)/" --optimize=1 --skip-build
|
python setup.py install --root="$(DESTDIR)/" --optimize=1 --skip-build
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf build naxalnet.egg-info
|
||||||
|
@ -63,13 +63,11 @@ git clone https://git.disroot.org/pranav/naxalnet.git
|
|||||||
cd naxalnet
|
cd naxalnet
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--
|
|
||||||
Or, if you have an [IPFS client][ipfs] running, try:
|
Or, if you have an [IPFS client][ipfs] running, try:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
git clone http://k51qzi5uqu5dlye74be0n9iihwk6sm54vexo7bf7pdr4w811y6mmrcp25djozv.ipns.localhost:8080/naxalnet.git
|
git clone http://k51qzi5uqu5dlye74be0n9iihwk6sm54vexo7bf7pdr4w811y6mmrcp25djozv.ipns.localhost:8080/naxalnet.git
|
||||||
```
|
```
|
||||||
-->
|
|
||||||
|
|
||||||
Run `sudo make install` to install naxalnet. This will install naxalnet in
|
Run `sudo make install` to install naxalnet. This will install naxalnet in
|
||||||
`/usr/bin/naxalnet`.
|
`/usr/bin/naxalnet`.
|
||||||
|
@ -1,3 +1,19 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
# Copyright (C) 2021 The naxalnet 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 Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
__version__ = "0.1.0a"
|
__version__ = "0.1.0a"
|
||||||
|
@ -1,5 +1,21 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
# Copyright (C) 2021 The naxalnet 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 Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
from naxalnet.scripts import here_be_dragons
|
from naxalnet.scripts import here_be_dragons
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -23,8 +23,6 @@ with systemd-networkd and iwd
|
|||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from shutil import copy
|
from shutil import copy
|
||||||
|
|
||||||
# from dasbus.connection import SystemMessageBus
|
|
||||||
from dasbus.error import DBusError
|
from dasbus.error import DBusError
|
||||||
from naxalnet.iwd import IWD, Device, Adapter
|
from naxalnet.iwd import IWD, Device, Adapter
|
||||||
|
|
||||||
@ -35,23 +33,33 @@ AP_SSID = "NaxalNet"
|
|||||||
AP_PASSWD = "naxalnet256"
|
AP_PASSWD = "naxalnet256"
|
||||||
|
|
||||||
|
|
||||||
|
def copy_files():
|
||||||
|
"""
|
||||||
|
Copy networkd configs to volatile dir.
|
||||||
|
The D-Bus API does not support creating new interfaces
|
||||||
|
or linking to bridges. So we use config files.
|
||||||
|
See man:systemd.network(5)
|
||||||
|
"""
|
||||||
|
|
||||||
|
print("Copying network config files")
|
||||||
|
dest = Path(NETWORKD_VOLATILE_DIR)
|
||||||
|
src = Path(NETWORKD_CONFIGS)
|
||||||
|
|
||||||
|
# Create the volatile directory if it doesn't exist
|
||||||
|
dest.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
# Copy all files in src to dest
|
||||||
|
for i in src.iterdir():
|
||||||
|
copy(i, dest)
|
||||||
|
|
||||||
|
|
||||||
def here_be_dragons():
|
def here_be_dragons():
|
||||||
# Copy networkd configs to volatile dir.
|
"""
|
||||||
# The D-Bus API does not support creating new interfaces
|
This function is run every time you
|
||||||
# or linking to bridges. So we use config files.
|
execute naxalnet from commandline
|
||||||
# See man:systemd.network(5)
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
print("Copying network config files")
|
copy_files()
|
||||||
dest = Path(NETWORKD_VOLATILE_DIR)
|
|
||||||
src = Path(NETWORKD_CONFIGS)
|
|
||||||
|
|
||||||
# Create the volatile directory if it doesn't exist
|
|
||||||
dest.mkdir(parents=True, exist_ok=True)
|
|
||||||
|
|
||||||
# Copy all files in src to dest
|
|
||||||
for i in src.iterdir():
|
|
||||||
copy(i, dest)
|
|
||||||
except PermissionError as error:
|
except PermissionError as error:
|
||||||
print(error)
|
print(error)
|
||||||
sys.exit("Make sure you are root")
|
sys.exit("Make sure you are root")
|
||||||
@ -64,11 +72,11 @@ def here_be_dragons():
|
|||||||
ap_devices = []
|
ap_devices = []
|
||||||
|
|
||||||
for i in devices:
|
for i in devices:
|
||||||
d = Device(i)
|
device = Device(i)
|
||||||
a = Adapter(d.adapter)
|
adapter = Adapter(device.adapter)
|
||||||
if a.supports_mode("ad-hoc"):
|
if adapter.supports_mode("ad-hoc"):
|
||||||
adhoc_devices.append(i)
|
adhoc_devices.append(i)
|
||||||
if a.supports_mode("ap"):
|
if adapter.supports_mode("ap"):
|
||||||
ap_devices.append(i)
|
ap_devices.append(i)
|
||||||
|
|
||||||
if len(adhoc_devices) != 0:
|
if len(adhoc_devices) != 0:
|
||||||
@ -76,19 +84,32 @@ def here_be_dragons():
|
|||||||
adhoc_device = Device(adhoc_devices.pop())
|
adhoc_device = Device(adhoc_devices.pop())
|
||||||
# The same device is likely to have ap support too.
|
# The same device is likely to have ap support too.
|
||||||
# But we can't start ad-hoc and ap on the same interface.
|
# But we can't start ad-hoc and ap on the same interface.
|
||||||
# Remove dev1 from ap_devices if it exists there
|
# Remove adhoc_device from ap_devices if it exists there
|
||||||
if adhoc_device.name in ap_devices:
|
if adhoc_device.name in ap_devices:
|
||||||
ap_devices.remove(adhoc_device.name)
|
ap_devices.remove(adhoc_device.name)
|
||||||
print("Working on ad-hoc")
|
print("Working on ad-hoc")
|
||||||
adhoc_device.start_adhoc_open(ADHOC_SSID)
|
# Turn on adapter if it is off
|
||||||
# Start Access point if ap_device is not empty,
|
# See issue #9
|
||||||
# ie, we have more devices
|
adhoc_adapter = Adapter(adhoc_device.adapter)
|
||||||
|
if not adhoc_adapter.is_powered_on():
|
||||||
|
adhoc_adapter.power_on()
|
||||||
|
adhoc_device.reload()
|
||||||
|
adhoc_device.start_adhoc_open(ADHOC_SSID)
|
||||||
|
# Start Access point if ap_device is not empty,
|
||||||
|
# ie, we have more devices
|
||||||
if len(ap_devices) != 0:
|
if len(ap_devices) != 0:
|
||||||
print("Working on AP")
|
print("Working on AP")
|
||||||
ap_device = Device(ap_devices.pop())
|
ap_device = Device(ap_devices.pop())
|
||||||
|
# Turn on adapter if it is off
|
||||||
|
# See issue #9
|
||||||
|
ap_adapter = Adapter(ap_device.adapter)
|
||||||
|
if not ap_adapter.is_powered_on():
|
||||||
|
ap_adapter.power_on()
|
||||||
|
ap_adapter.reload()
|
||||||
ap_device.start_ap(AP_SSID, AP_PASSWD)
|
ap_device.start_ap(AP_SSID, AP_PASSWD)
|
||||||
except DBusError as error:
|
except DBusError as error:
|
||||||
print(error)
|
print(error)
|
||||||
sys.exit("An error occured while communicating with iwd")
|
sys.exit("An error occured while communicating with iwd")
|
||||||
|
|
||||||
|
# naxalnet will print Bye if no errors occured
|
||||||
print("Bye")
|
print("Bye")
|
||||||
|
Loading…
Reference in New Issue
Block a user