示例#1
0
	def allow_network(self, klass):
		"""
		NOTE: this is a security related method and may lead to
		execution of arbritary code if used in a wrong way
		see documentation inside horizons.network.packets.SafeUnpickler
		"""
		SafeUnpickler.add('server', klass)
示例#2
0
    def allow_network(cls, klass):
        """
		NOTE: this is a security related method and may lead to
		execution of arbritary code if used in a wrong way
		see documentation inside horizons.network.packets.SafeUnpickler
		"""
        SafeUnpickler.add('server', klass)
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
# ###################################################

from horizons.network.packets import SafeUnpickler, packet


class cmd_session(packet):
    def __init__(self, sid, capabilities):
        self.sid = sid
        self.capabilities = capabilities


SafeUnpickler.add("server", cmd_session)

# -------------------------------------------------------------------------------


class data_gameslist(packet):
    def __init__(self):
        self.games = []

    def addgame(self, game):
        newgame = game.make_public_copy()
        self.games.append(newgame)


SafeUnpickler.add("server", data_gameslist)
示例#4
0
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
# ###################################################

from horizons.network.packets import packet, SafeUnpickler

class cmd_session(packet):
	def __init__(self, sid, capabilities):
		self.sid = sid
		self.capabilities = capabilities

SafeUnpickler.add('server', cmd_session)

#-------------------------------------------------------------------------------

class data_gameslist(packet):
	def __init__(self):
		self.games = []

	def addgame(self, game):
		newgame = game.make_public_copy()
		self.games.append(newgame)

SafeUnpickler.add('server', data_gameslist)

#-------------------------------------------------------------------------------
示例#5
0
            raise NetworkException("Invalid datatype: mapname")
        if not len(pkt.mapname):
            raise SoftNetworkException(
                "You can't run a game with an empty mapname")

        if not isinstance(pkt.maxplayers, int):
            raise NetworkException("Invalid datatype: maxplayers")

        if not isinstance(pkt.maphash, str):
            raise NetworkException("Invalid datatype: maphash")

        if not isinstance(pkt.password, str):
            raise NetworkException("Invalid datatype: password")


SafeUnpickler.add('client', cmd_creategame)

#-------------------------------------------------------------------------------


class cmd_listgames(packet):
    clientversion = 0
    mapname = None
    maxplayers = None

    def __init__(self, clientver, mapname=None, maxplayers=None):
        self.clientversion = clientver
        self.mapname = mapname
        self.maxplayers = maxplayers

    @staticmethod
示例#6
0
		if not isinstance(pkt.mapname, unicode):
			raise NetworkException("Invalid datatype: mapname")
		if not len(pkt.mapname):
			raise SoftNetworkException("You can't run a game with an empty mapname")

		if not isinstance(pkt.maxplayers, int):
			raise NetworkException("Invalid datatype: maxplayers")

		if not isinstance(pkt.maphash, str):
			raise NetworkException("Invalid datatype: maphash")

		if not isinstance(pkt.password, str):
			raise NetworkException("Invalid datatype: password")

SafeUnpickler.add('client', cmd_creategame)

#-------------------------------------------------------------------------------

class cmd_listgames(packet):
	clientversion = 0
	mapname       = None
	maxplayers    = None

	def __init__(self, clientver, mapname=None, maxplayers=None):
		self.clientversion = clientver
		self.mapname       = mapname
		self.maxplayers    = maxplayers

	@staticmethod
	def validate(pkt, protocol):