Esempio n. 1
0
def connectToStream(streamNumber):
    state.streamsInWhichIAmParticipating.append(streamNumber)
    shared.selfInitiatedConnections.setdefault(streamNumber, {})

    if helper_startup.isOurOperatingSystemLimitedToHavingVeryFewHalfOpenConnections():
        # Some XP and Vista systems can only have 10 outgoing connections at a time.
        maximumNumberOfHalfOpenConnections = 9
    else:
        maximumNumberOfHalfOpenConnections = 64
    try:
        # don't overload Tor
        if BMConfigParser().get('bitmessagesettings', 'socksproxytype') != 'none':
            maximumNumberOfHalfOpenConnections = 4
    except:
        pass
    
    with knownnodes.knownNodesLock:
        if streamNumber not in knownnodes.knownNodes:
            knownnodes.knownNodes[streamNumber] = {}
        if streamNumber*2 not in knownnodes.knownNodes:
            knownnodes.knownNodes[streamNumber*2] = {}
        if streamNumber*2+1 not in knownnodes.knownNodes:
            knownnodes.knownNodes[streamNumber*2+1] = {}

    for i in xrange(maximumNumberOfHalfOpenConnections):
        a = outgoingSynSender(streamNumber)
        a.start()
Esempio n. 2
0
def connectToStream(streamNumber):
    state.streamsInWhichIAmParticipating.append(streamNumber)
    selfInitiatedConnections[streamNumber] = {}

    if isOurOperatingSystemLimitedToHavingVeryFewHalfOpenConnections():
        # Some XP and Vista systems can only have 10 outgoing connections at a time.
        state.maximumNumberOfHalfOpenConnections = 9
    else:
        state.maximumNumberOfHalfOpenConnections = 64
    try:
        # don't overload Tor
        if BMConfigParser().get('bitmessagesettings',
                                'socksproxytype') != 'none':
            state.maximumNumberOfHalfOpenConnections = 4
    except:
        pass

    with knownnodes.knownNodesLock:
        if streamNumber not in knownnodes.knownNodes:
            knownnodes.knownNodes[streamNumber] = {}
        if streamNumber * 2 not in knownnodes.knownNodes:
            knownnodes.knownNodes[streamNumber * 2] = {}
        if streamNumber * 2 + 1 not in knownnodes.knownNodes:
            knownnodes.knownNodes[streamNumber * 2 + 1] = {}

    if BMConfigParser().get("network", "asyncore"):
        BMConnectionPool().connectToStream(streamNumber)
    else:
        for i in range(state.maximumNumberOfHalfOpenConnections):
            a = outgoingSynSender()
            a.setup(streamNumber, selfInitiatedConnections)
            a.start()
Esempio n. 3
0
def start():
    # Create socket function that some versoin of python does not implement
    _fixWinsock()

    # Bind signal to default so that we can use Ctrl+C to stop it
    signal.signal(signal.SIGINT, signal.SIG_DFL)

    # Load known nodes
    helper_bootstrap.knownNodes()

    # Load config
    helper_startup.loadConfig()
    helper_startup.loadPubkeys()

    # Start the thread that ... I don't know.
    singleWorkerThread = singleWorker()
    singleWorkerThread.daemon = True  # close the main program even if there are threads left
    singleWorkerThread.start()

    # Start the SQL thread
    sqlLookup = sqlThread()
    sqlLookup.daemon = False  # DON'T close the main program even if there are threads left. The closeEvent should command this thread to exit gracefully.
    sqlLookup.start()

    # Start the thread that process object
    objectProcessorThread = objectProcessor()
    objectProcessorThread.daemon = False  # DON'T close the main program even the thread remains. This thread checks the shutdown variable after processing each object.
    objectProcessorThread.start()

    # Start the cleanerThread
    singleCleanerThread = singleCleaner()
    singleCleanerThread.daemon = True  # close the main program even if there are threads left
    singleCleanerThread.start()

    # Load my address
    shared.reloadMyAddressHashes()

    # Connect to the root stream
    streamNumber = 1
    shared.streamsInWhichIAmParticipating[streamNumber] = 'no data'
    selfInitiatedConnections[streamNumber] = {}
    shared.inventorySets[streamNumber] = set(
    )  #We may write some codes below to initialise the set.

    if isOurOperatingSystemLimitedToHavingVeryFewHalfOpenConnections():
        maximumNumberOfHalfOpenConnections = 9
    else:
        maximumNumberOfHalfOpenConnections = 64
    for i in xrange(maximumNumberOfHalfOpenConnections):
        a = outgoingSynSender()
        a.setup(streamNumber, selfInitiatedConnections)
        a.start()

    # Start the singleListenerThread
    singleListenerThread = singleListener()
    singleListenerThread.setup(selfInitiatedConnections)
    singleListenerThread.daemon = True  # close the main program even if there are threads left
    singleListenerThread.start()
