Merge pull request #161 from Atheros1/master
New tray icon, also use existing local-IP rejection function for received addr messages
This commit is contained in:
commit
dcaf5e767e
|
@ -216,7 +216,7 @@ class singleListener(threading.Thread):
|
||||||
#The following code will, unfortunately, block an incoming connection if someone else on the same LAN is already connected because the two computers will share the same external IP. This is here to prevent connection flooding.
|
#The following code will, unfortunately, block an incoming connection if someone else on the same LAN is already connected because the two computers will share the same external IP. This is here to prevent connection flooding.
|
||||||
while HOST in shared.connectedHostsList:
|
while HOST in shared.connectedHostsList:
|
||||||
shared.printLock.acquire()
|
shared.printLock.acquire()
|
||||||
print 'incoming connection is from a host in shared.connectedHostsList (we are already connected to it). Ignoring it.'
|
print 'We are already connected to', HOST+'. Ignoring connection.'
|
||||||
shared.printLock.release()
|
shared.printLock.release()
|
||||||
a.close()
|
a.close()
|
||||||
a,(HOST,PORT) = sock.accept()
|
a,(HOST,PORT) = sock.accept()
|
||||||
|
@ -1667,10 +1667,7 @@ class receiveDataThread(threading.Thread):
|
||||||
if data[28+lengthOfNumberOfAddresses+(34*i)] == '\x7F':
|
if data[28+lengthOfNumberOfAddresses+(34*i)] == '\x7F':
|
||||||
print 'Ignoring IP address in loopback range:', hostFromAddrMessage
|
print 'Ignoring IP address in loopback range:', hostFromAddrMessage
|
||||||
continue
|
continue
|
||||||
if data[28+lengthOfNumberOfAddresses+(34*i)] == '\x0A':
|
if isHostInPrivateIPRange(hostFromAddrMessage):
|
||||||
print 'Ignoring IP address in private range:', hostFromAddrMessage
|
|
||||||
continue
|
|
||||||
if data[28+lengthOfNumberOfAddresses+(34*i):30+lengthOfNumberOfAddresses+(34*i)] == '\xC0A8':
|
|
||||||
print 'Ignoring IP address in private range:', hostFromAddrMessage
|
print 'Ignoring IP address in private range:', hostFromAddrMessage
|
||||||
continue
|
continue
|
||||||
timeSomeoneElseReceivedMessageFromThisNode, = unpack('>I',data[lengthOfNumberOfAddresses+(34*i):4+lengthOfNumberOfAddresses+(34*i)]) #This is the 'time' value in the received addr message.
|
timeSomeoneElseReceivedMessageFromThisNode, = unpack('>I',data[lengthOfNumberOfAddresses+(34*i):4+lengthOfNumberOfAddresses+(34*i)]) #This is the 'time' value in the received addr message.
|
||||||
|
@ -1836,21 +1833,21 @@ class receiveDataThread(threading.Thread):
|
||||||
for i in range(500):
|
for i in range(500):
|
||||||
random.seed()
|
random.seed()
|
||||||
HOST, = random.sample(shared.knownNodes[self.streamNumber], 1)
|
HOST, = random.sample(shared.knownNodes[self.streamNumber], 1)
|
||||||
if self.isHostInPrivateIPRange(HOST):
|
if isHostInPrivateIPRange(HOST):
|
||||||
continue
|
continue
|
||||||
addrsInMyStream[HOST] = shared.knownNodes[self.streamNumber][HOST]
|
addrsInMyStream[HOST] = shared.knownNodes[self.streamNumber][HOST]
|
||||||
if len(shared.knownNodes[self.streamNumber*2]) > 0:
|
if len(shared.knownNodes[self.streamNumber*2]) > 0:
|
||||||
for i in range(250):
|
for i in range(250):
|
||||||
random.seed()
|
random.seed()
|
||||||
HOST, = random.sample(shared.knownNodes[self.streamNumber*2], 1)
|
HOST, = random.sample(shared.knownNodes[self.streamNumber*2], 1)
|
||||||
if self.isHostInPrivateIPRange(HOST):
|
if isHostInPrivateIPRange(HOST):
|
||||||
continue
|
continue
|
||||||
addrsInChildStreamLeft[HOST] = shared.knownNodes[self.streamNumber*2][HOST]
|
addrsInChildStreamLeft[HOST] = shared.knownNodes[self.streamNumber*2][HOST]
|
||||||
if len(shared.knownNodes[(self.streamNumber*2)+1]) > 0:
|
if len(shared.knownNodes[(self.streamNumber*2)+1]) > 0:
|
||||||
for i in range(250):
|
for i in range(250):
|
||||||
random.seed()
|
random.seed()
|
||||||
HOST, = random.sample(shared.knownNodes[(self.streamNumber*2)+1], 1)
|
HOST, = random.sample(shared.knownNodes[(self.streamNumber*2)+1], 1)
|
||||||
if self.isHostInPrivateIPRange(HOST):
|
if isHostInPrivateIPRange(HOST):
|
||||||
continue
|
continue
|
||||||
addrsInChildStreamRight[HOST] = shared.knownNodes[(self.streamNumber*2)+1][HOST]
|
addrsInChildStreamRight[HOST] = shared.knownNodes[(self.streamNumber*2)+1][HOST]
|
||||||
shared.knownNodesLock.release()
|
shared.knownNodesLock.release()
|
||||||
|
@ -1992,16 +1989,7 @@ class receiveDataThread(threading.Thread):
|
||||||
if self.verackReceived == True:
|
if self.verackReceived == True:
|
||||||
self.connectionFullyEstablished()
|
self.connectionFullyEstablished()
|
||||||
|
|
||||||
def isHostInPrivateIPRange(self,host):
|
|
||||||
if host[:3] == '10.':
|
|
||||||
return True
|
|
||||||
if host[:4] == '172.':
|
|
||||||
if host[6] == '.':
|
|
||||||
if int(host[4:6]) >= 16 and int(host[4:6]) <= 31:
|
|
||||||
return True
|
|
||||||
if host[:8] == '192.168.':
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
#Every connection to a peer has a sendDataThread (and also a receiveDataThread).
|
#Every connection to a peer has a sendDataThread (and also a receiveDataThread).
|
||||||
class sendDataThread(threading.Thread):
|
class sendDataThread(threading.Thread):
|
||||||
|
@ -2294,6 +2282,17 @@ def assembleVersionMessage(remoteHost,remotePort,myStreamNumber):
|
||||||
datatosend = datatosend + hashlib.sha512(payload).digest()[0:4]
|
datatosend = datatosend + hashlib.sha512(payload).digest()[0:4]
|
||||||
return datatosend + payload
|
return datatosend + payload
|
||||||
|
|
||||||
|
def isHostInPrivateIPRange(host):
|
||||||
|
if host[:3] == '10.':
|
||||||
|
return True
|
||||||
|
if host[:4] == '172.':
|
||||||
|
if host[6] == '.':
|
||||||
|
if int(host[4:6]) >= 16 and int(host[4:6]) <= 31:
|
||||||
|
return True
|
||||||
|
if host[:8] == '192.168.':
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
#This thread exists because SQLITE3 is so un-threadsafe that we must submit queries to it and it puts results back in a different queue. They won't let us just use locks.
|
#This thread exists because SQLITE3 is so un-threadsafe that we must submit queries to it and it puts results back in a different queue. They won't let us just use locks.
|
||||||
class sqlThread(threading.Thread):
|
class sqlThread(threading.Thread):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
# Form implementation generated from reading ui file 'bitmessageui.ui'
|
# Form implementation generated from reading ui file 'bitmessageui.ui'
|
||||||
#
|
#
|
||||||
# Created: Mon Apr 22 16:34:47 2013
|
# Created: Tue May 21 14:09:58 2013
|
||||||
# by: PyQt4 UI code generator 4.9.4
|
# by: PyQt4 UI code generator 4.9.4
|
||||||
#
|
#
|
||||||
# WARNING! All changes made in this file will be lost!
|
# WARNING! All changes made in this file will be lost!
|
||||||
|
@ -428,6 +428,30 @@ class Ui_MainWindow(object):
|
||||||
QtCore.QObject.connect(self.radioButtonSpecific, QtCore.SIGNAL(_fromUtf8("clicked(bool)")), self.labelSendBroadcastWarning.hide)
|
QtCore.QObject.connect(self.radioButtonSpecific, QtCore.SIGNAL(_fromUtf8("clicked(bool)")), self.labelSendBroadcastWarning.hide)
|
||||||
QtCore.QObject.connect(self.radioButtonBroadcast, QtCore.SIGNAL(_fromUtf8("clicked()")), self.labelSendBroadcastWarning.show)
|
QtCore.QObject.connect(self.radioButtonBroadcast, QtCore.SIGNAL(_fromUtf8("clicked()")), self.labelSendBroadcastWarning.show)
|
||||||
QtCore.QMetaObject.connectSlotsByName(MainWindow)
|
QtCore.QMetaObject.connectSlotsByName(MainWindow)
|
||||||
|
MainWindow.setTabOrder(self.tabWidget, self.tableWidgetInbox)
|
||||||
|
MainWindow.setTabOrder(self.tableWidgetInbox, self.textEditInboxMessage)
|
||||||
|
MainWindow.setTabOrder(self.textEditInboxMessage, self.radioButtonSpecific)
|
||||||
|
MainWindow.setTabOrder(self.radioButtonSpecific, self.radioButtonBroadcast)
|
||||||
|
MainWindow.setTabOrder(self.radioButtonBroadcast, self.comboBoxSendFrom)
|
||||||
|
MainWindow.setTabOrder(self.comboBoxSendFrom, self.lineEditTo)
|
||||||
|
MainWindow.setTabOrder(self.lineEditTo, self.pushButtonLoadFromAddressBook)
|
||||||
|
MainWindow.setTabOrder(self.pushButtonLoadFromAddressBook, self.lineEditSubject)
|
||||||
|
MainWindow.setTabOrder(self.lineEditSubject, self.textEditMessage)
|
||||||
|
MainWindow.setTabOrder(self.textEditMessage, self.pushButtonSend)
|
||||||
|
MainWindow.setTabOrder(self.pushButtonSend, self.tableWidgetSent)
|
||||||
|
MainWindow.setTabOrder(self.tableWidgetSent, self.textEditSentMessage)
|
||||||
|
MainWindow.setTabOrder(self.textEditSentMessage, self.pushButtonNewAddress)
|
||||||
|
MainWindow.setTabOrder(self.pushButtonNewAddress, self.tableWidgetYourIdentities)
|
||||||
|
MainWindow.setTabOrder(self.tableWidgetYourIdentities, self.pushButtonAddSubscription)
|
||||||
|
MainWindow.setTabOrder(self.pushButtonAddSubscription, self.tableWidgetSubscriptions)
|
||||||
|
MainWindow.setTabOrder(self.tableWidgetSubscriptions, self.pushButtonAddAddressBook)
|
||||||
|
MainWindow.setTabOrder(self.pushButtonAddAddressBook, self.tableWidgetAddressBook)
|
||||||
|
MainWindow.setTabOrder(self.tableWidgetAddressBook, self.radioButtonBlacklist)
|
||||||
|
MainWindow.setTabOrder(self.radioButtonBlacklist, self.radioButtonWhitelist)
|
||||||
|
MainWindow.setTabOrder(self.radioButtonWhitelist, self.pushButtonAddBlacklist)
|
||||||
|
MainWindow.setTabOrder(self.pushButtonAddBlacklist, self.tableWidgetBlacklist)
|
||||||
|
MainWindow.setTabOrder(self.tableWidgetBlacklist, self.tableWidgetConnectionCount)
|
||||||
|
MainWindow.setTabOrder(self.tableWidgetConnectionCount, self.pushButtonStatusIcon)
|
||||||
|
|
||||||
def retranslateUi(self, MainWindow):
|
def retranslateUi(self, MainWindow):
|
||||||
MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "Bitmessage", None, QtGui.QApplication.UnicodeUTF8))
|
MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "Bitmessage", None, QtGui.QApplication.UnicodeUTF8))
|
||||||
|
|
|
@ -1003,6 +1003,33 @@ p, li { white-space: pre-wrap; }
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>tabWidget</tabstop>
|
||||||
|
<tabstop>tableWidgetInbox</tabstop>
|
||||||
|
<tabstop>textEditInboxMessage</tabstop>
|
||||||
|
<tabstop>radioButtonSpecific</tabstop>
|
||||||
|
<tabstop>radioButtonBroadcast</tabstop>
|
||||||
|
<tabstop>comboBoxSendFrom</tabstop>
|
||||||
|
<tabstop>lineEditTo</tabstop>
|
||||||
|
<tabstop>pushButtonLoadFromAddressBook</tabstop>
|
||||||
|
<tabstop>lineEditSubject</tabstop>
|
||||||
|
<tabstop>textEditMessage</tabstop>
|
||||||
|
<tabstop>pushButtonSend</tabstop>
|
||||||
|
<tabstop>tableWidgetSent</tabstop>
|
||||||
|
<tabstop>textEditSentMessage</tabstop>
|
||||||
|
<tabstop>pushButtonNewAddress</tabstop>
|
||||||
|
<tabstop>tableWidgetYourIdentities</tabstop>
|
||||||
|
<tabstop>pushButtonAddSubscription</tabstop>
|
||||||
|
<tabstop>tableWidgetSubscriptions</tabstop>
|
||||||
|
<tabstop>pushButtonAddAddressBook</tabstop>
|
||||||
|
<tabstop>tableWidgetAddressBook</tabstop>
|
||||||
|
<tabstop>radioButtonBlacklist</tabstop>
|
||||||
|
<tabstop>radioButtonWhitelist</tabstop>
|
||||||
|
<tabstop>pushButtonAddBlacklist</tabstop>
|
||||||
|
<tabstop>tableWidgetBlacklist</tabstop>
|
||||||
|
<tabstop>tableWidgetConnectionCount</tabstop>
|
||||||
|
<tabstop>pushButtonStatusIcon</tabstop>
|
||||||
|
</tabstops>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="bitmessage_icons.qrc"/>
|
<include location="bitmessage_icons.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 885 B After Width: | Height: | Size: 4.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 867 B After Width: | Height: | Size: 4.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 872 B After Width: | Height: | Size: 4.2 KiB |
Loading…
Reference in New Issue
Block a user