Beispiel #1
0
    def __init__(self,wedgeName,
                 nodeName="",
                 nsHost=None,nsPort=None,
                 listenPort=None,
                 bcLocate=False,
                 clHost=None,clPort=None,
                 allowUnfilteredChat=0,
                 bwDictPath=""):
        Pyro.config.PYRO_MULTITHREADED = 0
        Pyro.config.PYRO_TRACELEVEL = 2

        Pyro.core.SynchronizedObjBase.__init__(self)
        Pyro.core.initServer(banner=0)

        self.log = sbLog(":sb.wedge.%s"%wedgeName,clHost,clPort)

        badwordpy.init(bwDictPath,"")

        if not badwordpy.test("f**k") and not allowUnfilteredChat:
            self.log.error("Dirty word filter not working, refusing to start.  Devs should add .prc setting 'allow-unfiltered-chat 1' to bypass.")
            raise Exception("No dirty word filter, aborting SB Wedge startup.  Devs should add .prc setting 'allow-unfiltered-chat 1' to bypass.")

        self.wedgeName = wedgeName
        if nodeName == "":
            self.nodeName = wedgeName
        else:
            self.nodeName = nodeName
            
        self.node = None

        self.log.info("Starting.")
        self.sbConnected = False

        self.nsHost = nsHost
        self.nsPort = nsPort
        
        try:
            self.initPyro(nsHost,nsPort,listenPort,bcLocate)

            self.updateNode()
            self.log.debug("Enter sendEnterWedge")
            self.sendEnterWedge()
            self.log.debug("Exit sendEnterWedge")
            self.sbConnected = True
        except Exception as e:
            self.log.warning("Failed to connect to Switchboard.  Player friends are being faked.")

        self.onlinePlayers = 0
        self.servedLogins = 0
        self.servedChat = 0           
        self.servedChatSC = 0
        self.servedMail = 0
        self.servedMailSC = 0
            
        self.log.info("-- sb.wedge.%s is ready. --" %self.wedgeName)
import Pyro.errors
import sys
import time

from .sbLog import sbLog
from . import sbConfig

from Pyro.errors import ConnectionClosedError
from Pyro.errors import ProtocolError

from otp.switchboard.xd.ChannelManager import ChannelListener
from otp.switchboard.xd.ChannelManager import ChannelMessage

if sbConfig.scrubMessages:
    import badwordpy
    badwordpy.init("", "")


class sbNode(Pyro.core.SynchronizedObjBase, ChannelListener):
    def __init__(self,
                 nodeName,
                 wedgeName="",
                 nsHost=None,
                 nsPort=None,
                 listenPort=None,
                 clHost=None,
                 clPort=None,
                 chanMgr=None,
                 dislURL=None):

        ChannelListener.__init__(self, nodeName, chanMgr)
