GNU/Weeb Mailing List <[email protected]>
 help / color / mirror / Atom feed
From: Ammar Faizi <[email protected]>
To: Ammar Faizi <[email protected]>
Cc: Michael William Jonathan <[email protected]>,
	GNU/Weeb FB Team <[email protected]>,
	GNU/Weeb Mailing List <[email protected]>
Subject: [PATCH fb v1 1/3] fb: web: Don't use proxy if the host isn't an onion domain
Date: Sat, 13 May 2023 01:44:09 +0700	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

Speed up the HTTP request by not using the Tor proxy if the destination
host is not an onion domain. This is also a preparation to handle
Facebook assets (photos, video, files) better and faster.

Signed-off-by: Ammar Faizi <[email protected]>
 web/public/api.php | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/web/public/api.php b/web/public/api.php
index a427191b21639279..1b9ef97a2fb9c868 100644
--- a/web/public/api.php
+++ b/web/public/api.php
@@ -219,6 +219,16 @@ function handle_url_proxy(Facebook $fb, string $url)
 		return 0;
+	if (filter_var($data, FILTER_VALIDATE_URL)) {
+		/**
+		 * Don't use proxy for non onion URL.
+		 */
+		$u = parse_url($data);
+		if (!preg_match("/\\.onion$/i", $u["host"])) {
+			$fb->setProxy(NULL);
+		}
+	}
 	if (!fb_http_get($fb, $data))
Ammar Faizi

  reply	other threads:[~2023-05-12 18:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-12 18:44 [PATCH fb v1 0/3] Facebook Onion assets optimization Ammar Faizi
2023-05-12 18:44 ` Ammar Faizi [this message]
2023-05-12 18:44 ` [PATCH fb v1 2/3] fb: helper: Introduce `build_url()` function Ammar Faizi
2023-05-12 18:44 ` [PATCH fb v1 3/3] fb: web: Replace Facebook onion asset endpoint with non-onion Ammar Faizi
2023-05-12 19:10 ` [PATCH fb v1 0/3] Facebook Onion assets optimization GNU/Weeb Facebook Team

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox