I see, learn and rediscover… everyday!
 
Domain Tracker

Domain Tracker

This is script/project started when three of my friends ended up losing their domain simply because they forgot to renew the domain. It is a helpless situation to recover a lost domain and the ‘techie’ inside me realized I had to do something. Especially when I’m making more and more folks from my team to write on their own domain.

Technical considerations:

  1. Should be easy to implement.
  2. Should not have any need to monitor the script. Since I’m building a monitoring script, I don’t want to write another script to monitor my script.

The first practical solution was to simply use a free service. I really liked https://domaintracker.app/, but unfortunately it was free only for 5 domains. And I have too many domains to track.

Next solution was to build a complete web app (including front-end, back-end) and everything and soon realised this isn’t going well in the right direction.

The final solution was to use Google Apps Script. And a quick google search about a few services to

The core function which fetches all the domain details

function fetchDomainDetails(domain) {
  var options = {
    'contentType': 'application/json'
  };
  var url = 'https://api.beaglesecurity.com/v1/freecheck/domain?url=' + domain;
  var response = UrlFetchApp.fetch(url, options);
  return JSON.parse(response);
}

With this, everything should’ve been so much. But life is never so simple. The API service I was using had a rate-liming functionality and hence I had to fetch the details of one domain per minute. The following function uses the current minute to pick a row and update the row. The only side effect of this is that I can at max only track 60 domains. Might figure out a work around when I find more than 60.

function updateDomainData() {
  domains = getAllDomains();
  var i = (new Date().getMinutes()+1)%domains.length;
  response = fetchDomainDetails(domains[i]);
  updateDomainDetails(i, response);
}

You can access the full script at https://gist.github.com/sp2hari/2a728330dcae0faa91db979ab5f18c1b

Here is the final output of the script. No more domains lost!

What makes Google scripts a good solution for this problem is the automatic availability of the run and error logging. Google Apps Script gives a good way to look into these two.

Run logs

Error logs

Overall, this is exactly what I needed to solve this problem. And as far as those three friends, two of them got their domains back. The last one probably has to wait for few more months to recover her domain back.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.