Software /
code /
prosody
Comparison
plugins/mod_admin_telnet.lua @ 10619:ef620906ab82
Merge 0.11->trunk
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 24 Jan 2020 23:28:15 +0100 |
parent | 10544:0bd408d93f9a |
parent | 10618:232841373711 |
child | 10620:09d98cd38fe2 |
comparison
equal
deleted
inserted
replaced
10617:8941bebd64e4 | 10619:ef620906ab82 |
---|---|
1175 end | 1175 end |
1176 end | 1176 end |
1177 | 1177 |
1178 def_env.dns = {}; | 1178 def_env.dns = {}; |
1179 local adns = require"net.adns"; | 1179 local adns = require"net.adns"; |
1180 local dns = require"net.dns"; | 1180 |
1181 local function get_resolver(session) | |
1182 local resolver = session.dns_resolver; | |
1183 if not resolver then | |
1184 resolver = adns.resolver(); | |
1185 session.dns_resolver = resolver; | |
1186 end | |
1187 return resolver; | |
1188 end | |
1181 | 1189 |
1182 function def_env.dns:lookup(name, typ, class) | 1190 function def_env.dns:lookup(name, typ, class) |
1191 local resolver = get_resolver(self.session); | |
1183 local ret = "Query sent"; | 1192 local ret = "Query sent"; |
1184 local print = self.session.print; | 1193 local print = self.session.print; |
1185 local function handler(...) | 1194 local function handler(...) |
1186 ret = "Got response"; | 1195 ret = "Got response"; |
1187 print(...); | 1196 print(...); |
1188 end | 1197 end |
1189 adns.lookup(handler, name, typ, class); | 1198 resolver:lookup(handler, name, typ, class); |
1190 return true, ret; | 1199 return true, ret; |
1191 end | 1200 end |
1192 | 1201 |
1193 function def_env.dns:addnameserver(...) | 1202 function def_env.dns:addnameserver(...) |
1194 dns._resolver:addnameserver(...) | 1203 local resolver = get_resolver(self.session); |
1204 resolver._resolver:addnameserver(...) | |
1195 return true | 1205 return true |
1196 end | 1206 end |
1197 | 1207 |
1198 function def_env.dns:setnameserver(...) | 1208 function def_env.dns:setnameserver(...) |
1199 dns._resolver:setnameserver(...) | 1209 local resolver = get_resolver(self.session); |
1210 resolver._resolver:setnameserver(...) | |
1200 return true | 1211 return true |
1201 end | 1212 end |
1202 | 1213 |
1203 function def_env.dns:purge() | 1214 function def_env.dns:purge() |
1204 dns.purge() | 1215 local resolver = get_resolver(self.session); |
1216 resolver._resolver:purge() | |
1205 return true | 1217 return true |
1206 end | 1218 end |
1207 | 1219 |
1208 function def_env.dns:cache() | 1220 function def_env.dns:cache() |
1209 return true, "Cache:\n"..tostring(dns.cache()) | 1221 local resolver = get_resolver(self.session); |
1222 return true, "Cache:\n"..tostring(resolver._resolver.cache) | |
1210 end | 1223 end |
1211 | 1224 |
1212 def_env.http = {}; | 1225 def_env.http = {}; |
1213 | 1226 |
1214 function def_env.http:list() | 1227 function def_env.http:list() |