From anonymous, 3 Days ago, written in Python.
Embed
  1. import logging
  2. import datetime
  3.  
  4. from fbtftp.base_handler import BaseHandler
  5. from fbtftp.base_handler import ResponseData, StringResponseData
  6. from fbtftp.base_server import BaseServer
  7.  
  8.  
  9. class StaticHandler(BaseHandler):
  10.  
  11.     def get_response_data(self):
  12.         return StringResponseData(str(datetime.datetime.now()) + '\n')
  13.  
  14.  
  15. def _callback(stats):
  16.     pass
  17.  
  18.  
  19. class StaticServer(BaseServer):
  20.  
  21.     def get_handler(self, server_addr, peer, path, options):
  22.         return StaticHandler(server_addr, peer, path, options, stats_callback=_callback)
  23.  
  24.  
  25. def main():
  26.     logging.getLogger().setLevel(logging.DEBUG)
  27.     server = StaticServer('::', 1969, retries=5, timeout=2)
  28.     try:
  29.         server.run()
  30.     except KeyboardInterrupt:
  31.         server.close()
  32.  
  33.  
  34. if __name__ == "__main__":
  35.     main()
  36.