From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1683917060; bh=1jXcRVed5T/n45IRDa1EiSLnOKhC4RU/+yI4wObDrEA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=BoYp54vuqFaM8e52uKn3SkFWVyYP6YYvM58ffIpnS+b3dM0IYWxIUG+Jv6NXYB5Hs 2343/AWv++xYhmU9WyJ+RF0TD8bLNWelpeKiiCy/6zlChq6zNQnV3prhxbjStgcVI0 JJU4JvlUSTv50IuYjZpsXOruuzz1jLbEx7B97WEgmMWtJmcaIW+cON6A96nikn4MI1 xZQB5SZbFGN2JfaHeTwfLe2+53/5wY/2QRCveypsObTH4amFe1uAnhqp9564JkcOAy tyumJa/BPzAaYjzoInx3ZJP9CX+Qmans3yQ07e9oimfsb+q/RxQKWQkH/7BHsb+RwM ze8GJwNxnzeTQ== Received: from integral2.. (unknown [128.199.192.202]) by gnuweeb.org (Postfix) with ESMTPSA id BA0942491E1; Sat, 13 May 2023 01:44:18 +0700 (WIB) From: Ammar Faizi To: Ammar Faizi Cc: Michael William Jonathan , GNU/Weeb FB Team , GNU/Weeb Mailing List 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 Message-Id: <20230512184411.26860-2-ammarfaizi2@gnuweeb.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230512184411.26860-1-ammarfaizi2@gnuweeb.org> References: <20230512184411.26860-1-ammarfaizi2@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 --- 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)) exit(0); } -- Ammar Faizi