Ejemplo n.º 1
0
 def sendAcceptChallenge(self, name):
     isFbaPresent = self.checkInstallation()
     isRomPresent = self.checkRom()
     if not isRomPresent or not isFbaPresent:
         return
     if name in self.challengers:
         self.sendAndRemember(Protocol.ACCEPT_CHALLENGE, Protocol.packTLV(name) + Protocol.packTLV(self.rom))
         self.challengers.remove(name)
Ejemplo n.º 2
0
 def sendAcceptChallenge(self, name):
     isFbaPresent = self.checkInstallation()
     isRomPresent = self.checkRom()
     if not isRomPresent or not isFbaPresent:
         return
     if name in self.challengers:
         self.sendAndRemember(Protocol.ACCEPT_CHALLENGE, Protocol.packTLV(name) + Protocol.packTLV(self.rom))
         self.challengers.remove(name)
Ejemplo n.º 3
0
 def sendAuth(self, username, password):
     self.username = username
     try:
         port = self.udpSock.getsockname()[1]
     except:
         port=6009
     authdata = Protocol.packTLV(username) + Protocol.packTLV(password) + Protocol.packInt(port) + Protocol.packInt(copyright.versionNum())
     self.sendAndRemember(Protocol.AUTH, authdata)
Ejemplo n.º 4
0
 def sendAuth(self, username, password):
     self.username = username
     try:
         port = self.udpSock.getsockname()[1]
     except:
         port = 6009
     authdata = Protocol.packTLV(username) + Protocol.packTLV(
         password) + Protocol.packInt(port) + Protocol.packInt(
             copyright.versionNum())
     self.sendAndRemember(Protocol.AUTH, authdata)
Ejemplo n.º 5
0
 def sendChallenge(self, name):
     self.sendCancelChallenge()
     isFbaPresent = self.checkInstallation()
     isRomPresent = self.checkRom()
     if not isRomPresent or not isFbaPresent:
         return
     if (name==self.username):
         self.runFBA(self.channel)
     else:
         self.sendAndRemember(Protocol.SEND_CHALLENGE, Protocol.packTLV(name) + Protocol.packTLV(self.rom))
         self.challenged = name
Ejemplo n.º 6
0
 def sendChallenge(self, name):
     self.sendCancelChallenge()
     isFbaPresent = self.checkInstallation()
     isRomPresent = self.checkRom()
     if not isRomPresent or not isFbaPresent:
         return
     if (name==self.username):
         self.runFBA(self.channel)
     else:
         self.sigStatusMessage.emit("Challenging "+name)
         self.sendAndRemember(Protocol.SEND_CHALLENGE, Protocol.packTLV(name) + Protocol.packTLV(self.rom))
         self.challenged = name
Ejemplo n.º 7
0
 def sendCancelChallenge(self, name=None):
     if (name is None and self.challenged) or (name
                                               and name == self.challenged):
         self.sigStatusMessage.emit("Cancelling challenge")
         self.sendAndRemember(Protocol.CANCEL_CHALLENGE,
                              Protocol.packTLV(self.challenged))
         self.challenged = None
Ejemplo n.º 8
0
    def sendAuth(self, username, password):
        self.username = username
        try:
            port = self.udpSock.getsockname()[1]
        except:
            port=6009
            #raise

        # piggyback the OS and timezone onto the login request since there doesn't seem to be another convenient place to send it.
        authdata = Protocol.packTLV(username) + Protocol.packTLV(password) + Protocol.packInt(port) + \
                   Protocol.packInt(copyright.versionNum()) + \
                   Protocol.packInt(self.os) + \
                   Protocol.packTLV(str(self.utcoffset))  # There's a string conversion error here if packInt returns any
                   #Protocol.packInt(self.utcoffset)      # non-ascii bytes.  Send utcoffset as a string for now.

        self.sendAndRemember(Protocol.AUTH, authdata)
