mirror of
https://github.com/vel21ripn/nDPI.git
synced 2026-05-19 07:54:24 +00:00
Add specific protocol ids for Copilot, GitHub Actions and GitHub Packages. There is some overlapping between the addresses in the Github list and in the Azure one. Not sure about the best action here: add a (temporary?) workaround to avoid collisions. Close #2976 --------- Co-authored-by: Ivan Nardi <nardi.ivan@gmail.com>
41 lines
922 B
Python
Executable file
41 lines
922 B
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
import sys
|
|
import json
|
|
import urllib.request
|
|
|
|
GITHUB_META_URL = "https://api.github.com/meta"
|
|
|
|
def read_url(url):
|
|
try:
|
|
s = urllib.request.urlopen(url).read()
|
|
return json.loads(s)
|
|
except urllib.request.HTTPError:
|
|
print("Invalid HTTP response from %s" % url)
|
|
return {}
|
|
except json.decoder.JSONDecodeError:
|
|
print("Could not parse HTTP response from %s" % url)
|
|
return {}
|
|
|
|
def get_domains(github_domains, service):
|
|
website_domains = set(github_domains["website"])
|
|
|
|
if service == "website":
|
|
return website_domains
|
|
|
|
return set(github_domains[service]) - website_domains
|
|
|
|
|
|
|
|
def main():
|
|
service = sys.argv[1]
|
|
github_meta = read_url(GITHUB_META_URL)
|
|
|
|
service_domains = get_domains(github_meta["domains"], service)
|
|
|
|
for domain in service_domains:
|
|
print(domain)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|