Example #1
0
 def edit_ipv6(self):
     ''' Add ipv6 addresses to a box (sorta edits the box object) '''
     form = Form(box_uuid="Select a box", ipv6="Please provide a list of IPv6 addresses")
     if form.validate(self.request.arguments):
         errors = []
         box = Box.by_uuid(self.get_argument('box_uuid'))
         if box is not None:
             ips_string = self.get_argument('ipv6').replace('\n', ',').lower()
             ips = filter(lambda char: char in "1234567890abcdef:,", ips_string).split(",")
             for ip in filter(lambda ip: 0 < len(ip), ips):
                 try:
                     box = Box.by_ip_address(ip)
                     if box is None:
                         addr = IpAddress(box_id=box.id, v6=ip)
                         dbsession.add(addr)
                     else:
                         errors.append(
                             "%s has already been assigned to %s." % (ip, box.name,)
                         )
                 except ValueError:
                     errors.append(
                         "'%s' is not a valid IPv6 address" % str(ip[:39])
                     )
             dbsession.flush()
         else:
             errors.append("Box does not exist")
         self.render("admin/view/game_objects.html", errors=errors)
     else:
         self.render("admin/view/game_objects.html", errors=form.errors)
Example #2
0
 def edit_ipv6(self):
     ''' Add ipv6 addresses to a box (sorta edits the box object) '''
     form = Form(box_uuid="Select a box",
                 ipv6="Please provide a list of IPv6 addresses")
     if form.validate(self.request.arguments):
         errors = []
         box = Box.by_uuid(self.get_argument('box_uuid'))
         if box is not None:
             ips_string = self.get_argument('ipv6').replace('\n',
                                                            ',').lower()
             ips = filter(lambda char: char in "1234567890abcdef:,",
                          ips_string).split(",")
             for ip in filter(lambda ip: 0 < len(ip), ips):
                 try:
                     box = Box.by_ip_address(ip)
                     if box is None:
                         addr = IpAddress(box_id=box.id, v6=ip)
                         dbsession.add(addr)
                     else:
                         errors.append(
                             "%s has already been assigned to %s." % (
                                 ip,
                                 box.name,
                             ))
                 except ValueError:
                     errors.append("'%s' is not a valid IPv6 address" %
                                   str(ip[:39]))
             dbsession.flush()
         else:
             errors.append("Box does not exist")
         self.render("admin/view/game_objects.html", errors=errors)
     else:
         self.render("admin/view/game_objects.html", errors=form.errors)
Example #3
0
 def open(self):
     ''' When we receive a new websocket connect '''
     box = Box.by_ip_address(self.request.remote_ip)
     if box is not None:
         self.box = box
         self.remote_ip = self.request.remote_ip
         self.write_message("box ok")
     else:
         self.close()
Example #4
0
 def open(self):
     ''' When we receive a new websocket connect '''
     box = Box.by_ip_address(self.request.remote_ip)
     if box is not None:
         self.box = box
         self.remote_ip = self.request.remote_ip
         self.write_message("box ok")
     else:
         self.close()
Example #5
0
 def open(self, *args):
     """ Steps 1 and 2; called when a new bot connects """
     box = Box.by_ip_address(self.request.remote_ip)
     self.remote_ip = self.request.remote_ip
     if box is None and self.config.whitelist_box_ips:
         logging.debug("Rejected bot from '%s' (not a box)" % self.request.remote_ip)
         self.write_message({"opcode": "error", "message": "Invalid IP address."})
         self.close()
     else:
         logging.debug("Interrogating bot on %s" % self.request.remote_ip)
         self.write_message({"opcode": "interrogate", "xid": self.xid})
Example #6
0
 def open(self, *args):
     """ Steps 1 and 2; called when a new bot connects """
     box = Box.by_ip_address(self.request.remote_ip)
     self.remote_ip = self.request.remote_ip
     if box is None and self.config.whitelist_box_ips:
         logging.debug("Rejected bot from '%s' (not a box)" % self.request.remote_ip)
         self.write_message({"opcode": "error", "message": "Invalid IP address."})
         self.close()
     else:
         logging.debug("Interrogating bot on %s" % self.request.remote_ip)
         self.write_message({"opcode": "interrogate", "xid": self.xid})
