<> <> <> DIRECTORY BasicTime USING [GMT, Now, Period], Convert USING [RopeFromTime], IO USING [Flush, PutFR, PutRope, STREAM], Rope USING [Cat, Equal, ROPE], IPConfig USING[rootServers], IPDefs USING [Address], IPName USING [AddressToRope, LoadCacheFromName], IPNameSupport, IPNameCache USING [AddressEntry, AliasEntry, BogusAddressEntry, BogusNameEntry, DownAddressEntry, DownNameEntry, DownServerEntry, NameEntry, MXEntry, MXHostInfo, ZoneEntry], ViewerIO USING [CreateViewerStreams, GetViewerFromStream]; IPNameSupportImpl: CEDAR MONITOR IMPORTS BasicTime, Convert, IO, Rope, IPName, IPConfig, ViewerIO EXPORTS IPNameSupport = BEGIN ROPE: TYPE = Rope.ROPE; theLog: IO.STREAM; <> LogRope: PUBLIC PROC [rope: ROPE] ~ { putRope: PROC [stream: IO.STREAM] ~ { IO.PutRope[stream, rope] }; LogItem[putRope]; }; LogItem: ENTRY PROC [put: PROC [IO.STREAM]] ~ { put[theLog]; IO.Flush[theLog] }; NameSummaryLine: PUBLIC PROC [entry: IPNameCache.NameEntry, time: BOOLEAN, showttl: BOOLEAN _ FALSE, log: PROC[ROPE] _ LogRope] = { now: BasicTime.GMT _ BasicTime.Now[]; expires: INT _ BasicTime.Period[from: now, to: entry.expires]; ttl: INT _ entry.ttl; source: ROPE _ IPName.AddressToRope[entry.source]; line: ROPE; Put: PROC [r1, r2, r3, r4: ROPE _ NIL] = {line _ Rope.Cat[line, r1, r2, r3, r4]}; IF time THEN { Put[Convert.RopeFromTime[from: now, start: hours, end: seconds, useAMPM: FALSE, includeZone: FALSE]]; Put[" "]; }; Put[entry.name]; IF entry.addresses # NIL THEN Put[" => "]; FOR list: LIST OF IPDefs.Address _ entry.addresses, list.rest UNTIL list = NIL DO IF list # entry.addresses THEN Put[", "]; Put[IPName.AddressToRope[list.first]]; ENDLOOP; Put[IO.PutFR[", %G", [integer[expires]]]]; IF showttl THEN Put[IO.PutFR[", %G", [integer[ttl]]]]; Put[IO.PutFR[", %G", [rope[source]]]]; IF ~entry.authoritative THEN Put[", Not Auth"]; Put["\n"]; log[line]}; MXSummaryLine: PUBLIC PROC [entry: IPNameCache.MXEntry, time: BOOLEAN, showttl: BOOLEAN _ FALSE, log: PROC[ROPE] _ LogRope] = { now: BasicTime.GMT _ BasicTime.Now[]; expires: INT _ BasicTime.Period[from: now, to: entry.expires]; ttl: INT _ entry.ttl; source: ROPE _ IPName.AddressToRope[entry.source]; line: ROPE; Put: PROC [r1, r2, r3, r4: ROPE _ NIL] = {line _ Rope.Cat[line, r1, r2, r3, r4]}; IF time THEN { Put[Convert.RopeFromTime[from: now, start: hours, end: seconds, useAMPM: FALSE, includeZone: FALSE]]; Put[" "]; }; Put[entry.name]; IF entry.mxHosts # NIL THEN Put[" => "]; FOR list: LIST OF IPNameCache.MXHostInfo _ entry.mxHosts, list.rest UNTIL list = NIL DO IF list # entry.mxHosts THEN Put[" "]; Put[list.first.host]; Put[IO.PutFR[", MXP: %G", [integer[list.first.preference]]]]; Put[IO.PutFR[", %G", [integer[expires]]]]; IF showttl THEN Put[IO.PutFR[", %G", [integer[ttl]]]]; Put[IO.PutFR[", %G", [rope[source]]]]; IF ~entry.authoritative THEN Put[", Not Auth"]; Put["\n"]; ENDLOOP; log[line]}; AliasSummaryLine: PUBLIC PROC [entry: IPNameCache.AliasEntry, time: BOOLEAN, showttl: BOOLEAN _ FALSE, log: PROC[ROPE] _ LogRope] = { now: BasicTime.GMT _ BasicTime.Now[]; expires: INT _ BasicTime.Period[from: now, to: entry.expires]; ttl: INT _ entry.ttl; source: ROPE _ IPName.AddressToRope[entry.source]; line: ROPE; Put: PROC [r1, r2, r3, r4: ROPE _ NIL] = {line _ Rope.Cat[line, r1, r2, r3, r4]}; IF time THEN { Put[Convert.RopeFromTime[from: now, start: hours, end: seconds, useAMPM: FALSE, includeZone: FALSE]]; Put[" "]}; Put[entry.alias]; Put[" => "]; Put[entry.name]; Put[IO.PutFR[", %G", [integer[expires]]]]; IF showttl THEN Put[IO.PutFR[", %G", [integer[ttl]]]]; Put[IO.PutFR[", %G", [rope[source]]]]; IF ~entry.authoritative THEN Put[", Not Auth"]; Put["\n"]; log[line]}; BogusNameSummaryLine: PUBLIC PROC [entry: IPNameCache.BogusNameEntry, time: BOOLEAN, showttl: BOOLEAN _ FALSE, log: PROC[ROPE] _ LogRope] = { now: BasicTime.GMT _ BasicTime.Now[]; expires: INT _ BasicTime.Period[from: now, to: entry.expires]; ttl: INT _ entry.ttl; source: ROPE _ IPName.AddressToRope[entry.source]; line: ROPE; Put: PROC [r1, r2, r3, r4: ROPE _ NIL] = {line _ Rope.Cat[line, r1, r2, r3, r4]}; IF time THEN { Put[Convert.RopeFromTime[from: now, start: hours, end: seconds, useAMPM: FALSE, includeZone: FALSE]]; Put[" "]}; Put[entry.bogus]; Put[IO.PutFR[ " => ??, %G", [integer[expires]]]]; IF showttl THEN Put[IO.PutFR[", %G", [integer[ttl]]]]; Put[IO.PutFR[", %G", [rope[source]]]]; IF ~entry.authoritative THEN Put[", Not Auth"]; Put["\n"]; log[line]}; DownNameSummaryLine: PUBLIC PROC [entry: IPNameCache.DownNameEntry, time: BOOLEAN, showttl: BOOLEAN _ FALSE, log: PROC[ROPE] _ LogRope] = { now: BasicTime.GMT _ BasicTime.Now[]; expires: INT _ BasicTime.Period[from: now, to: entry.expires]; ttl: INT _ entry.ttl; line: ROPE; Put: PROC [r1, r2, r3, r4: ROPE _ NIL] = {line _ Rope.Cat[line, r1, r2, r3, r4]}; IF time THEN { Put[Convert.RopeFromTime[from: now, start: hours, end: seconds, useAMPM: FALSE, includeZone: FALSE]]; Put[" "]}; Put[entry.name]; Put[IO.PutFR[ " => ??, %G", [integer[expires]]]]; IF showttl THEN Put[IO.PutFR[ ", %G", [integer[ttl]]]]; Put["\n"]; log[line]}; AddressSummaryLine: PUBLIC PROC [entry: IPNameCache.AddressEntry, time: BOOLEAN, showttl: BOOLEAN _ FALSE, log: PROC[ROPE] _ LogRope] = { now: BasicTime.GMT _ BasicTime.Now[]; expires: INT _ BasicTime.Period[from: now, to: entry.expires]; ttl: INT _ entry.ttl; source: ROPE _ IPName.AddressToRope[entry.source]; line: ROPE; Put: PROC [r1, r2, r3, r4: ROPE _ NIL] = {line _ Rope.Cat[line, r1, r2, r3, r4]}; IF time THEN { Put[Convert.RopeFromTime[from: now, start: hours, end: seconds, useAMPM: FALSE, includeZone: FALSE]]; Put[" "]}; Put[IPName.AddressToRope[entry.address]]; Put[" => "]; FOR list: LIST OF ROPE _ entry.names, list.rest UNTIL list = NIL DO IF list # entry.names THEN Put[", "]; Put[list.first]; ENDLOOP; Put[IO.PutFR[ ", %G", [integer[expires]]]]; IF showttl THEN Put[IO.PutFR[ ", %G", [integer[ttl]]]]; Put[IO.PutFR[ ", %G", [rope[source]]]]; IF ~entry.authoritative THEN Put[", Not Auth"]; Put["\n"]; log[line]}; BogusAddressSummaryLine: PUBLIC PROC [entry: IPNameCache.BogusAddressEntry, time: BOOLEAN, showttl: BOOLEAN _ FALSE, log: PROC[ROPE] _ LogRope] = { now: BasicTime.GMT _ BasicTime.Now[]; expires: INT _ BasicTime.Period[from: now, to: entry.expires]; ttl: INT _ entry.ttl; source: ROPE _ IPName.AddressToRope[entry.source]; line: ROPE; Put: PROC [r1, r2, r3, r4: ROPE _ NIL] = {line _ Rope.Cat[line, r1, r2, r3, r4]}; IF time THEN { Put[Convert.RopeFromTime[from: now, start: hours, end: seconds, useAMPM: FALSE, includeZone: FALSE]]; Put[" "]}; Put[IPName.AddressToRope[entry.bogus]]; Put[IO.PutFR[ " => ??, %G", [integer[expires]]]]; IF showttl THEN Put[IO.PutFR[ ", %G", [integer[ttl]]]]; IF ~entry.authoritative THEN Put[", Not Auth"]; Put["\n"]; log[line]}; DownAddressSummaryLine: PUBLIC PROC [entry: IPNameCache.DownAddressEntry, time: BOOLEAN, showttl: BOOLEAN _ FALSE, log: PROC[ROPE] _ LogRope] = { now: BasicTime.GMT _ BasicTime.Now[]; expires: INT _ BasicTime.Period[from: now, to: entry.expires]; ttl: INT _ entry.ttl; line: ROPE; Put: PROC [r1, r2, r3, r4: ROPE _ NIL] = {line _ Rope.Cat[line, r1, r2, r3, r4]}; IF time THEN { Put[Convert.RopeFromTime[from: now, start: hours, end: seconds, useAMPM: FALSE, includeZone: FALSE]]; Put[" "]}; Put[IPName.AddressToRope[entry.address]]; Put[IO.PutFR[ " => ??, %G", [integer[expires]]]]; IF showttl THEN Put[IO.PutFR[ ", %G", [integer[ttl]]]]; Put["\n"]; log[line]}; DownServerSummaryLine: PUBLIC PROC [entry: IPNameCache.DownServerEntry, time: BOOLEAN, showttl: BOOLEAN _ FALSE, log: PROC[ROPE] _ LogRope] = { now: BasicTime.GMT _ BasicTime.Now[]; expires: INT _ BasicTime.Period[from: now, to: entry.expires]; ttl: INT _ entry.ttl; line: ROPE; Put: PROC [r1, r2, r3, r4: ROPE _ NIL] = {line _ Rope.Cat[line, r1, r2, r3, r4]}; IF time THEN { Put[Convert.RopeFromTime[from: now, start: hours, end: seconds, useAMPM: FALSE, includeZone: FALSE]]; Put[" "]}; Put[IPName.AddressToRope[entry.address]]; Put[IO.PutFR[ " => ??, %G", [integer[expires]]]]; IF showttl THEN Put[IO.PutFR[ ", %G", [integer[ttl]]]]; Put["\n"]; log[line]}; ZoneSummaryLine: PUBLIC PROC [entry: IPNameCache.ZoneEntry, time: BOOLEAN, showttl: BOOLEAN _ FALSE, log: PROC[ROPE] _ LogRope] = { now: BasicTime.GMT _ BasicTime.Now[]; expires: INT _ BasicTime.Period[from: now, to: entry.expires]; ttl: INT _ entry.ttl; source: ROPE _ IPName.AddressToRope[entry.source]; line: ROPE; Put: PROC [r1, r2, r3, r4: ROPE _ NIL] = {line _ Rope.Cat[line, r1, r2, r3, r4]}; IF time THEN { Put[Convert.RopeFromTime[from: now, start: hours, end: seconds, useAMPM: FALSE, includeZone: FALSE]]; Put[" "]}; Put[entry.zone]; Put[" is served by "]; FOR list: LIST OF ROPE _ entry.servers, list.rest UNTIL list = NIL DO IF list # entry.servers THEN Put[", "]; Put[list.first]; ENDLOOP; Put[IO.PutFR[ ", %G", [integer[expires]]]]; IF showttl THEN Put[IO.PutFR[ ", %G", [integer[ttl]]]]; Put[IO.PutFR[ ", %G", [rope[source]]]]; IF ~entry.authoritative THEN Put[", Not Auth"]; Put["\n"]; log[line]}; <> RopeInList: PUBLIC PROC [ropes: LIST OF ROPE, rope: ROPE] RETURNS [yes: BOOL] = { FOR list: LIST OF ROPE _ ropes, list.rest UNTIL list = NIL DO IF Rope.Equal[list.first, rope, FALSE] THEN RETURN [TRUE]; ENDLOOP; RETURN[FALSE]; }; AddressInList: PUBLIC PROC [addresses: LIST OF IPDefs.Address, address: IPDefs.Address] RETURNS [yes: BOOL] = { FOR list: LIST OF IPDefs.Address _ addresses, list.rest UNTIL list = NIL DO IF list.first = address THEN RETURN [TRUE]; ENDLOOP; RETURN[FALSE]; }; MakeRopeInList: PUBLIC PROC [ropes: LIST OF ROPE, name: ROPE] RETURNS [new: LIST OF ROPE] = { IF ropes = NIL THEN RETURN[LIST[name]]; new _ ropes; DO IF Rope.Equal[ropes.first, name, FALSE] THEN RETURN; IF ropes.rest = NIL THEN { ropes.rest _ LIST[name]; RETURN; }; ropes _ ropes.rest; ENDLOOP; }; MakeAddressInList: PUBLIC PROC [addresses: LIST OF IPDefs.Address, address: IPDefs.Address] RETURNS [new: LIST OF IPDefs.Address] = { IF addresses = NIL THEN RETURN[LIST[address]]; new _ addresses; DO IF addresses.first = address THEN RETURN; IF addresses.rest = NIL THEN { addresses.rest _ LIST[address]; RETURN; }; addresses _ addresses.rest; ENDLOOP; }; <> <<>> [, theLog] _ ViewerIO.CreateViewerStreams [ name: "Resolver Log", backingFile: "Resolver.log", editedStream: FALSE]; ViewerIO.GetViewerFromStream[theLog].inhibitDestroy _ TRUE; theLog.PutRope["########## ArpaGateway Resolver Log ##########\n\n"]; <> FOR servers: LIST OF Rope.ROPE _ IPConfig.rootServers, servers.rest UNTIL servers = NIL DO [] _ IPName.LoadCacheFromName[servers.first, FALSE, TRUE]; ENDLOOP; END.