Пример #1
0
    def __init__(self):
        svc.machoNet.__init__(self)
        self.logAllClientCalls = prefs.GetValue('logAllClientCalls', None)
        self.clientCallLogChannel = log.Channel(str(macho.mode), 'ClientCalls')
        self.sessionWatchIDs = None
        try:
            self.sessionWatchIDs = ({
                int(s)
                for s in strx(prefs.GetValue('sessionWatch_userID', '')).split(
                    ',') if s
            }, {
                int(s)
                for s in strx(prefs.GetValue('sessionWatch_charID', '')).split(
                    ',') if s
            }, {
                int(s)
                for s in strx(prefs.GetValue('sessionWatch_corpID', '')).split(
                    ',') if s
            }, {
                int(s)
                for s in strx(prefs.GetValue('sessionWatch_userType',
                                             '')).split(',') if s
            })
            if len(self.sessionWatchIDs[0]) == 0 and len(
                    self.sessionWatchIDs[1]) == 0 and len(
                        self.sessionWatchIDs[2]) == 0 and len(
                            self.sessionWatchIDs[3]) == 0:
                self.sessionWatchIDs = None
        except:
            log.LogException()
            sys.exc_clear()

        self.clusterSolarsystemStatistics = ({}, {}, 0)
Пример #2
0
from __future__ import with_statement
import gps
import socket
import errno
import exceptions
import sys
import log
import blue
import stackless
import uthread
import bluepy
import locks
import macho
import iocp
import localization
mylog = log.Channel('GPS', 'socket')
gai = socket.getaddrinfo

@locks.SingletonCall
def mygai(*args):
    return gai(*args)


socket.getaddrinfo = mygai
usingIOCP = iocp.UsingIOCP()
if not usingIOCP:
    import stacklessio
    usesmartwakeup = bool(prefs.GetValue('useSmartWakeup', 0))
    usependingcalls = bool(prefs.GetValue('usePendingCalls', 0))
    usethreaddispatch = bool(prefs.GetValue('useThreadDispatch', 0))
    stacklessio.ApplySettings({'useSmartWakeup': usesmartwakeup,
Пример #3
0
    def LogClientCall(self, session, objectName, method, args, kwargs):
        with util.ExceptionEater('LogClientCall'):

            def CleanKeywordArgs(kwargs):
                if not kwargs or 'machoVersion' not in kwargs:
                    return kwargs
                cleanKwargs = kwargs.copy()
                del cleanKwargs['machoVersion']
                return cleanKwargs

            excludedMethods = ['GetTime']
            if method in excludedMethods:
                return
            charID = getattr(session, 'charid', None)
            userID = getattr(session, 'userid', None)
            solarSystemID = getattr(session, 'solarsystemid2', None)
            argString = None
            if self.eventLog.IsChannelOpen('security'):
                argString = repr(args)
                kwargString = repr(CleanKeywordArgs(kwargs))
                self.eventLog.LogOwnerEvent('ClientCall',
                                            charID,
                                            solarSystemID,
                                            userID,
                                            objectName,
                                            method,
                                            len(argString),
                                            argString[:1024],
                                            len(kwargString),
                                            kwargString[:1024],
                                            eventLogChannel='security')
            logAll = self.logAllClientCalls
            if logAll is None and prefs.clusterMode == 'LOCAL':
                logAll = 1
            if logAll:
                self.clientCallLogChannel = log.Channel(
                    str(macho.mode), 'ClientCalls')
                callerInfo = 'User %s' % session.userid
                try:
                    callerInfo = 'Char %s (%s)' % (
                        session.charid, cfg.eveowners.Get(session.charid).name)
                except:
                    pass

                kwargsTxt = ''
                if kwargs:
                    kk = CleanKeywordArgs(kwargs)
                    if kk:
                        kwargsTxt = '. kwargs = %s' % repr(kk)
                self.clientCallLogChannel.Log(
                    '%s called %s.%s%s%s' %
                    (callerInfo, objectName, method, repr(args)[:128],
                     kwargsTxt[:128]), log.LGNOTICE)
            if not self.sessionWatchIDs:
                return
            if not charID:
                return
            corpID = getattr(session, 'corpid', None)
            userType = getattr(session, 'userType', None)
            logIt = False
            if userID in self.sessionWatchIDs[0]:
                logIt = True
            elif charID in self.sessionWatchIDs[1]:
                logIt = True
            elif corpID in self.sessionWatchIDs[2]:
                logIt = True
            elif userType in self.sessionWatchIDs[3]:
                logIt = True
            elif session.role & ROLEMASK_ELEVATEDPLAYER:
                logIt = True
            if logIt:
                if argString is None:
                    argString = repr(args)
                    kwargString = repr(CleanKeywordArgs(kwargs))
                self.eventLog.LogOwnerEvent('ClientCall', charID,
                                            solarSystemID,
                                            userID, objectName, method,
                                            len(argString), argString[:1024],
                                            len(kwargString),
                                            kwargString[:1024])
                self.eventLog.LogOwnerEventJson('ClientCall',
                                                charID,
                                                solarSystemID,
                                                userID=userID,
                                                objectName=objectName,
                                                method=method,
                                                argsLen=len(argString),
                                                args=argString[:1024],
                                                kwargsLen=len(kwargString),
                                                kwargs=kwargString[:1024])
Пример #4
0
    def LogClientCall(self, session, objectName, method, args, kwargs):
        with util.ExceptionEater('LogClientCall'):

            def CleanKeywordArgs(kwargs):
                cleanKwargs = {}
                if kwargs:
                    cleanKwargs = {
                        k: v
                        for k, v in kwargs.iteritems() if k != 'machoVersion'
                    }
                return cleanKwargs

            excludedMethods = ['GetTime']
            if method in excludedMethods:
                return
            logAll = self.logAllClientCalls
            if logAll is None and prefs.clusterMode == 'LOCAL':
                logAll = 1
            if logAll:
                self.clientCallLogChannel = log.Channel(
                    str(macho.mode), 'ClientCalls')
                callerInfo = 'User %s' % session.userid
                try:
                    callerInfo = 'Char %s (%s)' % (
                        session.charid, cfg.eveowners.Get(session.charid).name)
                except:
                    pass

                kwargsTxt = ''
                if kwargs:
                    kk = CleanKeywordArgs(kwargs)
                    if kk:
                        kwargsTxt = '. kwargs = %s' % repr(kk)
                self.clientCallLogChannel.Log(
                    '%s called %s.%s%s%s' %
                    (callerInfo, objectName, method, repr(args)[:128],
                     kwargsTxt[:128]), log.LGNOTICE)
            if not self.sessionWatchIDs:
                return
            charID = getattr(session, 'charid', None)
            if not charID:
                return
            userID = getattr(session, 'userid', None)
            corpID = getattr(session, 'corpid', None)
            userType = getattr(session, 'userType', None)
            solarSystemID = getattr(session, 'solarsystemid2', None)
            logIt = False
            if userID in self.sessionWatchIDs[0]:
                logIt = True
            elif charID in self.sessionWatchIDs[1]:
                logIt = True
            elif corpID in self.sessionWatchIDs[2]:
                logIt = True
            elif userType in self.sessionWatchIDs[3]:
                logIt = True
            elif session.role & ROLEMASK_ELEVATEDPLAYER:
                logIt = True
            if logIt:
                a = repr(args)
                k = repr(CleanKeywordArgs(kwargs))
                sm.GetService('eventLog').LogOwnerEvent(
                    'ClientCall', charID, solarSystemID, userID, objectName,
                    method, len(a), a[:1024], len(k), k[:1024])