Skip to content

Commit

Permalink
Add policy and DPSK queries and fields
Browse files Browse the repository at this point in the history
  • Loading branch information
ms264556 committed Oct 15, 2023
1 parent fe9f9d1 commit f746ce6
Show file tree
Hide file tree
Showing 5 changed files with 330 additions and 41 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ async def test_aioruckus():

#
# viewing configuration
# note: configuration functions resolve all related objects, so may be slower than stats functions
#
aps = await ruckus.get_aps()
ap_groups = await ruckus.get_ap_groups()
wlans = await ruckus.get_wlans()
wlan_groups = await ruckus.get_wlan_groups() # WLAN Groups are CLI-only on Unleashed
dpsks = await ruckus.get_dpsks()
mesh = await ruckus.get_mesh_info()
default_system_info = await ruckus.get_system_info()
all_system_info = await ruckus.get_system_info(SystemStat.ALL)
Expand Down
11 changes: 11 additions & 0 deletions aioruckus/abcsession.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ class ConfigItem(Enum):
MESH_LIST = "mesh-list"
ZTMESHSERIAL_LIST = "ztmeshSerial-list"
ACL_LIST = "acl-list"
DPSK_LIST = "dpsk-list"
ROLE_LIST = "role-list"
AVPPOLICY_LIST = "avppolicy-list"
AVPAPPLICATION_LIST = "avpapplication-list"
AVPPORT_LIST = "avpport-list"
PRECEDENCE_LIST = "precedence-list"
DEVICEPOLICY_LIST = "devicepolicy-list"
URLFILTERINGPOLICY_LIST = "urlfilteringpolicy-list"
URLFILTERINGCATEGORY_LIST = "urlfiltering-blockcategories-list"
POLICY_LIST = "policy-list"
POLICY6_LIST = "policy6-list"
SYSTEM = "system"

class AbcSession(ABC):
Expand Down
86 changes: 86 additions & 0 deletions aioruckus/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,89 @@ class WlanEncryption(Enum):
WPA2 = "wpa2"
WPA23_MIXED = "wpa23-mixed"
WPA3 = "wpa3"

DEFAULT_FILTER_BLOCKING_CATEGORIES = {
'1': 'Real Estate',
'2': 'Computer and Internet Security',
'3': 'Financial Services',
'4': 'Business and Economy',
'5': 'Computer and Internet Info',
'6': 'Auctions',
'7': 'Shopping',
'8': 'Cult and Occult',
'9': 'Travel',
'10': 'Abused Drugs',
'11': 'Adult and Pornography',
'12': 'Home and Garden',
'13': 'Military',
'14': 'Social Networking',
'15': 'Dead Sites',
'16': 'Stock and Advice Tools',
'17': 'Training and Tools',
'18': 'Dating',
'19': 'Sex Education',
'20': 'Religion',
'21': 'Entertainment and Arts',
'22': 'Personal sites and Blogs',
'23': 'Legal',
'24': 'Local Information',
'25': 'Streaming Media',
'26': 'Job Search',
'27': 'Gambling',
'28': 'Translation',
'29': 'Reference and Research',
'30': 'Shareware and Freeware',
'31': 'Peer to Peer',
'32': 'Marijuana',
'33': 'Hacking',
'34': 'Games',
'35': 'Philosophy and Political Advocacy',
'36': 'Weapons',
'37': 'Pay to Surf',
'38': 'Hunting and Fishing',
'39': 'Society',
'40': 'Educational Institutions',
'41': 'Online Greeting cards',
'42': 'Sports',
'43': 'Swimsuits & Intimate Apparel',
'44': 'Questionable',
'45': 'Kids',
'46': 'Hate and Racism',
'47': 'Personal Storage',
'48': 'Violence',
'49': 'Keyloggers and Monitoring',
'50': 'Search Engines',
'51': 'Internet Portals',
'52': 'Web Advertisements',
'53': 'Cheating',
'54': 'Gross',
'55': 'Web based Email',
'56': 'Malware Sites',
'57': 'Phishing and Other Frauds',
'58': 'Proxy Avoidance and Anonymizers',
'59': 'Spyware and Adware',
'60': 'Music',
'61': 'Government',
'62': 'Nudity',
'63': 'News and Media',
'64': 'Illegal',
'65': 'Content Delivery Networks',
'66': 'Internet Communications',
'67': 'Bot Nets',
'68': 'Abortion',
'69': 'Health and Medicine',
'70': 'Confirmed SPAM Sources',
'71': 'SPAM URLs',
'72': 'Unconfirmed SPAM Sources',
'73': 'Open HTTP Proxies',
'74': 'Dynamic Comment',
'75': 'Parked Domains',
'76': 'Alcohol and Tobacco',
'77': 'Private IP Addresses',
'78': 'Image and Video Search',
'79': 'Fashion and Beauty',
'80': 'Recreation and Hobbies',
'81': 'Motor Vehicles',
'82': 'Web Hosting',
'83': 'Food and Dining'
}
44 changes: 8 additions & 36 deletions aioruckus/ruckusajaxapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ async def get_wlan_group_stats(self) -> List:
"<wlangroup /></ajax-request>", ["wlangroup", "wlan"]
)

async def get_dpsk_stats(self) -> List:
"""Return a list of AP group statistics"""
return await self.cmdstat(
"<ajax-request action='getstat' comp='stamgr' enable-gzip='0'>"
"<dpsklist /></ajax-request>", ["dpsk"]
)

async def get_active_rogues(self) -> list[dict]:
"""Return a list of currently active rogue devices"""
return await self.cmdstat(
Expand Down Expand Up @@ -597,39 +604,4 @@ def _validate_passphrase(passphrase: str) -> str:
):
return passphrase
raise ValueError(ERROR_PASSPHRASE_LEN)

@staticmethod
def _normalize_conf_value(current_value: str, new_value: Any) -> str:
"""Normalize new_value format to match current_value"""
truthy_values = ("enable", "enabled", "true", "yes", "1")
falsy_values = ("disable", "disabled", "false", "no", "0")
normalization_map = {
"enable": ("ENABLE", "DISABLE"),
"disable": ("ENABLE", "DISABLE"),
"enabled": ("enabled", "disabled"),
"disabled": ("enabled", "disabled"),
"true": ("true", "false"),
"false": ("true", "false"),
"yes": ("yes", "no"),
"no": ("yes", "no"),
"1": ("1", "0"),
"0": ("1", "0"),
}
current_value_lowered = current_value.lower()
if current_value_lowered in normalization_map:
if isinstance(new_value, str):
new_value_lowered = new_value.lower()
if new_value_lowered in truthy_values:
new_value = True
elif new_value_lowered in falsy_values:
new_value = False
elif isinstance(new_value, (int, float)) and not isinstance(new_value, bool):
if new_value == 1:
new_value = True
elif new_value == 0:
new_value = False

if isinstance(new_value, bool):
true_value, false_value = normalization_map[current_value_lowered]
new_value = true_value if new_value else false_value
return new_value

Loading

0 comments on commit f746ce6

Please sign in to comment.