Пример #1
0
    def _handleRequestKey(cls, schid, cmd):
        req = _RequestKey.fromString(cmd)
        if not req:
            return

        err, myid = _ts3lib.getClientID(schid)
        if err != ts3defines.ERROR_ok or req.receiver != myid:
            return

        cls._sendSendKey(schid, req)
Пример #2
0
    def _handleSendKey(cls, schid, cmd):
        snd = _SendKey.fromString(cmd)
        if not snd:
            return (False, None, None)

        err, myid = _ts3lib.getClientID(schid)
        if err != ts3defines.ERROR_ok or snd.receiver != myid:
            return

        store = cls.getStore(schid)
        if store.hasRequest(snd.sender, snd.token):
            store.removeRequests(snd.sender)
            store.addPublickey(snd.sender, snd.publickey)
            return cls._processCommands(schid,
                                        store.popStoredCommands(snd.sender))

        return (False, None, None)
Пример #3
0
    def sendPluginCommand(cls, schid, command, targetMode, targetIDs,
                          *returnCode):
        err, myid = _ts3lib.getClientID(schid)
        if err != ts3defines.ERROR_ok:
            return err

        # we need to send the command to each client separately, otherwise
        # an attacker could copy the complete cmd ("header", data and
        # signature) and resend the complete package to the other receiving
        # clients
        # because of this it's not possible to use
        # PluginCommandTarget_CURRENT_CHANNEL_SUBSCRIBED_CLIENTS
        if targetMode == PluginTargetMode.PluginCommandTarget_CURRENT_CHANNEL:
            err, mychan = _ts3lib.getChannelOfClient(schid, myid)
            if err != ts3defines.ERROR_ok:
                return err

            err, clids = _ts3lib.getChannelClientList(schid, mychan)
            if err != ts3defines.ERROR_ok:
                return err
        elif targetMode == PluginTargetMode.PluginCommandTarget_SERVER:
            err, clids = _ts3lib.getClientList(schid)
            if err != ts3defines.ERROR_ok:
                return err
        elif targetMode == PluginTargetMode.PluginCommandTarget_CLIENT:
            clids = targetIDs
        elif targetMode == PluginTargetMode.PluginCommandTarget_CURRENT_CHANNEL_SUBSCRIBED_CLIENTS:
            return ts3defines.ERROR_parameter_invalid

        signer = cls.getStore(schid).signer

        for client in clids:
            pkgs = _PluginCommand.pack(myid, client, command)

            for p in pkgs:
                p.sign(signer)
                _ts3lib.sendPluginCommand(schid, p.toString(),
                                          PluginTargetMode.PluginCommandTarget_CLIENT,
                                          [client], *returnCode)

        return ts3defines.ERROR_ok
Пример #4
0
    def _handleCommand(cls, schid, command):
        cmd = _PluginCommand.fromString(command)

        if not cmd:
            return (False, None, None)

        err, myid = _ts3lib.getClientID(schid)
        if err != ts3defines.ERROR_ok:
            return (False, None, None)

        if myid != cmd.receiver:
            return (False, None, None)

        store = cls.getStore(schid)

        pubkey = store.publickey(cmd.sender)
        if pubkey is None:
            store.storeCommand(cmd)
            cls._sendRequestKey(schid, myid, cmd.sender)
            return (False, None, None)

        return cls._processCommands(schid, [cmd])