From dd0f8fbed7a0feb4d971fc95d7866f8b53de7bf4 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sun, 25 Sep 2022 05:23:50 +0200 Subject: [PATCH] proxy all requests we make --- files/helpers/actions.py | 2 +- files/helpers/cron.py | 2 +- files/helpers/offsitementions.py | 2 +- files/routes/admin.py | 4 ++-- files/routes/discord.py | 2 +- files/routes/giphy.py | 2 +- files/routes/posts.py | 4 ++-- files/routes/settings.py | 4 ++-- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/files/helpers/actions.py b/files/helpers/actions.py index a59946aaa..3799a76bb 100644 --- a/files/helpers/actions.py +++ b/files/helpers/actions.py @@ -30,7 +30,7 @@ def badge_grant(user, badge_id, description=None, url=None, notify=True): def archiveorg(url): - try: requests.get(f'https://web.archive.org/save/{url}', headers={'User-Agent': 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'}, timeout=100) + try: requests.get(f'https://web.archive.org/save/{url}', headers={'User-Agent': 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'}, timeout=100, proxies=proxies) except: pass def archive_url(url): diff --git a/files/helpers/cron.py b/files/helpers/cron.py index bd1c45e94..b7f4265d4 100644 --- a/files/helpers/cron.py +++ b/files/helpers/cron.py @@ -114,7 +114,7 @@ def give_monthly_marseybux_task(): data = {'access_token': GUMROAD_TOKEN} - emails = [x['email'] for x in requests.get(f'https://api.gumroad.com/v2/products/{GUMROAD_ID}/subscribers', data=data, timeout=5).json()["subscribers"]] + emails = [x['email'] for x in requests.get(f'https://api.gumroad.com/v2/products/{GUMROAD_ID}/subscribers', data=data, timeout=5, proxies=proxies).json()["subscribers"]] for u in g.db.query(User).filter(User.patron > 0, User.patron_utc == 0).all(): g.db.add(u) diff --git a/files/helpers/offsitementions.py b/files/helpers/offsitementions.py index 19dca258d..c615a4057 100644 --- a/files/helpers/offsitementions.py +++ b/files/helpers/offsitementions.py @@ -34,7 +34,7 @@ def get_mentions(queries): for kind, query in itertools.product(kinds, queries): try: data = requests.get(f'https://api.pushshift.io/reddit/{kind}/search' - + f'?html_decode=true&q={query}&size=1', timeout=5).json()['data'] + + f'?html_decode=true&q={query}&size=1', timeout=5, proxies=proxies).json()['data'] except: break for i in data: diff --git a/files/routes/admin.py b/files/routes/admin.py index e13582386..43ac06bfd 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -429,7 +429,7 @@ def admin_home(v): if v.admin_level > 2: if CF_ZONE == 'blahblahblah': response = 'high' - else: response = requests.get(f'https://api.cloudflare.com/client/v4/zones/{CF_ZONE}/settings/security_level', headers=CF_HEADERS, timeout=5).json()['result']['value'] + else: response = requests.get(f'https://api.cloudflare.com/client/v4/zones/{CF_ZONE}/settings/security_level', headers=CF_HEADERS, timeout=5, proxies=proxies).json()['result']['value'] under_attack = response == 'under_attack' gitref = admin_git_head() @@ -498,7 +498,7 @@ def purge_cache(v): @app.post("/admin/under_attack") @admin_level_required(3) def under_attack(v): - response = requests.get(f'https://api.cloudflare.com/client/v4/zones/{CF_ZONE}/settings/security_level', headers=CF_HEADERS, timeout=5).json()['result']['value'] + response = requests.get(f'https://api.cloudflare.com/client/v4/zones/{CF_ZONE}/settings/security_level', headers=CF_HEADERS, timeout=5, proxies=proxies).json()['result']['value'] if response == 'under_attack': ma = ModAction( diff --git a/files/routes/discord.py b/files/routes/discord.py index 23373758d..fff779aa6 100644 --- a/files/routes/discord.py +++ b/files/routes/discord.py @@ -67,7 +67,7 @@ def discord_redirect(v): headers={ 'Authorization': f"Bearer {token}" } - x=requests.get(url, headers=headers, timeout=5) + x=requests.get(url, headers=headers, timeout=5, proxies=proxies) x=x.json() diff --git a/files/routes/giphy.py b/files/routes/giphy.py index 11142c6a1..ee45a9c2b 100644 --- a/files/routes/giphy.py +++ b/files/routes/giphy.py @@ -19,4 +19,4 @@ def giphy(v=None, path=None): url = f"https://api.giphy.com/v1/gifs/search?q={searchTerm}&api_key={GIPHY_KEY}&limit=48" else: url = f"https://api.giphy.com/v1/gifs?api_key={GIPHY_KEY}&limit=48" - return jsonify(requests.get(url, timeout=5).json()) + return jsonify(requests.get(url, timeout=5, proxies=proxies).json()) diff --git a/files/routes/posts.py b/files/routes/posts.py index a770ea38e..12fc9d98c 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -769,7 +769,7 @@ def submit_post(v, sub=None): return error(reason) elif "twitter.com" == domain: try: - embed = requests.get("https://publish.twitter.com/oembed", params={"url":url, "omit_script":"t"}, timeout=5).json()["html"] + embed = requests.get("https://publish.twitter.com/oembed", params={"url":url, "omit_script":"t"}, timeout=5, proxies=proxies).json()["html"] embed = embed.replace('