&nbsp; Thanks so much.&nbsp; That makes perfect sense.&nbsp; <br><br><div class="gmail_quote">On Jan 1, 2008 7:52 AM, Mike Cardwell &lt;<a href="mailto:tor@lists.grepular.com">tor@lists.grepular.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">Mark Manning wrote:<br>&gt; That&#39;s awesome! &nbsp;That&#39;s exactly how I was thinking but to be honest I<br>&gt; wasn&#39;t sure how to implement the background service that ties the query<br>&gt; logs to the web server.
<br>&gt;<br>&gt; If it wouldn&#39;t take too long, do you think you could talk about the<br>&gt; specifics a little bit more?<br><br></div>1.) You visit <a href="http://clayman.tor.grepular.com/torcheck.cgi" target="_blank">
http://clayman.tor.grepular.com/torcheck.cgi</a><br><br>2.) The cgi generates a unique code. In this case, a 32 character<br>alphanumeric string. It then spits out some html containing several<br>triggers to try and make the web browser do a dns lookup on
<br>&quot;$code.tordnscheck.grepular.com&quot; where $code is replaced by the unique<br>id it just generated. The triggers are inside the &lt;head&gt;&lt;/head&gt; and are:<br><br>&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot;
<br>href=&quot;http://$code.tordnscheck.grepular.com/style.css&quot; /&gt;<br>&lt;link rel=&quot;shortcut icon&quot; type=&quot;image/x-icon&quot;<br>href=&quot;http://$code.tordnscheck.grepular.com/favicon.ico&quot; /&gt;
<br>&lt;script type=&quot;text/javascript&quot;<br>src=&quot;http://$code.tordnscheck.grepular.com/script.js&quot;&gt;&lt;/script&gt;<br><br>3.) A meta refresh then refreshes the page and adds ?code=$code to the<br>uri arguments.
<br><br>4.) When the page is reloaded it &quot;asks&quot; a separate process that I will<br>describe in a moment, whether or not it knows the IP that did the lookup<br>of $code.tordnscheck.grepular.com, and if so it displays it.
<br><br>5.) There is a separate process written in perl, which uses File::Tail<br>to monitor the bind query log. It&#39;s a threaded application. One thread<br>tails the log looking for entries like $code.tordnscheck.grepular.com.
<br>When it comes across any, it stores the code and the ip together in a<br>shared variable, for up to 10 minutes<br><br>6.) The second thread accepts incoming socket connections. Basically,<br>the torcheck.cgi script makes a tcp connection to the app tailing the
<br>log file and writes $code to it, and the app then returns the IP address<br>and closes the connection.<br><br>The gopher request works in a similar fashion. The trigger is:<br><br>&lt;img src=&quot;gopher://grepular.com/torgophertest/$code&quot; width=&quot;0&quot; height=&quot;0&quot; /&gt;
<br><br>Then I have another application listening on the gopher port looking for<br>requests like &quot;/torgophertest/$code&quot; and then linking $code with the<br>client IP. Then it makes the information available to the cgi via the
<br>same socket method.<br><br>I hope that all makes sense.<br><font color="#888888"><br>Mike<br></font></blockquote></div><br>