Example #7
0
 def open(self, *args):
     ''' Steps 1 and 2; called when a new bot connects '''
     box = Box.by_ip_address(self.request.remote_ip)
     self.remote_ip = self.request.remote_ip
     if box is None and self.config.whitelist_box_ips:
         logging.debug("Rejected bot from '%s' (not a box)" % self.request.remote_ip)
         self.write_message({
             'opcode': 'error',
             'message': 'Invalid IP address.'
         })
         self.close()
     else:
         logging.debug("Interrogating bot on %s" % self.request.remote_ip)
         self.write_message({'opcode': 'interrogate', 'xid': self.xid})
Example #8
0
 def open(self, *args):
     ''' Steps 1 and 2; called when a new bot connects '''
     box = Box.by_ip_address(self.request.remote_ip)
     self.remote_ip = self.request.remote_ip
     if box is None and self.config.whitelist_box_ips:
         logging.debug("Rejected bot from '%s' (not a box)" % self.request.remote_ip)
         self.write_message({
             'opcode': 'error',
             'message': 'Invalid IP address.'
         })
         self.close()
     else:
         logging.debug("Interrogating bot on %s" % self.request.remote_ip)
         self.write_message({'opcode': 'interrogate', 'xid': self.xid})
Example #9
0
 def open(self, *args):
     ''' When we receive a new websocket connect '''
     box = Box.by_ip_address(self.request.remote_ip)
     if box is not None:
         self.box_uuid = box.uuid
         self.box_name = box.name
         self.remote_ip = self.request.remote_ip
         self.write_message({
             'opcode': 'get_user',
         })
     else:
         logging.debug("Rejected bot from '%s' (not a box)" % self.request.remote_ip)
         self.write_message({
             'opcode': 'error',
             'message': 'Invalid IP address.'
         })
         self.close()
Example #10
0
 def open(self, *args):
     ''' When we receive a new websocket connect '''
     box = Box.by_ip_address(self.request.remote_ip)
     if box is not None:
         self.box_uuid = box.uuid
         self.box_name = box.name
         self.remote_ip = self.request.remote_ip
         self.write_message({
             'opcode': 'get_user',
         })
     else:
         logging.debug("Rejected bot from '%s' (not a box)" %
                       self.request.remote_ip)
         self.write_message({
             'opcode': 'error',
             'message': 'Invalid IP address.'
         })
         self.close()
Example #11
0
	def get(self, *args, **kwargs):
		''' Registers a reporting service on a remote box '''
		box = Box.by_ip_address(self.request.remote_ip)
		if box != None:
			try:
				display_name = self.get_argument("handle")
				user = User.by_display_name(display_name)
				if user != None and not user.team.is_controlling(box):
					user.give_control(box)
					self.dbsession.add(user)
					self.dbsession.flush()
					self.notify(user, box)
					self.write(unicode(user.team.listen_port))
				else:
					self.write("Invalid handle")
			except:
				self.write("Missing parameter")
		else:
			self.write("Invalid ip address")
		self.finish()
Example #12
0
 def get(self, *args, **kwargs):
     ''' Registers a reporting service on a remote box '''
     box = Box.by_ip_address(self.request.remote_ip)
     if box is not None:
         try:
             handle = self.get_argument("handle")
             user = User.by_handle(handle)
             if user is not None:
                 if not box in user.team.boxes:
                     user.team.boxes.append(box)
                     dbsession.add(user.team)
                     dbsession.flush()
                 self.write(unicode(user.team.listen_port))
             else:
                 self.write("Invalid handle")
         except:
             self.write("Missing parameter")
     else:
         self.write("Invalid ip address")
     self.finish()
 def get(self, *args, **kwargs):
     """ Registers a reporting service on a remote box """
     box = Box.by_ip_address(self.request.remote_ip)
     if box is not None:
         try:
             handle = self.get_argument("handle")
             user = User.by_handle(handle)
             if user is not None:
                 if not box in user.team.boxes:
                     user.team.boxes.append(box)
                     dbsession.add(user.team)
                     dbsession.flush()
                 self.write(unicode(user.team.listen_port))
             else:
                 self.write("Invalid handle")
         except:
             self.write("Missing parameter")
     else:
         self.write("Invalid ip address")
     self.finish()