ns2 0.2.6__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.
- ns2-0.2.6/PKG-INFO +78 -0
- ns2-0.2.6/pyproject.toml +98 -0
- ns2-0.2.6/src/ns2/__init__.py +0 -0
- ns2-0.2.6/src/ns2/core.py +0 -0
- ns2-0.2.6/src/ns2/dbus/__init__.py +0 -0
- ns2-0.2.6/src/ns2/dbus/dbus.py +13 -0
- ns2-0.2.6/src/ns2/lib/__init__.py +0 -0
- ns2-0.2.6/src/ns2/lib/accounts.py +130 -0
- ns2-0.2.6/src/ns2/lib/commands.py +32 -0
- ns2-0.2.6/src/ns2/lib/firewalld.py +167 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.fedoraproject.FirewallD1.config.xml +3 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.fedoraproject.FirewallD1.xml +763 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.AccessPoint.xml +106 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.AgentManager.xml +43 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Checkpoint.xml +36 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Connection.Active.xml +185 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.DHCP4Config.xml +21 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.DHCP6Config.xml +20 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Device.Adsl.xml +21 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Device.Bluetooth.xml +36 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Device.Bond.xml +40 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Device.Bridge.xml +41 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Device.Dummy.xml +20 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Device.Generic.xml +27 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Device.Hsr.xml +51 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Device.IPTunnel.xml +107 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Device.Infiniband.xml +31 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Device.Ipvlan.xml +38 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Device.Loopback.xml +8 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Device.Lowpan.xml +27 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Device.Macsec.xml +109 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Device.Macvlan.xml +39 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Device.Modem.xml +62 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Device.OlpcMesh.xml +34 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Device.OvsBridge.xml +21 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Device.OvsInterface.xml +11 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Device.OvsPort.xml +21 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Device.Ppp.xml +11 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Device.Statistics.xml +35 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Device.Team.xml +48 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Device.Tun.xml +65 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Device.Veth.xml +18 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Device.Vlan.xml +45 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Device.Vrf.xml +18 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Device.Vxlan.xml +139 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Device.WiMax.xml +109 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Device.WifiP2P.xml +76 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Device.WireGuard.xml +38 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Device.Wired.xml +53 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Device.Wireless.xml +131 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Device.Wpan.xml +20 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Device.xml +407 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.DnsManager.xml +40 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.IP4Config.xml +125 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.IP6Config.xml +95 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.PPP.xml +34 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.SecretAgent.xml +94 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Settings.Connection.xml +224 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.Settings.xml +233 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.VPN.Connection.xml +42 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.VPN.Plugin.xml +204 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.WiMax.Nsp.xml +35 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.WifiP2PPeer.xml +91 -0
- ns2-0.2.6/src/ns2/lib/introspection/org.freedesktop.NetworkManager.xml +598 -0
- ns2-0.2.6/src/ns2/lib/lib.py +0 -0
- ns2-0.2.6/src/ns2/lib/network_delay.py +92 -0
- ns2-0.2.6/src/ns2/lib/networking.py +528 -0
- ns2-0.2.6/src/ns2/lib/ntl.py +188 -0
- ns2-0.2.6/src/ns2/lib/pam_client.py +37 -0
- ns2-0.2.6/src/ns2/lib/ping_data_collector.py +37 -0
- ns2-0.2.6/src/ns2/lib/snmp.py +511 -0
- ns2-0.2.6/src/ns2/lib/socket.py +132 -0
- ns2-0.2.6/src/ns2/lib/socket_client.py +62 -0
- ns2-0.2.6/src/ns2/lib/systemd.py +151 -0
- ns2-0.2.6/src/ns2/lib/test.py +374 -0
- ns2-0.2.6/src/ns2/lib/udp_client.py +227 -0
- ns2-0.2.6/src/ns2/lib/udp_server.py +167 -0
- ns2-0.2.6/src/ns2/snmp/__init__.py +0 -0
- ns2-0.2.6/src/ns2/snmp/ns_dbus_service.py +38 -0
- ns2-0.2.6/src/ns2/snmp/pam_interface.py +19 -0
- ns2-0.2.6/src/ns2/snmp/snmp_interface.py +66 -0
- ns2-0.2.6/src/ns2/ui/__init__.py +0 -0
- ns2-0.2.6/src/ns2/ui/assets/NOVUS_LOGO.svg +105 -0
- ns2-0.2.6/src/ns2/ui/assets/favicon.png +0 -0
- ns2-0.2.6/src/ns2/ui/firewalld_page.py +375 -0
- ns2-0.2.6/src/ns2/ui/fpga_page.py +24 -0
- ns2-0.2.6/src/ns2/ui/login.py +65 -0
- ns2-0.2.6/src/ns2/ui/main.py +200 -0
- ns2-0.2.6/src/ns2/ui/networking_page.py +406 -0
- ns2-0.2.6/src/ns2/ui/ntp.py +105 -0
- ns2-0.2.6/src/ns2/ui/root.py +31 -0
- ns2-0.2.6/src/ns2/ui/snmp_page.py +353 -0
- ns2-0.2.6/src/ns2/ui/terminal.py +65 -0
- ns2-0.2.6/src/ns2/ui/tests_page.py +116 -0
- ns2-0.2.6/src/ns2/ui/theme.py +25 -0
- ns2-0.2.6/src/ns2/utils.py +5 -0
ns2-0.2.6/PKG-INFO
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ns2
|
|
3
|
+
Version: 0.2.6
|
|
4
|
+
Summary: Novus Power Products server configuration tool
|
|
5
|
+
License: MIT
|
|
6
|
+
Author: jowens25
|
|
7
|
+
Author-email: jowens@novuspower.com
|
|
8
|
+
Requires-Python: >=3.10,<4.0
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
16
|
+
Requires-Dist: aiofiles
|
|
17
|
+
Requires-Dist: aiohappyeyeballs
|
|
18
|
+
Requires-Dist: aiohttp
|
|
19
|
+
Requires-Dist: aiosignal
|
|
20
|
+
Requires-Dist: annotated-doc
|
|
21
|
+
Requires-Dist: annotated-types
|
|
22
|
+
Requires-Dist: anyio
|
|
23
|
+
Requires-Dist: attrs
|
|
24
|
+
Requires-Dist: beautifulsoup4
|
|
25
|
+
Requires-Dist: bidict
|
|
26
|
+
Requires-Dist: bs4
|
|
27
|
+
Requires-Dist: certifi
|
|
28
|
+
Requires-Dist: charset-normalizer
|
|
29
|
+
Requires-Dist: click
|
|
30
|
+
Requires-Dist: dbus-next
|
|
31
|
+
Requires-Dist: docutils
|
|
32
|
+
Requires-Dist: fastapi
|
|
33
|
+
Requires-Dist: frozenlist
|
|
34
|
+
Requires-Dist: h11
|
|
35
|
+
Requires-Dist: httpcore
|
|
36
|
+
Requires-Dist: httptools
|
|
37
|
+
Requires-Dist: httpx
|
|
38
|
+
Requires-Dist: idna
|
|
39
|
+
Requires-Dist: ifaddr
|
|
40
|
+
Requires-Dist: itsdangerous
|
|
41
|
+
Requires-Dist: jinja2
|
|
42
|
+
Requires-Dist: markdown2
|
|
43
|
+
Requires-Dist: markupsafe
|
|
44
|
+
Requires-Dist: multidict
|
|
45
|
+
Requires-Dist: narwhals
|
|
46
|
+
Requires-Dist: nicegui
|
|
47
|
+
Requires-Dist: numpy
|
|
48
|
+
Requires-Dist: orjson
|
|
49
|
+
Requires-Dist: packaging
|
|
50
|
+
Requires-Dist: pam
|
|
51
|
+
Requires-Dist: pandas
|
|
52
|
+
Requires-Dist: plotly
|
|
53
|
+
Requires-Dist: propcache
|
|
54
|
+
Requires-Dist: pydantic
|
|
55
|
+
Requires-Dist: pydantic-core
|
|
56
|
+
Requires-Dist: pygments
|
|
57
|
+
Requires-Dist: pyinstaller
|
|
58
|
+
Requires-Dist: python-dateutil
|
|
59
|
+
Requires-Dist: python-dotenv
|
|
60
|
+
Requires-Dist: python-engineio
|
|
61
|
+
Requires-Dist: python-multipart
|
|
62
|
+
Requires-Dist: python-pam
|
|
63
|
+
Requires-Dist: python-socketio
|
|
64
|
+
Requires-Dist: pyyaml
|
|
65
|
+
Requires-Dist: requests
|
|
66
|
+
Requires-Dist: simple-websocket
|
|
67
|
+
Requires-Dist: six
|
|
68
|
+
Requires-Dist: soupsieve
|
|
69
|
+
Requires-Dist: typing-extensions
|
|
70
|
+
Requires-Dist: typing-inspection
|
|
71
|
+
Requires-Dist: urllib3
|
|
72
|
+
Requires-Dist: uvicorn
|
|
73
|
+
Requires-Dist: uvloop
|
|
74
|
+
Requires-Dist: watchfiles
|
|
75
|
+
Requires-Dist: websockets
|
|
76
|
+
Requires-Dist: wheel2deb
|
|
77
|
+
Requires-Dist: wsproto
|
|
78
|
+
Requires-Dist: yarl
|
ns2-0.2.6/pyproject.toml
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "ns2"
|
|
3
|
+
version = "0.2.6"
|
|
4
|
+
description = "Novus Power Products server configuration tool"
|
|
5
|
+
authors = [
|
|
6
|
+
{name = "jowens25",email = "jowens@novuspower.com"}
|
|
7
|
+
]
|
|
8
|
+
license = {text = "MIT"}
|
|
9
|
+
requires-python = ">=3.10,<4.0"
|
|
10
|
+
|
|
11
|
+
dependencies = [
|
|
12
|
+
"aiofiles",
|
|
13
|
+
"aiohappyeyeballs",
|
|
14
|
+
"aiohttp",
|
|
15
|
+
"aiosignal",
|
|
16
|
+
"annotated-doc",
|
|
17
|
+
"annotated-types",
|
|
18
|
+
"anyio",
|
|
19
|
+
"attrs",
|
|
20
|
+
"beautifulsoup4",
|
|
21
|
+
"bidict",
|
|
22
|
+
"bs4",
|
|
23
|
+
"certifi",
|
|
24
|
+
"charset-normalizer",
|
|
25
|
+
"click",
|
|
26
|
+
"dbus-next",
|
|
27
|
+
"docutils",
|
|
28
|
+
"fastapi",
|
|
29
|
+
"frozenlist",
|
|
30
|
+
"h11",
|
|
31
|
+
"httpcore",
|
|
32
|
+
"httptools",
|
|
33
|
+
"httpx",
|
|
34
|
+
"idna",
|
|
35
|
+
"ifaddr",
|
|
36
|
+
"itsdangerous",
|
|
37
|
+
"jinja2",
|
|
38
|
+
"markdown2",
|
|
39
|
+
"markupsafe",
|
|
40
|
+
"multidict",
|
|
41
|
+
"narwhals",
|
|
42
|
+
"nicegui",
|
|
43
|
+
"numpy",
|
|
44
|
+
"orjson",
|
|
45
|
+
"packaging",
|
|
46
|
+
"pam",
|
|
47
|
+
"pandas",
|
|
48
|
+
"plotly",
|
|
49
|
+
"propcache",
|
|
50
|
+
"pydantic",
|
|
51
|
+
"pydantic-core",
|
|
52
|
+
"pygments",
|
|
53
|
+
"python-dateutil",
|
|
54
|
+
"python-dotenv",
|
|
55
|
+
"python-engineio",
|
|
56
|
+
"python-multipart",
|
|
57
|
+
"python-pam",
|
|
58
|
+
"python-socketio",
|
|
59
|
+
"pyinstaller",
|
|
60
|
+
"pyyaml",
|
|
61
|
+
"requests",
|
|
62
|
+
"simple-websocket",
|
|
63
|
+
"six",
|
|
64
|
+
"soupsieve",
|
|
65
|
+
"typing-inspection",
|
|
66
|
+
"typing-extensions",
|
|
67
|
+
"urllib3",
|
|
68
|
+
"uvicorn",
|
|
69
|
+
"uvloop",
|
|
70
|
+
"watchfiles",
|
|
71
|
+
"websockets",
|
|
72
|
+
"wheel2deb",
|
|
73
|
+
"wsproto",
|
|
74
|
+
"yarl",
|
|
75
|
+
]
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
[build-system]
|
|
80
|
+
requires = ["poetry-core>=2.0.0,<3.0.0"]
|
|
81
|
+
build-backend = "poetry.core.masonry.api"
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
[project.scripts]
|
|
86
|
+
ns = "ns.ui.main:main"
|
|
87
|
+
|
|
88
|
+
[tool.setuptools.packages.find]
|
|
89
|
+
where = ["src"]
|
|
90
|
+
|
|
91
|
+
[tool.setuptools.package-data]
|
|
92
|
+
ns = [
|
|
93
|
+
"ui/assets/**/*",
|
|
94
|
+
"lib/introspection/**/*"
|
|
95
|
+
]
|
|
96
|
+
|
|
97
|
+
[tool.setuptools]
|
|
98
|
+
include-package-data = true
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from dbus_next import BusType
|
|
2
|
+
from dbus_next.aio import MessageBus
|
|
3
|
+
|
|
4
|
+
global AppBus
|
|
5
|
+
|
|
6
|
+
async def setup():
|
|
7
|
+
global AppBus
|
|
8
|
+
AppBus = await MessageBus(bus_type=BusType.SYSTEM).connect()
|
|
9
|
+
|
|
10
|
+
async def cleanup():
|
|
11
|
+
global AppBus
|
|
12
|
+
AppBus.disconnect()
|
|
13
|
+
|
|
File without changes
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
from dataclasses import asdict, dataclass
|
|
2
|
+
from typing import Optional
|
|
3
|
+
from nicegui import ui, app
|
|
4
|
+
|
|
5
|
+
@dataclass
|
|
6
|
+
class SystemAccount:
|
|
7
|
+
Name: Optional[str] = None
|
|
8
|
+
PrimaryId: Optional[str] = None
|
|
9
|
+
SecondaryId: Optional[str] = None
|
|
10
|
+
Info: Optional[str] = None
|
|
11
|
+
Home: Optional[str] = None
|
|
12
|
+
Shell: Optional[str] = None
|
|
13
|
+
|
|
14
|
+
@dataclass
|
|
15
|
+
class SystemGroup:
|
|
16
|
+
Name: Optional[str] = None
|
|
17
|
+
Id: Optional[str] = None
|
|
18
|
+
NumLocalUsers : Optional[str] = None
|
|
19
|
+
LocalUsers : Optional[str] = None
|
|
20
|
+
|
|
21
|
+
def ReadPasswordsFile() -> list[SystemAccount]:
|
|
22
|
+
accounts = []
|
|
23
|
+
with open("/etc/passwd", "r") as f:
|
|
24
|
+
content = f.readlines()
|
|
25
|
+
for i, line in enumerate(content):
|
|
26
|
+
if ":" in line:
|
|
27
|
+
fields = line.split(":")
|
|
28
|
+
name = fields[0]
|
|
29
|
+
primaryId = fields[2]
|
|
30
|
+
secondaryId = fields[3]
|
|
31
|
+
info = fields[4]
|
|
32
|
+
home = fields[5]
|
|
33
|
+
shell = fields[6]
|
|
34
|
+
a = SystemAccount(name, primaryId, secondaryId, info, home, shell)
|
|
35
|
+
accounts.append(a)
|
|
36
|
+
pass #endfor
|
|
37
|
+
|
|
38
|
+
return accounts
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def ReadGroupFile() -> list[SystemGroup]:
|
|
42
|
+
groups = []
|
|
43
|
+
with open("/etc/group") as f:
|
|
44
|
+
content = f.readlines()
|
|
45
|
+
|
|
46
|
+
for i, line in enumerate(content):
|
|
47
|
+
if ":" in line:
|
|
48
|
+
fields = line.split(":")
|
|
49
|
+
name = fields[0]
|
|
50
|
+
id = fields[2]
|
|
51
|
+
accounts = fields[3].strip("\n")
|
|
52
|
+
num = len(accounts.split(","))
|
|
53
|
+
g = SystemGroup(name, id, num, accounts)
|
|
54
|
+
groups.append(g)
|
|
55
|
+
pass #endfor
|
|
56
|
+
|
|
57
|
+
return groups
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def CombineGroupsAndAccounts():
|
|
61
|
+
accounts = ReadPasswordsFile()
|
|
62
|
+
groups = ReadGroupFile()
|
|
63
|
+
|
|
64
|
+
newgroups = []
|
|
65
|
+
for g in groups:
|
|
66
|
+
for a in accounts:
|
|
67
|
+
if g.Id == a.SecondaryId:
|
|
68
|
+
g.NumLocalUsers += 1
|
|
69
|
+
g.LocalUsers += f",{a.Name}"
|
|
70
|
+
|
|
71
|
+
newgroups.append(g)
|
|
72
|
+
|
|
73
|
+
return newgroups
|
|
74
|
+
|
|
75
|
+
def GetCombinedDict():
|
|
76
|
+
return [asdict(i) for i in CombineGroupsAndAccounts()]
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def GetGroupDict():
|
|
81
|
+
return [asdict(i) for i in ReadGroupFile()]
|
|
82
|
+
|
|
83
|
+
def GetAccountsDict():
|
|
84
|
+
return [asdict(i) for i in ReadPasswordsFile()]
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
async def accounts_user_page(user: str):
|
|
89
|
+
#ui.label("User Configuration").classes("text-h5")
|
|
90
|
+
ui.label(user).classes("text-h5")
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
async def accounts_page():
|
|
94
|
+
"""user page content"""
|
|
95
|
+
|
|
96
|
+
ui.label("User Configuration").classes("text-h5")
|
|
97
|
+
|
|
98
|
+
#table("Groups", GetCombinedDict(), "Name", add_group_dialog(), "Name,Id,NumLocalUsers,LocalUsers") # Only show these
|
|
99
|
+
#ui.table("Groups", , "Name", add_group_dialog(), "Name,PrimaryId,SecondaryId,Info,Home,Shell") # Only show these
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
with ui.dialog() as asGroupDialog:
|
|
103
|
+
with ui.card():
|
|
104
|
+
ui.label("test")
|
|
105
|
+
ui.input("name")
|
|
106
|
+
ui.input("id")
|
|
107
|
+
ui.button("create")
|
|
108
|
+
ui.button("cancel")
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
table = ui.table(
|
|
113
|
+
title="Groups",
|
|
114
|
+
rows=GetAccountsDict(),
|
|
115
|
+
column_defaults={
|
|
116
|
+
"align": "left",
|
|
117
|
+
"headerClasses": "uppercase text-primary",
|
|
118
|
+
},
|
|
119
|
+
).classes("w-full")
|
|
120
|
+
|
|
121
|
+
table.add_slot(f'body-cell-Name', f''' <q-td :props="props">
|
|
122
|
+
<a :href="'/accounts/'+ props.row.Name" class="text-accent cursor-pointer hover:underline"> {{{{ props.value }}}} </a>
|
|
123
|
+
</q-td> ''')
|
|
124
|
+
|
|
125
|
+
table.props(f'visible-columns={"Name,PrimaryId,SecondaryId,Info,Home,Shell"}') # Only show these
|
|
126
|
+
|
|
127
|
+
with table.add_slot('top-right'):
|
|
128
|
+
ui.button(icon="add", on_click = asGroupDialog.open).props(
|
|
129
|
+
"flat color=accent align=left").classes("w-full").props("dense")
|
|
130
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
import subprocess
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
#def runCmd(args: list[str]) -> tuple[str, str]:
|
|
8
|
+
# print(f"running: {args}")
|
|
9
|
+
# result = subprocess.run(args, capture_output=True, text=True)
|
|
10
|
+
# return result.stdout
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
async def runCmd(args: list[str]) -> str:
|
|
14
|
+
print(f"running: {args}")
|
|
15
|
+
process = await asyncio.create_subprocess_exec(
|
|
16
|
+
*args,
|
|
17
|
+
stdout=asyncio.subprocess.PIPE,
|
|
18
|
+
stderr=asyncio.subprocess.PIPE
|
|
19
|
+
)
|
|
20
|
+
stdout, stderr = await process.communicate()
|
|
21
|
+
return stdout.decode()
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
async def runAsyncCmd(args: list[str]) -> str:
|
|
25
|
+
print(f"running: {args}")
|
|
26
|
+
process = await asyncio.create_subprocess_exec(
|
|
27
|
+
*args,
|
|
28
|
+
stdout=asyncio.subprocess.PIPE,
|
|
29
|
+
stderr=asyncio.subprocess.PIPE
|
|
30
|
+
)
|
|
31
|
+
stdout, stderr = await process.communicate()
|
|
32
|
+
return stdout.decode()
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
from dataclasses import asdict, field
|
|
3
|
+
from pprint import pprint
|
|
4
|
+
from typing import List, Optional
|
|
5
|
+
from nicegui import ui, app, binding
|
|
6
|
+
from ns.lib.commands import runCmd
|
|
7
|
+
from ns.ui.theme import init_colors
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
from dbus_next.signature import Variant
|
|
11
|
+
from dbus_next.errors import DBusError
|
|
12
|
+
from dbus_next.aio.proxy_object import ProxyInterface
|
|
13
|
+
from dbus_next.aio import MessageBus
|
|
14
|
+
from ns.dbus import dbus
|
|
15
|
+
from ns.utils import INTROSPECTION_DIR
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@binding.bindable_dataclass
|
|
19
|
+
class ServiceSetting:
|
|
20
|
+
Version: Optional[str] = ''
|
|
21
|
+
Name: Optional[str] = ''
|
|
22
|
+
Description: Optional[str] = ''
|
|
23
|
+
Ports: Optional[list[str]] = field(default_factory=list)
|
|
24
|
+
ModuleNames: Optional[list[str]] = field(default_factory=list)
|
|
25
|
+
Destinations: Optional[dict] = field(default_factory=dict)
|
|
26
|
+
Protocols: Optional[list[str]] = field(default_factory=list)
|
|
27
|
+
SourcePorts: Optional[list[str]] = field(default_factory=list)
|
|
28
|
+
Includes: Optional[list[str]] = field(default_factory=list)
|
|
29
|
+
Helpers: Optional[list[str]] = field(default_factory=list)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@binding.bindable_dataclass
|
|
33
|
+
class ZoneSetting:
|
|
34
|
+
Description: Optional[str] = ''
|
|
35
|
+
Interfaces: Optional[list[str]] = field(default_factory=list)
|
|
36
|
+
Services: Optional[list[str]] = field(default_factory=list)
|
|
37
|
+
Short: Optional[str] = ''
|
|
38
|
+
ServiceSettings: Optional[dict[ServiceSetting]] = field(default_factory=dict)
|
|
39
|
+
Sources: Optional[list[str]] = field(default_factory=list)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
@binding.bindable_dataclass
|
|
43
|
+
class Firewall:
|
|
44
|
+
Enable: Optional[bool] = False
|
|
45
|
+
Status: Optional[str] = ''
|
|
46
|
+
ActiveZones: Optional[dict[dict]] = field(default_factory=dict)
|
|
47
|
+
AllowedAddresses: Optional[list[str]] = field(default_factory=list)
|
|
48
|
+
Services: Optional[dict[dict]] = field(default_factory=dict)
|
|
49
|
+
ZoneSettings: Optional[dict[ZoneSetting]] = field(default_factory=dict)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
async def GetFirewalld(bus: MessageBus):
|
|
53
|
+
file_name = 'org.fedoraproject.FirewallD1.config.xml'
|
|
54
|
+
introspection = await bus.introspect('org.fedoraproject.FirewallD1', '/org/fedoraproject/FirewallD1')
|
|
55
|
+
#pprint(introspection.tostring())
|
|
56
|
+
obj = bus.get_proxy_object('org.fedoraproject.FirewallD1', '/org/fedoraproject/FirewallD1', introspection)
|
|
57
|
+
return obj.get_interface('org.fedoraproject.FirewallD1')
|
|
58
|
+
|
|
59
|
+
async def GetFirewalldConfig(bus: MessageBus):
|
|
60
|
+
file_name = 'org.fedoraproject.FirewallD1.config.xml'
|
|
61
|
+
introspection = await bus.introspect('org.fedoraproject.FirewallD1', '/org/fedoraproject/FirewallD1/config')
|
|
62
|
+
#pprint(introspection.tostring())
|
|
63
|
+
obj = bus.get_proxy_object('org.fedoraproject.FirewallD1', '/org/fedoraproject/FirewallD1/config', introspection)
|
|
64
|
+
return obj.get_interface('org.fedoraproject.FirewallD1.config')
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
async def GetFirewalldConfigZone(bus: MessageBus, path : str):
|
|
69
|
+
introspection = await bus.introspect('org.fedoraproject.FirewallD1', path)
|
|
70
|
+
obj = bus.get_proxy_object('org.fedoraproject.FirewallD1', path, introspection)
|
|
71
|
+
return obj.get_interface('org.fedoraproject.FirewallD1.config.zone')
|
|
72
|
+
|
|
73
|
+
#def GetDevice(bus: MessageBus, path : str):
|
|
74
|
+
# file_name = 'org.freedesktop.NetworkManager.Device.xml'
|
|
75
|
+
# with open(str(INTROSPECTION_DIR /file_name), "r") as f:
|
|
76
|
+
# introspection = f.read()
|
|
77
|
+
# obj = bus.get_proxy_object('org.freedesktop.NetworkManager', path, introspection)
|
|
78
|
+
# return obj.get_interface('org.freedesktop.NetworkManager.Device')
|
|
79
|
+
|
|
80
|
+
async def GetFirewalldZone(bus: MessageBus):
|
|
81
|
+
file_name = 'org.fedoraproject.FirewallD1.zone.xml'
|
|
82
|
+
introspection = await bus.introspect('org.fedoraproject.FirewallD1', '/org/fedoraproject/FirewallD1')
|
|
83
|
+
#pprint(introspection.tostring())
|
|
84
|
+
obj = bus.get_proxy_object('org.fedoraproject.FirewallD1', '/org/fedoraproject/FirewallD1', introspection)
|
|
85
|
+
return obj.get_interface('org.fedoraproject.FirewallD1.zone')
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def formatListToString(elements: list[str]) -> str:
|
|
91
|
+
if len(elements) == 0:
|
|
92
|
+
return None
|
|
93
|
+
return ', '.join(elements) if elements else ''
|
|
94
|
+
|
|
95
|
+
def getZoneInfo(name :str, zone :dict) -> dict:
|
|
96
|
+
|
|
97
|
+
interfaces = formatListToString(zone.get('interfaces', []))
|
|
98
|
+
sources = formatListToString(zone.get('sources', []))
|
|
99
|
+
|
|
100
|
+
return {'name':name, 'interfaces':interfaces, 'sources':sources}
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
async def getServices(bus: MessageBus):
|
|
104
|
+
'''all not just runtime'''
|
|
105
|
+
|
|
106
|
+
fire = await GetFirewalld(bus)
|
|
107
|
+
|
|
108
|
+
conf = await GetFirewalldConfig(bus)
|
|
109
|
+
serviceNames = await conf.call_get_service_names()
|
|
110
|
+
services = {}
|
|
111
|
+
for name in serviceNames:
|
|
112
|
+
s = ServiceSetting()
|
|
113
|
+
s.Name = name
|
|
114
|
+
serviceSettings = await fire.call_get_service_settings2(s.Name)
|
|
115
|
+
|
|
116
|
+
includes = serviceSettings.get('includes', False)
|
|
117
|
+
if includes:
|
|
118
|
+
for i in includes.value:
|
|
119
|
+
ser_set = await fire.call_get_service_settings2(i)
|
|
120
|
+
s.Ports.extend(ser_set.get('ports', Variant('a(ss)', [['port not available', 'protocol not available']])).value)
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
s.Name = serviceSettings.get('short', Variant('s', 'name not available')).value
|
|
124
|
+
s.Ports.extend(serviceSettings.get('ports', Variant('a(ss)', [['port not available', 'protocol not available']])).value)
|
|
125
|
+
s.Description = serviceSettings.get('description', Variant('s', 'Description not available')).value
|
|
126
|
+
|
|
127
|
+
services[name] = s
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
return services
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def getUdpPorts(ports) -> list:
|
|
135
|
+
out = []
|
|
136
|
+
for p in ports:
|
|
137
|
+
if p[1]=='udp':
|
|
138
|
+
out.append(p[0])
|
|
139
|
+
|
|
140
|
+
return formatListToString(out)
|
|
141
|
+
|
|
142
|
+
def getTcpPorts(ports) -> list:
|
|
143
|
+
out = []
|
|
144
|
+
for p in ports:
|
|
145
|
+
if p[1]=='tcp':
|
|
146
|
+
out.append(p[0])
|
|
147
|
+
|
|
148
|
+
return formatListToString(out)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def formatServicesInRows(serviceSettings :dict):
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
rows = []
|
|
156
|
+
for n, s in serviceSettings.items():
|
|
157
|
+
rows.append({
|
|
158
|
+
#"Select": False,
|
|
159
|
+
"Service": n
|
|
160
|
+
,"UDP": getUdpPorts(s.Ports)
|
|
161
|
+
,"TCP": getTcpPorts(s.Ports)
|
|
162
|
+
,"Description": s.Description
|
|
163
|
+
#,"remove": ''
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
#pprint(rows)
|
|
167
|
+
return rows
|