Thanks so much. That makes perfect sense. <br><br><div class="gmail_quote">On Jan 1, 2008 7:52 AM, Mike Cardwell <<a href="mailto:tor@lists.grepular.com">tor@lists.grepular.com</a>> 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>> That's awesome! That's exactly how I was thinking but to be honest I<br>> wasn't sure how to implement the background service that ties the query<br>> logs to the web server.
<br>><br>> If it wouldn't take too long, do you think you could talk about the<br>> 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>"$code.tordnscheck.grepular.com" where $code is replaced by the unique<br>id it just generated. The triggers are inside the <head></head> and are:<br><br><link rel="stylesheet" type="text/css"
<br>href="http://$code.tordnscheck.grepular.com/style.css" /><br><link rel="shortcut icon" type="image/x-icon"<br>href="http://$code.tordnscheck.grepular.com/favicon.ico" />
<br><script type="text/javascript"<br>src="http://$code.tordnscheck.grepular.com/script.js"></script><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 "asks" 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'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><img src="gopher://grepular.com/torgophertest/$code" width="0" height="0" />
<br><br>Then I have another application listening on the gopher port looking for<br>requests like "/torgophertest/$code" 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>