def get(self):
		# Get the info hash
		info_hash = self.get_hexencoded_argument("info_hash")
		if not info_hash:
			self.send_tracker_error("Your client forgot to send your torrent's info_hash")
			return

		# Get the peer id
		peer_id = self.get_hexencoded_argument("peer_id")

		# Get the port and check it for sanity
		port = self.get_port()
		if not port:
			self.send_tracker_error("Invalid port number or port number missing")
			return

		addr_ipv6, port_ipv6 = self.get_ipv6_address(port)
		addr_ipv4, port_ipv4 = self.get_ipv4_address(port)

		# Handle events
		event = self.get_argument("event", None)
		if event:
			if not event in ("started", "stopped", "completed"):
				self.send_tracker_error("Got unknown event")
				return

			self.tracker.handle_event(event, peer_id, info_hash)

			if event == "stopped":
				return

		peer_info = {
			"address6"   : addr_ipv6,
			"port6"      : port_ipv6,
			"address4"   : addr_ipv4,
			"port4"      : port_ipv4,
			"downloaded" : self.get_argument("downloaded", 0),
			"uploaded"   : self.get_argument("uploaded", 0),
			"left_data"  : self.get_argument("left", 0),
		}

		self.tracker.update_peer(peer_id, info_hash, **peer_info)

		no_peer_id = self.get_argument("no_peer_id", False)
		numwant = self.get_argument("numwant", self.tracker.numwant)

		peers = self.tracker.get_peers(info_hash, limit=numwant, no_peer_id=no_peer_id)

		response = bencode({
			"tracker id"   : self.tracker.tracker_id,
			"interval"     : self.tracker.interval,
			"min interval" : self.tracker.min_interval,
			"peers"        : peers,
			"complete"     : self.tracker.complete(info_hash),
			"incomplete"   : self.tracker.incomplete(info_hash),
		})
		self.finish(response)
	def send_tracker_error(self, error_message):
		msg = bencode({"failure reason" : error_message })
		self.finish(msg)
	def get(self):
		info_hashes = self.get_hexencoded_argument("info_hash", all=True)

		response = self.tracker.scrape(info_hashes)

		self.finish(bencode(response))