Now, let's have a look at an example URL redirector program in Python, which can be extended to fit any scenario:
#!/usr/bin/env python import sys def redirect_url(line, concurrent): list = line.split(' ') # 1st or 2nd element of the list # is the URL depending on concurrency if concurrent: old_url = list[1] else: old_url = list[0] # Do remember that the new_url # should contain a '\n' at the end. new_url = '\n' # Take the decision and modify the url if needed if old_url.endswith('.avi'): # Rewrite example new_url = 'http://example.com/' + new_url elif old_url.endswith('.exe'): # Redirect example new_url = '302:http://google.co.in/' + new_url return new_url def main(concurrent = True): # the format of the line read from stdin with concurrency is # ID URL ip-address/fqdn ident method myip=ip myport=port # and with concurrency disabled is # URL ip-address/fqdn ident...