Ejemplo n.º 9
0
    def sendJoinChannelRequest(self, channel=None):
        if channel:
            self.channel = channel
            Settings.setValue(Settings.SELECTED_CHANNEL, channel)
            if channel in self.channels:
                if channel != 'lobby':
                    self.rom = self.channels[channel]['rom']
                else:
                    self.rom = ''
            else:
                logdebug().error("Invalid channel {}".format(channel))

        if (int(self.channelport) != int(self.channels[channel]['port'])):
            self.switchingServer = True
            self.channelport = int(self.channels[channel]['port'])
            Settings.setValue(Settings.PORT, self.channelport)
            self.tcpSock.close()
            self.sequence = 0x1
            self.connectTcp()
            self.sendWelcome()
            self.sendAuth(self.username, self.password)
            if Settings.value(Settings.AWAY):
                self.sendToggleAFK(1)
        self.sendAndRemember(Protocol.JOIN_CHANNEL,
                             Protocol.packTLV(self.channel))
Ejemplo n.º 10
0
 def sendJoinChannelRequest(self, channel=None):
     if channel:
         self.channel = channel
         Settings.setValue(Settings.SELECTED_CHANNEL, channel)
         if channel in self.channels:
             if channel != 'lobby':
                 self.rom = self.channels[channel]['rom']
         else:
             logdebug().error("Invalid channel {}".format(channel))
     self.sendAndRemember(Protocol.JOIN_CHANNEL, Protocol.packTLV(self.channel))
Ejemplo n.º 11
0
 def sendJoinChannelRequest(self, channel=None):
     if channel:
         self.channel = channel
         Settings.setValue(Settings.SELECTED_CHANNEL, channel)
         if channel in self.channels:
             if channel != 'lobby':
                 self.rom = self.channels[channel]['rom']
         else:
             logdebug().error("Invalid channel {}".format(channel))
     self.sendAndRemember(Protocol.JOIN_CHANNEL,
                          Protocol.packTLV(self.channel))
Ejemplo n.º 12
0
    def sendMessage(self, extID, prefix, params=None):
        """ Encode a message and send it to the server

        Args:
            extID: positive integer.  0 for internal messages, 1 for referee messages, otherwise is an extension ID
            prefix: extension-defined positive integer
            params: json-serializable python object
        """
        data = Protocol.packInt(extID) + Protocol.packInt(prefix) + json.dumps(
            params)
        self.controller.sendAndRemember(Protocol.EXTENSION_OUTBOUND,
                                        Protocol.packTLV(data))

        # DEBUG
        dispext = "Extension" if extID == 0 else _ExtensionDict[extID].__name__
        dispprefix = self._codeToString.get((extID, prefix), prefix)
        self.controller.sigStatusMessage.emit(
            "Ext Snd: ext=%s, prefix=%s, params=%s" %
            (dispext, dispprefix, params))
Ejemplo n.º 13
0
    def sendJoinChannelRequest(self, channel=None):
        if channel:
            self.channel = channel
            Settings.setValue(Settings.SELECTED_CHANNEL, channel)
            if channel in self.channels:
                if channel != 'lobby':
                    self.rom = self.channels[channel]['rom']
                else:
                    self.rom = ''
            else:
                logdebug().error("Invalid channel {}".format(channel))

        if (int(self.channelport)!=int(self.channels[channel]['port'])):
            self.switchingServer=True
            self.channelport = int(self.channels[channel]['port'])
            Settings.setValue(Settings.PORT, self.channelport)
            self.tcpSock.close()
            self.sequence = 0x1
            self.connectTcp()
            self.sendWelcome()
            self.sendAuth(self.username, self.password)
            if Settings.value(Settings.AWAY):
                self.sendToggleAFK(1)
        self.sendAndRemember(Protocol.JOIN_CHANNEL, Protocol.packTLV(self.channel))
Ejemplo n.º 14
0
 def sendDeclineChallenge(self, name):
     self.sendAndRemember(Protocol.DECLINE_CHALLENGE, Protocol.packTLV(name))
     if name in self.challengers:
         self.challengers.remove(name)
Ejemplo n.º 15
0
 def sendChat(self, line):
     if self.channel == 'unsupported' and self.unsupportedRom:
         line = '[' + self.unsupportedRom + '] ' + line
     line = line.encode('utf-8')
     self.sendAndRemember(Protocol.CHAT, Protocol.packTLV(line))
