From: Robert Pluim <rpluim@gmail.com>
To: Jimmy Yuen Ho Wong <wyuenho@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: netsec 682578f 4/6: Add option to bypass NSM TLS checks on local networks
Date: Mon, 16 Jul 2018 15:34:35 +0200 [thread overview]
Message-ID: <87va9fs3ro.fsf@gmail.com> (raw)
In-Reply-To: <4C758D1D-7C3A-425A-852F-75E03C779E01@gmail.com> (Jimmy Yuen Ho Wong's message of "Sun, 15 Jul 2018 16:34:47 +0100")
Jimmy Yuen Ho Wong <wyuenho@gmail.com> writes:
>> On 15 Jul 2018, at 12:46 pm, Robert Pluim <rpluim@gmail.com> wrote:
>>
>> wyuenho@gmail.com (Jimmy Yuen Ho Wong) writes:
>>
>>> branch: netsec
>>> commit 682578fcf74d4598e39eca81e09d81810d3fc28d
>>> Author: Jimmy Yuen Ho Wong <wyuenho@gmail.com>
>>> Commit: Jimmy Yuen Ho Wong <wyuenho@gmail.com>
>>>
>>> Add option to bypass NSM TLS checks on local networks
>>>
>>> * lisp/net/net-utils.el (nslookup-host-ipv4, nslookup-host-ipv6,
>>> ipv6-expand): New functions to lookup IPv4 and IPv6 addresses from
>>> DNS.
>>
>> So this only works for people who have nslookup installed? Emacs
>> already uses getaddrinfo internally, would it help you if there was a
>> lisp-level interface to it?
>>
>
> Yes it would. I was asking for that exact same thing :) lend me a hand on this?
Iʼm terrible at choosing names, please suggest better ones
(hostname-lookup, gethostbyname,....?). Output currently looks like
this, including a port number, but thatʼs easily changed:
(get-address-info "www.slashdot.org" 'ipv4)
([216 105 38 15 0] [216 105 38 15 0] [216 105 38 15 0])
(get-address-info "google.com")
([172 217 19 238 0] [172 217 19 238 0] [172 217 19 238 0] [10752 5200 16391 2060 0 0 0 8206 0] [10752 5200 16391 2060 0 0 0 8206 0] [10752 5200 16391 2060 0 0 0 8206 0])
Eli, I see thereʼs a sys_getaddrinfo in w32.c, is something needed to get emacs
to use that on MS-Windows?
diff --git i/src/process.c w/src/process.c
index 279b74bc66..7d0bf74cbe 100644
--- i/src/process.c
+++ w/src/process.c
@@ -4531,6 +4531,55 @@ Data that is unavailable is returned as nil. */)
#endif
}
+DEFUN ("get-address-info", Fget_address_info, Sget_address_info, 1, 2, 0,
+ doc: /* Look up ip address info of NAME.
+Optional parameter FAMILY controls whether to look up IPv4 or IPv6
+addresses. The default of nil means look up both, symbol `ipv4' means
+IPv4 only, symbol `ipv6' mean IPv6 only. Returns a list of addresses,
+or nil if none were found. */)
+ (Lisp_Object name, Lisp_Object family)
+{
+ Lisp_Object addresses = Qnil;
+ struct addrinfo *res, *lres;
+ int ret;
+
+ struct addrinfo hints;
+ memset (&hints, 0, sizeof hints);
+ if (EQ (family, Qnil))
+ hints.ai_family = AF_UNSPEC;
+ if (EQ (family, Qipv4))
+ hints.ai_family = AF_INET;
+#ifdef AF_INET6
+ if (EQ (family, Qipv6))
+ hints.ai_family = AF_INET6;
+#endif
+ hints.ai_socktype = 0;
+
+ ret = getaddrinfo (SSDATA (name), NULL, &hints, &res);
+ if (ret)
+#ifdef HAVE_GAI_STRERROR
+ {
+ synchronize_system_messages_locale ();
+ char const *str = gai_strerror (ret);
+ if (! NILP (Vlocale_coding_system))
+ str = SSDATA (code_convert_string_norecord
+ (build_string (str), Vlocale_coding_system, 0));
+ message ("\"%s\" \"%s\"", SSDATA (name), str);
+ }
+#else
+ message ("%s get-address-info error %d", SSDATA (name), ret);
+#endif
+ else
+ {
+ for (lres = res; lres; lres = lres->ai_next)
+ addresses = Fcons (conv_sockaddr_to_lisp (lres->ai_addr, lres->ai_addrlen), addresses);
+ addresses = Fnreverse (addresses);
+
+ freeaddrinfo (res);
+ }
+ return addresses;
+}
+
/* Turn off input and output for process PROC. */
static void
@@ -8274,6 +8323,7 @@ returns non-`nil'. */);
defsubr (&Sset_network_process_option);
defsubr (&Smake_network_process);
defsubr (&Sformat_network_address);
+ defsubr (&Sget_address_info);
defsubr (&Snetwork_interface_list);
defsubr (&Snetwork_interface_info);
#ifdef DATAGRAM_SOCKETS
next prev parent reply other threads:[~2018-07-16 13:34 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20180714170806.8972.58581@vcs0.savannah.gnu.org>
[not found] ` <20180714170809.C3A3920456@vcs0.savannah.gnu.org>
2018-07-15 11:46 ` netsec 682578f 4/6: Add option to bypass NSM TLS checks on local networks Robert Pluim
2018-07-15 15:34 ` Jimmy Yuen Ho Wong
2018-07-16 13:34 ` Robert Pluim [this message]
2018-07-16 15:00 ` Eli Zaretskii
2018-07-16 15:24 ` Jimmy Yuen Ho Wong
2018-07-16 17:59 ` Eli Zaretskii
2018-07-16 16:23 ` Robert Pluim
2018-07-16 17:16 ` Jimmy Yuen Ho Wong
2018-07-16 17:46 ` Robert Pluim
2018-07-16 18:09 ` Eli Zaretskii
2018-07-17 10:09 ` Robert Pluim
2018-07-17 15:50 ` Eli Zaretskii
2018-07-17 15:53 ` Robert Pluim
2018-07-17 16:17 ` Robert Pluim
2018-07-17 17:15 ` Eli Zaretskii
2018-07-17 18:00 ` Robert Pluim
2018-07-16 15:31 ` Jimmy Yuen Ho Wong
2018-07-16 16:14 ` Stefan Monnier
2018-07-16 16:36 ` Robert Pluim
2018-07-16 18:11 ` Eli Zaretskii
2018-07-16 18:24 ` Stefan Monnier
2018-07-16 17:06 ` Andy Moreton
2018-07-16 17:15 ` Jimmy Yuen Ho Wong
2018-07-16 17:48 ` Paul Eggert
2018-07-17 5:56 ` Robert Pluim
2018-07-17 18:07 ` Robert Pluim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87va9fs3ro.fsf@gmail.com \
--to=rpluim@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=wyuenho@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.