Esempio n. 4
0
def start():
    # Create socket function that some versoin of python does not implement
    _fixWinsock()

    # Bind signal to default so that we can use Ctrl+C to stop it
    signal.signal(signal.SIGINT, signal.SIG_DFL)

    # Load known nodes
    helper_bootstrap.knownNodes()

    # Load config
    helper_startup.loadConfig()
    helper_startup.loadPubkeys()

    # Start the thread that ... I don't know.
    singleWorkerThread = singleWorker()
    singleWorkerThread.daemon = True  # close the main program even if there are threads left
    singleWorkerThread.start()

    # Start the SQL thread
    sqlLookup = sqlThread()
    sqlLookup.daemon = False  # DON'T close the main program even if there are threads left. The closeEvent should command this thread to exit gracefully.
    sqlLookup.start()

    # Start the thread that process object
    objectProcessorThread = objectProcessor()
    objectProcessorThread.daemon = False  # DON'T close the main program even the thread remains. This thread checks the shutdown variable after processing each object.
    objectProcessorThread.start()

    # Start the cleanerThread
    singleCleanerThread = singleCleaner()
    singleCleanerThread.daemon = True  # close the main program even if there are threads left
    singleCleanerThread.start()
    
    # Load my address
    shared.reloadMyAddressHashes()
    
    # Connect to the root stream 
    streamNumber = 1
    shared.streamsInWhichIAmParticipating[streamNumber] = 'no data'
    selfInitiatedConnections[streamNumber] = {}
    shared.inventorySets[streamNumber] = set() #We may write some codes below to initialise the set.

    if isOurOperatingSystemLimitedToHavingVeryFewHalfOpenConnections():
        maximumNumberOfHalfOpenConnections = 9
    else:
        maximumNumberOfHalfOpenConnections = 64
    for i in xrange(maximumNumberOfHalfOpenConnections):
        a = outgoingSynSender()
        a.setup(streamNumber, selfInitiatedConnections)
        a.start()

    # Start the singleListenerThread
    singleListenerThread = singleListener()
    singleListenerThread.setup(selfInitiatedConnections)
    singleListenerThread.daemon = True  # close the main program even if there are threads left
    singleListenerThread.start()
def connectToStream(streamNumber):
    shared.streamsInWhichIAmParticipating[streamNumber] = 'no data'
    selfInitiatedConnections[streamNumber] = {}
    shared.inventorySets[streamNumber] = set()
    queryData = sqlQuery('''SELECT hash FROM inventory WHERE streamnumber=?''', streamNumber)
    for row in queryData:
        shared.inventorySets[streamNumber].add(row[0])

    if sys.platform[0:3] == 'win':
        maximumNumberOfHalfOpenConnections = 9
    else:
        maximumNumberOfHalfOpenConnections = 32
    for i in range(maximumNumberOfHalfOpenConnections):
        a = outgoingSynSender()
        a.setup(streamNumber, selfInitiatedConnections)
        a.start()
