2009-08-20 22:57:24 +00:00
|
|
|
"""
|
|
|
|
|
Copyright 2009, Linden Research, Inc.
|
2021-04-30 17:30:24 +00:00
|
|
|
See NOTICE.md for previous contributors
|
|
|
|
|
Copyright 2021, Salad Dais
|
|
|
|
|
All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
|
version 3 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-08-20 22:57:24 +00:00
|
|
|
"""
|
2009-09-04 05:00:00 +00:00
|
|
|
from logging import getLogger
|
2009-06-05 21:02:59 +00:00
|
|
|
|
2022-10-14 03:47:48 +00:00
|
|
|
import llsd
|
2009-06-05 21:02:59 +00:00
|
|
|
|
2021-04-30 17:30:24 +00:00
|
|
|
from hippolyzer.lib.base.message.data import msg_details
|
2009-06-05 21:02:59 +00:00
|
|
|
|
|
|
|
|
logger = getLogger('...message.message_dot_xml')
|
|
|
|
|
|
|
|
|
|
|
2021-04-30 17:30:24 +00:00
|
|
|
class MessageDotXML:
|
|
|
|
|
""" storage class for a python representation of the llsd message.xml """
|
|
|
|
|
def __init__(self, message_xml=None):
|
2009-06-05 21:02:59 +00:00
|
|
|
""" parse message.xml and store a representation of the map """
|
2021-04-30 17:30:24 +00:00
|
|
|
self.raw_llsd = message_xml or msg_details
|
2009-06-05 21:02:59 +00:00
|
|
|
self.parsed_llsd = llsd.parse(self.raw_llsd)
|
|
|
|
|
|
|
|
|
|
self.serverDefaults = self.parsed_llsd['serverDefaults']
|
|
|
|
|
self.messages = self.parsed_llsd['messages']
|
|
|
|
|
self.capBans = self.parsed_llsd['capBans']
|
|
|
|
|
self.maxQueuedEvents = self.parsed_llsd['maxQueuedEvents']
|
|
|
|
|
self.messageBans = self.parsed_llsd['messageBans']
|
|
|
|
|
|
2009-10-20 22:43:49 +00:00
|
|
|
def validate_udp_msg(self, msg_name):
|
|
|
|
|
""" checks whether a message is allowed over UDP or not """
|
|
|
|
|
|
2021-04-30 17:30:24 +00:00
|
|
|
if msg_name in self.messages:
|
2009-10-20 22:43:49 +00:00
|
|
|
if self.messages[msg_name]['flavor'] == 'template':
|
|
|
|
|
return True
|
|
|
|
|
else:
|
|
|
|
|
return False
|
|
|
|
|
else:
|
2021-04-30 17:30:24 +00:00
|
|
|
return True
|