A PHP Error was encountered

Severity: 8192

Message: Function create_function() is deprecated

Filename: geshi/geshi.php

Line Number: 4698

Backtrace:

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4698
Function: _error_handler

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4621
Function: _optimize_regexp_list_tokens_to_string

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 1655
Function: optimize_regexp_list

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2029
Function: optimize_keyword_group

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2168
Function: build_parse_cache

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/Process.php
Line: 45
Function: parse_code

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/models/Pastes.php
Line: 517
Function: syntax

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/controllers/Main.php
Line: 693
Function: getPaste

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/index.php
Line: 315
Function: require_once

Re: Traceroute in python - Stikked
From tera.lav007@gmail.com, 5 Years ago, written in Python.
This paste is a reply to Traceroute in python from Jessica - view diff
Embed
  1. import socket
  2. import sys
  3.  
  4. class TraceRoute(object):
  5.    
  6.     BADDR = "0.0.0.0" # default bind address - (all IPs)
  7.     PORT = 33434 # default port
  8.     ICMP = socket.getprotobyname('icmp')
  9.     UDP = socket.getprotobyname('udp')
  10.  
  11.     desternation = ""
  12.     ttl = 0 # we inrecement this by one each time.    
  13.  
  14.     # sockets
  15.     reciever = None
  16.     sender = None
  17.  
  18.     # finished?
  19.     finished = False
  20.  
  21.     def __init__(self, desternation):
  22.         self.desternation = socket.gethostbyname(desternation)
  23.        
  24.         self.reciever = socket.socket(socket.AF_INET, socket.SOCK_RAW, self.ICMP)
  25.         self.sender = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, self.UDP)
  26.        
  27.         # bind to reciever so we can listen for replies
  28.         self.reciever.bind((self.BADDR, self.PORT))
  29.  
  30.     def next_server(self):
  31.         """ Connects to next server 1 hop away from current server (i.e. server[ttl + 1]) """
  32.         if self.finished:
  33.             # we have nothing to do, just return
  34.             return
  35.  
  36.         # first job increment the ttl on the socket
  37.         self.ttl += 1
  38.         self.sender.setsockopt(socket.SOL_IP, socket.IP_TTL, self.ttl)
  39.        
  40.         self.sender.sendto("", (self.desternation, self.PORT))
  41.         current_server = self.reciever.recvfrom(512)[1][0] # get 512 bytes from the reciever
  42.         self.display(current_server)
  43.  
  44.         if current_server == self.desternation:
  45.             self.finished = True
  46.  
  47.     def display(self, address):
  48.         """ Gets the hostname (if we can) and displays """
  49.         try:
  50.             name = socket.gethostbyaddr(address)[0]
  51.             print "%s) %s (%s)" % (self.ttl, name, address)
  52.         except socket.error:
  53.             # we couldn't - we'll just tell them the IP address
  54.             print "%s) %s" % (self.ttl, address)
  55.        
  56.     def __del__(self):
  57.         """ Be good and close our sockets """
  58.         try:
  59.             self.reciever.close()
  60.         except socket.error:
  61.             # already closed
  62.             pass
  63.  
  64.         try:
  65.             self.sender.close()
  66.         except socket.error:
  67.             # already closed
  68.             pass
  69.  
  70. if __name__ == "__main__":
  71.     # lets get the address from the commandline args
  72.     if len(sys.argv) <= 1:
  73.         # nothing been specified
  74.         print "You need to give an address"
  75.         print "%s <server>" % sys.argv[0]
  76.         sys.exit() # we can't do anything.
  77.    
  78.     tracert = TraceRoute(sys.argv[1])
  79.     while not tracert.finished:
  80.         tracert.next_server()