Esempio n. 6
0
def connect_to_stream(stream_number):
    shared.streamsInWhichIAmParticipating[stream_number] = 'no data'
    self_initiated_connections[stream_number] = {}
    shared.inventorySets[stream_number] = set()
    query_data = sqlQuery('''SELECT hash FROM inventory WHERE streamnumber=?''', stream_number)
    for row in query_data:
        shared.inventorySets[stream_number].add(row[0])

    if isOurOperatingSystemLimitedToHavingVeryFewHalfOpenConnections():
        # Some XP and Vista systems can only have 10 outgoing connections at a time.
        maximum_number_of_half_open_connections = 9
    else:
        maximum_number_of_half_open_connections = 64
    for i in range(maximum_number_of_half_open_connections):
        a = outgoingSynSender()
        a.setup(stream_number, self_initiated_connections)
        a.start()
Esempio n. 7
0
def connectToStream(streamNumber):
    shared.streamsInWhichIAmParticipating[streamNumber] = "no data"
    selfInitiatedConnections[streamNumber] = {}
    shared.inventorySets[streamNumber] = set()
    queryData = sqlQuery("""SELECT hash FROM inventory WHERE streamnumber=?""", streamNumber)
    for row in queryData:
        shared.inventorySets[streamNumber].add(row[0])

    if isOurOperatingSystemLimitedToHavingVeryFewHalfOpenConnections():
        # Some XP and Vista systems can only have 10 outgoing connections at a time.
        maximumNumberOfHalfOpenConnections = 9
    else:
        maximumNumberOfHalfOpenConnections = 64
    for i in range(maximumNumberOfHalfOpenConnections):
        a = outgoingSynSender()
        a.setup(streamNumber, selfInitiatedConnections)
        a.start()
Esempio n. 8
0
def connectToStream(streamNumber):
    shared.streamsInWhichIAmParticipating[streamNumber] = 'no data'
    selfInitiatedConnections[streamNumber] = {}
    shared.inventorySets[streamNumber] = set()
    queryData = sqlQuery('''SELECT hash FROM inventory WHERE streamnumber=?''',
                         streamNumber)
    for row in queryData:
        shared.inventorySets[streamNumber].add(row[0])

    if isOurOperatingSystemLimitedToHavingVeryFewHalfOpenConnections():
        # Some XP and Vista systems can only have 10 outgoing connections at a time.
        maximumNumberOfHalfOpenConnections = 9
    else:
        maximumNumberOfHalfOpenConnections = 64
    for i in range(maximumNumberOfHalfOpenConnections):
        a = outgoingSynSender()
        a.setup(streamNumber, selfInitiatedConnections)
        a.start()
Esempio n. 9
0
def connectToStream(streamNumber):
    shared.streamsInWhichIAmParticipating[streamNumber] = 'no data'
    selfInitiatedConnections[streamNumber] = {}

    if isOurOperatingSystemLimitedToHavingVeryFewHalfOpenConnections():
        # Some XP and Vista systems can only have 10 outgoing connections at a time.
        maximumNumberOfHalfOpenConnections = 9
    else:
        maximumNumberOfHalfOpenConnections = 64
    try:
        # don't overload Tor
        if shared.config.get('bitmessagesettings', 'socksproxytype') != 'none':
            maximumNumberOfHalfOpenConnections = 4
    except:
        pass
    for i in range(maximumNumberOfHalfOpenConnections):
        a = outgoingSynSender()
        a.setup(streamNumber, selfInitiatedConnections)
        a.start()
Esempio n. 10
0
def connectToStream(streamNumber):
    shared.streamsInWhichIAmParticipating[streamNumber] = 'no data'
    selfInitiatedConnections[streamNumber] = {}

    if isOurOperatingSystemLimitedToHavingVeryFewHalfOpenConnections():
        # Some XP and Vista systems can only have 10 outgoing connections at a time.
        maximumNumberOfHalfOpenConnections = 9
    else:
        maximumNumberOfHalfOpenConnections = 64
    try:
        # don't overload Tor
        if shared.config.get('bitmessagesettings', 'socksproxytype') != 'none':
            maximumNumberOfHalfOpenConnections = 4
    except:
        pass
    for i in range(maximumNumberOfHalfOpenConnections):
        a = outgoingSynSender()
        a.setup(streamNumber, selfInitiatedConnections)
        a.start()