net.dns: Fix tostring() for SRV records
authorMatthew Wild <mwild1@gmail.com>
Fri, 21 Jan 2011 14:02:02 +0000 (14:02 +0000)
committerMatthew Wild <mwild1@gmail.com>
Fri, 21 Jan 2011 14:02:02 +0000 (14:02 +0000)
net/dns.lua

index 61fb62e8e2f6855f5f2117bcb74f977b46dfe21e..c905f56c5d612565d416a2fcd85321cc64f58b7a 100644 (file)
@@ -158,8 +158,6 @@ resolver.__index = resolver;
 
 resolver.timeout = default_timeout;
 
-local SRV_tostring;
-
 local function default_rr_tostring(rr)
        local rr_val = rr.type and rr[rr.type:lower()];
        if type(rr_val) ~= "string" then
@@ -170,8 +168,13 @@ end
 
 local special_tostrings = {
        LOC = resolver.LOC_tostring;
-       MX = function (rr) return string.format('%2i %s', rr.pref, rr.mx); end;
-       SRV = SRV_tostring;
+       MX  = function (rr)
+               return string.format('%2i %s', rr.pref, rr.mx);
+       end;
+       SRV = function (rr)
+               local s = rr.srv;
+               return string.format('%5d %5d %5d %s', s.priority, s.weight, s.port, s.target);
+       end;
 };
 
 local rr_metatable = {};   -- - - - - - - - - - - - - - - - - - -  rr_metatable
@@ -475,12 +478,6 @@ function resolver:PTR(rr)
        rr.ptr = self:name();
 end
 
-function SRV_tostring(rr)    -- - - - - - - - - - - - - - - - - - SRV_tostring
-       local s = rr.srv;
-       return string.format( '%5d %5d %5d %s', s.priority, s.weight, s.port, s.target );
-end
-
-
 function resolver:TXT(rr)    -- - - - - - - - - - - - - - - - - - - - - -  TXT
        rr.txt = self:sub (rr.rdlength);
 end