예제 #1
0
def NukeUser(publicname):
    user = User.byName(publicname)
    if user.lastConnectSubnet:
        try:
            BannedIP(address=user.lastConnectSubnet)
        except:
            pass
    else:
        print "WARNING: User had no last connection subnet, ip ban not possible"
    user.banLevel = 3
예제 #2
0
    def requestAvatar(self, avatarId, mind, *interfaces):
        
        if pb.IPerspective in interfaces:
            username,role=avatarId.split('-')
            
            #user and ip banning
            if mind: #blah, I wish I could get this regardless!!!!
                ip = mind.broker.transport.getPeer()
                try:
                    subnet=ip.host[:ip.host.rfind('.')]
                except:
                    print "Warning:  IP logging isn't working... Windows 2000?"
                    subnet = ""
                
                
                if role == 'Registration' and subnet: #old client didn't pass pb.Root here... grr
                    try:
                        bi = BannedIP.byAddress(subnet)
                        return failure.Failure(BannedIPError())
                    except:
                        pass
        
                    
                if role in ('Player','Guardian','Immortal'):
                    u = User.byName(username)
                    if subnet:
                        u.lastConnectSubnet = subnet

            if role in ('Player','Guardian','Immortal'):
                if not THESERVER.allowConnections:
                    return failure.Failure(AllowConnectionsError())
            
            role=Role.byName(role)       
            print "-------->",THESERVER.__class__.__name__,role.name                     
            avatar = MasterPerspective(role,username,mind,self)
            avatar.realm = self
            self.avatars.append(avatar)
            return pb.IPerspective, avatar, avatar.logout 
        else:
            raise NotImplementedError("no interface")
예제 #3
0
파일: main.py 프로젝트: MoMReborn/MoMServer
    def perspective_submitPlayerToWorld(self, worldName):
        # TODO: should have some logging here that can be linked to fail2ban
        if not CHARSERVER_MIND:
            return (False, "Character Server is down.")

        u = User.byName(self.username)
        if u.banLevel >= 2:
            return (False, "This account is banned.")

        if u.banLevel == 1 and ("Premium " in worldName
                                or "Free " in worldName):
            return (False, "This account is banned.")

        subnet = ""
        if self.mind:  #grrrrr, old client and client dependency on sending this
            ip = self.mind.broker.transport.getPeer()
            subnet = ip.host[:ip.host.rfind('.')]

            try:
                bi = BannedIP.byAddress(subnet)
                return (False, "The IP you are connected from is banned.")
            except:
                pass

        premium = False
        account = Account.byPublicName(self.username)

        account.lastActivityTime = datetime.now()

        if account.hasProduct("MOM"):
            premium = True

        if "Premium " in worldName and not premium:
            return (False, "This server requires the Premium Edition.")

        d = CHARSERVER_MIND.callRemote("installPlayer", self.username,
                                       worldName, premium, subnet)
        d.addCallback(self.playerSubmitted)
        d.addErrback(self.playerSubmissionError)
        return d
예제 #4
0
    def perspective_submitPlayerToWorld(self, worldName):
        if not CHARSERVER_MIND:
            return (False, "Character Server is down.")

        
        u = User.byName(self.username)
        if u.banLevel >= 2:
            return (False, "This account is banned.")
            
        if u.banLevel ==1 and ("Premium " in worldName or "Free " in worldName):
            return (False, "This account is banned.")
        
        subnet = ""
        if self.mind: #grrrrr, old client and client dependency on sending this
            ip = self.mind.broker.transport.getPeer()
            subnet=ip.host[:ip.host.rfind('.')]
            
            try:
                bi = BannedIP.byAddress(subnet)
                return (False, "The IP you are connected from is banned.")
            except:
                pass

        
        premium = False
        account = Account.byPublicName(self.username)
        
        account.lastActivityTime = datetime.now()
        
        if account.hasProduct("MOM"):
            premium = True
            
        if "Premium " in worldName and not premium:
            return (False, "This server requires the Premium Edition.")
        
        d = CHARSERVER_MIND.callRemote("installPlayer", self.username, worldName, premium, subnet)
        d.addCallback(self.playerSubmitted)
        d.addErrback(self.playerSubmissionError)
        return d
예제 #5
0
    def requestAvatar(self, avatarId, mind, *interfaces):

        if pb.IPerspective in interfaces:
            username, role = avatarId.split('-')

            #user and ip banning
            if mind:  #blah, I wish I could get this regardless!!!!
                ip = mind.broker.transport.getPeer()
                try:
                    subnet = ip.host[:ip.host.rfind('.')]
                except:
                    print "Warning:  IP logging isn't working... Windows 2000?"
                    subnet = ""

                if role == 'Registration' and subnet:  #old client didn't pass pb.Root here... grr
                    try:
                        bi = BannedIP.byAddress(subnet)
                        return failure.Failure(BannedIPError())
                    except:
                        pass

                if role in ('Player', 'Guardian', 'Immortal'):
                    u = User.byName(username)
                    if subnet:
                        u.lastConnectSubnet = subnet

            if role in ('Player', 'Guardian', 'Immortal'):
                if not THESERVER.allowConnections:
                    return failure.Failure(AllowConnectionsError())

            role = Role.byName(role)
            print "-------->", THESERVER.__class__.__name__, role.name
            avatar = MasterPerspective(role, username, mind, self)
            avatar.realm = self
            self.avatars.append(avatar)
            return pb.IPerspective, avatar, avatar.logout
        else:
            raise NotImplementedError("no interface")
예제 #6
0
def UnbanSubnet(subnet):
    bi = BannedIP.byAddress(subnet)
    bi.destroySelf()
def UnbanSubnet(subnet):
    bi = BannedIP.byAddress(subnet)
    bi.destroySelf()