(20250225) Safetyu Pusj
This commit is contained in:
@@ -2298,41 +2298,41 @@ if __name__ == "__main__":
|
||||
|
||||
await logs_mongo.connect()
|
||||
|
||||
api_response = await my_mikrotik.list_system_resources()
|
||||
print("SYS RESOURCES:", json.to_string(api_response.data))
|
||||
|
||||
api_response = await my_mikrotik.list_interfaces()
|
||||
print(f"INTERFACES ({len(api_response.data)}):", json.to_string(api_response.data))
|
||||
|
||||
api_response = await my_mikrotik.list_vlans()
|
||||
print(f"VLANS ({len(api_response.data)}):", json.to_string(api_response.data))
|
||||
|
||||
api_response = await my_mikrotik.list_ip_pools()
|
||||
print(f"IP POOLS ({len(api_response.data)}):", json.to_string(api_response.data))
|
||||
|
||||
api_response = await my_mikrotik.list_ppp_profiles()
|
||||
print(f"PPP PROFILES ({len(api_response.data)}):", json.to_string(api_response.data))
|
||||
|
||||
api_response = await my_mikrotik.list_ppp_servers()
|
||||
print(f"PPP SERVERS ({len(api_response.data)}):", json.to_string(api_response.data))
|
||||
|
||||
api_response = await my_mikrotik.list_hotspot_profiles()
|
||||
print(f"HOTSPOT PROFILES ({len(api_response.data)}):", json.to_string(api_response.data))
|
||||
|
||||
api_response = await my_mikrotik.list_hotspot_servers()
|
||||
print(f"HOTSPOT SERVERS ({len(api_response.data)}):", json.to_string(api_response.data))
|
||||
|
||||
# api_response = await my_mikrotik.list_system_resources()
|
||||
# print("SYS RESOURCES:", json.to_string(api_response.data))
|
||||
#
|
||||
# api_response = await my_mikrotik.list_interfaces()
|
||||
# print(f"INTERFACES ({len(api_response.data)}):", json.to_string(api_response.data))
|
||||
#
|
||||
# api_response = await my_mikrotik.list_vlans()
|
||||
# print(f"VLANS ({len(api_response.data)}):", json.to_string(api_response.data))
|
||||
#
|
||||
# api_response = await my_mikrotik.list_ip_pools()
|
||||
# print(f"IP POOLS ({len(api_response.data)}):", json.to_string(api_response.data))
|
||||
#
|
||||
# api_response = await my_mikrotik.list_ppp_profiles()
|
||||
# print(f"PPP PROFILES ({len(api_response.data)}):", json.to_string(api_response.data))
|
||||
#
|
||||
# api_response = await my_mikrotik.list_ppp_servers()
|
||||
# print(f"PPP SERVERS ({len(api_response.data)}):", json.to_string(api_response.data))
|
||||
#
|
||||
# api_response = await my_mikrotik.list_hotspot_profiles()
|
||||
# print(f"HOTSPOT PROFILES ({len(api_response.data)}):", json.to_string(api_response.data))
|
||||
#
|
||||
# api_response = await my_mikrotik.list_hotspot_servers()
|
||||
# print(f"HOTSPOT SERVERS ({len(api_response.data)}):", json.to_string(api_response.data))
|
||||
#
|
||||
api_response = await my_mikrotik.list_hotspot_walled_gardens()
|
||||
print(f"HOTSPOT WALLED GARDENS ({len(api_response.data)}):", json.to_string(api_response.data))
|
||||
|
||||
api_response = await my_mikrotik.list_hotspot_walled_garden_ips()
|
||||
print(f"HOTSPOT WALLED GARDEN IPS ({len(api_response.data)}):", json.to_string(api_response.data))
|
||||
|
||||
api_response = await my_mikrotik.list_radius_servers()
|
||||
print(f"RADIUS SERVERS ({len(api_response.data)}):", json.to_string(api_response.data))
|
||||
|
||||
api_response = await my_mikrotik.list_firewall_nat()
|
||||
print(f"FIREWALL NAT ({len(api_response.data)}):")
|
||||
#
|
||||
# api_response = await my_mikrotik.list_hotspot_walled_garden_ips()
|
||||
# print(f"HOTSPOT WALLED GARDEN IPS ({len(api_response.data)}):", json.to_string(api_response.data))
|
||||
#
|
||||
# api_response = await my_mikrotik.list_radius_servers()
|
||||
# print(f"RADIUS SERVERS ({len(api_response.data)}):", json.to_string(api_response.data))
|
||||
#
|
||||
# api_response = await my_mikrotik.list_firewall_nat()
|
||||
# print(f"FIREWALL NAT ({len(api_response.data)}):")
|
||||
|
||||
async def hotspot_steps():
|
||||
|
||||
@@ -2419,59 +2419,59 @@ if __name__ == "__main__":
|
||||
# print("JSON:", api_response.data)
|
||||
# print("\n\n")
|
||||
|
||||
# STEP 5:
|
||||
# Add a new Hotspot Profile:
|
||||
api_response = await my_mikrotik.add_hotspot_profile(
|
||||
json_payload = {
|
||||
"dns-name": "hs01.easyfi.net.in",
|
||||
"hotspot-address": HS_GATEWAY_PRIVATE_IP,
|
||||
"html-directory": "hotspot",
|
||||
"html-directory-override": "",
|
||||
"http-cookie-lifetime": "3d",
|
||||
"http-proxy": "0.0.0.0:0",
|
||||
"install-hotspot-queue": "false",
|
||||
"login-by": "cookie,http-chap",
|
||||
# "name": "hs01.easyfi.net.in",
|
||||
"name": HS_PROFILE_NAME,
|
||||
"split-user-domain": "false",
|
||||
"use-radius": "true",
|
||||
"nas-port-type": "wireless-802.11",
|
||||
"radius-accounting": "true",
|
||||
"radius-default-domain": "",
|
||||
"radius-interim-update": "received",
|
||||
"radius-location-id": "",
|
||||
"radius-location-name": "",
|
||||
"radius-mac-format": "XX:XX:XX:XX:XX:XX",
|
||||
# "comment": HS_COMMENT
|
||||
}
|
||||
)
|
||||
print("STEP 5:", api_response.success, f"({api_response.action})")
|
||||
print("MESSAGE:", api_response.message)
|
||||
print("JSON:", api_response.data)
|
||||
print("\n\n")
|
||||
# # STEP 5:
|
||||
# # Add a new Hotspot Profile:
|
||||
# api_response = await my_mikrotik.add_hotspot_profile(
|
||||
# json_payload = {
|
||||
# "dns-name": "hs01.easyfi.net.in",
|
||||
# "hotspot-address": HS_GATEWAY_PRIVATE_IP,
|
||||
# "html-directory": "hotspot",
|
||||
# "html-directory-override": "",
|
||||
# "http-cookie-lifetime": "3d",
|
||||
# "http-proxy": "0.0.0.0:0",
|
||||
# "install-hotspot-queue": "false",
|
||||
# "login-by": "cookie,http-chap",
|
||||
# # "name": "hs01.easyfi.net.in",
|
||||
# "name": HS_PROFILE_NAME,
|
||||
# "split-user-domain": "false",
|
||||
# "use-radius": "true",
|
||||
# "nas-port-type": "wireless-802.11",
|
||||
# "radius-accounting": "true",
|
||||
# "radius-default-domain": "",
|
||||
# "radius-interim-update": "received",
|
||||
# "radius-location-id": "",
|
||||
# "radius-location-name": "",
|
||||
# "radius-mac-format": "XX:XX:XX:XX:XX:XX",
|
||||
# # "comment": HS_COMMENT
|
||||
# }
|
||||
# )
|
||||
# print("STEP 5:", api_response.success, f"({api_response.action})")
|
||||
# print("MESSAGE:", api_response.message)
|
||||
# print("JSON:", api_response.data)
|
||||
# print("\n\n")
|
||||
|
||||
# STEP 6:
|
||||
# Add a new Hotspot Server:
|
||||
api_response = await my_mikrotik.add_hotspot_server(
|
||||
json_payload = {
|
||||
"address-pool": HS_IP_POOL_NAME,
|
||||
"addresses-per-mac": "2",
|
||||
"idle-timeout": "5m",
|
||||
"interface": HS_VLAN_NAME,
|
||||
"keepalive-timeout": "none",
|
||||
"login-timeout": "none",
|
||||
# "name": "hs01.easyfi.net.in",
|
||||
"name": HS_SERVER_NAME,
|
||||
# "profile": "hs01.easyfi.net.in",
|
||||
"profile": HS_PROFILE_NAME,
|
||||
"disabled": "false",
|
||||
# "comment": HS_COMMENT
|
||||
}
|
||||
)
|
||||
print("STEP 6:", api_response.success, f"({api_response.action})")
|
||||
print("MESSAGE:", api_response.message)
|
||||
print("JSON:", api_response.data)
|
||||
print("\n\n")
|
||||
# # STEP 6:
|
||||
# # Add a new Hotspot Server:
|
||||
# api_response = await my_mikrotik.add_hotspot_server(
|
||||
# json_payload = {
|
||||
# "address-pool": HS_IP_POOL_NAME,
|
||||
# "addresses-per-mac": "2",
|
||||
# "idle-timeout": "5m",
|
||||
# "interface": HS_VLAN_NAME,
|
||||
# "keepalive-timeout": "none",
|
||||
# "login-timeout": "none",
|
||||
# # "name": "hs01.easyfi.net.in",
|
||||
# "name": HS_SERVER_NAME,
|
||||
# # "profile": "hs01.easyfi.net.in",
|
||||
# "profile": HS_PROFILE_NAME,
|
||||
# "disabled": "false",
|
||||
# # "comment": HS_COMMENT
|
||||
# }
|
||||
# )
|
||||
# print("STEP 6:", api_response.success, f"({api_response.action})")
|
||||
# print("MESSAGE:", api_response.message)
|
||||
# print("JSON:", api_response.data)
|
||||
# print("\n\n")
|
||||
|
||||
# # STEP 7:
|
||||
# # Add a new DHCP Server:
|
||||
@@ -2492,23 +2492,41 @@ if __name__ == "__main__":
|
||||
# print("JSON:", api_response.data)
|
||||
# print("\n\n")
|
||||
|
||||
# STEP 8:
|
||||
# Add a new DHCP Network:
|
||||
api_response = await my_mikrotik.add_dhcp_network(
|
||||
json_payload = {
|
||||
"address": HS_PRIVATE_IP_SUBNET,
|
||||
"gateway": HS_GATEWAY_PRIVATE_IP,
|
||||
"netmask": HS_PRIVATE_IP_SUBNET.split("/")[-1],
|
||||
"dns-server": HS_GATEWAY_PRIVATE_IP,
|
||||
"comment": HS_COMMENT
|
||||
}
|
||||
)
|
||||
print("STEP 8:", api_response.success, f"({api_response.action})")
|
||||
print("MESSAGE:", api_response.message)
|
||||
print("JSON:", api_response.data)
|
||||
print("\n\n")
|
||||
# # STEP 8:
|
||||
# # Add a new DHCP Network:
|
||||
# api_response = await my_mikrotik.add_dhcp_network(
|
||||
# json_payload = {
|
||||
# "address": HS_PRIVATE_IP_SUBNET,
|
||||
# "gateway": HS_GATEWAY_PRIVATE_IP,
|
||||
# "netmask": HS_PRIVATE_IP_SUBNET.split("/")[-1],
|
||||
# "dns-server": HS_GATEWAY_PRIVATE_IP,
|
||||
# "comment": HS_COMMENT
|
||||
# }
|
||||
# )
|
||||
# print("STEP 8:", api_response.success, f"({api_response.action})")
|
||||
# print("MESSAGE:", api_response.message)
|
||||
# print("JSON:", api_response.data)
|
||||
# print("\n\n")
|
||||
|
||||
# # STEP 9:
|
||||
# STEP 9-A
|
||||
# Set up the Walled-Garden:
|
||||
for index, url in enumerate([
|
||||
"api.thecaoffice.com",
|
||||
"cdn.jsdelivr.net"
|
||||
]):
|
||||
api_response = await my_mikrotik.add_hotspot_walled_garden(
|
||||
json_payload = {
|
||||
"action": "allow",
|
||||
"dst-host": url,
|
||||
"comment": HS_COMMENT
|
||||
}
|
||||
)
|
||||
print(f"STEP 9-A.{index}:", api_response.success, f"({api_response.action})")
|
||||
print("MESSAGE:", api_response.message)
|
||||
print("JSON:", api_response.data)
|
||||
print("\n\n")
|
||||
|
||||
# # STEP 9-B:
|
||||
# # Set up the Walled-Garden IP:
|
||||
# api_response = await my_mikrotik.add_hotspot_walled_garden_ip(
|
||||
# json_payload = {
|
||||
@@ -2517,11 +2535,11 @@ if __name__ == "__main__":
|
||||
# "comment": HS_COMMENT
|
||||
# }
|
||||
# )
|
||||
# print("STEP 9:", api_response.success, f"({api_response.action})")
|
||||
# print("STEP 9-B:", api_response.success, f"({api_response.action})")
|
||||
# print("MESSAGE:", api_response.message)
|
||||
# print("JSON:", api_response.data)
|
||||
# print("\n\n")
|
||||
#
|
||||
|
||||
# # STEP 10:
|
||||
# # Add a new RADIUS Server:
|
||||
# api_response = await my_mikrotik.add_radius_server(
|
||||
@@ -2541,7 +2559,7 @@ if __name__ == "__main__":
|
||||
# print("MESSAGE:", api_response.message)
|
||||
# print("JSON:", api_response.data)
|
||||
# print("\n\n")
|
||||
#
|
||||
|
||||
# # STEP 11:
|
||||
# # Allow incoming traffic from RADIUS:
|
||||
# api_response = await my_mikrotik.set_radius_incoming(
|
||||
@@ -2555,7 +2573,7 @@ if __name__ == "__main__":
|
||||
# print("MESSAGE:", api_response.message)
|
||||
# print("JSON:", api_response.data)
|
||||
# print("\n\n")
|
||||
#
|
||||
|
||||
# # STEP 12:
|
||||
# # Set up the DNS:
|
||||
# api_response = await my_mikrotik.set_dns(
|
||||
@@ -2611,7 +2629,7 @@ if __name__ == "__main__":
|
||||
# print("MESSAGE:", api_response.message)
|
||||
# print("JSON:", api_response.data)
|
||||
# print("\n\n")
|
||||
#
|
||||
|
||||
# # STEP 14:
|
||||
# # Set up the SNMP Community:
|
||||
# api_response = await my_mikrotik.add_snmp_community(
|
||||
@@ -2635,4 +2653,4 @@ if __name__ == "__main__":
|
||||
# print("\n\n")
|
||||
|
||||
|
||||
asyncio.run(main())
|
||||
asyncio.run(hotspot_steps())
|
||||
|
||||
Reference in New Issue
Block a user