diodos 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- diodos/__init__.py +0 -0
- diodos/__main__.py +9 -0
- diodos/main.py +49 -0
- diodos/utils/__init__.py +0 -0
- diodos/utils/config.py +45 -0
- diodos/utils/network.py +49 -0
- diodos/utils/sample.config.toml +11 -0
- diodos-0.1.0.dist-info/METADATA +117 -0
- diodos-0.1.0.dist-info/RECORD +12 -0
- diodos-0.1.0.dist-info/WHEEL +4 -0
- diodos-0.1.0.dist-info/entry_points.txt +3 -0
- diodos-0.1.0.dist-info/licenses/LICENSE +21 -0
diodos/__init__.py
ADDED
|
File without changes
|
diodos/__main__.py
ADDED
diodos/main.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import time
|
|
2
|
+
import typer
|
|
3
|
+
|
|
4
|
+
from .utils.config import load_config
|
|
5
|
+
from .utils.network import network_check, attempt_login
|
|
6
|
+
|
|
7
|
+
app = typer.Typer(no_args_is_help=True)
|
|
8
|
+
context_settings = dict(help_option_names=["-h", "--help"])
|
|
9
|
+
|
|
10
|
+
@app.callback(context_settings=context_settings)
|
|
11
|
+
def callback() -> None:
|
|
12
|
+
"""
|
|
13
|
+
Diodos is a command-line tool that helps you automatically log in to captive portals on saved Wi-Fi networks. It monitors network connections and detects when a captive portal is present, allowing you to seamlessly authenticate without manual intervention.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
@app.command()
|
|
17
|
+
def run() -> None:
|
|
18
|
+
"""
|
|
19
|
+
This command will start the daemon process and keep it running in the background, monitoring network connections for captive portals. When a captive portal is detected, the daemon will attempt to automatically log in using the provided credentials or configuration.
|
|
20
|
+
"""
|
|
21
|
+
try:
|
|
22
|
+
config = load_config()
|
|
23
|
+
except FileNotFoundError as e:
|
|
24
|
+
typer.echo(f"Error: {e}")
|
|
25
|
+
raise typer.Exit(code=1)
|
|
26
|
+
|
|
27
|
+
typer.echo("Starting the diodos daemon...")
|
|
28
|
+
interval = config.get("network_check", {}).get("interval", 60)
|
|
29
|
+
|
|
30
|
+
try:
|
|
31
|
+
next_run = time.monotonic()
|
|
32
|
+
while True:
|
|
33
|
+
now = time.monotonic()
|
|
34
|
+
if now >= next_run:
|
|
35
|
+
check = network_check(config)
|
|
36
|
+
if check:
|
|
37
|
+
typer.echo("Captive portal detected. Attempting to log in...")
|
|
38
|
+
login_success = attempt_login(config)
|
|
39
|
+
if login_success:
|
|
40
|
+
typer.echo("Login successful!")
|
|
41
|
+
else:
|
|
42
|
+
typer.echo("Login failed. Please check your credentials or configuration.")
|
|
43
|
+
|
|
44
|
+
next_run = now + interval # Default to 60 seconds if not specified
|
|
45
|
+
|
|
46
|
+
time.sleep(5) # Sleep for a short duration to avoid busy waiting
|
|
47
|
+
except KeyboardInterrupt:
|
|
48
|
+
typer.echo("\nDaemon stopped by user.")
|
|
49
|
+
raise typer.Exit(code=0)
|
diodos/utils/__init__.py
ADDED
|
File without changes
|
diodos/utils/config.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
import subprocess
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from tomlkit import load
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def get_config_path() -> Path:
|
|
10
|
+
if sys.platform == "win32":
|
|
11
|
+
base = Path(os.environ.get("APPDATA", Path.home() / "AppData/Roaming"))
|
|
12
|
+
elif sys.platform == "darwin":
|
|
13
|
+
base = Path.home() / "Library/Application Support"
|
|
14
|
+
else:
|
|
15
|
+
base = Path(os.environ.get("XDG_CONFIG_HOME", Path.home() / ".config"))
|
|
16
|
+
|
|
17
|
+
return base / "diodos" / "config.toml"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def load_config(path: str | Path | None = None) -> dict:
|
|
21
|
+
"""Load the diodos configuration from TOML."""
|
|
22
|
+
config_path = Path(path).expanduser() if path else get_config_path()
|
|
23
|
+
|
|
24
|
+
if not config_path.exists():
|
|
25
|
+
config_path.parent.mkdir(parents=True, exist_ok=True)
|
|
26
|
+
config_path.touch()
|
|
27
|
+
with config_path.open("w") as file:
|
|
28
|
+
with open(Path(__file__).parent / "sample.config.toml", "r") as default_file:
|
|
29
|
+
file.write(default_file.read())
|
|
30
|
+
open_config_file(config_path)
|
|
31
|
+
raise FileNotFoundError(f"Config file not found. Created default at: {config_path}")
|
|
32
|
+
|
|
33
|
+
with config_path.open("rb") as file:
|
|
34
|
+
return load(file).unwrap()
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def open_config_file(path: str | Path) -> None:
|
|
38
|
+
path = Path(path)
|
|
39
|
+
|
|
40
|
+
if sys.platform == "win32":
|
|
41
|
+
os.startfile(path)
|
|
42
|
+
elif sys.platform == "darwin":
|
|
43
|
+
subprocess.run(["open", str(path)], check=False)
|
|
44
|
+
else:
|
|
45
|
+
subprocess.run(["xdg-open", str(path)], check=False)
|
diodos/utils/network.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
|
|
3
|
+
def network_check(config: dict) -> bool:
|
|
4
|
+
"""
|
|
5
|
+
Check if the network is behind a captive portal by making a request to a known URL.
|
|
6
|
+
Returns True if a captive portal is detected, False otherwise.
|
|
7
|
+
"""
|
|
8
|
+
network_check_config = config.get("network_check", {})
|
|
9
|
+
|
|
10
|
+
test_url = network_check_config.get("url")
|
|
11
|
+
test_msg = network_check_config.get("msg", "Success")
|
|
12
|
+
|
|
13
|
+
if not test_url:
|
|
14
|
+
return True
|
|
15
|
+
|
|
16
|
+
try:
|
|
17
|
+
response = requests.get(test_url, timeout=5)
|
|
18
|
+
# Check if the response contains the expected message
|
|
19
|
+
if test_msg in response.text:
|
|
20
|
+
return False
|
|
21
|
+
else:
|
|
22
|
+
return True
|
|
23
|
+
except requests.RequestException as e:
|
|
24
|
+
return True
|
|
25
|
+
|
|
26
|
+
def attempt_login(config: dict) -> bool:
|
|
27
|
+
"""
|
|
28
|
+
Attempt to log in to the captive portal using the provided credentials or configuration.
|
|
29
|
+
Returns True if login is successful, False otherwise.
|
|
30
|
+
"""
|
|
31
|
+
login_config = config.get("login", {})
|
|
32
|
+
login_url = login_config.get("url")
|
|
33
|
+
credentials = login_config.get("credentials", {})
|
|
34
|
+
|
|
35
|
+
if not login_url:
|
|
36
|
+
return False
|
|
37
|
+
|
|
38
|
+
try:
|
|
39
|
+
with requests.Session() as session:
|
|
40
|
+
response = session.post(
|
|
41
|
+
login_url,
|
|
42
|
+
data=credentials,
|
|
43
|
+
timeout=5,
|
|
44
|
+
allow_redirects=True,
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
return response.status_code == 200
|
|
48
|
+
except requests.RequestException:
|
|
49
|
+
return False
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: diodos
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Auto detect and login to the captive portal of given networks.
|
|
5
|
+
Keywords: captive-portal,network,cli,automation,wifi
|
|
6
|
+
Author: RushiVivek
|
|
7
|
+
Author-email: RushiVivek <rushivivek123@gmail.com>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Classifier: Topic :: Internet
|
|
16
|
+
Classifier: Topic :: Utilities
|
|
17
|
+
Requires-Dist: requests>=2.34.2
|
|
18
|
+
Requires-Dist: tomlkit>=0.15.1
|
|
19
|
+
Requires-Dist: typer>=0.27.1
|
|
20
|
+
Requires-Python: >=3.13
|
|
21
|
+
Project-URL: Homepage, https://github.com/RushiVivek/Diodos
|
|
22
|
+
Project-URL: Repository, https://github.com/RushiVivek/Diodos
|
|
23
|
+
Project-URL: Issues, https://github.com/RushiVivek/Diodos/issues
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# diodos
|
|
27
|
+
|
|
28
|
+
`diodos` is a CLI daemon that monitors your network and automatically attempts login when a captive portal is detected.
|
|
29
|
+
|
|
30
|
+
## Features
|
|
31
|
+
|
|
32
|
+
- Checks connectivity on a configurable interval.
|
|
33
|
+
- Detects likely captive-portal redirects.
|
|
34
|
+
- Submits configured credentials automatically.
|
|
35
|
+
- Works with `python -m diodos` and the installed `diodos` command.
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
### With uv (recommended)
|
|
40
|
+
|
|
41
|
+
Install as a global CLI tool:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
uv tool install diodos
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Run without installing globally:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
uvx diodos run
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### With pip (alternative)
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pip install diodos
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### From source
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
git clone <your-repo-url>
|
|
63
|
+
cd Diodos
|
|
64
|
+
uv sync
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Usage
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
diodos run
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Or:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
python -m diodos run
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
On first run, `diodos` creates a default config file and opens it for editing.
|
|
80
|
+
|
|
81
|
+
## Configuration
|
|
82
|
+
|
|
83
|
+
Default config path:
|
|
84
|
+
|
|
85
|
+
- Linux: `~/.config/diodos/config.toml` (or `$XDG_CONFIG_HOME/diodos/config.toml`)
|
|
86
|
+
- macOS: `~/Library/Application Support/diodos/config.toml`
|
|
87
|
+
- Windows: `%APPDATA%/diodos/config.toml`
|
|
88
|
+
|
|
89
|
+
Example:
|
|
90
|
+
|
|
91
|
+
```toml
|
|
92
|
+
[network_check]
|
|
93
|
+
url = "https://example.com"
|
|
94
|
+
msg = "Success"
|
|
95
|
+
interval = 60
|
|
96
|
+
|
|
97
|
+
[login]
|
|
98
|
+
url = "https://portal.example.com/login"
|
|
99
|
+
|
|
100
|
+
[login.credentials]
|
|
101
|
+
username = "your-username"
|
|
102
|
+
password = "your-password"
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Development
|
|
106
|
+
|
|
107
|
+
Build distributables:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
uv build
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Validate package metadata:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
uvx twine check dist/*
|
|
117
|
+
```
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
diodos/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
diodos/__main__.py,sha256=GJuuBkM5akIdXxKqSJFLdy9icFaZzoGNhAUPnxLcGFs,90
|
|
3
|
+
diodos/main.py,sha256=Lfup3rD78NnFfc4rEeBVV2VFtTXPN15XSlBAg_qbVBY,1992
|
|
4
|
+
diodos/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
diodos/utils/config.py,sha256=pEbNO5PTPO5DK4ru94Pw3XxvhNzR5I6smRUAD5Mjulk,1454
|
|
6
|
+
diodos/utils/network.py,sha256=hG9ZFh-UASQyA8QcWSMhBw7NTI_8o5EX15cCGI2aZxY,1456
|
|
7
|
+
diodos/utils/sample.config.toml,sha256=7V22UMUDcRShsk9YLRIQsuRUQeUA6khpcvB9wkldNiM,140
|
|
8
|
+
diodos-0.1.0.dist-info/licenses/LICENSE,sha256=LGiR4yr4NfxkuqOdKDU1W2l8-NnnXgNdmmi3hE6KE-s,1066
|
|
9
|
+
diodos-0.1.0.dist-info/WHEEL,sha256=4OL6Foqnnp3xRY5wMkjgc25_i5YJC6dKsC6LPcjqEoU,80
|
|
10
|
+
diodos-0.1.0.dist-info/entry_points.txt,sha256=feXnY5rl5zFyzHuKBI_0k0OaHgkACT9giL0Ux7s1s2Q,44
|
|
11
|
+
diodos-0.1.0.dist-info/METADATA,sha256=nngLko-ArzHXt11t1yOtOaYc2AJv7hdBIcL3yJ9XEWY,2316
|
|
12
|
+
diodos-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 RushiVivek
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|