From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Chris Vine Newsgroups: gmane.lisp.guile.devel Subject: Re: (web server) serving on both ipv6 and ipv4? Date: Wed, 19 Jan 2022 21:12:37 +0000 Message-ID: <20220119211237.c451bfb4a6f9369d926f2cde@gmail.com> References: <87k0ewi0w2.fsf@web.de> <20220119130733.fe13d5f14bd2a818266ddc10@gmail.com> <20220119134413.20b5d9944b9bbf51b198b948@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4662"; mail-complaints-to="usenet@ciao.gmane.io" To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Wed Jan 19 22:12:49 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 1nAIG9-000158-IP for guile-devel@m.gmane-mx.org; Wed, 19 Jan 2022 22:12:49 +0100 Original-Received: from localhost ([::1]:45932 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nAIG7-0004ui-SD for guile-devel@m.gmane-mx.org; Wed, 19 Jan 2022 16:12:47 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:48384) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAIFp-0004uV-LM for guile-devel@gnu.org; Wed, 19 Jan 2022 16:12:29 -0500 Original-Received: from [2a00:1450:4864:20::32d] (port=54108 helo=mail-wm1-x32d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nAIFo-0005Kx-63 for guile-devel@gnu.org; Wed, 19 Jan 2022 16:12:29 -0500 Original-Received: by mail-wm1-x32d.google.com with SMTP id n8so7728936wmk.3 for ; Wed, 19 Jan 2022 13:12:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:subject:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=BnJUnsYIF17BPC9mSWOTd/5EwFwqq83EEMDoR9NVis4=; b=D/qIEn+duBFVz5CknBLLbb8iCWR6o/Fd3rP8ru+5yP8ouC01KFIvcHyMeWNUX8V6wO eMeUbNLbwpgxeQMhmrc8gKs1fbHRAEt2tGhigwifubzaU+62y7MoTi3eOInDpmSW5TFL USpcm7RUGUdtve00FQzc6/nDKXl5wr3fxLJs6scOp2O9/oWIMURV1erHvDeoeQbFwCEz nGYWp97nje2yifUPtNLaIZvEr8ows2C5cJe5BpURxeMxlgmR33QTQgSbCB0XOPxY09KT AttDJb0KEyCnnq2NBdmBfDpOvNLi2/HorukrPyIMSMq0IhN76g+r5xw1Mcd6UDgFwpVV vX1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BnJUnsYIF17BPC9mSWOTd/5EwFwqq83EEMDoR9NVis4=; b=rOgrrMHiB4+6/+hRG8uJoKDMNxdlD4T+kWHb3QMSD1jGaxUa9peVBF6DiPVCxC/76A lKHwYqc3wsIoE+P7Y0fUnW7zEk7XxIrzAPlX8b4k95ziSlRnUYd1KagMVLkhxsmJjvxd ib87wCyTmkWzyjWbbU9ZlwSrqSJuJcvRZfOIpdU55/ZGElX0IfBVmOA9q7cLdlkgh8VR UIuFc+WZFy2rpuotkW7FQ5I00nZ2rpbXohDQXP+a5ZGBns5FznIf8UC7BrJo6VaFY7cA lCUYjIA6UjSvDksH6oDux8kmmP0/N4B/sNjywaTELWbbJrePIMKn/LLhAZItl4DB1kD1 jFZw== X-Gm-Message-State: AOAM532RzMyLfQ/HHL1h87kHNn+N3Z3Dv9QuEU/C/FVGKstF7Jx347Hl rFq4fT0mBfPjwU8FFwb+yOUf25OzAAA= X-Google-Smtp-Source: ABdhPJyIq1rP19o1XZ2ed6Jkt7fpQNwT3sO2cCzw56icfAu667Bc51hyVizvKr0FMSg4kLotGR0bMg== X-Received: by 2002:a05:600c:154b:: with SMTP id f11mr5576282wmg.62.1642626746653; Wed, 19 Jan 2022 13:12:26 -0800 (PST) Original-Received: from bother.homenet ([2.27.184.177]) by smtp.gmail.com with ESMTPSA id v124sm6102960wme.30.2022.01.19.13.12.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jan 2022 13:12:26 -0800 (PST) Original-Received: from bother.homenet (localhost [127.0.0.1]) by bother.homenet (Postfix) with SMTP id 1769E2637CA for ; Wed, 19 Jan 2022 21:12:38 +0000 (GMT) In-Reply-To: <20220119134413.20b5d9944b9bbf51b198b948@gmail.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-unknown-linux-gnu) X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::32d (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=vine35792468@gmail.com; helo=mail-wm1-x32d.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.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_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, NICE_REPLY_A=-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 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:21043 Archived-At: On Wed, 19 Jan 2022 13:44:13 +0000 Chris Vine wrote: > On Wed, 19 Jan 2022 13:07:33 +0000 > Chris Vine wrote: > [snip] > > As I understand it, with linux IPv6 sockets are dual stack capable, and > > in earlier kernel versions this was be enabled by default. I believe > > with current versions that is no longer the case, and that you have to > > specifically enable dual stack by turning off IPV6_V6ONLY using > > setsockopt before binding on the socket. > > > > Then, if receiving a IPv4 connection from address 1.2.3.4, this would be > > mapped as ::::ffff:1.2.3.4. > > > > I do not know about other OSes. I have half a memory that some earlier > > versions of windows did not support dual stack sockets (XP?). > > By the way I did use dual stack some years ago, and I cannot now > remember all the details, but I think I may have had to bind on > in6addr_any (which in dual stack would cover INADDR_ANY) or on ::1 > (which would cover 127.0.0.1) to get dual stack to work. I suggest you > play around with it to see. > > One other correction: when I said there was a mapping to ::::ffff: > 1.2.3.4 I meant ::ffff:1.2.3.4. You have stimulated my interest and this is what I have found. First, in C the correct call in linux to do what you want to obtain a dual stack socket is to set the IPV6_V6ONLY option in the IPPROTO_IPV6 level to 0 (off). However neither IPV6_V6ONLY nor IPPROTO_IPV6 is defined in guile, so you have to enter the numeric values for your OS by hand. In linux this will do it in guile, but of course it is non-portable: (setsockopt [sock] 41 26 0) However, this only actually seems to accept a connection from a IPv4 address if the socket binds to :: (which is in6addr_any, but the in6addr_any symbol also appears not to be defined in guile). Binding to ::1 (localhost) will not enable you to connect from 127.0.0.1 on my computer. Whether binding to :: and so permitting any interface to access the socket is OK for you depends on what your needs are. If not then it looks as if you are stuck with having two sockets, one for IPv4 and one for IPv6.