View/Edit #142:Lookup

Switch to edit mode.

Name(s): Lookup
1:  if (!caller_perms().wizard)
2:    raise(E_PERM)
3:  endif
4:  {Item, Type, ?IgnoreCache = 0, ?Servers = this.DNSServers} = args
5:  if (typeof(Type) == $STR)
6:    Type = Type in this.Types
7:  endif
8:  if (Type == 0 || (Type > 16 && Type < 251))
9:    raise(E_INVARG)
10: endif
11: this:debug("Item: ", Item, "  Type: ", Type)
12: if (!IgnoreCache && (i = $list_utils:iassoc({Item, Type}, this.cache)))
13:   if (time() < this.Cache[i][2])
14:     this:Debug("Item found in cache.")
15:     return this.Cache[i][3]
16:   endif
17: endif
18: for Server in ({@Servers})
19:   if ((Data = this:GetDNSData(Item, Type, Server)) != E_NONE && Data != {})
20:     break
21:   endif
22: endfor
23: if (Data == E_NONE)
24:   return {}
25: endif
26: Data = this:ProcessReply(Data)
27: suspend(0)
28: Data = Data[2]
29: expire = Data ? $maxint | 86400
30: for i in [1..length(Data)]
31:   expire = min(expire, Data[i][4])
32:   if (Data[i][2] <= length(this.Types))
33:     Data[i][2] = this.Types[Data[i][2]]
34:   endif
35:   if (Data[i][3] <= length(this.Classes))
36:     Data[i][3] = this.Classes[Data[i][3]]
37:   endif
38: endfor
39: if (Data && expire > 0)
40:   if (j = $list_utils:iassoc({Item, Type}, this.Cache))
41:     this.cache[j][2] = expire + time()
42:     this.cache[j][3] = Data
43:   else
44:     this.cache = {@this.cache, {{Item, Type}, expire + time(), Data}}
45:   endif
46: endif
47: return Data
48: "Last modified by manta (#7165) on Sat Mar 11 19:36:30 2000 MST."
49: "This verb previously owned by manta (#7165), and chowned to $slacker upon dewizarding (Sat Aug 17 14:50:05 2002 MDT)."
50: "Last modified by Dax (#789) on Tue May  3 13:43:07 2005 MDT."

Verb arguments: this none this
Verb perms: Readable eXecutable NOT-Debug
Verb owned by: Slacker (#55)

You are not logged in.

[home | help | who | search | setup | code]