Debian Codegraph @

asusrouter/modules/endpoint/hook_const.py

raw
1 """Constants for hook endpoint module."""
2
3 # Network
4
5 from asusrouter.modules.connection import ConnectionState, ConnectionStatus
6 from asusrouter.modules.endpoint.wan import AsusDualWAN
7 from asusrouter.modules.ip_address import (
8 read_dns_ip_address,
9 read_ip_address_type,
10 )
11 from asusrouter.modules.openvpn import AsusOVPNServer
12 from asusrouter.modules.wireguard import AsusWireGuardServer
13 from asusrouter.tools.converters import (
14 safe_bool,
15 safe_int,
16 safe_list_csv,
17 safe_list_from_string,
18 )
19
20 MAP_NETWORK: dict[str, str] = {
21 "INTERNET": "wan",
22 "INTERNET1": "usb",
23 "WIRED": "wired",
24 "BRIDGE": "bridge",
25 "WIRELESS0": "2ghz",
26 "WIRELESS1": "5ghz",
27 "WIRELESS2": "5ghz2",
28 "WIRELESS3": "6ghz",
29 "LACP1": "lacp1",
30 "LACP2": "lacp2",
31 }
32
33 MAP_OVPN_SERVER_388 = (
34 ("vpn_server_unit", "unit", safe_int),
35 ("vpn_serverx_dns", "response_to_dns", safe_bool),
36 ("vpn_server_port", "port", safe_int),
37 ("vpn_server_tls_keysize", "tls_keysize", safe_int),
38 ("vpn_server_if", "interface"),
39 ("vpn_server_proto", "protocol"),
40 ("vpn_server_pdns", "advertise_dns", safe_bool),
41 ("vpn_server_cipher", "cipher"),
42 ("vpn_server_digest", "digest"),
43 ("vpn_server_comp", "compression"),
44 ("vpn_server_igncrt", "password_only", safe_bool),
45 ("vpn_server_crypt", "auth_mode"),
46 ("vpn_server_hmac", "hmac"),
47 ("vpn_server_sn", "subnet"),
48 ("vpn_server_nm", "netmask"),
49 ("vpn_server_dhcp", "dhcp", safe_bool),
50 ("vpn_server_r1", "server_r1"),
51 ("vpn_server_r2", "server_r2"),
52 ("vpn_server_local", "address"),
53 ("vpn_server_remote", "remote_address"),
54 ("vpn_server_plan", "allow_lan", safe_bool),
55 ("vpn_server_rgw", "allow_wan", safe_bool),
56 ("vpn_server_reneg", "tls_reneg", safe_int),
57 ("vpn_server_ccd", "client_specific_config", safe_bool),
58 ("vpn_server_c2c", "client_to_client", safe_bool),
59 ("vpn_server_ccd_excl", "allow_specific_clients", safe_bool),
60 ("vpn_server_ccd_val", "specific_clients"),
61 ("vpn_serverx_clientlist", "clients"),
62 ("VPNServer_enable", "state", [safe_int, AsusOVPNServer]),
63 )
64
65 MAP_SPEEDTEST = (
66 ("ookla_state", "state", safe_int),
67 ("ookla_speedtest_get_history", "history"),
68 ("ookla_speedtest_get_servers", "servers"),
69 ("ookla_speedtest_get_result", "result"),
70 )
71
72 MAP_WAN = (
73 ("get_wan_unit", "unit", safe_int),
74 ("link_internet", "link", [safe_int, ConnectionStatus]),
75 ("link_wan", "link_0", [safe_int, ConnectionState]),
76 ("link_wan1", "link_1", [safe_int, ConnectionState]),
77 ("wans_mode", "dualwan_mode", AsusDualWAN),
78 ("wans_dualwan", "dualwan_priority", safe_list_from_string),
79 ("bond_wan", "aggregation_state", safe_bool),
80 ("wanports_bond", "aggregation_ports", safe_list_from_string),
81 )
82
83 MAP_WAN_ITEM = (
84 ("auxstate_t", "auxstate", [safe_int, ConnectionStatus]),
85 ("primary", "primary", safe_bool),
86 ("proto", "protocol", read_ip_address_type),
87 ("realip_ip", "real_ip"),
88 ("realip_state", "real_ip_state", safe_bool),
89 ("state_t", "state", [safe_int, ConnectionStatus]),
90 ("sbstate_t", "bstate", [safe_int, ConnectionStatus]),
91 )
92
93 MAP_WAN_ITEM_X = (
94 ("dns", "dns", read_dns_ip_address),
95 ("expires", "expires", safe_int),
96 ("gateway", "gateway"),
97 ("ipaddr", "ip_address"),
98 ("lease", "lease", safe_int),
99 ("netmask", "mask"),
100 )
101
102 MAP_WIREGUARD_SERVER = (
103 ("wgs_enable", "state", [safe_int, AsusWireGuardServer]),
104 ("wgs_lanaccess", "lan_access", safe_bool),
105 ("wgs_addr", "address"),
106 ("wgs_port", "port", safe_int),
107 ("wgs_dns", "dns", safe_bool),
108 ("wgs_nat6", "nat6", safe_bool),
109 ("wgs_psk", "psk", safe_bool),
110 ("wgs_alive", "keep_alive", safe_int),
111 ("wgs_priv", "private_key"),
112 ("wgs_pub", "public_key"),
113 ("get_wgsc_status", "status"),
114 )
115
116 MAP_WIREGUARD_CLIENT = (
117 ("enable", "enabled", safe_bool),
118 ("name", "name"),
119 ("addr", "address"),
120 ("aips", "allowed_ips", safe_list_csv),
121 ("caips", "client_allowed_ips", safe_list_csv),
122 )
123
124 MAP_VPNC_WIREGUARD = (
125 ("enable", "state", safe_bool),
126 ("nat", "nat", safe_bool),
127 ("priv", "private_key"),
128 ("addr", "address"),
129 ("dns", "dns", safe_bool),
130 ("mtu", "mtu", safe_int),
131 ("ppub", "public_key"),
132 ("psk", "psk"),
133 ("aips", "allowed_ips", safe_list_csv),
134 ("ep_addr", "endpoint_address"),
135 ("ep_port", "endpoint_port", safe_int),
136 ("alive", "keep_alive", safe_int),
137 )