mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-03-27 03:43:22 -04:00
@@ -28,31 +28,17 @@ Limitations:
|
||||
- The Freebox must be your gateway
|
||||
- The device must be in the same lan as the Freebox
|
||||
|
||||
### Offline setup (recommended)
|
||||
|
||||
Use this configuration if you wish to connect to your Freebox even when you are offline, or the Freebox is not your gateway.
|
||||
|
||||
Find the local IP address of your Freebox, if it is your gateway, you can find the address on your computer/smartphone network configuration (usually it's `192.168.1.1`). Go in the plugin settings and set the IP as address and `80` as the port (do *not* use `443` as the port). This configuration works regardless of your internet connection and poses little limitations.
|
||||
|
||||
Limitations:
|
||||
- *If* there is no internet connection, the plugin will fallback to HTTP (not HTTPS)
|
||||
|
||||
For more detail: the plugin will connect to the specified address and port to fetch information about the Freebox, then it will either connect in HTTPS through the Freebox's unique domain name, or connect over HTTP if there is no internet connection. The freebox does offer an HTTPS port on the local network, but the certificate will be invalid for the local IP, and the connection will be aborted.
|
||||
|
||||
### Remote setup
|
||||
|
||||
Use this configuration if you wish to connect to your Freebox through the internet. You still need to pair from the local network.
|
||||
|
||||
If the Freebox is not your gateway, configure a NAT and follow the [offline setup](#offline-setup-recommended).
|
||||
|
||||
If the Freebox is your gateway you need to find its HTTPS (or HTTP if you prefer) public port. This can be found either in the Freeboxe's web interface and by navigating to `settings>access management`, or (just for the HTTPS port) by visiting http://mafreebox.freebox.fr:80/api_version from the local network (you can use the local ip as well). This is the port you need to access your Freebox through the internet
|
||||
|
||||
As address, you can either use the public IP of the Freebox, or the unique domain name you found on http://mafreebox.freebox.fr:80/api_version listed as `api_domain`.
|
||||
|
||||
|
||||
## Other info
|
||||
|
||||
- Version: 1.0
|
||||
- Version: 2.0
|
||||
- Author: [KayJay7](https://github.com/KayJay7), [Lucide](https://github.com/Lucide)
|
||||
- Maintainers: [mathoudebine](https://github.com/mathoudebine)
|
||||
- Release Date: 2-Dec-2024
|
||||
@@ -8,10 +8,11 @@ from datetime import datetime
|
||||
from pathlib import Path
|
||||
from typing import cast
|
||||
import socket
|
||||
import aiofreepybox
|
||||
from aiofreepybox import Freepybox
|
||||
from aiofreepybox.api.lan import Lan
|
||||
from aiofreepybox.exceptions import NotOpenError, AuthorizationError
|
||||
import freebox_api
|
||||
from freebox_api import Freepybox
|
||||
from freebox_api.api.lan import Lan
|
||||
from freebox_api.api.system import System
|
||||
from freebox_api.exceptions import NotOpenError, AuthorizationError
|
||||
|
||||
# Define the installation path and extend the system path for plugin imports
|
||||
INSTALL_PATH = os.getenv('NETALERTX_APP', '/app')
|
||||
@@ -83,8 +84,7 @@ def map_device_type(type: str):
|
||||
|
||||
async def get_device_data(api_version: int, api_address: str, api_port: int):
|
||||
# ensure existence of db path
|
||||
config_base = Path(os.getenv("NETALERTX_CONFIG", "/data/config"))
|
||||
data_dir = config_base / "freeboxdb"
|
||||
data_dir = Path(os.getenv("NETALERTX_CONFIG", "/data/config")) / "freeboxdb"
|
||||
data_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# Instantiate Freepybox class using default application descriptor
|
||||
@@ -93,25 +93,27 @@ async def get_device_data(api_version: int, api_address: str, api_port: int):
|
||||
app_desc={
|
||||
"app_id": "netalertx",
|
||||
"app_name": "NetAlertX",
|
||||
"app_version": aiofreepybox.__version__,
|
||||
"app_version": freebox_api.__version__,
|
||||
"device_name": socket.gethostname(),
|
||||
},
|
||||
api_version="v" + str(api_version),
|
||||
data_dir=data_dir,
|
||||
token_file=data_dir / "token",
|
||||
)
|
||||
|
||||
# Connect to the freebox
|
||||
# Be ready to authorize the application on the Freebox if you run this
|
||||
# for the first time
|
||||
try:
|
||||
await fbx.open(host=api_address, port=api_port)
|
||||
await fbx.open(host=api_address, port=str(api_port))
|
||||
except NotOpenError as e:
|
||||
mylog("verbose", [f"[{pluginName}] Error connecting to freebox: {e}"])
|
||||
return None, []
|
||||
except AuthorizationError as e:
|
||||
mylog("verbose", [f"[{pluginName}] Auth error: {str(e)}"])
|
||||
return None, []
|
||||
|
||||
# get also info of the freebox itself
|
||||
config = await fbx.system.get_config()
|
||||
config = await cast(System, fbx.system).get_config()
|
||||
freebox = await cast(Lan, fbx.lan).get_config()
|
||||
hosts = await cast(Lan, fbx.lan).get_hosts_list()
|
||||
assert config is not None
|
||||
@@ -145,16 +147,17 @@ def main():
|
||||
mylog("verbose", [freebox])
|
||||
mylog("verbose", [hosts])
|
||||
|
||||
plugin_objects.add_object(
|
||||
primaryId=freebox["mac"],
|
||||
secondaryId=freebox["ip"],
|
||||
watched1=freebox["name"],
|
||||
watched2=freebox["operator"],
|
||||
watched3="Gateway",
|
||||
watched4=timeNowUTC(),
|
||||
extra="",
|
||||
foreignKey=freebox["mac"],
|
||||
)
|
||||
if freebox:
|
||||
plugin_objects.add_object(
|
||||
primaryId=freebox["mac"],
|
||||
secondaryId=freebox["ip"],
|
||||
watched1=freebox["name"],
|
||||
watched2=freebox["operator"],
|
||||
watched3="Gateway",
|
||||
watched4=timeNowUTC(),
|
||||
extra="",
|
||||
foreignKey=freebox["mac"],
|
||||
)
|
||||
for host in hosts:
|
||||
# Check if 'l3connectivities' exists and is a list
|
||||
if "l3connectivities" in host and isinstance(host["l3connectivities"], list):
|
||||
@@ -175,7 +178,7 @@ def main():
|
||||
# Optional: Log or handle hosts without 'l3connectivities'
|
||||
mylog("verbose", [f"[{pluginName}] Host missing 'l3connectivities': {host}"])
|
||||
|
||||
# commit result
|
||||
# Commit result
|
||||
plugin_objects.write_result_file()
|
||||
|
||||
return 0
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICOjCCAcCgAwIBAgIUI0Tu7zsrBJACQIZgLMJobtbdNn4wCgYIKoZIzj0EAwIw
|
||||
TDELMAkGA1UEBhMCSVQxDjAMBgNVBAgMBUl0YWx5MQ4wDAYDVQQKDAVJbGlhZDEd
|
||||
MBsGA1UEAwwUSWxpYWRib3ggRUNDIFJvb3QgQ0EwHhcNMjAxMTI3MDkzODEzWhcN
|
||||
NDAxMTIyMDkzODEzWjBMMQswCQYDVQQGEwJJVDEOMAwGA1UECAwFSXRhbHkxDjAM
|
||||
BgNVBAoMBUlsaWFkMR0wGwYDVQQDDBRJbGlhZGJveCBFQ0MgUm9vdCBDQTB2MBAG
|
||||
ByqGSM49AgEGBSuBBAAiA2IABMryJyb2loHNAioY8IztN5MI3UgbVHVP/vZwcnre
|
||||
ZvJOyDvE4HJgIti5qmfswlnMzpNbwf/MkT+7HAU8jJoTorRm1wtAnQ9cWD3Ebv79
|
||||
RPwtjjy3Bza3SgdVxmd6fWPUKaNjMGEwHQYDVR0OBBYEFDUij/4lpoJ+kOXRyrcM
|
||||
jf2RPzOqMB8GA1UdIwQYMBaAFDUij/4lpoJ+kOXRyrcMjf2RPzOqMA8GA1UdEwEB
|
||||
/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2gAMGUCMQC6eUV1
|
||||
pFh4UpJOTc1JToztN4ttnQR6rIzxMZ6mNCe+nhjkohWp24pr7BpUYSbEizYCMAQ6
|
||||
LCiBKV2j7QQGy7N1aBmdur17ZepYzR1YV0eI+Kd978aZggsmhjXENQYVTmm/XA==
|
||||
-----END CERTIFICATE-----
|
||||
@@ -24,4 +24,4 @@ librouteros
|
||||
yattag
|
||||
zeroconf
|
||||
psutil
|
||||
git+https://github.com/foreign-sub/aiofreepybox.git
|
||||
freebox-api
|
||||
|
||||
@@ -24,4 +24,4 @@ librouteros
|
||||
yattag
|
||||
zeroconf
|
||||
psutil
|
||||
git+https://github.com/foreign-sub/aiofreepybox.git
|
||||
freebox-api
|
||||
|
||||
@@ -30,7 +30,7 @@ six
|
||||
urllib3
|
||||
httplib2
|
||||
gunicorn
|
||||
git+https://github.com/foreign-sub/aiofreepybox.git
|
||||
freebox-api
|
||||
mcp
|
||||
psutil
|
||||
pydantic>=2.0,<3.0
|
||||
|
||||
Reference in New Issue
Block a user