Ejemplo n.º 16
0
 def sendAcceptChallenge(self, name):
     if name in self.challengers:
         self.sendAndRemember(
             Protocol.ACCEPT_CHALLENGE,
             Protocol.packTLV(name) + Protocol.packTLV(self.rom))
         self.challengers.remove(name)
Ejemplo n.º 17
0
 def sendCancelChallenge(self, name=None):
     if (name is None and self.challenged) or (name and name == self.challenged):
         self.sendAndRemember(Protocol.CANCEL_CHALLENGE, Protocol.packTLV(self.challenged))
         self.challenged = None
Ejemplo n.º 18
0
 def sendChat(self, line):
     if self.channel == 'unsupported' and self.unsupportedRom:
         line = '[' + self.unsupportedRom + '] ' + line
     line = line.encode('utf-8')
     self.sendAndRemember(Protocol.CHAT, Protocol.packTLV(line))
Ejemplo n.º 19
0
 def sendAuth(self, username, password):
     self.username = username
     authdata = Protocol.packTLV(username) + Protocol.packTLV(
         password) + "\x00\x00\x17\x79"
     self.sendAndRemember(Protocol.AUTH, authdata)
Ejemplo n.º 20
0
 def sendAuth(self, username, password):
     self.username = username
     authdata = Protocol.packTLV(username) + Protocol.packTLV(password) + "\x00\x00\x17\x79"
     self.sendAndRemember(Protocol.AUTH, authdata)
Ejemplo n.º 21
0
 def sendChallenge(self, name):
     self.sendCancelChallenge()
     self.sendAndRemember(Protocol.SEND_CHALLENGE, Protocol.packTLV(name) + Protocol.packTLV(self.rom))
     self.challenged = name
Ejemplo n.º 22
0
 def sendChallenge(self, name):
     self.sendCancelChallenge()
     self.sendAndRemember(
         Protocol.SEND_CHALLENGE,
         Protocol.packTLV(name) + Protocol.packTLV(self.rom))
     self.challenged = name
Ejemplo n.º 23
0
 def sendAcceptChallenge(self, name):
     if name in self.challengers:
         self.sendAndRemember(Protocol.ACCEPT_CHALLENGE, Protocol.packTLV(name) + Protocol.packTLV(self.rom))
         self.challengers.remove(name)
Ejemplo n.º 24
0
 def sendSpectateRequest(self, name):
     isFbaPresent = self.checkInstallation()
     isRomPresent = self.checkRom()
     if not isRomPresent or not isFbaPresent:
         return
     self.sendAndRemember(Protocol.SPECTATE, Protocol.packTLV(name))
Ejemplo n.º 25
0
 def sendSpectateRequest(self, name):
     self.sendAndRemember(Protocol.SPECTATE, Protocol.packTLV(name))
Ejemplo n.º 26
0
 def sendDeclineChallenge(self, name):
     self.sendAndRemember(Protocol.DECLINE_CHALLENGE,
                          Protocol.packTLV(name))
     if name in self.challengers:
         self.challengers.remove(name)
Ejemplo n.º 27
0
 def sendCancelChallenge(self, name=None):
     if (name is None and self.challenged) or (name and name == self.challenged):
         self.sigStatusMessage.emit("Cancelling challenge")
         self.sendAndRemember(Protocol.CANCEL_CHALLENGE, Protocol.packTLV(self.challenged))
         self.challenged = None
Ejemplo n.º 28
0
 def sendSpectateRequest(self, name):
     self.sendAndRemember(Protocol.SPECTATE, Protocol.packTLV(name))
Ejemplo n.º 29
0
 def sendSpectateRequest(self, name):
     isFbaPresent = self.checkInstallation()
     isRomPresent = self.checkRom()
     if not isRomPresent or not isFbaPresent:
         return
     self.sendAndRemember(Protocol.SPECTATE, Protocol.packTLV(name))
Ejemplo n.º 30
0
 def sendCancelChallenge(self, name=None):
     if (name is None and self.challenged) or (name
                                               and name == self.challenged):
         self.sendAndRemember(Protocol.CANCEL_CHALLENGE,
                              Protocol.packTLV(self.challenged))
         self.challenged = None