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_Conchillo_Flaqu=C3=A9?= Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH] web: default to INADDR_ANY instead of INADDR_LOOPBACK Date: Thu, 21 Jul 2022 17:44:53 -0700 Message-ID: References: <20220203002638.34504-1-aconchillo@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000016aae105e45a2548" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4020"; mail-complaints-to="usenet@ciao.gmane.io" To: guile-devel Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Fri Jul 22 02:45:24 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 1oEgnD-0000t3-M0 for guile-devel@m.gmane-mx.org; Fri, 22 Jul 2022 02:45:23 +0200 Original-Received: from localhost ([::1]:53030 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oEgnC-0007eI-5v for guile-devel@m.gmane-mx.org; Thu, 21 Jul 2022 20:45:22 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEgmx-0007eA-TK for guile-devel@gnu.org; Thu, 21 Jul 2022 20:45:07 -0400 Original-Received: from mail-vs1-xe2d.google.com ([2607:f8b0:4864:20::e2d]:39643) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oEgmv-0007Hl-NY for guile-devel@gnu.org; Thu, 21 Jul 2022 20:45:07 -0400 Original-Received: by mail-vs1-xe2d.google.com with SMTP id c3so3070003vsc.6 for ; Thu, 21 Jul 2022 17:45:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=5PZ6UAMbo1l0hmdfR2GkzSu15v9290jWHBH10U6AZUI=; b=F5+BLps1uqcPCNM2AD1JPvIljJINwgauy34/K8ZRVEEL8mBXFpuuIdanaerQtZcw5v sP91qzwNHttKm7qm++I06iX9SJMNQSTR3sgzZeTjlAniSFLiL9/VM5igwM8K1vQHi04v Bj6tOJbSCJf3zDFH36BjgCxwRqzjJAopoZ/4aIW4S0reVqNT0A4+vCNeFvpfNrb9Vbzz xOd4u91rmo3kxF57b/nd9h7SejjRj/Lxa4h3LQPXcSEcdd+1Ak1FzsjyMIQWUxjwCTzp 9eB0Va5GSCvGwUKvQOAC0x2rfqrSZEG4HVIcjTttuZMR9A965Ti0oD4BFYAUAiQd1QF0 oawg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=5PZ6UAMbo1l0hmdfR2GkzSu15v9290jWHBH10U6AZUI=; b=A6Iy6EVm9lAC6eyIxHBroJyl3moEMv3W9fpk/rJu6rxVjr6WfLdjZDXC/nhSyBuMoj 140ehAaxwzkLlL4p4mCYKB3Atr/dEdlQvL4CJ8UOMk4BK0h1nMhlR/epespWpJTud+sb tCSLg1pUO1DmPJ269Zes7YUzpTw31BL1u8F173viD8rVOJmr3S/Xepcr6uxowVkuxfs8 EFGBUByrEIkytcNeKfGk/0HuNPIKc8SAfT2hq1DuNNNn/8iSYFLvJqqDWRAOrgc4Vo8Y m3b9dCGy2BAIeftYXYD8HZSp5Z1Q+F6GDGtQNJ2je1YWng4hb/b2oouVugMMzzXYjd2N 14jA== X-Gm-Message-State: AJIora9lW9S2lbM34pCfaXYObeqixkkThK0BLssxFcPT0a8xRKIIWm8g 1r3A4QjNwSkB+mw71pkDWMWY8Qpqllie3YrXyp2VW0DK X-Google-Smtp-Source: AGRyM1t451jB1N1vESGJtuijaecHaCNvGiTA0ojz5EOqZ/fu9ijW1im5gHGeQEcBA/KIR9T6A1K1UChkR3zEIFGCd2M= X-Received: by 2002:a67:eed0:0:b0:357:304a:1785 with SMTP id o16-20020a67eed0000000b00357304a1785mr296583vsp.46.1658450703984; Thu, 21 Jul 2022 17:45:03 -0700 (PDT) In-Reply-To: <20220203002638.34504-1-aconchillo@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::e2d; envelope-from=aconchillo@gmail.com; helo=mail-vs1-xe2d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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:21264 Archived-At: --00000000000016aae105e45a2548 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable ping. easy one but might be more controversial. On Wed, Feb 2, 2022 at 4:26 PM Aleix Conchillo Flaqu=C3=A9 wrote: > 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=3D#f] @ > [#:family=3DAF_INET] @ > - [#:addr=3DINADDR_LOOPBACK] @ > + [#:addr=3DINADDR_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 > > --00000000000016aae105e45a2548 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
ping. easy one but might be more controversial.

On= Wed, Feb 2, 2022 at 4:26 PM Aleix Conchillo Flaqu=C3=A9 <aconchillo@gmail.com> wrote:
Using INADDR_ANY instead of I= NADDR_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 als= o
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.
---
=C2=A0doc/ref/web.texi=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| 10 +++++--= ---
=C2=A0module/web/server/http.scm |=C2=A0 4 ++--
=C2=A02 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.

=C2=A0@deffn {HTTP Implementation} http [#:host=3D#f] @
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 [#:family=3DAF_INET] @
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0[#:addr=3DINADDR_LOOPBACK] @
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0[#:addr=3DINADDR_ANY] @
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 [#:port 8080] [#:socket]
=C2=A0The default HTTP implementation.=C2=A0 We document it as a function w= ith
=C2=A0keyword arguments, because that is precisely the way that it is -- al= l
@@ -1815,7 +1815,7 @@ of the @var{open-params} to @code{run-server} get pas= sed to the
=C2=A0implementation's open function.

=C2=A0@example
-;; The defaults: localhost:8080
+;; The defaults: any local IP on port 8080
=C2=A0(run-server handler)
=C2=A0;; Same thing
=C2=A0(run-server handler 'http '())
@@ -1866,9 +1866,9 @@ handler:
=C2=A0(run-server hello-world-handler)
=C2=A0@end example

-By default, the web server listens for requests on
-@code{localhost:8080}.=C2=A0 Visit that address in your web browser to
-test.=C2=A0 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.=C2=A0 If y= ou
+see the string, @code{Hello World!}, sweet!

=C2=A0@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 @@
=C2=A0;;; Web I/O: HTTP

-;; Copyright (C)=C2=A0 2010, 2011, 2012, 2015 Free Software Foundation, In= c.
+;; Copyright (C)=C2=A0 2010, 2011, 2012, 2015, 2022 Free Software Foundati= on, Inc.

=C2=A0;; This library is free software; you can redistribute it and/or
=C2=A0;; modify it under the terms of the GNU Lesser General Public
@@ -61,7 +61,7 @@
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0(family AF_INET)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0(addr (if host
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(inet-pton family host)
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 INADDR_LOOPBACK))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 INADDR_ANY))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0(port 8080)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0(socket (make-default-socket family addr port)))
=C2=A0 =C2=A0(listen socket 128)
--
2.35.1

--00000000000016aae105e45a2548--