messages = [] messages.append(kzorp.messages.KZorpAddForwardServiceMessage(self.name, \ flags, 0, router_target_family, router_target_ip, router_target_port)) if self.snat_policy: addNATMappings(messages, NAT_SNAT, self.snat_policy) if self.dnat_policy: addNATMappings(messages, NAT_DNAT, self.dnat_policy) return messages DenyIPv4 = enum(DROP=0, TCP_RESET=1, ICMP_NET_UNREACHABLE=2, ICMP_HOST_UNREACHABLE=3, ICMP_PROTO_UNREACHABLE=4, ICMP_PORT_UNREACHABLE=5, ICMP_NET_PROHIBITED=6, ICMP_HOST_PROHIBITED=7, ICMP_ADMIN_PROHIBITED=8) DenyIPv6 = enum(DROP=0, TCP_RESET=1, ICMP_NO_ROUTE=2, ICMP_ADMIN_PROHIBITED=3, ICMP_ADDR_UNREACHABLE=4, ICMP_PORT_UNREACHABLE=5) class DenyService(AbstractService): """
flags = flags | kzorp.kzorp_netlink.KZF_SVC_FORGE_ADDR messages = [] messages.append(kzorp.kzorp_netlink.KZorpAddForwardServiceMessage(self.name, \ flags, 0, router_target_family, router_target_ip, router_target_port)) if self.snat_policy: addNATMappings(messages, NAT_SNAT, self.snat_policy) if self.dnat_policy: addNATMappings(messages, NAT_DNAT, self.dnat_policy) return messages DenyIPv4 = enum(DROP=0, TCP_RESET=1, ICMP_NET_UNREACHABLE=2, ICMP_HOST_UNREACHABLE=3, ICMP_PROTO_UNREACHABLE=4, ICMP_PORT_UNREACHABLE=5, ICMP_NET_PROHIBITED=6, ICMP_HOST_PROHIBITED=7, ICMP_ADMIN_PROHIBITED=8) DenyIPv6 = enum(DROP=0, TCP_RESET=1, ICMP_NO_ROUTE=2, ICMP_ADMIN_PROHIBITED=3, ICMP_ADDR_UNREACHABLE=4, ICMP_PORT_UNREACHABLE=5) class DenyService(AbstractService): """ <class maturity="stable">
from zope.interface import implementer, Interface from twisted.conch import avatar from twisted.conch.interfaces import ISession from twisted.conch.ssh import session from twisted.conch.insults import insults from Util import enum, log, LogLevel import World, Things State = enum('New', 'LoggedIn') prelogincmds = [] commands = {} class commandHandler(object): # Decorator """ Decorator that marks a method as a command handler. """ def __init__(self, *aliases, **kwargs): self.cmds = aliases self.kwargs = kwargs def __call__(self, f): for cmd in self.cmds: commands[cmd] = f if 'prelogin' in self.kwargs and self.kwargs['prelogin']: for cmd in self.cmds: prelogincmds.append(cmd) class commandHelpText(object): # Decorator
from zope.interface import implements, Interface from twisted.conch import avatar from twisted.conch.interfaces import ISession from twisted.conch.ssh import session from twisted.conch.insults import insults from Util import enum, log, LogLevel import World, Things State = enum("New", "LoggedIn") prelogincmds = [] commands = {} class commandHandler: """ Decorator that marks a method as a command handler. """ def __init__(self, *aliases, **kwargs): self.cmds = aliases self.kwargs = kwargs def __call__(self, f): for cmd in self.cmds: commands[cmd] = f if "prelogin" in self.kwargs and self.kwargs["prelogin"]: for cmd in self.cmds:
from twisted.cred.checkers import ICredentialsChecker from zope.interface import implements from abc import * import hashlib, struct, random, time from Things import * from Util import enum, log, LogLevel # This is the master list of Thing types as used in the database. # DO NOT CHANGE THE ORDER OF THIS LIST as it will break existing databases. thingtypes = [Room, Player, Item, Action, Script] # Generate enum from the above list DBType = enum(*[t.__name__ for t in thingtypes]) # Attach dbtype to classes for t in thingtypes: t.dbtype = DBType[t.__name__] def Thing_of_type(dbtype): return thingtypes[dbtype.value()] active = True class DatabaseNotConnected(Exception): pass