Comparison

plugins/mod_s2s/s2sout.lib.lua @ 8896:739deb514140

mod_s2s: Add setting for overriding DNS resolvers (and avoid reading /etc/resolv.conf every time)
author Kim Alvefur <zash@zash.se>
date Sun, 03 Jun 2018 00:57:51 +0200
parent 8483:6d47b74926dd
child 8902:ac21f13798ae
comparison
equal deleted inserted replaced
8895:d00ea07de9a0 8896:739deb514140
29 local sources = {}; 29 local sources = {};
30 local has_ipv4, has_ipv6; 30 local has_ipv4, has_ipv6;
31 31
32 local dns_timeout = module:get_option_number("dns_timeout", 15); 32 local dns_timeout = module:get_option_number("dns_timeout", 15);
33 dns.settimeout(dns_timeout); 33 dns.settimeout(dns_timeout);
34 local resolvers = module:get_option_set("s2s_dns_resolvers")
34 35
35 local s2sout = {}; 36 local s2sout = {};
36 37
37 local s2s_listener; 38 local s2s_listener;
38 39
48 function s2sout.initiate_connection(host_session) 49 function s2sout.initiate_connection(host_session)
49 initialize_filters(host_session); 50 initialize_filters(host_session);
50 host_session.version = 1; 51 host_session.version = 1;
51 52
52 host_session.resolver = adns.resolver(); 53 host_session.resolver = adns.resolver();
54 if resolvers then
55 for resolver in resolvers do
56 host_session.resolver._resolver:addnameserver(resolver);
57 end
58 end
53 59
54 -- Kick the connection attempting machine into life 60 -- Kick the connection attempting machine into life
55 if not s2sout.attempt_connection(host_session) then 61 if not s2sout.attempt_connection(host_session) then
56 -- Intentionally not returning here, the 62 -- Intentionally not returning here, the
57 -- session is needed, connected or not 63 -- session is needed, connected or not