Esempio n. 1
0
    def belowMinimumVersion(self):

        if not self.version:
            return False

        min_v, new_v, url = self.version
        min_vc = cmpify_version(min_v)

        if self.override_vc < min_vc:

            self.main.shutdown(reconnect='no')
            
            text = (
                " ",
                "Your version of Dtella (%s) is too old to be used on this "
                "network.  Please upgrade to the latest version (%s)."
                % (local.version, new_v),
                " ",
                "[If unusual circumstances prevent you from upgrading, "
                "type !VERSION_OVERRIDE to attempt to connect using this "
                "unsupported client.]",
                " ",
                "Download link: %s" % url
                )

            for par in text:
                for line in word_wrap(par):
                    self.main.showLoginStatus(line)
            return True

        return False
Esempio n. 2
0
    def belowMinimumVersion(self):

        if not self.version:
            return False

        min_v, new_v, url = self.version
        min_vc = cmpify_version(min_v)

        if self.override_vc < min_vc:

            self.main.shutdown(reconnect='no')

            text = (
                " ",
                "Your version of Dtella (%s) is too old to be used on this "
                "network.  Please upgrade to the latest version (%s)." %
                (local.version, new_v), " ",
                "[If unusual circumstances prevent you from upgrading, "
                "type !VERSION_OVERRIDE to attempt to connect using this "
                "unsupported client.]", " ", "Download link: %s" % url)

            for par in text:
                for line in word_wrap(par):
                    self.main.showLoginStatus(line)
            return True

        return False
Esempio n. 3
0
    def remoteNickCollision(self):

        text = ("*** Another node on the network has reported that your nick "
                "seems to be in a conflicting state.  This could prevent your "
                "chat and search messages from reaching everyone, so it'd be "
                "a good idea to try changing your nick.  Or you could wait "
                "and see if the problem resolves itself.")

        for line in word_wrap(text):
            self.pushStatus(line)
Esempio n. 4
0
File: dc.py Progetto: LiPeK/dtella
    def remoteNickCollision(self):

        text = (
            "*** Another node on the network has reported that your nick "
            "seems to be in a conflicting state.  This could prevent your "
            "chat and search messages from reaching everyone, so it'd be "
            "a good idea to try changing your nick.  Or you could wait "
            "and see if the problem resolves itself."
            )

        for line in word_wrap(text):
            self.pushStatus(line)
Esempio n. 5
0
    def bindUDPPort(self):
        # Returns True if the UDP port is bound

        udp_state = self.ph.getSocketState()

        if udp_state == 'alive':
            # Port already bound, yay!
            return True
        elif udp_state == 'dying':
            # Port is busy disconnecting.  Wait.
            return False

        # Otherwise, the port is dead, so try to rebind it.
        CHECK(udp_state == 'dead')

        # Anhad addition, Uncomment for debugging
        try:
        #    print 'port debugging'
        #    print self.state.udp_port
            self.state.udp_port = local.default_udpport
        #    print 'done port debugging'
        except:
            print 'Error setting default port'

        try:
            reactor.listenUDP(self.state.udp_port, self.ph)

        except twisted.internet.error.BindError:

            self.showLoginStatus("*** FAILED TO BIND UDP PORT ***")

            text = (
                "Dtella was not able to listen on UDP port %d. One possible "
                "reason for this is that you've tried to make your DC "
                "client use the same UDP port as Dtella. Two programs "
                "are not allowed listen on the same port.  To tell Dtella "
                "to use a different port, type !UDP followed by a number. "
                "Note that if you have a firewall or router, you will have "
                "to tell it to let traffic through on this port."
                % self.state.udp_port
                )

            for line in word_wrap(text):
                self.showLoginStatus(line)

        return self.ph.getSocketState() == 'alive'
Esempio n. 6
0
    def bindUDPPort(self):
        # Returns True if the UDP port is bound

        udp_state = self.ph.getSocketState()

        if udp_state == 'alive':
            # Port already bound, yay!
            return True
        elif udp_state == 'dying':
            # Port is busy disconnecting.  Wait.
            return False

        # Otherwise, the port is dead, so try to rebind it.
        CHECK(udp_state == 'dead')

        # Anhad addition, Uncomment for debugging
        try:
            #    print 'port debugging'
            #    print self.state.udp_port
            self.state.udp_port = local.default_udpport
        #    print 'done port debugging'
        except:
            print 'Error setting default port'

        try:
            reactor.listenUDP(self.state.udp_port, self.ph)

        except twisted.internet.error.BindError:

            self.showLoginStatus("*** FAILED TO BIND UDP PORT ***")

            text = (
                "Dtella was not able to listen on UDP port %d. One possible "
                "reason for this is that you've tried to make your DC "
                "client use the same UDP port as Dtella. Two programs "
                "are not allowed listen on the same port.  To tell Dtella "
                "to use a different port, type !UDP followed by a number. "
                "Note that if you have a firewall or router, you will have "
                "to tell it to let traffic through on this port." %
                self.state.udp_port)

            for line in word_wrap(text):
                self.showLoginStatus(line)

        return self.ph.getSocketState() == 'alive'
Esempio n. 7
0
File: dc.py Progetto: LiPeK/dtella
 def wrapped_out(line):
     for l in word_wrap(line):
         if l:
             out(l)
         else:
             out(" ")
Esempio n. 8
0
 def wrapped_out(line):
     for l in word_wrap(line):
         if l:
             out(l)
         else:
             out(" ")
Esempio n. 9
0
    def handleConfig(self, config_lines):
        # config_lines is a series of raw "key=value" lines.
        # Extract some useful information out of them.

        state = self.main.state

        # Defaults
        self.minshare = 1
        self.version = None
        state.dns_pkhashes = set()
        state.dns_ipcache = (0, [])

        for line in config_lines:
            try:
                name, value = line.split('=', 1)
            except ValueError:
                continue

            name = name.lower()

            if name == 'minshare':
                try:
                    self.minshare = parse_bytes(value)
                except ValueError:
                    pass
                else:
                    cap = local.minshare_cap
                    if (cap is not None) and (self.minshare > cap):
                        self.minshare = cap

            elif name == 'version':
                try:
                    min_v, new_v, url = value.split()
                except ValueError:
                    pass
                else:
                    self.version = (min_v, new_v, url)

            elif name == 'pkhash':
                h = binascii.a2b_base64(value)
                state.dns_pkhashes.add(h)

            elif name == 'netstatus':
                if value == '0':
                    self.main.showLoginStatus('--')
                    self.main.showLoginStatus(
                        'The network is not available at this time.')
                    self.main.showLoginStatus('Shutting down.')
                    self.dtellaShutdown()

            elif name == 'motd':
                text = (
                    "*** SYSTEM MESSAGE ***",
                    " ",
                    "%s"
                    % value
                    )
                
                if value != '':
                    for par in text:
                        for line in word_wrap(par):
                            self.main.showSystemMessage(line)

            elif name == 'blacklist':
                if value.count('%s' % self.main.getCurrentNick()):
                    self.main.showLoginStatus('--')
                    self.main.showLoginStatus(
                        'You have been banned from accessing this network.')
                    self.main.showLoginStatus('Shutting down.')
                    self.dtellaShutdown()
            
            elif name == 'ipcache':
                try:
                    data = binascii.a2b_base64(value)
                    data = self.main.pk_enc.decrypt(data)
                except (ValueError, binascii.Error):
                    continue

                if (len(data)-4) % 6 != 0:
                    continue

                state.setDNSIPCache(data)