Beispiel #3
0
    def __init__(self, host, port, user, passwd, dbname):
        self.sqlAvailable = uber.sqlAvailable
        if not self.sqlAvailable:
            return

        # Now set the bwDictPath. Used during token generation to make sure
        # we're not giving out any strings that contain bad words

        self.bwDictPath = uber.bwDictPath

        # If Path string is empty, flag the dict as being offline

        if self.bwDictPath == "":
            self.bwDictOnline = False
            self.notify.info(
                "Badword filtering for Guild Tokens not online. Dict path not provided"
            )
        else:
            self.bwDictOnline = True
            # Now that the module has loaded, try to init the lib with the
            # bwDictPath provided
            badwordpy.init(self.bwDictPath, "")
            # If the path provided is good, the next if statement should return 1
            if not badwordpy.test("shit"):
                self.notify.info(
                    "Bad Word Filtering not online for token guild generation. Dict test failed"
                )
                self.bwDistOnline = False

        # Place startCleanUpExpiredTokens into TaskMgr. It will clean up the
        # expired guild membership tokens every 5 minutes.

        self.startCleanUpExpiredTokens()

        self.host = host
        self.port = port
        self.user = user
        self.passwd = passwd
        self.dbname = self.processDBName(dbname)

        if __debug__:
            self.notify.info("About to connect to %s MySQL db at %s:%d." %
                             (self.dbname, host, port))
        self.db = MySQLdb.connect(host=host,
                                  port=port,
                                  user=user,
                                  passwd=passwd)

        if __debug__:
            self.notify.info("Connected to %s MySQL db at %s:%d." %
                             (self.dbname, host, port))

        #temp hack for initial dev, create DB structure if it doesn't exist already
        cursor = self.db.cursor()
        try:
            cursor.execute("CREATE DATABASE `%s`" % self.dbname)
            if __debug__:
                self.notify.debug(
                    "Database '%s' did not exist, created a new one!" %
                    self.dbname)
        except _mysql_exceptions.ProgrammingError, e:
            pass
    def __init__(self,host,port,user,passwd,dbname):
        self.sqlAvailable = uber.sqlAvailable
        if not self.sqlAvailable:
            return

        # Now set the bwDictPath. Used during token generation to make sure
        # we're not giving out any strings that contain bad words
        
        self.bwDictPath = uber.bwDictPath

        # If Path string is empty, flag the dict as being offline

        if self.bwDictPath == "":
            self.bwDictOnline = False
            self.notify.info("Badword filtering for Guild Tokens not online. Dict path not provided")
        else:
            self.bwDictOnline = True
            # Now that the module has loaded, try to init the lib with the
            # bwDictPath provided
            badwordpy.init(self.bwDictPath,"")
            # If the path provided is good, the next if statement should return 1
            if not badwordpy.test("shit"):
                self.notify.info("Bad Word Filtering not online for token guild generation. Dict test failed")
                self.bwDistOnline = False

        # Place startCleanUpExpiredTokens into TaskMgr. It will clean up the
        # expired guild membership tokens every 5 minutes.

        self.startCleanUpExpiredTokens()

        self.host = host
        self.port = port
        self.user = user
        self.passwd = passwd
        self.dbname = self.processDBName(dbname)

        if __debug__:
            self.notify.info("About to connect to %s MySQL db at %s:%d." % (self.dbname, host, port))
        self.db = MySQLdb.connect(host=host,
                                  port=port,
                                  user=user,
                                  passwd=passwd)

        if __debug__:
            self.notify.info("Connected to %s MySQL db at %s:%d." % (self.dbname, host, port))

        #temp hack for initial dev, create DB structure if it doesn't exist already
        cursor = self.db.cursor()
        try:
            cursor.execute("CREATE DATABASE `%s`" % self.dbname)
            if __debug__:
                self.notify.debug("Database '%s' did not exist, created a new one!" % self.dbname)
        except _mysql_exceptions.ProgrammingError as e:
            pass

        cursor.execute("USE `%s`" % self.dbname)
        if __debug__:
            self.notify.debug("Using database '%s'" % self.dbname)
        
        try:
            cursor.execute("CREATE TABLE `guildinfo` (`gid` INT(32) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, `name` VARCHAR(21), `wantname` VARCHAR(21), `namestatus` INT(8), `create_date` DATETIME)")
            if __debug__:
                self.notify.debug("Table guildinfo did not exist, created a new one!")
        except _mysql_exceptions.OperationalError as e:
            pass

        try:
            cursor.execute("CREATE TABLE `member` (`gid` INT(32) UNSIGNED NOT NULL, `avid` INT(32) UNSIGNED NOT NULL PRIMARY KEY, `rank` INT(8) NOT NULL, FOREIGN KEY (`gid`) REFERENCES `guildinfo` (`gid`))")
            if __debug__:
                self.notify.debug("Table member did not exist, created a new one!")
        except _mysql_exceptions.OperationalError as e:
            pass

        try:
            cursor.execute("CREATE TABLE `guildtokens` (`tokenid` VARCHAR(8) NOT NULL PRIMARY KEY, `createtime` DATETIME, `ttl` INT(8) UNSIGNED NOT NULL, `gid` INT(32) UNSIGNED, `avid` INT(32) UNSIGNED, `rcount` INT(8), FOREIGN KEY (`gid`) REFERENCES `guildinfo` (`gid`), FOREIGN KEY (`avid`) REFERENCES `member` (`avid`))")
            # An index should also be added to the avid col
            cursor.execute("CREATE INDEX `avatarid` on guildtokens (avid)")
            if __debug__:
                self.notify.debug("Table guildtokens did not exist, created a new one!")
        except _mysql_exceptions.OperationalError as e:
            pass