py-nic-manager 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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 GGN_2015
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.
@@ -0,0 +1,171 @@
1
+ Metadata-Version: 2.4
2
+ Name: py-nic-manager
3
+ Version: 0.1.0
4
+ Summary: A cross-platform GUI network adapter and route manager.
5
+ Author: GGN_2015
6
+ License: MIT
7
+ Keywords: network,gui,nic,route,loopback
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Environment :: Win32 (MS Windows)
10
+ Classifier: Environment :: MacOS X
11
+ Classifier: Environment :: X11 Applications
12
+ Classifier: Intended Audience :: System Administrators
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: MacOS
15
+ Classifier: Operating System :: Microsoft :: Windows
16
+ Classifier: Operating System :: POSIX
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Topic :: System :: Networking
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: is-admin-user>=0.1.0
23
+ Dynamic: license-file
24
+
25
+ # Py NIC Manager
26
+
27
+ Py NIC Manager is a cross-platform Python GUI for viewing and changing network
28
+ adapter settings, loopback-style adapters, route tables, and saved network
29
+ configuration snapshots.
30
+
31
+ The application is written in English and uses the Python standard `tkinter`
32
+ GUI toolkit. It can run on Windows and POSIX systems. Administrative actions
33
+ require Administrator/root privileges; when the app is started without those
34
+ privileges, it opens in read-only mode and clearly asks the user to restart it
35
+ with elevated permissions.
36
+
37
+ ## Features
38
+
39
+ - View network adapters, IPv4 addresses, MAC addresses, gateways, DNS servers,
40
+ DHCP state, and loopback status.
41
+ - Edit existing adapter IPv4 address, prefix length, gateway, DNS servers, MAC
42
+ address, and DHCP mode where the operating system backend supports it.
43
+ - Create, edit, and delete loopback-style adapters:
44
+ - Windows: Microsoft KM-TEST Loopback Adapter through `devcon.exe`.
45
+ - Linux: dummy interfaces through `ip link`.
46
+ - macOS and generic POSIX: loopback aliases on `lo0`.
47
+ - View, add, update, and delete IPv4 routes through a visual route table editor.
48
+ - Export the current adapters and routes to a JSON configuration snapshot.
49
+ - Import a saved snapshot and apply it as a best-effort one-click restore after
50
+ previewing the system commands that will run.
51
+ - Preview every mutating command before execution.
52
+
53
+ ## Installation
54
+
55
+ ```powershell
56
+ python -m venv .venv
57
+ .\.venv\Scripts\Activate.ps1
58
+ python -m pip install -e .
59
+ ```
60
+
61
+ On Linux or macOS:
62
+
63
+ ```bash
64
+ python3 -m venv .venv
65
+ . .venv/bin/activate
66
+ python -m pip install -e .
67
+ ```
68
+
69
+ The project depends on
70
+ [`is-admin-user`](https://pypi.org/project/is-admin-user/) for privilege
71
+ detection.
72
+
73
+ ## Running
74
+
75
+ ```bash
76
+ py-nic-manager
77
+ ```
78
+
79
+ Or:
80
+
81
+ ```bash
82
+ python -m py_nic_manager
83
+ ```
84
+
85
+ Use an elevated shell when you want to change system settings:
86
+
87
+ - Windows: run PowerShell or Command Prompt as Administrator.
88
+ - Linux/macOS/POSIX: run with `sudo`, `doas`, or an equivalent root session.
89
+
90
+ Without elevation, the app can still view adapters/routes and export
91
+ configuration snapshots.
92
+
93
+ ## Platform Notes
94
+
95
+ ### Windows
96
+
97
+ The Windows backend uses PowerShell networking cmdlets, `netsh`, `route`, and
98
+ `pnputil`.
99
+
100
+ Creating a Microsoft KM-TEST Loopback Adapter requires `devcon.exe` from the
101
+ Windows Driver Kit to be available on `PATH`. Windows does not provide a simple
102
+ built-in `netsh` command that reliably creates this adapter on every version.
103
+
104
+ ### Linux
105
+
106
+ The Linux backend uses `ip` from iproute2. DNS and DHCP persistence are handled
107
+ through NetworkManager (`nmcli`) when available, with `resolvectl` used as a DNS
108
+ fallback.
109
+
110
+ Loopback-style adapters are implemented as Linux dummy interfaces.
111
+
112
+ ### macOS
113
+
114
+ The macOS backend uses `networksetup`, `ifconfig`, `route`, and `netstat`.
115
+ Loopback creation is implemented as an address alias on `lo0`, because macOS
116
+ does not create independent loopback NICs in the same way Linux creates dummy
117
+ interfaces.
118
+
119
+ ### Generic POSIX
120
+
121
+ For POSIX systems that are not Linux or macOS, the app uses a conservative
122
+ `ifconfig`/`route` fallback. Viewing should work on many Unix-like systems, but
123
+ some mutating operations are intentionally limited because network management
124
+ varies widely across BSDs and commercial Unix systems.
125
+
126
+ ## Configuration Snapshots
127
+
128
+ Exported files are JSON documents with this high-level shape:
129
+
130
+ ```json
131
+ {
132
+ "schema_version": 1,
133
+ "platform": "Windows",
134
+ "captured_at": "2026-06-17T02:00:00+00:00",
135
+ "adapters": [],
136
+ "routes": []
137
+ }
138
+ ```
139
+
140
+ When applying an imported snapshot, Py NIC Manager:
141
+
142
+ 1. Matches adapters by backend ID first, then by adapter name.
143
+ 2. Updates matched adapters with the saved IPv4, gateway, DNS, MAC, and DHCP
144
+ values where supported.
145
+ 3. Adds saved IPv4 routes.
146
+ 4. Shows skipped adapters and platform limitations in the command preview.
147
+
148
+ Applying a snapshot from another operating system is allowed only after a
149
+ warning and is best-effort.
150
+
151
+ ## Development
152
+
153
+ Run tests:
154
+
155
+ ```bash
156
+ python -m pytest -q
157
+ ```
158
+
159
+ Run a syntax check:
160
+
161
+ ```bash
162
+ python -m compileall py_nic_manager tests
163
+ ```
164
+
165
+ ## Safety
166
+
167
+ Network configuration changes can disconnect the machine, break DNS resolution,
168
+ or remove routes that are needed for remote access. Always review the command
169
+ preview before applying changes, and export a known-good snapshot before making
170
+ large edits.
171
+
@@ -0,0 +1,147 @@
1
+ # Py NIC Manager
2
+
3
+ Py NIC Manager is a cross-platform Python GUI for viewing and changing network
4
+ adapter settings, loopback-style adapters, route tables, and saved network
5
+ configuration snapshots.
6
+
7
+ The application is written in English and uses the Python standard `tkinter`
8
+ GUI toolkit. It can run on Windows and POSIX systems. Administrative actions
9
+ require Administrator/root privileges; when the app is started without those
10
+ privileges, it opens in read-only mode and clearly asks the user to restart it
11
+ with elevated permissions.
12
+
13
+ ## Features
14
+
15
+ - View network adapters, IPv4 addresses, MAC addresses, gateways, DNS servers,
16
+ DHCP state, and loopback status.
17
+ - Edit existing adapter IPv4 address, prefix length, gateway, DNS servers, MAC
18
+ address, and DHCP mode where the operating system backend supports it.
19
+ - Create, edit, and delete loopback-style adapters:
20
+ - Windows: Microsoft KM-TEST Loopback Adapter through `devcon.exe`.
21
+ - Linux: dummy interfaces through `ip link`.
22
+ - macOS and generic POSIX: loopback aliases on `lo0`.
23
+ - View, add, update, and delete IPv4 routes through a visual route table editor.
24
+ - Export the current adapters and routes to a JSON configuration snapshot.
25
+ - Import a saved snapshot and apply it as a best-effort one-click restore after
26
+ previewing the system commands that will run.
27
+ - Preview every mutating command before execution.
28
+
29
+ ## Installation
30
+
31
+ ```powershell
32
+ python -m venv .venv
33
+ .\.venv\Scripts\Activate.ps1
34
+ python -m pip install -e .
35
+ ```
36
+
37
+ On Linux or macOS:
38
+
39
+ ```bash
40
+ python3 -m venv .venv
41
+ . .venv/bin/activate
42
+ python -m pip install -e .
43
+ ```
44
+
45
+ The project depends on
46
+ [`is-admin-user`](https://pypi.org/project/is-admin-user/) for privilege
47
+ detection.
48
+
49
+ ## Running
50
+
51
+ ```bash
52
+ py-nic-manager
53
+ ```
54
+
55
+ Or:
56
+
57
+ ```bash
58
+ python -m py_nic_manager
59
+ ```
60
+
61
+ Use an elevated shell when you want to change system settings:
62
+
63
+ - Windows: run PowerShell or Command Prompt as Administrator.
64
+ - Linux/macOS/POSIX: run with `sudo`, `doas`, or an equivalent root session.
65
+
66
+ Without elevation, the app can still view adapters/routes and export
67
+ configuration snapshots.
68
+
69
+ ## Platform Notes
70
+
71
+ ### Windows
72
+
73
+ The Windows backend uses PowerShell networking cmdlets, `netsh`, `route`, and
74
+ `pnputil`.
75
+
76
+ Creating a Microsoft KM-TEST Loopback Adapter requires `devcon.exe` from the
77
+ Windows Driver Kit to be available on `PATH`. Windows does not provide a simple
78
+ built-in `netsh` command that reliably creates this adapter on every version.
79
+
80
+ ### Linux
81
+
82
+ The Linux backend uses `ip` from iproute2. DNS and DHCP persistence are handled
83
+ through NetworkManager (`nmcli`) when available, with `resolvectl` used as a DNS
84
+ fallback.
85
+
86
+ Loopback-style adapters are implemented as Linux dummy interfaces.
87
+
88
+ ### macOS
89
+
90
+ The macOS backend uses `networksetup`, `ifconfig`, `route`, and `netstat`.
91
+ Loopback creation is implemented as an address alias on `lo0`, because macOS
92
+ does not create independent loopback NICs in the same way Linux creates dummy
93
+ interfaces.
94
+
95
+ ### Generic POSIX
96
+
97
+ For POSIX systems that are not Linux or macOS, the app uses a conservative
98
+ `ifconfig`/`route` fallback. Viewing should work on many Unix-like systems, but
99
+ some mutating operations are intentionally limited because network management
100
+ varies widely across BSDs and commercial Unix systems.
101
+
102
+ ## Configuration Snapshots
103
+
104
+ Exported files are JSON documents with this high-level shape:
105
+
106
+ ```json
107
+ {
108
+ "schema_version": 1,
109
+ "platform": "Windows",
110
+ "captured_at": "2026-06-17T02:00:00+00:00",
111
+ "adapters": [],
112
+ "routes": []
113
+ }
114
+ ```
115
+
116
+ When applying an imported snapshot, Py NIC Manager:
117
+
118
+ 1. Matches adapters by backend ID first, then by adapter name.
119
+ 2. Updates matched adapters with the saved IPv4, gateway, DNS, MAC, and DHCP
120
+ values where supported.
121
+ 3. Adds saved IPv4 routes.
122
+ 4. Shows skipped adapters and platform limitations in the command preview.
123
+
124
+ Applying a snapshot from another operating system is allowed only after a
125
+ warning and is best-effort.
126
+
127
+ ## Development
128
+
129
+ Run tests:
130
+
131
+ ```bash
132
+ python -m pytest -q
133
+ ```
134
+
135
+ Run a syntax check:
136
+
137
+ ```bash
138
+ python -m compileall py_nic_manager tests
139
+ ```
140
+
141
+ ## Safety
142
+
143
+ Network configuration changes can disconnect the machine, break DNS resolution,
144
+ or remove routes that are needed for remote access. Always review the command
145
+ preview before applying changes, and export a known-good snapshot before making
146
+ large edits.
147
+
@@ -0,0 +1,6 @@
1
+ """Cross-platform GUI network adapter manager."""
2
+
3
+ __all__ = ["__version__"]
4
+
5
+ __version__ = "0.1.0"
6
+
@@ -0,0 +1,6 @@
1
+ from .app import main
2
+
3
+
4
+ if __name__ == "__main__":
5
+ main()
6
+
@@ -0,0 +1,28 @@
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ import platform
5
+
6
+
7
+ def is_admin() -> bool:
8
+ try:
9
+ from is_admin_user import is_admin_user
10
+
11
+ return bool(is_admin_user())
12
+ except Exception:
13
+ return _fallback_is_admin()
14
+
15
+
16
+ def _fallback_is_admin() -> bool:
17
+ if platform.system().lower() == "windows":
18
+ try:
19
+ import ctypes
20
+
21
+ return bool(ctypes.windll.shell32.IsUserAnAdmin())
22
+ except Exception:
23
+ return False
24
+ geteuid = getattr(os, "geteuid", None)
25
+ if geteuid is None:
26
+ return False
27
+ return geteuid() == 0
28
+