From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 0A5812CB92 for ; Tue, 30 Apr 2019 18:31:31 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QYuIWt3Duqb9 for ; Tue, 30 Apr 2019 18:31:30 -0400 (EDT) Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 90D332C996 for ; Tue, 30 Apr 2019 18:31:30 -0400 (EDT) From: Vladislav Shpilevoy Subject: [tarantool-patches] [PATCH 4/5] swim: allow to omit host in URI Date: Wed, 1 May 2019 01:31:26 +0300 Message-Id: <6dcbe9a1f1efbc07092109336427520109f1e3a3.1556663421.git.v.shpilevoy@tarantool.org> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org Cc: kostja@tarantool.org Before the patch swim.cfg() was returning an error on an attempt to use URI like 'port', without a host. But it would be useful, easy, and short to allow that, and use '127.0.0.1' host by default. Compare: swim:cfg({uri = 1234}) vs swim:cfg({uri = '127.0.0.1:1234'}) It is remarkable that box.cfg{listen} also allows to omit host. Note, that use '0.0.0.0' (INADDR_ANY) is forbidden. Otherwise 1) Different instances interacting with this one via not the same interfaces would see different source IP addresses. It would mess member tables; 2) This instance would not be able to encode its IP address in the meta section, because it has no a fixed IP. At the same time omission of it and usage of UDP header source address is not possible as well, because UDP header is not encrypted and therefore is not safe to look at. Part of #3234 --- src/lib/swim/swim.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/swim/swim.c b/src/lib/swim/swim.c index 22dfc3d2a..b2b4901b1 100644 --- a/src/lib/swim/swim.c +++ b/src/lib/swim/swim.c @@ -1696,7 +1696,9 @@ swim_uri_to_addr(const char *uri, struct sockaddr_in *addr, return -1; } *addr = *((struct sockaddr_in *) &storage); - if (addr->sin_addr.s_addr == 0) { + if (is_host_empty) { + addr->sin_addr.s_addr = htonl(INADDR_LOOPBACK); + } else if (addr->sin_addr.s_addr == 0) { diag_set(IllegalParams, "%s INADDR_ANY is not supported", prefix); return -1; -- 2.20.1 (Apple Git-117)