[systemd-devel] [RFC 3/6] proxy-discoveryd: Add PAC support through duktape js engine
Lennart Poettering
lennart at poettering.net
Sun Apr 12 11:32:59 PDT 2015
On Fri, 10.04.15 15:26, Marcel Holtmann (marcel at holtmann.org) wrote:
> >> +static int pac_dns_resolve(duk_context *ctx) {
> >> + _cleanup_free_ char *address = NULL;
> >> + struct addrinfo hints = {};
> >> + struct addrinfo *res, *addr;
> >> + const char *hostname;
> >> + int r;
> >> +
> >> + hostname = duk_require_string(ctx, 0);
> >> +
> >> + hints.ai_family = AF_INET;
> >> +
> >> + r = getaddrinfo(hostname, NULL, &hints, &res);
> >> + if (r != 0)
> >> + return 0;
> >
> > Hm, synchronous getaddrinfo() is nasty... Please use sd-resolve for
> > this, which adds asynchronous getaddrinfo() for cases like this...
>
> you do realize that you want this synchronous. These are the magic
> dnsResolve and myIpAddress Javascript functions that are expected to
> be present when executing the PAC file. There are a few more, but
> they can be implemented in Javascript and don't need a C
> backend. These two actually need that. So you need to report the
> result.
Ah I see, this function is only ever called from the PAC javascript
code? OK, in that case it should be synchronous indeed.
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list