router-cli 0.1.0__tar.gz

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.
@@ -0,0 +1,228 @@
1
+ Metadata-Version: 2.3
2
+ Name: router-cli
3
+ Version: 0.1.0
4
+ Summary: CLI tool to manage D-Link DSL-2750U router
5
+ Author: d3vr
6
+ Author-email: d3vr <hi@f3.al>
7
+ Requires-Dist: tomli>=2.0.0 ; python_full_version < '3.11'
8
+ Requires-Python: >=3.10
9
+ Description-Content-Type: text/markdown
10
+
11
+ # router-cli
12
+
13
+ A command-line tool to manage and monitor D-Link DSL-2750U routers.
14
+
15
+ Since the router doesn't provide a formal API, this tool works by authenticating with the router's web interface and parsing the HTML status pages to extract information.
16
+
17
+ ## Features
18
+
19
+ - **Zero external dependencies** - Uses only Python standard library
20
+ - **Colorized output** - Highlights known vs unknown devices on your network
21
+ - **Comprehensive monitoring** - View status, clients, DHCP leases, routes, statistics, and logs
22
+ - **Remote management** - Reboot the router from the command line
23
+ - **ADSL statistics** - Monitor line quality metrics (SNR, attenuation, sync rates)
24
+ - **Configurable** - Define known devices with friendly aliases
25
+
26
+ ## Installation
27
+
28
+ Requires Python 3.11 or higher.
29
+
30
+ ### Using uv (recommended)
31
+
32
+ ```bash
33
+ uv tool install router-cli
34
+ ```
35
+
36
+ ### Using pip
37
+
38
+ ```bash
39
+ pip install router-cli
40
+ ```
41
+
42
+ ### From source
43
+
44
+ ```bash
45
+ git clone https://github.com/d3vr/router-cli
46
+ cd router-cli
47
+ uv sync
48
+ ```
49
+
50
+ ## Configuration
51
+
52
+ Create a configuration file at `~/.config/router/config.toml`:
53
+
54
+ ```toml
55
+ [router]
56
+ ip = "192.168.1.1"
57
+ username = "admin"
58
+ password = "your_password_here"
59
+
60
+ # Optional: Define known devices for colorized output
61
+ [known_devices]
62
+ "AA:BB:CC:DD:EE:FF" = "My Phone"
63
+ "11:22:33:44:55:66" = "Smart TV"
64
+ "DE:AD:BE:EF:00:01" = "Work Laptop"
65
+ ```
66
+
67
+ The tool searches for configuration in the following locations (in order):
68
+ 1. `./config.toml` (current directory)
69
+ 2. `~/.config/router/config.toml`
70
+ 3. `/etc/router/config.toml`
71
+
72
+ ## Usage
73
+
74
+ ### Quick Overview
75
+
76
+ ```bash
77
+ router overview
78
+ ```
79
+
80
+ Shows a dashboard with connection status, sync rates, connected devices, and warnings:
81
+
82
+ ```
83
+ ============================================================
84
+ ROUTER OVERVIEW
85
+ ============================================================
86
+
87
+ CONNECTION
88
+ ADSL Status: Showtime
89
+ Sync Rate: 8180 / 1022 Kbps (down/up)
90
+ SNR Margin: 6.5 / 12.0 dB
91
+ Default Gateway: 10.0.0.1
92
+ WAN IP: 203.0.113.45 (Connected)
93
+
94
+ NETWORK
95
+ Router IP: 192.168.1.1
96
+ SSID: MyNetwork
97
+ Wireless Clients: 3
98
+ DHCP Leases: 5
99
+
100
+ DEVICES
101
+ My Phone AA:BB:CC:DD:EE:FF 192.168.1.100 ⏱ 22:45:30
102
+ Smart TV 11:22:33:44:55:66 192.168.1.101 ⏱ 20:15:45
103
+ unknown-device CC:DD:EE:FF:00:11 192.168.1.102 ⏱ 18:30:00
104
+
105
+ WARNINGS
106
+ Unknown devices on network: 1
107
+
108
+ ============================================================
109
+ ```
110
+
111
+ ### Available Commands
112
+
113
+ | Command | Description |
114
+ |---------|-------------|
115
+ | `router status` | Display full router status (system, internet, wireless, local network) |
116
+ | `router overview` | Show quick dashboard with highlights |
117
+ | `router clients` | List connected wireless clients |
118
+ | `router dhcp` | Show DHCP leases with expiration times |
119
+ | `router stats` | Show network interface and ADSL statistics |
120
+ | `router routes` | Display the kernel routing table |
121
+ | `router logs` | Show system logs |
122
+ | `router reboot` | Reboot the router |
123
+
124
+ ### Command Details
125
+
126
+ #### Status
127
+
128
+ ```bash
129
+ router status
130
+ ```
131
+
132
+ Displays comprehensive router information:
133
+ - System info (model, firmware, date/time)
134
+ - Internet info (gateway, DNS servers, WAN connections)
135
+ - Wireless info (SSID, MAC, security mode)
136
+ - Local network (IP, subnet, DHCP status)
137
+
138
+ #### Wireless Clients
139
+
140
+ ```bash
141
+ router clients
142
+ ```
143
+
144
+ Lists all connected wireless devices with association and authorization status.
145
+
146
+ #### DHCP Leases
147
+
148
+ ```bash
149
+ router dhcp
150
+ ```
151
+
152
+ Shows all active DHCP leases with device names, MAC addresses, IP addresses, and lease expiration times.
153
+
154
+ #### Network Statistics
155
+
156
+ ```bash
157
+ router stats
158
+ ```
159
+
160
+ Displays detailed statistics including:
161
+ - LAN interface traffic (bytes, packets, errors, drops)
162
+ - WAN interface traffic
163
+ - ADSL line metrics (sync rate, SNR margin, attenuation, output power)
164
+
165
+ #### System Logs
166
+
167
+ ```bash
168
+ router logs # Show all logs
169
+ router logs --tail 20 # Show last 20 entries
170
+ router logs --level error # Filter by severity level
171
+ router logs -n 10 -l warning # Combine options
172
+ ```
173
+
174
+ #### Routing Table
175
+
176
+ ```bash
177
+ router routes
178
+ ```
179
+
180
+ Displays the kernel routing table with destination, gateway, subnet mask, flags, metric, and service.
181
+
182
+ #### Reboot
183
+
184
+ ```bash
185
+ router reboot
186
+ ```
187
+
188
+ Sends a reboot command to the router.
189
+
190
+ ## Known Devices
191
+
192
+ The `[known_devices]` section in your config file maps MAC addresses to friendly names. This enables:
193
+
194
+ - **Color-coded output**: Known devices appear in green, unknown in red
195
+ - **Friendly names**: See "My Phone" instead of a hostname or MAC address
196
+ - **Security awareness**: Quickly spot unauthorized devices on your network
197
+
198
+ ```toml
199
+ [known_devices]
200
+ "AA:BB:CC:DD:EE:FF" = "My Phone"
201
+ "11:22:33:44:55:66" = "Smart TV"
202
+ ```
203
+
204
+ MAC addresses are matched case-insensitively.
205
+
206
+ ## Development
207
+
208
+ See [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md) for the full development guide.
209
+
210
+ ### Quick Start
211
+
212
+ ```bash
213
+ git clone https://github.com/d3vr/router-cli
214
+ cd router-cli
215
+ uv sync --all-groups
216
+ uv run pytest
217
+ ```
218
+
219
+ ## Compatibility
220
+
221
+ - **Python**: 3.11+
222
+ - **Router**: D-Link DSL-2750U (firmware ME_1.00)
223
+
224
+ This tool may work with other D-Link routers that share a similar web interface, but has only been tested with the DSL-2750U.
225
+
226
+ ## License
227
+
228
+ MIT
@@ -0,0 +1,218 @@
1
+ # router-cli
2
+
3
+ A command-line tool to manage and monitor D-Link DSL-2750U routers.
4
+
5
+ Since the router doesn't provide a formal API, this tool works by authenticating with the router's web interface and parsing the HTML status pages to extract information.
6
+
7
+ ## Features
8
+
9
+ - **Zero external dependencies** - Uses only Python standard library
10
+ - **Colorized output** - Highlights known vs unknown devices on your network
11
+ - **Comprehensive monitoring** - View status, clients, DHCP leases, routes, statistics, and logs
12
+ - **Remote management** - Reboot the router from the command line
13
+ - **ADSL statistics** - Monitor line quality metrics (SNR, attenuation, sync rates)
14
+ - **Configurable** - Define known devices with friendly aliases
15
+
16
+ ## Installation
17
+
18
+ Requires Python 3.11 or higher.
19
+
20
+ ### Using uv (recommended)
21
+
22
+ ```bash
23
+ uv tool install router-cli
24
+ ```
25
+
26
+ ### Using pip
27
+
28
+ ```bash
29
+ pip install router-cli
30
+ ```
31
+
32
+ ### From source
33
+
34
+ ```bash
35
+ git clone https://github.com/d3vr/router-cli
36
+ cd router-cli
37
+ uv sync
38
+ ```
39
+
40
+ ## Configuration
41
+
42
+ Create a configuration file at `~/.config/router/config.toml`:
43
+
44
+ ```toml
45
+ [router]
46
+ ip = "192.168.1.1"
47
+ username = "admin"
48
+ password = "your_password_here"
49
+
50
+ # Optional: Define known devices for colorized output
51
+ [known_devices]
52
+ "AA:BB:CC:DD:EE:FF" = "My Phone"
53
+ "11:22:33:44:55:66" = "Smart TV"
54
+ "DE:AD:BE:EF:00:01" = "Work Laptop"
55
+ ```
56
+
57
+ The tool searches for configuration in the following locations (in order):
58
+ 1. `./config.toml` (current directory)
59
+ 2. `~/.config/router/config.toml`
60
+ 3. `/etc/router/config.toml`
61
+
62
+ ## Usage
63
+
64
+ ### Quick Overview
65
+
66
+ ```bash
67
+ router overview
68
+ ```
69
+
70
+ Shows a dashboard with connection status, sync rates, connected devices, and warnings:
71
+
72
+ ```
73
+ ============================================================
74
+ ROUTER OVERVIEW
75
+ ============================================================
76
+
77
+ CONNECTION
78
+ ADSL Status: Showtime
79
+ Sync Rate: 8180 / 1022 Kbps (down/up)
80
+ SNR Margin: 6.5 / 12.0 dB
81
+ Default Gateway: 10.0.0.1
82
+ WAN IP: 203.0.113.45 (Connected)
83
+
84
+ NETWORK
85
+ Router IP: 192.168.1.1
86
+ SSID: MyNetwork
87
+ Wireless Clients: 3
88
+ DHCP Leases: 5
89
+
90
+ DEVICES
91
+ My Phone AA:BB:CC:DD:EE:FF 192.168.1.100 ⏱ 22:45:30
92
+ Smart TV 11:22:33:44:55:66 192.168.1.101 ⏱ 20:15:45
93
+ unknown-device CC:DD:EE:FF:00:11 192.168.1.102 ⏱ 18:30:00
94
+
95
+ WARNINGS
96
+ Unknown devices on network: 1
97
+
98
+ ============================================================
99
+ ```
100
+
101
+ ### Available Commands
102
+
103
+ | Command | Description |
104
+ |---------|-------------|
105
+ | `router status` | Display full router status (system, internet, wireless, local network) |
106
+ | `router overview` | Show quick dashboard with highlights |
107
+ | `router clients` | List connected wireless clients |
108
+ | `router dhcp` | Show DHCP leases with expiration times |
109
+ | `router stats` | Show network interface and ADSL statistics |
110
+ | `router routes` | Display the kernel routing table |
111
+ | `router logs` | Show system logs |
112
+ | `router reboot` | Reboot the router |
113
+
114
+ ### Command Details
115
+
116
+ #### Status
117
+
118
+ ```bash
119
+ router status
120
+ ```
121
+
122
+ Displays comprehensive router information:
123
+ - System info (model, firmware, date/time)
124
+ - Internet info (gateway, DNS servers, WAN connections)
125
+ - Wireless info (SSID, MAC, security mode)
126
+ - Local network (IP, subnet, DHCP status)
127
+
128
+ #### Wireless Clients
129
+
130
+ ```bash
131
+ router clients
132
+ ```
133
+
134
+ Lists all connected wireless devices with association and authorization status.
135
+
136
+ #### DHCP Leases
137
+
138
+ ```bash
139
+ router dhcp
140
+ ```
141
+
142
+ Shows all active DHCP leases with device names, MAC addresses, IP addresses, and lease expiration times.
143
+
144
+ #### Network Statistics
145
+
146
+ ```bash
147
+ router stats
148
+ ```
149
+
150
+ Displays detailed statistics including:
151
+ - LAN interface traffic (bytes, packets, errors, drops)
152
+ - WAN interface traffic
153
+ - ADSL line metrics (sync rate, SNR margin, attenuation, output power)
154
+
155
+ #### System Logs
156
+
157
+ ```bash
158
+ router logs # Show all logs
159
+ router logs --tail 20 # Show last 20 entries
160
+ router logs --level error # Filter by severity level
161
+ router logs -n 10 -l warning # Combine options
162
+ ```
163
+
164
+ #### Routing Table
165
+
166
+ ```bash
167
+ router routes
168
+ ```
169
+
170
+ Displays the kernel routing table with destination, gateway, subnet mask, flags, metric, and service.
171
+
172
+ #### Reboot
173
+
174
+ ```bash
175
+ router reboot
176
+ ```
177
+
178
+ Sends a reboot command to the router.
179
+
180
+ ## Known Devices
181
+
182
+ The `[known_devices]` section in your config file maps MAC addresses to friendly names. This enables:
183
+
184
+ - **Color-coded output**: Known devices appear in green, unknown in red
185
+ - **Friendly names**: See "My Phone" instead of a hostname or MAC address
186
+ - **Security awareness**: Quickly spot unauthorized devices on your network
187
+
188
+ ```toml
189
+ [known_devices]
190
+ "AA:BB:CC:DD:EE:FF" = "My Phone"
191
+ "11:22:33:44:55:66" = "Smart TV"
192
+ ```
193
+
194
+ MAC addresses are matched case-insensitively.
195
+
196
+ ## Development
197
+
198
+ See [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md) for the full development guide.
199
+
200
+ ### Quick Start
201
+
202
+ ```bash
203
+ git clone https://github.com/d3vr/router-cli
204
+ cd router-cli
205
+ uv sync --all-groups
206
+ uv run pytest
207
+ ```
208
+
209
+ ## Compatibility
210
+
211
+ - **Python**: 3.11+
212
+ - **Router**: D-Link DSL-2750U (firmware ME_1.00)
213
+
214
+ This tool may work with other D-Link routers that share a similar web interface, but has only been tested with the DSL-2750U.
215
+
216
+ ## License
217
+
218
+ MIT
@@ -0,0 +1,18 @@
1
+ [project]
2
+ name = "router-cli"
3
+ version = "0.1.0"
4
+ description = "CLI tool to manage D-Link DSL-2750U router"
5
+ readme = "README.md"
6
+ authors = [{ name = "d3vr", email = "hi@f3.al" }]
7
+ requires-python = ">=3.10"
8
+ dependencies = ["tomli>=2.0.0; python_version < '3.11'"]
9
+
10
+ [project.scripts]
11
+ router = "router_cli.main:main"
12
+
13
+ [dependency-groups]
14
+ dev = ["pytest>=8.0.0"]
15
+
16
+ [build-system]
17
+ requires = ["uv_build>=0.9.28,<0.10.0"]
18
+ build-backend = "uv_build"
@@ -0,0 +1,3 @@
1
+ """Router CLI - Manage D-Link DSL-2750U router."""
2
+
3
+ __version__ = "0.1.0"