From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Newsgroups: gmane.lisp.guile.devel Subject: [PATCH] web: default to INADDR_ANY instead of INADDR_LOOPBACK Date: Wed, 2 Feb 2022 16:26:38 -0800 Message-ID: <20220203002638.34504-1-aconchillo@gmail.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1383"; mail-complaints-to="usenet@ciao.gmane.io" Cc: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Thu Feb 03 01:27:01 2022 Return-path: Envelope-to: guile-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nFPxl-0000Ax-DU for guile-devel@m.gmane-mx.org; Thu, 03 Feb 2022 01:27:01 +0100 Original-Received: from localhost ([::1]:35616 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nFPxk-0000o2-22 for guile-devel@m.gmane-mx.org; Wed, 02 Feb 2022 19:27:00 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:33310) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nFPxY-0000ns-Ja for guile-devel@gnu.org; Wed, 02 Feb 2022 19:26:48 -0500 Original-Received: from [2607:f8b0:4864:20::434] (port=35483 helo=mail-pf1-x434.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nFPxW-0006uL-An for guile-devel@gnu.org; Wed, 02 Feb 2022 19:26:48 -0500 Original-Received: by mail-pf1-x434.google.com with SMTP id u130so772912pfc.2 for ; Wed, 02 Feb 2022 16:26:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=zsc7MzeUpS5LhA0przTdO0ucWDeWozvnDer/riJiHOU=; b=mqmKqM+n6NaCwyEp+9fhZm6L1ixU8NaHBEYJgt+lP6OSr+6JQ71PzP4M3xdAit21wU FwfvszFgrCGbuACnL0TdBhv0HXtOgiX9YneVrUapQXdrt1EelEo7PniiIHrU/ID8PZ7L HPKivRDuoQUri0T5K+xp1LQqFTpEN3dQqJM1x90LIB9fPWwSyaxWtp1cuJUPDkyHDWbg LO3BlhbS/gC1Uqo2xY1VkYJ6fkuUwI/itGY+eq5YbP/y0657JBu9bXmdFeFRSxkzcF3i 3uYmDUQFff78zxGcGr1GaMUQr9Mtz9EN5TiQKWrEd+N94/t4ZAy9Y1pNcFpSdF1v6c5E YoJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=zsc7MzeUpS5LhA0przTdO0ucWDeWozvnDer/riJiHOU=; b=CKkggV3Mi9QLe6os8wRw6ZV/HsphuWz0Oum+oKJl+IZVm545Gthham0mdAdvtIeDUT mnQ0y0nAXV6e1PdpuvfwvGnkbzj1ycMN+NxkV80zhaTdOVasF3xvvmbe+noVZ+L5WOzY p7vCBH7DKZj7n8MMJxC/7tQfzgpATGaPsntOQBLeBR/eTznGQmISHj3Ea2b17xfyFQ5D gYBTprmTcgopZVVkkEG62PNUNU76dcf9gX3a56/mwoFbQ3nyZc210AxEYFhA6i6AU129 UZDfZZI2ScdW8TcvUs1diagReGI1FZODQ1mcHN5coIqmdUCWwYG4wvwOegXypWRfpzHH H/YA== X-Gm-Message-State: AOAM532ZRh0lKlUnf6FKy+TBGt5AxPoxYO0GLUVdHv2JqVQcM4CrHIws kZNMZ4zvU4PQ668yq9cU0tSG3mYWMFQ= X-Google-Smtp-Source: ABdhPJyEaguB0KffiZjrXz5ZNJq2dWWzDhiueR7FNROpHHbNSSrhb1sv06ANjgf4ZoRAz08vFXv9QQ== X-Received: by 2002:a62:1813:: with SMTP id 19mr31573777pfy.14.1643848004418; Wed, 02 Feb 2022 16:26:44 -0800 (PST) Original-Received: from localhost (cpe-198-72-134-0.socal.res.rr.com. [198.72.134.0]) by smtp.gmail.com with ESMTPSA id j4sm27053870pfc.217.2022.02.02.16.26.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Feb 2022 16:26:44 -0800 (PST) X-Mailer: git-send-email 2.35.1 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::434 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=aconchillo@gmail.com; helo=mail-pf1-x434.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.io gmane.lisp.guile.devel:21061 Archived-At: Using INADDR_ANY instead of INADDR_LOOPBACK makes it convenient when starting the web server inside containers without the need to having to specify INADDR_ANY all the time. This is the default in most libraries and languages. This doesn't break backwards compatibility since INADDR_LOOPBACK is also included in INADDR_ANY. * doc/ref/web.texi (Web Server): update INADDR_LOOPBACK to INADDR_ANY and related text. * module/web/server/http.scm (http-open): default to INADDR_ANY for the web server. --- doc/ref/web.texi | 10 +++++----- module/web/server/http.scm | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/ref/web.texi b/doc/ref/web.texi index 93cd0214f..6b42b8ff6 100644 --- a/doc/ref/web.texi +++ b/doc/ref/web.texi @@ -1807,7 +1807,7 @@ socket, listening for request on that port. @deffn {HTTP Implementation} http [#:host=#f] @ [#:family=AF_INET] @ - [#:addr=INADDR_LOOPBACK] @ + [#:addr=INADDR_ANY] @ [#:port 8080] [#:socket] The default HTTP implementation. We document it as a function with keyword arguments, because that is precisely the way that it is -- all @@ -1815,7 +1815,7 @@ of the @var{open-params} to @code{run-server} get passed to the implementation's open function. @example -;; The defaults: localhost:8080 +;; The defaults: any local IP on port 8080 (run-server handler) ;; Same thing (run-server handler 'http '()) @@ -1866,9 +1866,9 @@ handler: (run-server hello-world-handler) @end example -By default, the web server listens for requests on -@code{localhost:8080}. Visit that address in your web browser to -test. If you see the string, @code{Hello World!}, sweet! +By default, the web server listens for requests on port @code{8080}. +Visit @code{http://localhost:8080} in your web browser to test. If you +see the string, @code{Hello World!}, sweet! @subsubsection Inspecting the Request diff --git a/module/web/server/http.scm b/module/web/server/http.scm index 05bf46bf0..91354021c 100644 --- a/module/web/server/http.scm +++ b/module/web/server/http.scm @@ -1,6 +1,6 @@ ;;; Web I/O: HTTP -;; Copyright (C) 2010, 2011, 2012, 2015 Free Software Foundation, Inc. +;; Copyright (C) 2010, 2011, 2012, 2015, 2022 Free Software Foundation, Inc. ;; This library is free software; you can redistribute it and/or ;; modify it under the terms of the GNU Lesser General Public @@ -61,7 +61,7 @@ (family AF_INET) (addr (if host (inet-pton family host) - INADDR_LOOPBACK)) + INADDR_ANY)) (port 8080) (socket (make-default-socket family addr port))) (listen socket 128) -- 2.35.1