Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add endpoints for IPv4 and IPv6 only #94

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion sources/TechTeamBot.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ def __setup_support_enpoints(self):
"""
support_listener = SupportListener()
self.add_endpoint("/support/wprocket-ips", endpoint_name='support_wprocket_ips',
handler=support_listener.get_wprocket_ips, methods=['GET'])
handler=support_listener.get_wprocket_ips_human_readable, methods=['GET'])
self.add_endpoint("/support/wprocket-ips/ipv4", endpoint_name='support_wprocket_ipv4',
handler=support_listener.get_wprocket_ipv4_machine_readable, methods=['GET'])
self.add_endpoint("/support/wprocket-ips/ipv6", endpoint_name='support_wprocket_ipv6',
handler=support_listener.get_wprocket_ipv6_machine_readable, methods=['GET'])

def __load_config(self):
with open(Path(__file__).parent.parent / "config" / "app.json", encoding='utf-8') as file_app_config:
Expand Down
96 changes: 84 additions & 12 deletions sources/handlers/ServerListHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self):
self.slack_message_factory = SlackMessageFactory()
self.ovh_api_factory = OvhApiFactory()

def get_groupone_live2_ips(self):
def get_groupone_live2_ipv4(self):
"""
Lists all IP used by live2 cluster from group.One
"""
Expand All @@ -30,29 +30,62 @@ def get_groupone_live2_ips(self):
live2_ips += "46.30.212.70\n46.30.212.71\n46.30.212.72\n46.30.212.73\n"
return live2_ips

def generate_wp_rocket_ips(self, app_context):
def get_groupone_cpcss_ipv4(self):
"""
Generates a text list of all IPs used by WP Rocket
Lists all IPv4 used specifically by CPCSS service from group.One
"""
ipv4 = ''
ipv4 += "46.30.212.116\n"
return ipv4

def get_groupone_saas_ipv4(self):
"""
Lists all IPv4 used specifically by WP Rocket SaaS service from group.One
"""
ipv4 = ''
ipv4 += "46.30.212.106\n"
return ipv4

def get_groupone_backend_ipv4(self):
"""
Lists all IPv4 used specifically by backend service from group.One
"""
ipv4 = ''
ipv4 += "46.30.212.116\n"
return ipv4

def get_groupone_proxy_ipv4(self):
"""
Lists all IPv4 used for the wpmedia pod proxies
"""
ipv4 = ''
ipv4 += "185.10.9.100\n"
ipv4 += "185.10.9.101\n"
return ipv4

def generate_wp_rocket_ips_human_readable(self, app_context):
"""
Generates a text list of all IPs used by WP Rocket, human readable
"""
text = "List of IPs used for WP Rocket:\n\n"

text += "License validation/activation, update check, plugin information:\n"
# Defined in https://gitlab.one.com/systems/group.one-authdns/-/blob/main/octodns/wp-rocket.me.yaml?ref_type=heads
text += "https://wp-rocket.me\n"
text += "185.10.9.101\n"
text += self.get_groupone_proxy_ipv4()
text += "\n"

text += "Load CSS Asynchronously:\n"
# Defined in https://gitlab.one.com/systems/group.one-authdns/-/blob/main/octodns/wp-rocket.me.yaml?ref_type=heads
text += "https://cpcss.wp-rocket.me\n"
text += "46.30.212.116\n"
text += self.get_groupone_live2_ips()
text += self.get_groupone_cpcss_ipv4()
text += self.get_groupone_live2_ipv4()
text += "\n"

text += "Remove Unused CSS:\n"
# SaaS CNAME in https://gitlab.one.com/systems/group.one-authdns/-/blob/main/octodns/wp-rocket.me.yaml?ref_type=heads
text += "46.30.212.106\n"
text += self.get_groupone_live2_ips()
text += self.get_groupone_saas_ipv4()
text += self.get_groupone_live2_ipv4()
# OVH servers
all_server_list = self.ovh_api_factory.get_dedicated_servers(app_context)
ovh_ipv4 = ''
Expand All @@ -70,19 +103,58 @@ def generate_wp_rocket_ips(self, app_context):
text += "Dynamic exclusions and inclusions:\n"
# Defined in https://gitlab.one.com/systems/group.one-authdns/-/blob/main/octodns/wp-rocket.me.yaml?ref_type=heads
text += "https://b.rucss.wp-rocket.me\n"
text += "46.30.212.116\n"
text += self.get_groupone_backend_ipv4()
text += "\n"

text += "RocketCDN subscription:\n"
text += "https://rocketcdn.me/api/\n"
text += "185.10.9.100\n"
text += self.get_groupone_live2_ips()
text += self.get_groupone_proxy_ipv4()
text += self.get_groupone_live2_ipv4()

return text

def generate_wp_rocket_ipv4_machine_readable(self, app_context):
"""
List all IPv4 used for WP Rocket, machine readable with one IP per line and no text
"""
text = ""
# group.One
text += self.get_groupone_proxy_ipv4()
text += self.get_groupone_cpcss_ipv4()
text += self.get_groupone_saas_ipv4()
text += self.get_groupone_backend_ipv4()
text += self.get_groupone_live2_ipv4()
# OVH servers
all_server_list = self.ovh_api_factory.get_dedicated_servers(app_context)
ovh_ipv4 = ''
for server_name in all_server_list:
display_name = self.ovh_api_factory.get_dedicated_server_display_name(app_context, server_name)
if 'worker' in display_name:
server_ips = self.ovh_api_factory.get_dedicated_server_ips(app_context, server_name)
ovh_ipv4 += server_ips[IpAddress.IP_ADDRESS_IPV4] + "\n"
text += ovh_ipv4
return text

def generate_wp_rocket_ipv6_machine_readable(self, app_context):
"""
List all IPv6 used for WP Rocket, machine readable with one IP per line and no text
"""
text = ""
# group.One
# OVH servers
all_server_list = self.ovh_api_factory.get_dedicated_servers(app_context)
ovh_ipv6 = ''
for server_name in all_server_list:
display_name = self.ovh_api_factory.get_dedicated_server_display_name(app_context, server_name)
if 'worker' in display_name:
server_ips = self.ovh_api_factory.get_dedicated_server_ips(app_context, server_name)
ovh_ipv6 += server_ips[IpAddress.IP_ADDRESS_IPV6] + "\n"
text += ovh_ipv6
return text

def send_wp_rocket_ips_to_slack(self, app_context, slack_user):
"""
List all IPs used for WP Rocket and sends it in a Slack DM
"""
text = self.generate_wp_rocket_ips(app_context)
text = self.generate_wp_rocket_ips_human_readable(app_context)
self.slack_message_factory.post_message(app_context, slack_user, text)
21 changes: 19 additions & 2 deletions sources/listeners/SupportListener.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,26 @@ def __init__(self):
"""
self.server_list_handler = ServerListHandler()

def get_wprocket_ips(self):
def get_wprocket_ips_human_readable(self):
"""
Method generating the list of IPs used by WP Rocket and returning it in a list as a string.
"""
response_payload = self.server_list_handler.generate_wp_rocket_ips(app_context=current_app.app_context())
response_payload = self.server_list_handler.generate_wp_rocket_ips_human_readable(
app_context=current_app.app_context())
return response_payload, 200

def get_wprocket_ipv4_machine_readable(self):
"""
Method generating the list of IPv4 used by WP Rocket and returning it as a machine readable string
"""
response_payload = self.server_list_handler.generate_wp_rocket_ipv4_machine_readable(
app_context=current_app.app_context())
return response_payload, 200

def get_wprocket_ipv6_machine_readable(self):
"""
Method generating the list of IPv4 used by WP Rocket and returning it as a machine readable string
"""
response_payload = self.server_list_handler.generate_wp_rocket_ipv6_machine_readable(
app_context=current_app.app_context())
return response_payload, 200
Loading