Use import paths compatible with both Python2 and Python3 #2239
|
@ -22,38 +22,38 @@ import shared
|
||||||
import state
|
import state
|
||||||
from debug import logger
|
from debug import logger
|
||||||
from tr import _translate
|
from tr import _translate
|
||||||
from account import (
|
from .account import (
|
||||||
accountClass, getSortedSubscriptions,
|
accountClass, getSortedSubscriptions,
|
||||||
BMAccount, GatewayAccount, MailchuckAccount, AccountColor)
|
BMAccount, GatewayAccount, MailchuckAccount, AccountColor)
|
||||||
from addresses import decodeAddress, addBMIfNotPresent
|
from addresses import decodeAddress, addBMIfNotPresent
|
||||||
from bitmessageui import Ui_MainWindow
|
from bitmessageqt.bitmessageui import Ui_MainWindow
|
||||||
from bmconfigparser import config
|
from bmconfigparser import config
|
||||||
import namecoin
|
import namecoin
|
||||||
from messageview import MessageView
|
from .messageview import MessageView
|
||||||
from migrationwizard import Ui_MigrationWizard
|
from .migrationwizard import Ui_MigrationWizard
|
||||||
from foldertree import (
|
from .foldertree import (
|
||||||
AccountMixin, Ui_FolderWidget, Ui_AddressWidget, Ui_SubscriptionWidget,
|
AccountMixin, Ui_FolderWidget, Ui_AddressWidget, Ui_SubscriptionWidget,
|
||||||
MessageList_AddressWidget, MessageList_SubjectWidget,
|
MessageList_AddressWidget, MessageList_SubjectWidget,
|
||||||
Ui_AddressBookWidgetItemLabel, Ui_AddressBookWidgetItemAddress,
|
Ui_AddressBookWidgetItemLabel, Ui_AddressBookWidgetItemAddress,
|
||||||
MessageList_TimeWidget)
|
MessageList_TimeWidget)
|
||||||
import settingsmixin
|
from bitmessageqt import settingsmixin
|
||||||
import support
|
from bitmessageqt import support
|
||||||
from helper_sql import sqlQuery, sqlExecute, sqlExecuteChunked, sqlStoredProcedure
|
from helper_sql import sqlQuery, sqlExecute, sqlExecuteChunked, sqlStoredProcedure
|
||||||
import helper_addressbook
|
import helper_addressbook
|
||||||
import helper_search
|
import helper_search
|
||||||
import l10n
|
import l10n
|
||||||
from utils import str_broadcast_subscribers, avatarize
|
from .utils import str_broadcast_subscribers, avatarize
|
||||||
import dialogs
|
from bitmessageqt import dialogs
|
||||||
from network.stats import pendingDownload, pendingUpload
|
from network.stats import pendingDownload, pendingUpload
|
||||||
from uisignaler import UISignaler
|
from .uisignaler import UISignaler
|
||||||
import paths
|
import paths
|
||||||
from proofofwork import getPowType
|
from proofofwork import getPowType
|
||||||
import queues
|
import queues
|
||||||
import shutdown
|
import shutdown
|
||||||
from statusbar import BMStatusBar
|
from .statusbar import BMStatusBar
|
||||||
import sound
|
from bitmessageqt import sound
|
||||||
# This is needed for tray icon
|
# This is needed for tray icon
|
||||||
import bitmessage_icons_rc # noqa:F401 pylint: disable=unused-import
|
from bitmessageqt import bitmessage_icons_rc # noqa:F401 pylint: disable=unused-import
|
||||||
import helper_sent
|
import helper_sent
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -8,9 +8,9 @@ import hashlib
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
import queues
|
import queues
|
||||||
import widgets
|
from bitmessageqt import widgets
|
||||||
import state
|
import state
|
||||||
from account import AccountMixin, GatewayAccount, MailchuckAccount, accountClass
|
from .account import AccountMixin, GatewayAccount, MailchuckAccount, accountClass
|
||||||
from addresses import addBMIfNotPresent, decodeAddress, encodeVarint
|
from addresses import addBMIfNotPresent, decodeAddress, encodeVarint
|
||||||
from bmconfigparser import config as global_config
|
from bmconfigparser import config as global_config
|
||||||
from tr import _translate
|
from tr import _translate
|
||||||
|
|
|
@ -11,7 +11,7 @@ from addresses import decodeAddress, addBMIfNotPresent
|
||||||
from bmconfigparser import config
|
from bmconfigparser import config
|
||||||
from queues import apiAddressGeneratorReturnQueue, addressGeneratorQueue
|
from queues import apiAddressGeneratorReturnQueue, addressGeneratorQueue
|
||||||
from tr import _translate
|
from tr import _translate
|
||||||
from utils import str_chan
|
from .utils import str_chan
|
||||||
|
|
||||||
|
|
||||||
class AddressPassPhraseValidatorMixin(object):
|
class AddressPassPhraseValidatorMixin(object):
|
||||||
|
|
|
@ -9,12 +9,12 @@
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
from bmconfigparser import config
|
from bmconfigparser import config
|
||||||
from foldertree import AddressBookCompleter
|
from .foldertree import AddressBookCompleter
|
||||||
from messageview import MessageView
|
from .messageview import MessageView
|
||||||
from messagecompose import MessageCompose
|
from .messagecompose import MessageCompose
|
||||||
import settingsmixin
|
from bitmessageqt import settingsmixin
|
||||||
from networkstatus import NetworkStatus
|
from .networkstatus import NetworkStatus
|
||||||
from blacklist import Blacklist
|
from .blacklist import Blacklist
|
||||||
|
|
||||||
try:
|
try:
|
||||||
_fromUtf8 = QtCore.QString.fromUtf8
|
_fromUtf8 = QtCore.QString.fromUtf8
|
||||||
|
|
|
@ -3,13 +3,13 @@ from PyQt4 import QtCore, QtGui
|
||||||
import widgets
|
import widgets
|
||||||
from addresses import addBMIfNotPresent
|
from addresses import addBMIfNotPresent
|
||||||
from bmconfigparser import config
|
from bmconfigparser import config
|
||||||
from dialogs import AddAddressDialog
|
from .dialogs import AddAddressDialog
|
||||||
from helper_sql import sqlExecute, sqlQuery
|
from helper_sql import sqlExecute, sqlQuery
|
||||||
from queues import UISignalQueue
|
from queues import UISignalQueue
|
||||||
from retranslateui import RetranslateMixin
|
from .retranslateui import RetranslateMixin
|
||||||
from tr import _translate
|
from tr import _translate
|
||||||
from uisignaler import UISignaler
|
from .uisignaler import UISignaler
|
||||||
from utils import avatarize
|
from .utils import avatarize
|
||||||
|
|
||||||
|
|
||||||
class Blacklist(QtGui.QWidget, RetranslateMixin):
|
class Blacklist(QtGui.QWidget, RetranslateMixin):
|
||||||
|
|
|
@ -5,14 +5,14 @@ Custom dialog classes
|
||||||
from PyQt4 import QtGui
|
from PyQt4 import QtGui
|
||||||
|
|
||||||
import paths
|
import paths
|
||||||
import widgets
|
from bitmessageqt import widgets
|
||||||
from address_dialogs import (
|
from .address_dialogs import (
|
||||||
AddAddressDialog, EmailGatewayDialog, NewAddressDialog,
|
AddAddressDialog, EmailGatewayDialog, NewAddressDialog,
|
||||||
NewSubscriptionDialog, RegenerateAddressesDialog,
|
NewSubscriptionDialog, RegenerateAddressesDialog,
|
||||||
SpecialAddressBehaviorDialog
|
SpecialAddressBehaviorDialog
|
||||||
)
|
)
|
||||||
from newchandialog import NewChanDialog
|
from .newchandialog import NewChanDialog
|
||||||
from settings import SettingsDialog
|
from .settings import SettingsDialog
|
||||||
from tr import _translate
|
from tr import _translate
|
||||||
from version import softwareVersion
|
from version import softwareVersion
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,9 @@ from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from bmconfigparser import config
|
from bmconfigparser import config
|
||||||
from helper_sql import sqlExecute, sqlQuery
|
from helper_sql import sqlExecute, sqlQuery
|
||||||
from settingsmixin import SettingsMixin
|
from .settingsmixin import SettingsMixin
|
||||||
from tr import _translate
|
from tr import _translate
|
||||||
from utils import avatarize
|
from .utils import avatarize
|
||||||
|
|
||||||
# for pylupdate
|
# for pylupdate
|
||||||
_translate("MainWindow", "inbox")
|
_translate("MainWindow", "inbox")
|
||||||
|
|
|
@ -7,7 +7,7 @@ zoom and URL click warning popup
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from safehtmlparser import SafeHTMLParser
|
from .safehtmlparser import SafeHTMLParser
|
||||||
from tr import _translate
|
from tr import _translate
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,11 +9,11 @@ from PyQt4 import QtCore, QtGui
|
||||||
import l10n
|
import l10n
|
||||||
import network.stats
|
import network.stats
|
||||||
import state
|
import state
|
||||||
import widgets
|
from bitmessageqt import widgets
|
||||||
from network import connectionpool, knownnodes
|
from network import connectionpool, knownnodes
|
||||||
from retranslateui import RetranslateMixin
|
from .retranslateui import RetranslateMixin
|
||||||
from tr import _translate
|
from tr import _translate
|
||||||
from uisignaler import UISignaler
|
from .uisignaler import UISignaler
|
||||||
|
|
||||||
|
|
||||||
class NetworkStatus(QtGui.QWidget, RetranslateMixin):
|
class NetworkStatus(QtGui.QWidget, RetranslateMixin):
|
||||||
|
|
|
@ -6,13 +6,13 @@ src/bitmessageqt/newchandialog.py
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
import widgets
|
from bitmessageqt import widgets
|
||||||
from addresses import addBMIfNotPresent
|
from addresses import addBMIfNotPresent
|
||||||
from addressvalidator import AddressValidator, PassPhraseValidator
|
from .addressvalidator import AddressValidator, PassPhraseValidator
|
||||||
from queues import (
|
from queues import (
|
||||||
addressGeneratorQueue, apiAddressGeneratorReturnQueue, UISignalQueue)
|
addressGeneratorQueue, apiAddressGeneratorReturnQueue, UISignalQueue)
|
||||||
from tr import _translate
|
from tr import _translate
|
||||||
from utils import str_chan
|
from .utils import str_chan
|
||||||
|
|
||||||
|
|
||||||
class NewChanDialog(QtGui.QDialog):
|
class NewChanDialog(QtGui.QDialog):
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from os import path
|
from os import path
|
||||||
from PyQt4 import QtGui
|
from PyQt4 import QtGui
|
||||||
from debug import logger
|
from debug import logger
|
||||||
import widgets
|
from bitmessageqt import widgets
|
||||||
|
|
||||||
class RetranslateMixin(object):
|
class RetranslateMixin(object):
|
||||||
def retranslateUi(self):
|
def retranslateUi(self):
|
||||||
|
|
|
@ -16,7 +16,7 @@ import openclpow
|
||||||
import paths
|
import paths
|
||||||
import queues
|
import queues
|
||||||
import state
|
import state
|
||||||
import widgets
|
from bitmessageqt import widgets
|
||||||
from bmconfigparser import config as config_obj
|
from bmconfigparser import config as config_obj
|
||||||
from helper_sql import sqlExecute, sqlStoredProcedure
|
from helper_sql import sqlExecute, sqlStoredProcedure
|
||||||
from helper_startup import start_proxyconfig
|
from helper_startup import start_proxyconfig
|
||||||
|
|
|
@ -8,7 +8,7 @@ import time
|
||||||
|
|
||||||
from PyQt4 import QtCore
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
import account
|
from bitmessageqt import account
|
||||||
import defaults
|
import defaults
|
||||||
import network.stats
|
import network.stats
|
||||||
import paths
|
import paths
|
||||||
|
@ -16,12 +16,12 @@ import proofofwork
|
||||||
import queues
|
import queues
|
||||||
import state
|
import state
|
||||||
from bmconfigparser import config
|
from bmconfigparser import config
|
||||||
from foldertree import AccountMixin
|
from .foldertree import AccountMixin
|
||||||
from helper_sql import sqlExecute, sqlQuery
|
from helper_sql import sqlExecute, sqlQuery
|
||||||
from l10n import getTranslationLanguage
|
from l10n import getTranslationLanguage
|
||||||
from openclpow import openclEnabled
|
from openclpow import openclEnabled
|
||||||
from pyelliptic.openssl import OpenSSL
|
from pyelliptic.openssl import OpenSSL
|
||||||
from settings import getSOCKSProxyType
|
from .settings import getSOCKSProxyType
|
||||||
from version import softwareVersion
|
from version import softwareVersion
|
||||||
from tr import _translate
|
from tr import _translate
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
"""bitmessageqt tests"""
|
"""bitmessageqt tests"""
|
||||||
|
|
||||||
from addressbook import TestAddressbook
|
from .addressbook import TestAddressbook
|
||||||
from main import TestMain, TestUISignaler
|
from .main import TestMain, TestUISignaler
|
||||||
from settings import TestSettings
|
from .settings import TestSettings
|
||||||
from support import TestSupport
|
from .support import TestSupport
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"TestAddressbook", "TestMain", "TestSettings", "TestSupport",
|
"TestAddressbook", "TestMain", "TestSettings", "TestSupport",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import helper_addressbook
|
import helper_addressbook
|
||||||
from bitmessageqt.support import createAddressIfNeeded
|
from bitmessageqt.support import createAddressIfNeeded
|
||||||
|
|
||||||
from main import TestBase
|
from .main import TestBase
|
||||||
|
|
||||||
|
|
||||||
class TestAddressbook(TestBase):
|
class TestAddressbook(TestBase):
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from main import TestBase
|
from .main import TestBase
|
||||||
from bmconfigparser import config
|
from bmconfigparser import config
|
||||||
from bitmessageqt import settings
|
from bitmessageqt import settings
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import sys
|
||||||
|
|
||||||
from shared import isAddressInMyAddressBook
|
from shared import isAddressInMyAddressBook
|
||||||
|
|
||||||
from main import TestBase
|
from .main import TestBase
|
||||||
|
|
||||||
|
|
||||||
class TestSupport(TestBase):
|
class TestSupport(TestBase):
|
||||||
|
|
|
@ -12,7 +12,7 @@ def start(config, state):
|
||||||
"""Start network threads"""
|
"""Start network threads"""
|
||||||
import state
|
import state
|
||||||
from .announcethread import AnnounceThread
|
from .announcethread import AnnounceThread
|
||||||
import connectionpool # pylint: disable=relative-import
|
from network import connectionpool
|
||||||
from .addrthread import AddrThread
|
from .addrthread import AddrThread
|
||||||
from .dandelion import Dandelion
|
from .dandelion import Dandelion
|
||||||
from .downloadthread import DownloadThread
|
from .downloadthread import DownloadThread
|
||||||
|
|
|
@ -4,12 +4,12 @@ Announce addresses as they are received from other hosts
|
||||||
from six.moves import queue
|
from six.moves import queue
|
||||||
|
|
||||||
# magic imports!
|
# magic imports!
|
||||||
import connectionpool
|
from network import connectionpool
|
||||||
from helper_random import randomshuffle
|
from helper_random import randomshuffle
|
||||||
from protocol import assembleAddrMessage
|
from protocol import assembleAddrMessage
|
||||||
from queues import addrQueue # FIXME: init with queue
|
from queues import addrQueue # FIXME: init with queue
|
||||||
|
|
||||||
from threads import StoppableThread
|
from .threads import StoppableThread
|
||||||
|
|
||||||
|
|
||||||
class AddrThread(StoppableThread):
|
class AddrThread(StoppableThread):
|
||||||
|
|
|
@ -7,7 +7,7 @@ import time
|
||||||
|
|
||||||
import network.asyncore_pollchoose as asyncore
|
import network.asyncore_pollchoose as asyncore
|
||||||
import state
|
import state
|
||||||
from threads import BusyError, nonBlocking
|
from .threads import BusyError, nonBlocking
|
||||||
|
|
||||||
|
|
||||||
class ProcessingError(Exception):
|
class ProcessingError(Exception):
|
||||||
|
|
|
@ -4,12 +4,12 @@ Announce myself (node address)
|
||||||
import time
|
import time
|
||||||
|
|
||||||
# magic imports!
|
# magic imports!
|
||||||
import connectionpool
|
from network import connectionpool
|
||||||
from bmconfigparser import config
|
from bmconfigparser import config
|
||||||
from protocol import assembleAddrMessage
|
from protocol import assembleAddrMessage
|
||||||
|
|
||||||
from node import Peer
|
from .node import Peer
|
||||||
from threads import StoppableThread
|
from .threads import StoppableThread
|
||||||
|
|
||||||
|
|
||||||
class AnnounceThread(StoppableThread):
|
class AnnounceThread(StoppableThread):
|
||||||
|
|
|
@ -6,7 +6,7 @@ import time
|
||||||
|
|
||||||
import protocol
|
import protocol
|
||||||
import state
|
import state
|
||||||
import connectionpool
|
import network.connectionpool # use long name to address recursive import
|
||||||
from highlevelcrypto import calculateInventoryHash
|
from highlevelcrypto import calculateInventoryHash
|
||||||
|
|
||||||
logger = logging.getLogger('default')
|
logger = logging.getLogger('default')
|
||||||
|
@ -99,7 +99,7 @@ class BMObject(object): # pylint: disable=too-many-instance-attributes
|
||||||
logger.warning(
|
logger.warning(
|
||||||
'The object has invalid stream: %s', self.streamNumber)
|
'The object has invalid stream: %s', self.streamNumber)
|
||||||
raise BMObjectInvalidError()
|
raise BMObjectInvalidError()
|
||||||
if self.streamNumber not in connectionpool.pool.streams:
|
if self.streamNumber not in network.connectionpool.pool.streams:
|
||||||
logger.debug(
|
logger.debug(
|
||||||
'The streamNumber %i isn\'t one we are interested in.',
|
'The streamNumber %i isn\'t one we are interested in.',
|
||||||
self.streamNumber)
|
self.streamNumber)
|
||||||
|
|
|
@ -12,10 +12,10 @@ import time
|
||||||
|
|
||||||
# magic imports!
|
# magic imports!
|
||||||
import addresses
|
import addresses
|
||||||
import knownnodes
|
from network import knownnodes
|
||||||
import protocol
|
import protocol
|
||||||
import state
|
import state
|
||||||
import connectionpool
|
import network.connectionpool # use long name to address recursive import
|
||||||
from bmconfigparser import config
|
from bmconfigparser import config
|
||||||
from queues import invQueue, objectProcessorQueue, portCheckerQueue
|
from queues import invQueue, objectProcessorQueue, portCheckerQueue
|
||||||
from randomtrackingdict import RandomTrackingDict
|
from randomtrackingdict import RandomTrackingDict
|
||||||
|
@ -27,8 +27,8 @@ from network.bmobject import (
|
||||||
)
|
)
|
||||||
from network.proxy import ProxyError
|
from network.proxy import ProxyError
|
||||||
|
|
||||||
from node import Node, Peer
|
from .node import Node, Peer
|
||||||
from objectracker import ObjectTracker, missingObjects
|
from .objectracker import ObjectTracker, missingObjects
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger('default')
|
logger = logging.getLogger('default')
|
||||||
|
@ -445,7 +445,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
|
||||||
for seenTime, stream, _, ip, port in self._decode_addr():
|
for seenTime, stream, _, ip, port in self._decode_addr():
|
||||||
ip = str(ip)
|
ip = str(ip)
|
||||||
if (
|
if (
|
||||||
stream not in connectionpool.pool.streams
|
stream not in network.connectionpool.pool.streams
|
||||||
# FIXME: should check against complete list
|
# FIXME: should check against complete list
|
||||||
or ip.startswith('bootstrap')
|
or ip.startswith('bootstrap')
|
||||||
):
|
):
|
||||||
|
@ -540,7 +540,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
|
||||||
if not self.isOutbound:
|
if not self.isOutbound:
|
||||||
self.append_write_buf(protocol.assembleVersionMessage(
|
self.append_write_buf(protocol.assembleVersionMessage(
|
||||||
self.destination.host, self.destination.port,
|
self.destination.host, self.destination.port,
|
||||||
connectionpool.pool.streams, True,
|
network.connectionpool.pool.streams, True,
|
||||||
nodeid=self.nodeid))
|
nodeid=self.nodeid))
|
||||||
logger.debug(
|
logger.debug(
|
||||||
'%(host)s:%(port)i sending version',
|
'%(host)s:%(port)i sending version',
|
||||||
|
@ -596,7 +596,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
|
||||||
'Closed connection to %s because there is no overlapping'
|
'Closed connection to %s because there is no overlapping'
|
||||||
' interest in streams.', self.destination)
|
' interest in streams.', self.destination)
|
||||||
return False
|
return False
|
||||||
if connectionpool.pool.inboundConnections.get(
|
if network.connectionpool.pool.inboundConnections.get(
|
||||||
self.destination):
|
self.destination):
|
||||||
try:
|
try:
|
||||||
if not protocol.checkSocksIP(self.destination.host):
|
if not protocol.checkSocksIP(self.destination.host):
|
||||||
|
@ -614,8 +614,8 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
|
||||||
# or server full report the same error to counter deanonymisation
|
# or server full report the same error to counter deanonymisation
|
||||||
if (
|
if (
|
||||||
Peer(self.destination.host, self.peerNode.port)
|
Peer(self.destination.host, self.peerNode.port)
|
||||||
in connectionpool.pool.inboundConnections
|
in network.connectionpool.pool.inboundConnections
|
||||||
or len(connectionpool.pool)
|
or len(network.connectionpool.pool)
|
||||||
> config.safeGetInt(
|
> config.safeGetInt(
|
||||||
'bitmessagesettings', 'maxtotalconnections')
|
'bitmessagesettings', 'maxtotalconnections')
|
||||||
+ config.safeGetInt(
|
+ config.safeGetInt(
|
||||||
|
@ -627,7 +627,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
|
||||||
'Closed connection to %s due to server full'
|
'Closed connection to %s due to server full'
|
||||||
' or duplicate inbound/outbound.', self.destination)
|
' or duplicate inbound/outbound.', self.destination)
|
||||||
return False
|
return False
|
||||||
if connectionpool.pool.isAlreadyConnected(self.nonce):
|
if network.connectionpool.pool.isAlreadyConnected(self.nonce):
|
||||||
self.append_write_buf(protocol.assembleErrorMessage(
|
self.append_write_buf(protocol.assembleErrorMessage(
|
||||||
errorText="I'm connected to myself. Closing connection.",
|
errorText="I'm connected to myself. Closing connection.",
|
||||||
fatal=2))
|
fatal=2))
|
||||||
|
@ -641,7 +641,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def stopDownloadingObject(hashId, forwardAnyway=False):
|
def stopDownloadingObject(hashId, forwardAnyway=False):
|
||||||
"""Stop downloading object *hashId*"""
|
"""Stop downloading object *hashId*"""
|
||||||
for connection in connectionpool.pool.connections():
|
for connection in network.connectionpool.pool.connections():
|
||||||
try:
|
try:
|
||||||
del connection.objectsNewToMe[hashId]
|
del connection.objectsNewToMe[hashId]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|
|
@ -5,7 +5,7 @@ Select which node to connect to
|
||||||
import logging
|
import logging
|
||||||
import random
|
import random
|
||||||
|
|
||||||
import knownnodes
|
from network import knownnodes
|
||||||
import protocol
|
import protocol
|
||||||
import state
|
import state
|
||||||
from bmconfigparser import config
|
from bmconfigparser import config
|
||||||
|
|
|
@ -8,19 +8,19 @@ import socket
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import asyncore_pollchoose as asyncore
|
from network import asyncore_pollchoose as asyncore
|
||||||
import helper_random
|
import helper_random
|
||||||
import knownnodes
|
from network import knownnodes
|
||||||
import protocol
|
import protocol
|
||||||
import state
|
import state
|
||||||
from bmconfigparser import config
|
from bmconfigparser import config
|
||||||
from connectionchooser import chooseConnection
|
from .connectionchooser import chooseConnection
|
||||||
from node import Peer
|
from .node import Peer
|
||||||
from proxy import Proxy
|
from .proxy import Proxy
|
||||||
from tcp import (
|
from .tcp import (
|
||||||
bootstrap, Socks4aBMConnection, Socks5BMConnection,
|
bootstrap, Socks4aBMConnection, Socks5BMConnection,
|
||||||
TCPConnection, TCPServer)
|
TCPConnection, TCPServer)
|
||||||
from udp import UDPSocket
|
from .udp import UDPSocket
|
||||||
|
|
||||||
logger = logging.getLogger('default')
|
logger = logging.getLogger('default')
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ from random import choice, expovariate, sample
|
||||||
from threading import RLock
|
from threading import RLock
|
||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
import connectionpool
|
from network import connectionpool
|
||||||
import state
|
import state
|
||||||
from queues import invQueue
|
from queues import invQueue
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,9 @@ import state
|
||||||
import addresses
|
import addresses
|
||||||
import helper_random
|
import helper_random
|
||||||
import protocol
|
import protocol
|
||||||
import connectionpool
|
from network import connectionpool
|
||||||
from objectracker import missingObjects
|
from .objectracker import missingObjects
|
||||||
from threads import StoppableThread
|
from .threads import StoppableThread
|
||||||
|
|
||||||
|
|
||||||
class DownloadThread(StoppableThread):
|
class DownloadThread(StoppableThread):
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
from advanceddispatcher import AdvancedDispatcher
|
from .advanceddispatcher import AdvancedDispatcher
|
||||||
import asyncore_pollchoose as asyncore
|
from network import asyncore_pollchoose as asyncore
|
||||||
from proxy import ProxyError
|
from .proxy import ProxyError
|
||||||
from socks5 import Socks5Connection, Socks5Resolver
|
from .socks5 import Socks5Connection, Socks5Resolver
|
||||||
from socks4a import Socks4aConnection, Socks4aResolver
|
from .socks4a import Socks4aConnection, Socks4aResolver
|
||||||
|
|
||||||
|
|
||||||
class HttpError(ProxyError):
|
class HttpError(ProxyError):
|
||||||
|
|
|
@ -8,9 +8,9 @@ from time import time
|
||||||
import addresses
|
import addresses
|
||||||
import protocol
|
import protocol
|
||||||
import state
|
import state
|
||||||
import connectionpool
|
from network import connectionpool
|
||||||
from queues import invQueue
|
from queues import invQueue
|
||||||
from threads import StoppableThread
|
from .threads import StoppableThread
|
||||||
|
|
||||||
|
|
||||||
def handleExpiredDandelion(expired):
|
def handleExpiredDandelion(expired):
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
A thread to handle network concerns
|
A thread to handle network concerns
|
||||||
"""
|
"""
|
||||||
import network.asyncore_pollchoose as asyncore
|
import network.asyncore_pollchoose as asyncore
|
||||||
import connectionpool
|
from network import connectionpool
|
||||||
from queues import excQueue
|
from queues import excQueue
|
||||||
from threads import StoppableThread
|
from .threads import StoppableThread
|
||||||
|
|
||||||
|
|
||||||
class BMNetworkThread(StoppableThread):
|
class BMNetworkThread(StoppableThread):
|
||||||
|
|
|
@ -5,7 +5,7 @@ import time
|
||||||
from threading import RLock
|
from threading import RLock
|
||||||
|
|
||||||
import state
|
import state
|
||||||
import connectionpool
|
import network.connectionpool # use long name to address recursive import
|
||||||
from randomtrackingdict import RandomTrackingDict
|
from randomtrackingdict import RandomTrackingDict
|
||||||
|
|
||||||
haveBloom = False
|
haveBloom = False
|
||||||
|
@ -100,7 +100,7 @@ class ObjectTracker(object):
|
||||||
|
|
||||||
def handleReceivedObject(self, streamNumber, hashid):
|
def handleReceivedObject(self, streamNumber, hashid):
|
||||||
"""Handling received object"""
|
"""Handling received object"""
|
||||||
for i in connectionpool.pool.connections():
|
for i in network.connectionpool.pool.connections():
|
||||||
if not i.fullyEstablished:
|
if not i.fullyEstablished:
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -6,10 +6,10 @@ import logging
|
||||||
import socket
|
import socket
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import asyncore_pollchoose as asyncore
|
from network import asyncore_pollchoose as asyncore
|
||||||
from advanceddispatcher import AdvancedDispatcher
|
from .advanceddispatcher import AdvancedDispatcher
|
||||||
from bmconfigparser import config
|
from bmconfigparser import config
|
||||||
from node import Peer
|
from .node import Peer
|
||||||
|
|
||||||
logger = logging.getLogger('default')
|
logger = logging.getLogger('default')
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,10 @@ import errno
|
||||||
import Queue
|
import Queue
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
import connectionpool
|
from network import connectionpool
|
||||||
from network.advanceddispatcher import UnknownStateError
|
from network.advanceddispatcher import UnknownStateError
|
||||||
from queues import receiveDataQueue
|
from queues import receiveDataQueue
|
||||||
from threads import StoppableThread
|
from .threads import StoppableThread
|
||||||
|
|
||||||
|
|
||||||
class ReceiveQueueThread(StoppableThread):
|
class ReceiveQueueThread(StoppableThread):
|
||||||
|
|
|
@ -6,7 +6,7 @@ import logging
|
||||||
import socket
|
import socket
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
from proxy import GeneralProxyError, Proxy, ProxyError
|
from .proxy import GeneralProxyError, Proxy, ProxyError
|
||||||
|
|
||||||
logger = logging.getLogger('default')
|
logger = logging.getLogger('default')
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,8 @@ import logging
|
||||||
import socket
|
import socket
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
from node import Peer
|
from .node import Peer
|
||||||
from proxy import GeneralProxyError, Proxy, ProxyError
|
from .proxy import GeneralProxyError, Proxy, ProxyError
|
||||||
|
|
||||||
logger = logging.getLogger('default')
|
logger = logging.getLogger('default')
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,9 @@ Network statistics
|
||||||
"""
|
"""
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import asyncore_pollchoose as asyncore
|
from network import asyncore_pollchoose as asyncore
|
||||||
import connectionpool
|
from network import connectionpool
|
||||||
from objectracker import missingObjects
|
from .objectracker import missingObjects
|
||||||
|
|
||||||
|
|
||||||
lastReceivedTimestamp = time.time()
|
lastReceivedTimestamp = time.time()
|
||||||
|
|
|
@ -15,21 +15,21 @@ import helper_random
|
||||||
import l10n
|
import l10n
|
||||||
import protocol
|
import protocol
|
||||||
import state
|
import state
|
||||||
import connectionpool
|
import network.connectionpool # use long name to address recursive import
|
||||||
from bmconfigparser import config
|
from bmconfigparser import config
|
||||||
from highlevelcrypto import randomBytes
|
from highlevelcrypto import randomBytes
|
||||||
from queues import invQueue, receiveDataQueue, UISignalQueue
|
from queues import invQueue, receiveDataQueue, UISignalQueue
|
||||||
from tr import _translate
|
from tr import _translate
|
||||||
|
|
||||||
import asyncore_pollchoose as asyncore
|
from network import asyncore_pollchoose as asyncore
|
||||||
import knownnodes
|
from network import knownnodes
|
||||||
from network.advanceddispatcher import AdvancedDispatcher
|
from network.advanceddispatcher import AdvancedDispatcher
|
||||||
from network.bmproto import BMProto
|
from network.bmproto import BMProto
|
||||||
from network.objectracker import ObjectTracker
|
from network.objectracker import ObjectTracker
|
||||||
from network.socks4a import Socks4aConnection
|
from network.socks4a import Socks4aConnection
|
||||||
from network.socks5 import Socks5Connection
|
from network.socks5 import Socks5Connection
|
||||||
from network.tls import TLSDispatcher
|
from network.tls import TLSDispatcher
|
||||||
from node import Peer
|
from .node import Peer
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger('default')
|
logger = logging.getLogger('default')
|
||||||
|
@ -267,7 +267,7 @@ class TCPConnection(BMProto, TLSDispatcher):
|
||||||
self.append_write_buf(
|
self.append_write_buf(
|
||||||
protocol.assembleVersionMessage(
|
protocol.assembleVersionMessage(
|
||||||
self.destination.host, self.destination.port,
|
self.destination.host, self.destination.port,
|
||||||
connectionpool.pool.streams,
|
network.connectionpool.pool.streams,
|
||||||
False, nodeid=self.nodeid))
|
False, nodeid=self.nodeid))
|
||||||
self.connectedAt = time.time()
|
self.connectedAt = time.time()
|
||||||
receiveDataQueue.put(self.destination)
|
receiveDataQueue.put(self.destination)
|
||||||
|
@ -318,7 +318,7 @@ class Socks5BMConnection(Socks5Connection, TCPConnection):
|
||||||
self.append_write_buf(
|
self.append_write_buf(
|
||||||
protocol.assembleVersionMessage(
|
protocol.assembleVersionMessage(
|
||||||
self.destination.host, self.destination.port,
|
self.destination.host, self.destination.port,
|
||||||
connectionpool.pool.streams,
|
network.connectionpool.pool.streams,
|
||||||
False, nodeid=self.nodeid))
|
False, nodeid=self.nodeid))
|
||||||
self.set_state("bm_header", expectBytes=protocol.Header.size)
|
self.set_state("bm_header", expectBytes=protocol.Header.size)
|
||||||
return True
|
return True
|
||||||
|
@ -342,7 +342,7 @@ class Socks4aBMConnection(Socks4aConnection, TCPConnection):
|
||||||
self.append_write_buf(
|
self.append_write_buf(
|
||||||
protocol.assembleVersionMessage(
|
protocol.assembleVersionMessage(
|
||||||
self.destination.host, self.destination.port,
|
self.destination.host, self.destination.port,
|
||||||
connectionpool.pool.streams,
|
network.connectionpool.pool.streams,
|
||||||
False, nodeid=self.nodeid))
|
False, nodeid=self.nodeid))
|
||||||
self.set_state("bm_header", expectBytes=protocol.Header.size)
|
self.set_state("bm_header", expectBytes=protocol.Header.size)
|
||||||
return True
|
return True
|
||||||
|
@ -430,7 +430,7 @@ class TCPServer(AdvancedDispatcher):
|
||||||
|
|
||||||
state.ownAddresses[Peer(*sock.getsockname())] = True
|
state.ownAddresses[Peer(*sock.getsockname())] = True
|
||||||
if (
|
if (
|
||||||
len(connectionpool.pool)
|
len(network.connectionpool.pool)
|
||||||
> config.safeGetInt(
|
> config.safeGetInt(
|
||||||
'bitmessagesettings', 'maxtotalconnections')
|
'bitmessagesettings', 'maxtotalconnections')
|
||||||
+ config.safeGetInt(
|
+ config.safeGetInt(
|
||||||
|
@ -442,7 +442,7 @@ class TCPServer(AdvancedDispatcher):
|
||||||
sock.close()
|
sock.close()
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
connectionpool.pool.addConnection(
|
network.connectionpool.pool.addConnection(
|
||||||
TCPConnection(sock=sock))
|
TCPConnection(sock=sock))
|
||||||
except socket.error:
|
except socket.error:
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -8,12 +8,12 @@ import time
|
||||||
# magic imports!
|
# magic imports!
|
||||||
import protocol
|
import protocol
|
||||||
import state
|
import state
|
||||||
import connectionpool
|
import network.connectionpool # use long name to address recursive import
|
||||||
from queues import receiveDataQueue
|
from queues import receiveDataQueue
|
||||||
|
|
||||||
from bmproto import BMProto
|
from .bmproto import BMProto
|
||||||
from node import Peer
|
from .node import Peer
|
||||||
from objectracker import ObjectTracker
|
from .objectracker import ObjectTracker
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger('default')
|
logger = logging.getLogger('default')
|
||||||
|
@ -82,7 +82,7 @@ class UDPSocket(BMProto): # pylint: disable=too-many-instance-attributes
|
||||||
remoteport = False
|
remoteport = False
|
||||||
for seenTime, stream, _, ip, port in addresses:
|
for seenTime, stream, _, ip, port in addresses:
|
||||||
decodedIP = protocol.checkIPAddress(str(ip))
|
decodedIP = protocol.checkIPAddress(str(ip))
|
||||||
if stream not in connectionpool.pool.streams:
|
if stream not in network.connectionpool.pool.streams:
|
||||||
continue
|
continue
|
||||||
if (seenTime < time.time() - protocol.MAX_TIME_OFFSET
|
if (seenTime < time.time() - protocol.MAX_TIME_OFFSET
|
||||||
or seenTime > time.time() + protocol.MAX_TIME_OFFSET):
|
or seenTime > time.time() + protocol.MAX_TIME_OFFSET):
|
||||||
|
|
|
@ -6,9 +6,9 @@ import time
|
||||||
import helper_random
|
import helper_random
|
||||||
import protocol
|
import protocol
|
||||||
import state
|
import state
|
||||||
import connectionpool
|
from network import connectionpool
|
||||||
from randomtrackingdict import RandomTrackingDict
|
from randomtrackingdict import RandomTrackingDict
|
||||||
from threads import StoppableThread
|
from .threads import StoppableThread
|
||||||
|
|
||||||
|
|
||||||
class UploadThread(StoppableThread):
|
class UploadThread(StoppableThread):
|
||||||
|
|
Reference in New Issue
Block a user