From 3411f8f39aac0a10dcd2c3d367fdd37fdbff14e1 Mon Sep 17 00:00:00 2001 From: Jonathan Warren Date: Tue, 18 Dec 2012 13:09:10 -0500 Subject: [PATCH 1/5] added SOCKS --- about.py | 6 +- about.ui | 14 +- bitmessagemain.py | 243 +++++++++++++++++++++++------ iconglossary.py | 43 +++--- iconglossary.ui | 240 +++++++++++++---------------- settings.py | 107 ++++++++++--- settings.ui | 220 +++++++++++++++++++++----- socks/BUGS | 25 +++ socks/LICENSE | 22 +++ socks/README | 201 ++++++++++++++++++++++++ socks/__init__.py | 382 ++++++++++++++++++++++++++++++++++++++++++++++ 11 files changed, 1239 insertions(+), 264 deletions(-) create mode 100644 socks/BUGS create mode 100644 socks/LICENSE create mode 100644 socks/README create mode 100644 socks/__init__.py diff --git a/about.py b/about.py index 0c0f20e1..7b48d7d9 100644 --- a/about.py +++ b/about.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'about.ui' # -# Created: Mon Nov 19 13:33:47 2012 +# Created: Mon Dec 17 16:00:04 2012 # by: PyQt4 UI code generator 4.9.4 # # WARNING! All changes made in this file will be lost! @@ -39,11 +39,11 @@ class Ui_aboutDialog(object): self.label_2.setAlignment(QtCore.Qt.AlignCenter) self.label_2.setObjectName(_fromUtf8("label_2")) self.label_3 = QtGui.QLabel(aboutDialog) - self.label_3.setGeometry(QtCore.QRect(30, 210, 321, 51)) + self.label_3.setGeometry(QtCore.QRect(20, 210, 331, 61)) self.label_3.setWordWrap(True) self.label_3.setObjectName(_fromUtf8("label_3")) self.label_4 = QtGui.QLabel(aboutDialog) - self.label_4.setGeometry(QtCore.QRect(30, 260, 321, 101)) + self.label_4.setGeometry(QtCore.QRect(20, 280, 331, 81)) self.label_4.setWordWrap(True) self.label_4.setObjectName(_fromUtf8("label_4")) self.label_5 = QtGui.QLabel(aboutDialog) diff --git a/about.ui b/about.ui index b1cb77aa..7903525d 100644 --- a/about.ui +++ b/about.ui @@ -83,10 +83,10 @@ - 30 + 20 210 - 321 - 51 + 331 + 61 @@ -99,10 +99,10 @@ - 30 - 260 - 321 - 101 + 20 + 280 + 331 + 81 diff --git a/bitmessagemain.py b/bitmessagemain.py index 1362be1c..7dc164ce 100644 --- a/bitmessagemain.py +++ b/bitmessagemain.py @@ -44,10 +44,10 @@ import random import sqlite3 import threading #used for the locks, not for the threads import cStringIO -#from email.parser import Parser from time import strftime, localtime import os import string +import socks #For each stream to which we connect, one outgoingSynSender thread will exist and will create 8 connections with peers. class outgoingSynSender(QThread): @@ -79,10 +79,42 @@ class outgoingSynSender(QThread): resetTime = int(time.time()) self.alreadyAttemptedConnectionsList.append(HOST) PORT, timeNodeLastSeen = knownNodes[self.streamNumber][HOST] - printLock.acquire() - print 'Trying an outgoing connection to', HOST, ':', PORT - printLock.release() - sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock = socks.socksocket(socket.AF_INET, socket.SOCK_STREAM) + sock.settimeout(6) + if config.get('bitmessagesettings', 'socksproxytype') == 'none': + printLock.acquire() + print 'Trying an outgoing connection to', HOST, ':', PORT + printLock.release() + #sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + elif config.get('bitmessagesettings', 'socksproxytype') == 'SOCKS4a': + printLock.acquire() + print '(Using SOCKS4a) Trying an outgoing connection to', HOST, ':', PORT + printLock.release() + proxytype = socks.PROXY_TYPE_SOCKS4 + sockshostname = config.get('bitmessagesettings', 'sockshostname') + socksport = config.getint('bitmessagesettings', 'socksport') + rdns = True #Do domain name lookups through the proxy; though this setting doesn't really matter since we won't be doing any domain name lookups anyway. + if config.getboolean('bitmessagesettings', 'socksauthentication'): + socksusername = config.get('bitmessagesettings', 'socksusername') + sockspassword = config.get('bitmessagesettings', 'sockspassword') + sock.setproxy(proxytype, sockshostname, socksport, rdns, socksusername, sockspassword) + else: + sock.setproxy(proxytype, sockshostname, socksport, rdns) + elif config.get('bitmessagesettings', 'socksproxytype') == 'SOCKS5': + printLock.acquire() + print '(Using SOCKS5) Trying an outgoing connection to', HOST, ':', PORT + printLock.release() + proxytype = socks.PROXY_TYPE_SOCKS5 + sockshostname = config.get('bitmessagesettings', 'sockshostname') + socksport = config.getint('bitmessagesettings', 'socksport') + rdns = True #Do domain name lookups through the proxy; though this setting doesn't really matter since we won't be doing any domain name lookups anyway. + if config.getboolean('bitmessagesettings', 'socksauthentication'): + socksusername = config.get('bitmessagesettings', 'socksusername') + sockspassword = config.get('bitmessagesettings', 'sockspassword') + sock.setproxy(proxytype, sockshostname, socksport, rdns, socksusername, sockspassword) + else: + sock.setproxy(proxytype, sockshostname, socksport, rdns) + try: sock.connect((HOST, PORT)) rd = receiveDataThread() @@ -98,13 +130,38 @@ class outgoingSynSender(QThread): sd.start() sd.sendVersionMessage() - except Exception, err: + except socks.GeneralProxyError, err: print 'Could NOT connect to', HOST, 'during outgoing attempt.', err PORT, timeLastSeen = knownNodes[self.streamNumber][HOST] - if (int(time.time())-timeLastSeen) > 172800: # for nodes older than 48 hours old, delete from the knownNodes data-structure. - if len(knownNodes[self.streamNumber]) > 1000: #as long as we have more than 1000 hosts in our list + if (int(time.time())-timeLastSeen) > 172800 and len(knownNodes[self.streamNumber]) > 1000: # for nodes older than 48 hours old if we have more than 1000 hosts in our list, delete from the knownNodes data-structure. + del knownNodes[self.streamNumber][HOST] + print 'deleting ', HOST, 'from knownNodes because it is more than 48 hours old and we could not connect to it.' + except socks.Socks5AuthError, err: + self.emit(SIGNAL("updateStatusBar(PyQt_PyObject)"),"SOCKS5 Authentication problem: "+str(err)) + except socks.Socks5Error, err: + pass + print 'SOCKS5 error. (It is possible that the server wants authentication).)' ,str(err) + #self.emit(SIGNAL("updateStatusBar(PyQt_PyObject)"),"SOCKS5 error. Server might require authentication. "+str(err)) + except socks.Socks4Error, err: + print 'Socks4Error:', err + #self.emit(SIGNAL("updateStatusBar(PyQt_PyObject)"),"SOCKS4 error: "+str(err)) + except socket.error, err: + if config.get('bitmessagesettings', 'socksproxytype')[0:5] == 'SOCKS': + self.emit(SIGNAL("updateStatusBar(PyQt_PyObject)"),"Problem: Bitmessage can not connect to the SOCKS server. "+str(err)) + else: + print 'Could NOT connect to', HOST, 'during outgoing attempt.', err + PORT, timeLastSeen = knownNodes[self.streamNumber][HOST] + if (int(time.time())-timeLastSeen) > 172800 and len(knownNodes[self.streamNumber]) > 1000: # for nodes older than 48 hours old if we have more than 1000 hosts in our list, delete from the knownNodes data-structure. del knownNodes[self.streamNumber][HOST] print 'deleting ', HOST, 'from knownNodes because it is more than 48 hours old and we could not connect to it.' + + + """except Exception, err: + print 'Could NOT connect to', HOST, 'during outgoing attempt.', err + PORT, timeLastSeen = knownNodes[self.streamNumber][HOST] + if (int(time.time())-timeLastSeen) > 172800 and len(knownNodes[self.streamNumber]) > 1000: # for nodes older than 48 hours old if we have more than 1000 hosts in our list, delete from the knownNodes data-structure. + del knownNodes[self.streamNumber][HOST] + print 'deleting ', HOST, 'from knownNodes because it is more than 48 hours old and we could not connect to it.' """ time.sleep(1) #Only one singleListener thread will ever exist. It creates the receiveDataThread and sendDataThread for each incoming connection. Note that it cannot set the stream number because it is not known yet- the other node will have to tell us its stream number in a version message. If we don't care about their stream, we will close the connection (within the recversion function of the recieveData thread) @@ -114,6 +171,9 @@ class singleListener(QThread): def run(self): + #We don't want to accept incoming connections if the user is using a SOCKS proxy. If they eventually select proxy 'none' then this will start listening for connections. + while config.get('bitmessagesettings', 'socksproxytype')[0:5] == 'SOCKS': + time.sleep(300) print 'bitmessage listener running' HOST = '' # Symbolic name meaning all available interfaces @@ -123,17 +183,19 @@ class singleListener(QThread): sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.bind((HOST, PORT)) sock.listen(2) - self.incomingConnectionList = [] + self.incomingConnectionList = [] #This list isn't used for anything. The reason it exists is because receiveData threads expect that a list be passed to them. They expect this because the outgoingSynSender thread DOES use a similar list to keep track of the number of outgoing connections it has created. while True: - #for i in range(0,1): #uncomment this line and comment the line above this to accept only one connection. - rd = receiveDataThread() + #We don't want to accept incoming connections if the user is using a SOCKS proxy. If they eventually select proxy 'none' then this will start listening for connections. + while config.get('bitmessagesettings', 'socksproxytype')[0:5] == 'SOCKS': + time.sleep(10) a,(HOST,PORT) = sock.accept() while HOST in connectedHostsList: print 'incoming connection is from a host in connectedHostsList (we are already connected to it). Ignoring it.' a.close() a,(HOST,PORT) = sock.accept() + rd = receiveDataThread() self.emit(SIGNAL("passObjectThrough(PyQt_PyObject)"),rd) rd.setup(a,HOST,PORT,-1,self.incomingConnectionList) print self, 'connected to', HOST,'during INCOMING request.' @@ -213,7 +275,11 @@ class receiveDataThread(QThread): connectionsCount[self.streamNumber] -= 1 self.emit(SIGNAL("updateNetworkStatusTab(PyQt_PyObject,PyQt_PyObject)"),self.streamNumber,connectionsCount[self.streamNumber]) connectionsCountLock.release() - del connectedHostsList[self.HOST] + try: + del connectedHostsList[self.HOST] + except Exception, err: + #I think that the only way an exception could occur here is if we connect to ourselves because it would try to delete the same IP from connectedHostsList twice. + print 'Could not delete', self.HOST, 'from connectedHostsList.', err def processData(self): global verbose @@ -831,7 +897,7 @@ class receiveDataThread(QThread): print 'within recpubkey, addressVersion', addressVersion print 'streamNumber', streamNumber - print 'ripe', ripe + print 'ripe', repr(ripe) print 'n=', convertStringToInt(nString) print 'e=', convertStringToInt(eString) @@ -1137,6 +1203,8 @@ class receiveDataThread(QThread): #print 'Within recaddr(): IP', recaddrIP, ', Port', recaddrPort, ', i', i hostFromAddrMessage = socket.inet_ntoa(self.data[52+lengthOfNumberOfAddresses+(34*i):56+lengthOfNumberOfAddresses+(34*i)]) #print 'hostFromAddrMessage', hostFromAddrMessage + if hostFromAddrMessage == '127.0.0.1': + continue timeSomeoneElseReceivedMessageFromThisNode, = unpack('>I',self.data[24+lengthOfNumberOfAddresses+(34*i):28+lengthOfNumberOfAddresses+(34*i)]) #This is the 'time' value in the received addr message. if hostFromAddrMessage not in knownNodes[recaddrStream]: if len(knownNodes[recaddrStream]) < 20000 and timeSomeoneElseReceivedMessageFromThisNode > (int(time.time())-10800) and timeSomeoneElseReceivedMessageFromThisNode < (int(time.time()) + 10800): #If we have more than 20000 nodes in our list already then just forget about adding more. Also, make sure that the time that someone else received a message from this node is within three hours from now. @@ -1550,7 +1618,8 @@ class sqlThread(QThread): self.cur.execute('''DELETE FROM pubkeys WHERE hash='1234' ''') self.conn.commit() if transmitdata == '': - sys.stderr.write('Problem: The version of SQLite you have cannot store Null values. Please download and install the latest revision of your version of Python (for example, the latest Python 2.7 revision) and try again. Exiting.\n') + sys.stderr.write('Problem: The version of SQLite you have cannot store Null values. Please download and install the latest revision of your version of Python (for example, the latest Python 2.7 revision) and try again.\n') + sys.stderr.write('PyBitmessage will now exist very abruptly. You may now see threading errors related to this abrupt exit but the problem you need to solve is related to SQLite.\n\n') sys.exit() except Exception, err: print err @@ -2015,6 +2084,7 @@ class addressGenerator(QThread): config.add_section(address) config.set(address,'label',self.label) config.set(address,'enabled','true') + config.set(address,'decoy','false') config.set(address,'n',str(privkey['n'])) config.set(address,'e',str(privkey['e'])) config.set(address,'d',str(privkey['d'])) @@ -2110,14 +2180,56 @@ class settingsDialog(QtGui.QDialog): self.parent = parent self.ui.checkBoxStartOnLogon.setChecked(config.getboolean('bitmessagesettings', 'startonlogon')) self.ui.checkBoxMinimizeToTray.setChecked(config.getboolean('bitmessagesettings', 'minimizetotray')) - self.ui.lineEditTCPPort.setText(str(config.get('bitmessagesettings', 'port'))) self.ui.checkBoxShowTrayNotifications.setChecked(config.getboolean('bitmessagesettings', 'showtraynotifications')) self.ui.checkBoxStartInTray.setChecked(config.getboolean('bitmessagesettings', 'startintray')) if 'darwin' in sys.platform: self.ui.checkBoxStartOnLogon.setDisabled(True) - self.ui.labelSettingsNote.setText('Some options have been disabled because they haven\'t yet been implimented for your operating system.') + self.ui.checkBoxMinimizeToTray.setDisabled(True) + self.ui.checkBoxShowTrayNotifications.setDisabled(True) + self.ui.checkBoxStartInTray.setDisabled(True) + self.ui.labelSettingsNote.setText('Options have been disabled because they either arn\'t applicable or because they haven\'t yet been implimented for your operating system.') elif 'linux' in sys.platform: - pass + self.ui.checkBoxStartOnLogon.setDisabled(True) + self.ui.labelSettingsNote.setText('Options have been disabled because they either arn\'t applicable or because they haven\'t yet been implimented for your operating system.') + #On the Network settings tab: + self.ui.lineEditTCPPort.setText(str(config.get('bitmessagesettings', 'port'))) + self.ui.checkBoxAuthentication.setChecked(config.getboolean('bitmessagesettings', 'socksauthentication')) + if str(config.get('bitmessagesettings', 'socksproxytype')) == 'none': + self.ui.comboBoxProxyType.setCurrentIndex(0) + self.ui.lineEditSocksHostname.setEnabled(False) + self.ui.lineEditSocksPort.setEnabled(False) + self.ui.lineEditSocksUsername.setEnabled(False) + self.ui.lineEditSocksPassword.setEnabled(False) + self.ui.checkBoxAuthentication.setEnabled(False) + elif str(config.get('bitmessagesettings', 'socksproxytype')) == 'SOCKS4a': + self.ui.comboBoxProxyType.setCurrentIndex(1) + self.ui.lineEditTCPPort.setEnabled(False) + elif str(config.get('bitmessagesettings', 'socksproxytype')) == 'SOCKS5': + self.ui.comboBoxProxyType.setCurrentIndex(2) + self.ui.lineEditTCPPort.setEnabled(False) + + self.ui.lineEditSocksHostname.setText(str(config.get('bitmessagesettings', 'sockshostname'))) + self.ui.lineEditSocksPort.setText(str(config.get('bitmessagesettings', 'socksport'))) + self.ui.lineEditSocksUsername.setText(str(config.get('bitmessagesettings', 'socksusername'))) + self.ui.lineEditSocksPassword.setText(str(config.get('bitmessagesettings', 'sockspassword'))) + QtCore.QObject.connect(self.ui.comboBoxProxyType, QtCore.SIGNAL("currentIndexChanged(int)"), self.comboBoxProxyTypeChanged) + + def comboBoxProxyTypeChanged(self,comboBoxIndex): + if comboBoxIndex == 0: + self.ui.lineEditSocksHostname.setEnabled(False) + self.ui.lineEditSocksPort.setEnabled(False) + self.ui.lineEditSocksUsername.setEnabled(False) + self.ui.lineEditSocksPassword.setEnabled(False) + self.ui.checkBoxAuthentication.setEnabled(False) + self.ui.lineEditTCPPort.setEnabled(True) + elif comboBoxIndex == 1 or comboBoxIndex == 2: + self.ui.lineEditSocksHostname.setEnabled(True) + self.ui.lineEditSocksPort.setEnabled(True) + self.ui.checkBoxAuthentication.setEnabled(True) + if self.ui.checkBoxAuthentication.isChecked(): + self.ui.lineEditSocksUsername.setEnabled(True) + self.ui.lineEditSocksPassword.setEnabled(True) + self.ui.lineEditTCPPort.setEnabled(False) class NewSubscriptionDialog(QtGui.QDialog): def __init__(self,parent): @@ -2161,7 +2273,7 @@ class MyForm(QtGui.QMainWindow): self.ui = Ui_MainWindow() #Jonathan changed this line self.ui.setupUi(self) #Jonathan left this line alone - if 'win' in sys.platform: + if 'win32' in sys.platform or 'win64' in sys.platform: #Auto-startup for Windows RUN_PATH = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run" self.settings = QSettings(RUN_PATH, QSettings.NativeFormat) @@ -2182,6 +2294,9 @@ class MyForm(QtGui.QMainWindow): menu = QtGui.QMenu() self.exitAction = menu.addAction("Exit", self.close) self.trayIcon.setContextMenu(menu) + #I'm currently under the impression that Mac users have different expectations for the tray icon. They don't necessairly expect it to open the main window when clicked and they still expect a program showing a tray icon to also be in the dock. + if 'darwin' in sys.platform: + self.trayIcon.show() #FILE MENU and other buttons QtCore.QObject.connect(self.ui.actionExit, QtCore.SIGNAL("triggered()"), self.close) @@ -2492,12 +2607,14 @@ class MyForm(QtGui.QMainWindow): QtCore.QObject.connect(self.workerThread, QtCore.SIGNAL("updateSentItemStatusByAckdata(PyQt_PyObject,PyQt_PyObject)"), self.updateSentItemStatusByAckdata) def click_actionManageKeys(self): - reply = QtGui.QMessageBox.question(self, 'Open keys.dat?','You may manage your keys by editing the keys.dat file stored in\n' + appdata + '\nIt is important that you back up this file. Would you like to open the file now? (Be sure to close Bitmessage before making any changes.)', QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) - - if reply == QtGui.QMessageBox.Yes: - self.openKeysFile() - else: - pass + if 'darwin' in sys.platform or 'linux' in sys.platform: + reply = QtGui.QMessageBox.information(self, 'keys.dat?','You may manage your keys by editing the keys.dat file stored in\n' + appdata + '\nIt is important that you back up this file.', QMessageBox.Ok) + elif sys.platform == 'win32' or sys.platform == 'win64': + reply = QtGui.QMessageBox.question(self, 'Open keys.dat?','You may manage your keys by editing the keys.dat file stored in\n' + appdata + '\nIt is important that you back up this file. Would you like to open the file now? (Be sure to close Bitmessage before making any changes.)', QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) + if reply == QtGui.QMessageBox.Yes: + self.openKeysFile() + else: + pass def openKeysFile(self): if 'linux' in sys.platform: @@ -2506,13 +2623,13 @@ class MyForm(QtGui.QMainWindow): os.startfile(appdata + '\\keys.dat') def changeEvent(self, event): - if config.getboolean('bitmessagesettings', 'minimizetotray'): + if config.getboolean('bitmessagesettings', 'minimizetotray') and not 'darwin' in sys.platform: if event.type() == QtCore.QEvent.WindowStateChange: if self.windowState() & QtCore.Qt.WindowMinimized: self.hide() self.trayIcon.show() #self.hidden = True - if 'win' in sys.platform: + if 'win32' in sys.platform or 'win64' in sys.platform: self.setWindowFlags(Qt.ToolTip) elif event.oldState() & QtCore.Qt.WindowMinimized: #The window state has just been changed to Normal/Maximised/FullScreen @@ -2521,13 +2638,23 @@ class MyForm(QtGui.QMainWindow): def __icon_activated(self, reason): if reason == QtGui.QSystemTrayIcon.Trigger: - self.trayIcon.hide() - self.setWindowFlags(Qt.Window) - self.show() - if 'win' in sys.platform: + if 'linux' in sys.platform: + self.trayIcon.hide() + self.setWindowFlags(Qt.Window) + self.show() + elif 'win32' in sys.platform or 'win64' in sys.platform: + self.trayIcon.hide() + self.setWindowFlags(Qt.Window) + self.show() self.setWindowState(self.windowState() & ~QtCore.Qt.WindowMinimized | QtCore.Qt.WindowActive) self.activateWindow() - + elif 'darwin' in sys.platform: + #self.trayIcon.hide() #this line causes a segmentation fault + #self.setWindowFlags(Qt.Window) + #self.show() + self.setWindowState(self.windowState() & ~QtCore.Qt.WindowMinimized | QtCore.Qt.WindowActive) + self.activateWindow() + def incrementNumberOfMessagesProcessed(self): self.numberOfMessagesProcessed += 1 self.ui.labelMessageCount.setText('Processed ' + str(self.numberOfMessagesProcessed) + ' person-to-person messages.') @@ -2845,6 +2972,7 @@ class MyForm(QtGui.QMainWindow): a = outgoingSynSender() self.listOfOutgoingSynSenderThreads.append(a) QtCore.QObject.connect(a, QtCore.SIGNAL("passObjectThrough(PyQt_PyObject)"), self.connectObjectToSignals) + QtCore.QObject.connect(a, QtCore.SIGNAL("updateStatusBar(PyQt_PyObject)"), self.updateStatusBar) a.setup(streamNumber) a.start() @@ -2956,7 +3084,6 @@ class MyForm(QtGui.QMainWindow): self.statusBar().showMessage('The address you entered was invalid. Ignoring it.') def click_pushButtonAddSubscription(self): - print 'click_pushButtonAddSubscription' self.NewSubscriptionDialogInstance = NewSubscriptionDialog(self) if self.NewSubscriptionDialogInstance.exec_(): @@ -3021,6 +3148,7 @@ class MyForm(QtGui.QMainWindow): self.aboutDialogInstance.exec_() def click_actionSettings(self): + global statusIconColor self.settingsDialogInstance = settingsDialog(self) if self.settingsDialogInstance.exec_(): config.set('bitmessagesettings', 'startonlogon', str(self.settingsDialogInstance.ui.checkBoxStartOnLogon.isChecked())) @@ -3030,10 +3158,22 @@ class MyForm(QtGui.QMainWindow): if int(config.get('bitmessagesettings','port')) != int(self.settingsDialogInstance.ui.lineEditTCPPort.text()): QMessageBox.about(self, "Restart", "You must restart Bitmessage for the port number change to take effect.") config.set('bitmessagesettings', 'port', str(self.settingsDialogInstance.ui.lineEditTCPPort.text())) + if config.get('bitmessagesettings', 'socksproxytype') == 'none' and str(self.settingsDialogInstance.ui.comboBoxProxyType.currentText())[0:5] == 'SOCKS': + if statusIconColor != 'red': + QMessageBox.about(self, "Restart", "Bitmessage will use your proxy from now on now but you may want to manually restart Bitmessage now to close existing connections.") + if config.get('bitmessagesettings', 'socksproxytype')[0:5] == 'SOCKS' and str(self.settingsDialogInstance.ui.comboBoxProxyType.currentText()) == 'none': + self.statusBar().showMessage('') + config.set('bitmessagesettings', 'socksproxytype', str(self.settingsDialogInstance.ui.comboBoxProxyType.currentText())) + config.set('bitmessagesettings', 'socksauthentication', str(self.settingsDialogInstance.ui.checkBoxAuthentication.isChecked())) + config.set('bitmessagesettings', 'sockshostname', str(self.settingsDialogInstance.ui.lineEditSocksHostname.text())) + config.set('bitmessagesettings', 'socksport', str(self.settingsDialogInstance.ui.lineEditSocksPort.text())) + config.set('bitmessagesettings', 'socksusername', str(self.settingsDialogInstance.ui.lineEditSocksUsername.text())) + config.set('bitmessagesettings', 'sockspassword', str(self.settingsDialogInstance.ui.lineEditSocksPassword.text())) + with open(appdata + 'keys.dat', 'wb') as configfile: config.write(configfile) - if 'win' in sys.platform: + if 'win32' in sys.platform or 'win64' in sys.platform: #Auto-startup for Windows RUN_PATH = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run" self.settings = QSettings(RUN_PATH, QSettings.NativeFormat) @@ -3347,14 +3487,14 @@ class MyForm(QtGui.QMainWindow): def tableWidgetAddressBookItemChanged(self): currentRow = self.ui.tableWidgetAddressBook.currentRow() sqlLock.acquire() - try: + if currentRow >= 0: addressAtCurrentRow = self.ui.tableWidgetAddressBook.item(currentRow,1).text() t = (str(self.ui.tableWidgetAddressBook.item(currentRow,0).text().toUtf8()),str(addressAtCurrentRow)) sqlSubmitQueue.put('''UPDATE addressbook set label=? WHERE address=?''') sqlSubmitQueue.put(t) sqlReturnQueue.get() - except Exception, err: - print 'Program Exception in tableWidgetAddressBookItemChanged:', err + #except Exception, err: + # print 'Program Exception in tableWidgetAddressBookItemChanged:', err sqlLock.release() self.rerenderInboxFromLabels() self.rerenderSentToLabels() @@ -3362,18 +3502,17 @@ class MyForm(QtGui.QMainWindow): def tableWidgetSubscriptionsItemChanged(self): currentRow = self.ui.tableWidgetSubscriptions.currentRow() sqlLock.acquire() - try: + if currentRow >= 0: addressAtCurrentRow = self.ui.tableWidgetSubscriptions.item(currentRow,1).text() t = (str(self.ui.tableWidgetSubscriptions.item(currentRow,0).text().toUtf8()),str(addressAtCurrentRow)) sqlSubmitQueue.put('''UPDATE subscriptions set label=? WHERE address=?''') sqlSubmitQueue.put(t) sqlReturnQueue.get() - except Exception, err: - print 'Program Exception in tableWidgetSubscriptionsItemChanged:', err + #except Exception, err: + # print 'Program Exception in tableWidgetSubscriptionsItemChanged:', err sqlLock.release() self.rerenderInboxFromLabels() - self.rerenderSentToLabels() - + self.rerenderSentToLabels() def writeNewAddressToTable(self,label,address,streamNumber): self.ui.tableWidgetYourIdentities.insertRow(0) @@ -3464,7 +3603,7 @@ if __name__ == "__main__": print 'Could not find home folder, please report this message and your OS X version to the BitMessage Github.' sys.exit() - elif 'win' in sys.platform: + elif 'win32' in sys.platform or 'win64' in sys.platform: appdata = path.join(environ['APPDATA'], APPNAME) + '\\' else: appdata = path.expanduser(path.join("~", "." + APPNAME + "/")) @@ -3478,7 +3617,7 @@ if __name__ == "__main__": config.get('bitmessagesettings', 'settingsversion') print 'Loading config files from', appdata except: - #This appears to be the first time running the program; there is no config file (or it cannot be accessed). Create config and known-nodes file. + #This appears to be the first time running the program; there is no config file (or it cannot be accessed). Create config file. config.add_section('bitmessagesettings') config.set('bitmessagesettings','settingsversion','1') config.set('bitmessagesettings','bitstrength','2048') @@ -3496,6 +3635,20 @@ if __name__ == "__main__": config.write(configfile) print 'Storing config files in', appdata + if config.getint('bitmessagesettings','settingsversion') == 1: + config.set('bitmessagesettings','settingsversion','2') + config.set('bitmessagesettings','socksproxytype','none') + config.set('bitmessagesettings','sockshostname','localhost') + config.set('bitmessagesettings','socksport','9050') + config.set('bitmessagesettings','socksauthentication','false') + config.set('bitmessagesettings','socksusername','') + config.set('bitmessagesettings','sockspassword','') + config.set('bitmessagesettings','keysencrypted','false') + config.set('bitmessagesettings','messagesencrypted','false') + with open(appdata + 'keys.dat', 'wb') as configfile: + config.write(configfile) + + try: pickleFile = open(appdata + 'knownnodes.dat', 'rb') knownNodes = pickle.load(pickleFile) @@ -3506,7 +3659,7 @@ if __name__ == "__main__": knownNodes = pickle.load(pickleFile) pickleFile.close() - if config.getint('bitmessagesettings', 'settingsversion') > 1: + if config.getint('bitmessagesettings', 'settingsversion') > 2: print 'Bitmessage cannot read future versions of the keys file (keys.dat). Run the newer version of Bitmessage.' raise SystemExit @@ -3522,7 +3675,7 @@ if __name__ == "__main__": #self.hidden = True #self.setWindowState(self.windowState() & QtCore.Qt.WindowMinimized) #self.hide() - if 'win' in sys.platform: + if 'win32' in sys.platform or 'win64' in sys.platform: myapp.setWindowFlags(Qt.ToolTip) sys.exit(app.exec_()) diff --git a/iconglossary.py b/iconglossary.py index c8802ed9..a2a3e0d4 100644 --- a/iconglossary.py +++ b/iconglossary.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'iconglossary.ui' # -# Created: Mon Nov 05 16:56:02 2012 +# Created: Mon Dec 17 17:14:03 2012 # by: PyQt4 UI code generator 4.9.4 # # WARNING! All changes made in this file will be lost! @@ -17,44 +17,51 @@ except AttributeError: class Ui_iconGlossaryDialog(object): def setupUi(self, iconGlossaryDialog): iconGlossaryDialog.setObjectName(_fromUtf8("iconGlossaryDialog")) - iconGlossaryDialog.resize(400, 300) - self.buttonBox = QtGui.QDialogButtonBox(iconGlossaryDialog) - self.buttonBox.setGeometry(QtCore.QRect(50, 260, 341, 32)) - self.buttonBox.setOrientation(QtCore.Qt.Horizontal) - self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) - self.buttonBox.setObjectName(_fromUtf8("buttonBox")) + iconGlossaryDialog.resize(424, 282) + self.gridLayout = QtGui.QGridLayout(iconGlossaryDialog) + self.gridLayout.setObjectName(_fromUtf8("gridLayout")) self.groupBox = QtGui.QGroupBox(iconGlossaryDialog) - self.groupBox.setGeometry(QtCore.QRect(10, 10, 381, 241)) self.groupBox.setObjectName(_fromUtf8("groupBox")) + self.gridLayout_2 = QtGui.QGridLayout(self.groupBox) + self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2")) self.label = QtGui.QLabel(self.groupBox) - self.label.setGeometry(QtCore.QRect(20, 30, 21, 21)) self.label.setText(_fromUtf8("")) self.label.setPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/redicon.png"))) self.label.setObjectName(_fromUtf8("label")) + self.gridLayout_2.addWidget(self.label, 0, 0, 1, 1) self.label_2 = QtGui.QLabel(self.groupBox) - self.label_2.setGeometry(QtCore.QRect(50, 30, 281, 20)) self.label_2.setObjectName(_fromUtf8("label_2")) + self.gridLayout_2.addWidget(self.label_2, 0, 1, 1, 1) self.label_3 = QtGui.QLabel(self.groupBox) - self.label_3.setGeometry(QtCore.QRect(20, 70, 16, 21)) self.label_3.setText(_fromUtf8("")) self.label_3.setPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/yellowicon.png"))) self.label_3.setObjectName(_fromUtf8("label_3")) + self.gridLayout_2.addWidget(self.label_3, 1, 0, 1, 1) self.label_4 = QtGui.QLabel(self.groupBox) - self.label_4.setGeometry(QtCore.QRect(50, 60, 321, 101)) + self.label_4.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) self.label_4.setWordWrap(True) self.label_4.setObjectName(_fromUtf8("label_4")) + self.gridLayout_2.addWidget(self.label_4, 1, 1, 2, 1) + spacerItem = QtGui.QSpacerItem(20, 73, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.gridLayout_2.addItem(spacerItem, 2, 0, 2, 1) + self.labelPortNumber = QtGui.QLabel(self.groupBox) + self.labelPortNumber.setObjectName(_fromUtf8("labelPortNumber")) + self.gridLayout_2.addWidget(self.labelPortNumber, 3, 1, 1, 1) self.label_5 = QtGui.QLabel(self.groupBox) - self.label_5.setGeometry(QtCore.QRect(20, 200, 21, 21)) self.label_5.setText(_fromUtf8("")) self.label_5.setPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/greenicon.png"))) self.label_5.setObjectName(_fromUtf8("label_5")) + self.gridLayout_2.addWidget(self.label_5, 4, 0, 1, 1) self.label_6 = QtGui.QLabel(self.groupBox) - self.label_6.setGeometry(QtCore.QRect(50, 200, 301, 31)) self.label_6.setWordWrap(True) self.label_6.setObjectName(_fromUtf8("label_6")) - self.labelPortNumber = QtGui.QLabel(self.groupBox) - self.labelPortNumber.setGeometry(QtCore.QRect(50, 160, 321, 16)) - self.labelPortNumber.setObjectName(_fromUtf8("labelPortNumber")) + self.gridLayout_2.addWidget(self.label_6, 4, 1, 1, 1) + self.gridLayout.addWidget(self.groupBox, 0, 0, 1, 1) + self.buttonBox = QtGui.QDialogButtonBox(iconGlossaryDialog) + self.buttonBox.setOrientation(QtCore.Qt.Horizontal) + self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok) + self.buttonBox.setObjectName(_fromUtf8("buttonBox")) + self.gridLayout.addWidget(self.buttonBox, 1, 0, 1, 1) self.retranslateUi(iconGlossaryDialog) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), iconGlossaryDialog.accept) @@ -66,7 +73,7 @@ class Ui_iconGlossaryDialog(object): self.groupBox.setTitle(QtGui.QApplication.translate("iconGlossaryDialog", "Icon Glossary", None, QtGui.QApplication.UnicodeUTF8)) self.label_2.setText(QtGui.QApplication.translate("iconGlossaryDialog", "You have no connections with other peers. ", None, QtGui.QApplication.UnicodeUTF8)) self.label_4.setText(QtGui.QApplication.translate("iconGlossaryDialog", "You have made at least one connection to a peer using an outgoing connection but you have not yet received any incoming connections. Your firewall or home router probably isn\'t configured to foward incoming TCP connections to your computer. Bitmessage will work just fine but it would help the Bitmessage network if you allowed for incoming connections and will help you be a better-connected node.", None, QtGui.QApplication.UnicodeUTF8)) - self.label_6.setText(QtGui.QApplication.translate("iconGlossaryDialog", "You do have connections with other peers and your firewall is correctly configured.", None, QtGui.QApplication.UnicodeUTF8)) self.labelPortNumber.setText(QtGui.QApplication.translate("iconGlossaryDialog", "You are using TCP port ?. (This can be changed in the settings).", None, QtGui.QApplication.UnicodeUTF8)) + self.label_6.setText(QtGui.QApplication.translate("iconGlossaryDialog", "You do have connections with other peers and your firewall is correctly configured.", None, QtGui.QApplication.UnicodeUTF8)) import bitmessage_icons_rc diff --git a/iconglossary.ui b/iconglossary.ui index 053d3ccf..62ea6a98 100644 --- a/iconglossary.ui +++ b/iconglossary.ui @@ -6,148 +6,114 @@ 0 0 - 400 - 300 + 424 + 282 Icon Glossary - - - - 50 - 260 - 341 - 32 - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - 10 - 10 - 381 - 241 - - - - Icon Glossary - - - - - 20 - 30 - 21 - 21 - - - - - - - :/newPrefix/images/redicon.png - - - - - - 50 - 30 - 281 - 20 - - - - You have no connections with other peers. - - - - - - 20 - 70 - 16 - 21 - - - - - - - :/newPrefix/images/yellowicon.png - - - - - - 50 - 60 - 321 - 101 - - - - You have made at least one connection to a peer using an outgoing connection but you have not yet received any incoming connections. Your firewall or home router probably isn't configured to foward incoming TCP connections to your computer. Bitmessage will work just fine but it would help the Bitmessage network if you allowed for incoming connections and will help you be a better-connected node. - - - true - - - - - - 20 - 200 - 21 - 21 - - - - - - - :/newPrefix/images/greenicon.png - - - - - - 50 - 200 - 301 - 31 - - - - You do have connections with other peers and your firewall is correctly configured. - - - true - - - - - - 50 - 160 - 321 - 16 - - - - You are using TCP port ?. (This can be changed in the settings). - - - + + + + + Icon Glossary + + + + + + + + + :/newPrefix/images/redicon.png + + + + + + + You have no connections with other peers. + + + + + + + + + + :/newPrefix/images/yellowicon.png + + + + + + + You have made at least one connection to a peer using an outgoing connection but you have not yet received any incoming connections. Your firewall or home router probably isn't configured to foward incoming TCP connections to your computer. Bitmessage will work just fine but it would help the Bitmessage network if you allowed for incoming connections and will help you be a better-connected node. + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + Qt::Vertical + + + + 20 + 73 + + + + + + + + You are using TCP port ?. (This can be changed in the settings). + + + + + + + + + + :/newPrefix/images/greenicon.png + + + + + + + You do have connections with other peers and your firewall is correctly configured. + + + true + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Ok + + + + diff --git a/settings.py b/settings.py index 833989ff..19c063ad 100644 --- a/settings.py +++ b/settings.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'settings.ui' # -# Created: Mon Nov 19 13:33:39 2012 +# Created: Mon Dec 17 16:00:13 2012 # by: PyQt4 UI code generator 4.9.4 # # WARNING! All changes made in this file will be lost! @@ -17,9 +17,14 @@ except AttributeError: class Ui_settingsDialog(object): def setupUi(self, settingsDialog): settingsDialog.setObjectName(_fromUtf8("settingsDialog")) - settingsDialog.resize(417, 297) + settingsDialog.resize(476, 340) self.gridLayout = QtGui.QGridLayout(settingsDialog) self.gridLayout.setObjectName(_fromUtf8("gridLayout")) + self.buttonBox = QtGui.QDialogButtonBox(settingsDialog) + self.buttonBox.setOrientation(QtCore.Qt.Horizontal) + self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) + self.buttonBox.setObjectName(_fromUtf8("buttonBox")) + self.gridLayout.addWidget(self.buttonBox, 1, 0, 1, 1) self.tabWidgetSettings = QtGui.QTabWidget(settingsDialog) self.tabWidgetSettings.setObjectName(_fromUtf8("tabWidgetSettings")) self.tabUserInterface = QtGui.QWidget() @@ -51,31 +56,88 @@ class Ui_settingsDialog(object): self.tabWidgetSettings.addTab(self.tabUserInterface, _fromUtf8("")) self.tabNetworkSettings = QtGui.QWidget() self.tabNetworkSettings.setObjectName(_fromUtf8("tabNetworkSettings")) - self.gridLayout_2 = QtGui.QGridLayout(self.tabNetworkSettings) - self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2")) - spacerItem1 = QtGui.QSpacerItem(56, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.gridLayout_2.addItem(spacerItem1, 0, 0, 1, 1) - self.label = QtGui.QLabel(self.tabNetworkSettings) + self.gridLayout_4 = QtGui.QGridLayout(self.tabNetworkSettings) + self.gridLayout_4.setObjectName(_fromUtf8("gridLayout_4")) + self.groupBox = QtGui.QGroupBox(self.tabNetworkSettings) + self.groupBox.setObjectName(_fromUtf8("groupBox")) + self.gridLayout_3 = QtGui.QGridLayout(self.groupBox) + self.gridLayout_3.setObjectName(_fromUtf8("gridLayout_3")) + spacerItem1 = QtGui.QSpacerItem(125, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.gridLayout_3.addItem(spacerItem1, 0, 0, 1, 1) + self.label = QtGui.QLabel(self.groupBox) self.label.setObjectName(_fromUtf8("label")) - self.gridLayout_2.addWidget(self.label, 0, 1, 1, 1) - self.lineEditTCPPort = QtGui.QLineEdit(self.tabNetworkSettings) + self.gridLayout_3.addWidget(self.label, 0, 1, 1, 1) + self.lineEditTCPPort = QtGui.QLineEdit(self.groupBox) self.lineEditTCPPort.setObjectName(_fromUtf8("lineEditTCPPort")) - self.gridLayout_2.addWidget(self.lineEditTCPPort, 0, 2, 1, 1) - spacerItem2 = QtGui.QSpacerItem(20, 169, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) - self.gridLayout_2.addItem(spacerItem2, 1, 2, 1, 1) + self.gridLayout_3.addWidget(self.lineEditTCPPort, 0, 2, 1, 1) + self.gridLayout_4.addWidget(self.groupBox, 0, 0, 1, 1) + self.groupBox_2 = QtGui.QGroupBox(self.tabNetworkSettings) + self.groupBox_2.setObjectName(_fromUtf8("groupBox_2")) + self.gridLayout_2 = QtGui.QGridLayout(self.groupBox_2) + self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2")) + self.label_2 = QtGui.QLabel(self.groupBox_2) + self.label_2.setObjectName(_fromUtf8("label_2")) + self.gridLayout_2.addWidget(self.label_2, 0, 0, 1, 1) + self.comboBoxProxyType = QtGui.QComboBox(self.groupBox_2) + self.comboBoxProxyType.setObjectName(_fromUtf8("comboBoxProxyType")) + self.comboBoxProxyType.addItem(_fromUtf8("")) + self.comboBoxProxyType.addItem(_fromUtf8("")) + self.comboBoxProxyType.addItem(_fromUtf8("")) + self.gridLayout_2.addWidget(self.comboBoxProxyType, 0, 1, 1, 1) + self.label_3 = QtGui.QLabel(self.groupBox_2) + self.label_3.setObjectName(_fromUtf8("label_3")) + self.gridLayout_2.addWidget(self.label_3, 1, 1, 1, 1) + self.lineEditSocksHostname = QtGui.QLineEdit(self.groupBox_2) + self.lineEditSocksHostname.setObjectName(_fromUtf8("lineEditSocksHostname")) + self.gridLayout_2.addWidget(self.lineEditSocksHostname, 1, 2, 1, 2) + self.label_4 = QtGui.QLabel(self.groupBox_2) + self.label_4.setObjectName(_fromUtf8("label_4")) + self.gridLayout_2.addWidget(self.label_4, 1, 4, 1, 1) + self.lineEditSocksPort = QtGui.QLineEdit(self.groupBox_2) + self.lineEditSocksPort.setObjectName(_fromUtf8("lineEditSocksPort")) + self.gridLayout_2.addWidget(self.lineEditSocksPort, 1, 5, 1, 1) + self.checkBoxAuthentication = QtGui.QCheckBox(self.groupBox_2) + self.checkBoxAuthentication.setObjectName(_fromUtf8("checkBoxAuthentication")) + self.gridLayout_2.addWidget(self.checkBoxAuthentication, 2, 1, 1, 1) + self.label_5 = QtGui.QLabel(self.groupBox_2) + self.label_5.setObjectName(_fromUtf8("label_5")) + self.gridLayout_2.addWidget(self.label_5, 2, 2, 1, 1) + self.lineEditSocksUsername = QtGui.QLineEdit(self.groupBox_2) + self.lineEditSocksUsername.setEnabled(False) + self.lineEditSocksUsername.setObjectName(_fromUtf8("lineEditSocksUsername")) + self.gridLayout_2.addWidget(self.lineEditSocksUsername, 2, 3, 1, 1) + self.label_6 = QtGui.QLabel(self.groupBox_2) + self.label_6.setObjectName(_fromUtf8("label_6")) + self.gridLayout_2.addWidget(self.label_6, 2, 4, 1, 1) + self.lineEditSocksPassword = QtGui.QLineEdit(self.groupBox_2) + self.lineEditSocksPassword.setEnabled(False) + self.lineEditSocksPassword.setObjectName(_fromUtf8("lineEditSocksPassword")) + self.gridLayout_2.addWidget(self.lineEditSocksPassword, 2, 5, 1, 1) + self.gridLayout_4.addWidget(self.groupBox_2, 1, 0, 1, 1) + spacerItem2 = QtGui.QSpacerItem(20, 70, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.gridLayout_4.addItem(spacerItem2, 2, 0, 1, 1) self.tabWidgetSettings.addTab(self.tabNetworkSettings, _fromUtf8("")) self.gridLayout.addWidget(self.tabWidgetSettings, 0, 0, 1, 1) - self.buttonBox = QtGui.QDialogButtonBox(settingsDialog) - self.buttonBox.setOrientation(QtCore.Qt.Horizontal) - self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) - self.buttonBox.setObjectName(_fromUtf8("buttonBox")) - self.gridLayout.addWidget(self.buttonBox, 1, 0, 1, 1) self.retranslateUi(settingsDialog) self.tabWidgetSettings.setCurrentIndex(0) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), settingsDialog.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), settingsDialog.reject) + QtCore.QObject.connect(self.checkBoxAuthentication, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), self.lineEditSocksUsername.setEnabled) + QtCore.QObject.connect(self.checkBoxAuthentication, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), self.lineEditSocksPassword.setEnabled) QtCore.QMetaObject.connectSlotsByName(settingsDialog) + settingsDialog.setTabOrder(self.tabWidgetSettings, self.checkBoxStartOnLogon) + settingsDialog.setTabOrder(self.checkBoxStartOnLogon, self.checkBoxStartInTray) + settingsDialog.setTabOrder(self.checkBoxStartInTray, self.checkBoxMinimizeToTray) + settingsDialog.setTabOrder(self.checkBoxMinimizeToTray, self.checkBoxShowTrayNotifications) + settingsDialog.setTabOrder(self.checkBoxShowTrayNotifications, self.lineEditTCPPort) + settingsDialog.setTabOrder(self.lineEditTCPPort, self.comboBoxProxyType) + settingsDialog.setTabOrder(self.comboBoxProxyType, self.lineEditSocksHostname) + settingsDialog.setTabOrder(self.lineEditSocksHostname, self.lineEditSocksPort) + settingsDialog.setTabOrder(self.lineEditSocksPort, self.checkBoxAuthentication) + settingsDialog.setTabOrder(self.checkBoxAuthentication, self.lineEditSocksUsername) + settingsDialog.setTabOrder(self.lineEditSocksUsername, self.lineEditSocksPassword) + settingsDialog.setTabOrder(self.lineEditSocksPassword, self.buttonBox) def retranslateUi(self, settingsDialog): settingsDialog.setWindowTitle(QtGui.QApplication.translate("settingsDialog", "Settings", None, QtGui.QApplication.UnicodeUTF8)) @@ -84,6 +146,17 @@ class Ui_settingsDialog(object): self.checkBoxMinimizeToTray.setText(QtGui.QApplication.translate("settingsDialog", "Minimize to tray", None, QtGui.QApplication.UnicodeUTF8)) self.checkBoxShowTrayNotifications.setText(QtGui.QApplication.translate("settingsDialog", "Show notification when message received and minimzed to tray", None, QtGui.QApplication.UnicodeUTF8)) self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tabUserInterface), QtGui.QApplication.translate("settingsDialog", "User Interface", None, QtGui.QApplication.UnicodeUTF8)) + self.groupBox.setTitle(QtGui.QApplication.translate("settingsDialog", "Listening port", None, QtGui.QApplication.UnicodeUTF8)) self.label.setText(QtGui.QApplication.translate("settingsDialog", "Listen for connections on port:", None, QtGui.QApplication.UnicodeUTF8)) + self.groupBox_2.setTitle(QtGui.QApplication.translate("settingsDialog", "Proxy server / Tor", None, QtGui.QApplication.UnicodeUTF8)) + self.label_2.setText(QtGui.QApplication.translate("settingsDialog", "Type:", None, QtGui.QApplication.UnicodeUTF8)) + self.comboBoxProxyType.setItemText(0, QtGui.QApplication.translate("settingsDialog", "none", None, QtGui.QApplication.UnicodeUTF8)) + self.comboBoxProxyType.setItemText(1, QtGui.QApplication.translate("settingsDialog", "SOCKS4a", None, QtGui.QApplication.UnicodeUTF8)) + self.comboBoxProxyType.setItemText(2, QtGui.QApplication.translate("settingsDialog", "SOCKS5", None, QtGui.QApplication.UnicodeUTF8)) + self.label_3.setText(QtGui.QApplication.translate("settingsDialog", "Server hostname:", None, QtGui.QApplication.UnicodeUTF8)) + self.label_4.setText(QtGui.QApplication.translate("settingsDialog", "Port:", None, QtGui.QApplication.UnicodeUTF8)) + self.checkBoxAuthentication.setText(QtGui.QApplication.translate("settingsDialog", "Authentication", None, QtGui.QApplication.UnicodeUTF8)) + self.label_5.setText(QtGui.QApplication.translate("settingsDialog", "Username:", None, QtGui.QApplication.UnicodeUTF8)) + self.label_6.setText(QtGui.QApplication.translate("settingsDialog", "Pass:", None, QtGui.QApplication.UnicodeUTF8)) self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tabNetworkSettings), QtGui.QApplication.translate("settingsDialog", "Network Settings", None, QtGui.QApplication.UnicodeUTF8)) diff --git a/settings.ui b/settings.ui index 23da4ad7..1a9c21c9 100644 --- a/settings.ui +++ b/settings.ui @@ -6,14 +6,24 @@ 0 0 - 417 - 297 + 476 + 340 Settings + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + @@ -90,31 +100,130 @@ Network Settings - + - - - Qt::Horizontal - - - - 56 - 20 - - - - - - - - Listen for connections on port: + + + Listening port + + + + + Qt::Horizontal + + + + 125 + 20 + + + + + + + + Listen for connections on port: + + + + + + + - - + + + + Proxy server / Tor + + + + + + Type: + + + + + + + + none + + + + + SOCKS4a + + + + + SOCKS5 + + + + + + + + Server hostname: + + + + + + + + + + Port: + + + + + + + + + + Authentication + + + + + + + Username: + + + + + + + false + + + + + + + Pass: + + + + + + + false + + + + + - + Qt::Vertical @@ -122,7 +231,7 @@ 20 - 169 + 70 @@ -131,18 +240,23 @@ - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - + + tabWidgetSettings + checkBoxStartOnLogon + checkBoxStartInTray + checkBoxMinimizeToTray + checkBoxShowTrayNotifications + lineEditTCPPort + comboBoxProxyType + lineEditSocksHostname + lineEditSocksPort + checkBoxAuthentication + lineEditSocksUsername + lineEditSocksPassword + buttonBox + @@ -152,8 +266,8 @@ accept() - 248 - 254 + 257 + 330 157 @@ -168,8 +282,8 @@ reject() - 316 - 260 + 325 + 330 286 @@ -177,5 +291,37 @@ + + checkBoxAuthentication + toggled(bool) + lineEditSocksUsername + setEnabled(bool) + + + 125 + 190 + + + 233 + 189 + + + + + checkBoxAuthentication + toggled(bool) + lineEditSocksPassword + setEnabled(bool) + + + 79 + 190 + + + 370 + 192 + + + diff --git a/socks/BUGS b/socks/BUGS new file mode 100644 index 00000000..fa8ccfad --- /dev/null +++ b/socks/BUGS @@ -0,0 +1,25 @@ +SocksiPy version 1.00 +A Python SOCKS module. +(C) 2006 Dan-Haim. All rights reserved. +See LICENSE file for details. + + +KNOWN BUGS AND ISSUES +---------------------- + +There are no currently known bugs in this module. +There are some limits though: + +1) Only outgoing connections are supported - This module currently only supports +outgoing TCP connections, though some servers may support incoming connections +as well. UDP is not supported either. + +2) GSSAPI Socks5 authenticaion is not supported. + + +If you find any new bugs, please contact the author at: + +negativeiq@users.sourceforge.net + + +Thank you! diff --git a/socks/LICENSE b/socks/LICENSE new file mode 100644 index 00000000..04b6b1f3 --- /dev/null +++ b/socks/LICENSE @@ -0,0 +1,22 @@ +Copyright 2006 Dan-Haim. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +3. Neither the name of Dan Haim nor the names of his contributors may be used + to endorse or promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY DAN HAIM "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +EVENT SHALL DAN HAIM OR HIS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA +OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMANGE. diff --git a/socks/README b/socks/README new file mode 100644 index 00000000..a52f55f3 --- /dev/null +++ b/socks/README @@ -0,0 +1,201 @@ +SocksiPy version 1.00 +A Python SOCKS module. +(C) 2006 Dan-Haim. All rights reserved. +See LICENSE file for details. + + +WHAT IS A SOCKS PROXY? +A SOCKS proxy is a proxy server at the TCP level. In other words, it acts as +a tunnel, relaying all traffic going through it without modifying it. +SOCKS proxies can be used to relay traffic using any network protocol that +uses TCP. + +WHAT IS SOCKSIPY? +This Python module allows you to create TCP connections through a SOCKS +proxy without any special effort. + +PROXY COMPATIBILITY +SocksiPy is compatible with three different types of proxies: +1. SOCKS Version 4 (Socks4), including the Socks4a extension. +2. SOCKS Version 5 (Socks5). +3. HTTP Proxies which support tunneling using the CONNECT method. + +SYSTEM REQUIREMENTS +Being written in Python, SocksiPy can run on any platform that has a Python +interpreter and TCP/IP support. +This module has been tested with Python 2.3 and should work with greater versions +just as well. + + +INSTALLATION +------------- + +Simply copy the file "socks.py" to your Python's lib/site-packages directory, +and you're ready to go. + + +USAGE +------ + +First load the socks module with the command: + +>>> import socks +>>> + +The socks module provides a class called "socksocket", which is the base to +all of the module's functionality. +The socksocket object has the same initialization parameters as the normal socket +object to ensure maximal compatibility, however it should be noted that socksocket +will only function with family being AF_INET and type being SOCK_STREAM. +Generally, it is best to initialize the socksocket object with no parameters + +>>> s = socks.socksocket() +>>> + +The socksocket object has an interface which is very similiar to socket's (in fact +the socksocket class is derived from socket) with a few extra methods. +To select the proxy server you would like to use, use the setproxy method, whose +syntax is: + +setproxy(proxytype, addr[, port[, rdns[, username[, password]]]]) + +Explaination of the parameters: + +proxytype - The type of the proxy server. This can be one of three possible +choices: PROXY_TYPE_SOCKS4, PROXY_TYPE_SOCKS5 and PROXY_TYPE_HTTP for Socks4, +Socks5 and HTTP servers respectively. + +addr - The IP address or DNS name of the proxy server. + +port - The port of the proxy server. Defaults to 1080 for socks and 8080 for http. + +rdns - This is a boolean flag than modifies the behavior regarding DNS resolving. +If it is set to True, DNS resolving will be preformed remotely, on the server. +If it is set to False, DNS resolving will be preformed locally. Please note that +setting this to True with Socks4 servers actually use an extension to the protocol, +called Socks4a, which may not be supported on all servers (Socks5 and http servers +always support DNS). The default is True. + +username - For Socks5 servers, this allows simple username / password authentication +with the server. For Socks4 servers, this parameter will be sent as the userid. +This parameter is ignored if an HTTP server is being used. If it is not provided, +authentication will not be used (servers may accept unauthentication requests). + +password - This parameter is valid only for Socks5 servers and specifies the +respective password for the username provided. + +Example of usage: + +>>> s.setproxy(socks.PROXY_TYPE_SOCKS5,"socks.example.com") +>>> + +After the setproxy method has been called, simply call the connect method with the +traditional parameters to establish a connection through the proxy: + +>>> s.connect(("www.sourceforge.net",80)) +>>> + +Connection will take a bit longer to allow negotiation with the proxy server. +Please note that calling connect without calling setproxy earlier will connect +without a proxy (just like a regular socket). + +Errors: Any errors in the connection process will trigger exceptions. The exception +may either be generated by the underlying socket layer or may be custom module +exceptions, whose details follow: + +class ProxyError - This is a base exception class. It is not raised directly but +rather all other exception classes raised by this module are derived from it. +This allows an easy way to catch all proxy-related errors. + +class GeneralProxyError - When thrown, it indicates a problem which does not fall +into another category. The parameter is a tuple containing an error code and a +description of the error, from the following list: +1 - invalid data - This error means that unexpected data has been received from +the server. The most common reason is that the server specified as the proxy is +not really a Socks4/Socks5/HTTP proxy, or maybe the proxy type specified is wrong. +4 - bad proxy type - This will be raised if the type of the proxy supplied to the +setproxy function was not PROXY_TYPE_SOCKS4/PROXY_TYPE_SOCKS5/PROXY_TYPE_HTTP. +5 - bad input - This will be raised if the connect method is called with bad input +parameters. + +class Socks5AuthError - This indicates that the connection through a Socks5 server +failed due to an authentication problem. The parameter is a tuple containing a +code and a description message according to the following list: + +1 - authentication is required - This will happen if you use a Socks5 server which +requires authentication without providing a username / password at all. +2 - all offered authentication methods were rejected - This will happen if the proxy +requires a special authentication method which is not supported by this module. +3 - unknown username or invalid password - Self descriptive. + +class Socks5Error - This will be raised for Socks5 errors which are not related to +authentication. The parameter is a tuple containing a code and a description of the +error, as given by the server. The possible errors, according to the RFC are: + +1 - General SOCKS server failure - If for any reason the proxy server is unable to +fulfill your request (internal server error). +2 - connection not allowed by ruleset - If the address you're trying to connect to +is blacklisted on the server or requires authentication. +3 - Network unreachable - The target could not be contacted. A router on the network +had replied with a destination net unreachable error. +4 - Host unreachable - The target could not be contacted. A router on the network +had replied with a destination host unreachable error. +5 - Connection refused - The target server has actively refused the connection +(the requested port is closed). +6 - TTL expired - The TTL value of the SYN packet from the proxy to the target server +has expired. This usually means that there are network problems causing the packet +to be caught in a router-to-router "ping-pong". +7 - Command not supported - The client has issued an invalid command. When using this +module, this error should not occur. +8 - Address type not supported - The client has provided an invalid address type. +When using this module, this error should not occur. + +class Socks4Error - This will be raised for Socks4 errors. The parameter is a tuple +containing a code and a description of the error, as given by the server. The +possible error, according to the specification are: + +1 - Request rejected or failed - Will be raised in the event of an failure for any +reason other then the two mentioned next. +2 - request rejected because SOCKS server cannot connect to identd on the client - +The Socks server had tried an ident lookup on your computer and has failed. In this +case you should run an identd server and/or configure your firewall to allow incoming +connections to local port 113 from the remote server. +3 - request rejected because the client program and identd report different user-ids - +The Socks server had performed an ident lookup on your computer and has received a +different userid than the one you have provided. Change your userid (through the +username parameter of the setproxy method) to match and try again. + +class HTTPError - This will be raised for HTTP errors. The parameter is a tuple +containing the HTTP status code and the description of the server. + + +After establishing the connection, the object behaves like a standard socket. +Call the close method to close the connection. + +In addition to the socksocket class, an additional function worth mentioning is the +setdefaultproxy function. The parameters are the same as the setproxy method. +This function will set default proxy settings for newly created socksocket objects, +in which the proxy settings haven't been changed via the setproxy method. +This is quite useful if you wish to force 3rd party modules to use a socks proxy, +by overriding the socket object. +For example: + +>>> socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5,"socks.example.com") +>>> socket.socket = socks.socksocket +>>> urllib.urlopen("http://www.sourceforge.net/") + + +PROBLEMS +--------- + +If you have any problems using this module, please first refer to the BUGS file +(containing current bugs and issues). If your problem is not mentioned you may +contact the author at the following E-Mail address: + +negativeiq@users.sourceforge.net + +Please allow some time for your question to be received and handled. + + +Dan-Haim, +Author. diff --git a/socks/__init__.py b/socks/__init__.py new file mode 100644 index 00000000..ebb68f45 --- /dev/null +++ b/socks/__init__.py @@ -0,0 +1,382 @@ +"""SocksiPy - Python SOCKS module. +Version 1.00 + +Copyright 2006 Dan-Haim. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +3. Neither the name of Dan Haim nor the names of his contributors may be used + to endorse or promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY DAN HAIM "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +EVENT SHALL DAN HAIM OR HIS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA +OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMANGE. + + +This module provides a standard socket-like interface for Python +for tunneling connections through SOCKS proxies. + +""" + +""" + +Minor modifications made by Christopher Gilbert (http://motomastyle.com/) +for use in PyLoris (http://pyloris.sourceforge.net/) + +Minor modifications made by Mario Vilas (http://breakingcode.wordpress.com/) +mainly to merge bug fixes found in Sourceforge + +""" + +import socket +import struct +import sys + +PROXY_TYPE_SOCKS4 = 1 +PROXY_TYPE_SOCKS5 = 2 +PROXY_TYPE_HTTP = 3 + +_defaultproxy = None +_orgsocket = socket.socket + +class ProxyError(Exception): pass +class GeneralProxyError(ProxyError): pass +class Socks5AuthError(ProxyError): pass +class Socks5Error(ProxyError): pass +class Socks4Error(ProxyError): pass +class HTTPError(ProxyError): pass + +_generalerrors = ("success", + "invalid data", + "not connected", + "not available", + "bad proxy type", + "bad input") + +_socks5errors = ("succeeded", + "general SOCKS server failure", + "connection not allowed by ruleset", + "Network unreachable", + "Host unreachable", + "Connection refused", + "TTL expired", + "Command not supported", + "Address type not supported", + "Unknown error") + +_socks5autherrors = ("succeeded", + "authentication is required", + "all offered authentication methods were rejected", + "unknown username or invalid password", + "unknown error") + +_socks4errors = ("request granted", + "request rejected or failed", + "request rejected because SOCKS server cannot connect to identd on the client", + "request rejected because the client program and identd report different user-ids", + "unknown error") + +def setdefaultproxy(proxytype=None, addr=None, port=None, rdns=True, username=None, password=None): + """setdefaultproxy(proxytype, addr[, port[, rdns[, username[, password]]]]) + Sets a default proxy which all further socksocket objects will use, + unless explicitly changed. + """ + global _defaultproxy + _defaultproxy = (proxytype, addr, port, rdns, username, password) + +def wrapmodule(module): + """wrapmodule(module) + Attempts to replace a module's socket library with a SOCKS socket. Must set + a default proxy using setdefaultproxy(...) first. + This will only work on modules that import socket directly into the namespace; + most of the Python Standard Library falls into this category. + """ + if _defaultproxy != None: + module.socket.socket = socksocket + else: + raise GeneralProxyError((4, "no proxy specified")) + +class socksocket(socket.socket): + """socksocket([family[, type[, proto]]]) -> socket object + Open a SOCKS enabled socket. The parameters are the same as + those of the standard socket init. In order for SOCKS to work, + you must specify family=AF_INET, type=SOCK_STREAM and proto=0. + """ + + def __init__(self, family=socket.AF_INET, type=socket.SOCK_STREAM, proto=0, _sock=None): + _orgsocket.__init__(self, family, type, proto, _sock) + if _defaultproxy != None: + self.__proxy = _defaultproxy + else: + self.__proxy = (None, None, None, None, None, None) + self.__proxysockname = None + self.__proxypeername = None + + def __recvall(self, count): + """__recvall(count) -> data + Receive EXACTLY the number of bytes requested from the socket. + Blocks until the required number of bytes have been received. + """ + data = self.recv(count) + while len(data) < count: + d = self.recv(count-len(data)) + if not d: raise GeneralProxyError((0, "connection closed unexpectedly")) + data = data + d + return data + + def setproxy(self, proxytype=None, addr=None, port=None, rdns=True, username=None, password=None): + """setproxy(proxytype, addr[, port[, rdns[, username[, password]]]]) + Sets the proxy to be used. + proxytype - The type of the proxy to be used. Three types + are supported: PROXY_TYPE_SOCKS4 (including socks4a), + PROXY_TYPE_SOCKS5 and PROXY_TYPE_HTTP + addr - The address of the server (IP or DNS). + port - The port of the server. Defaults to 1080 for SOCKS + servers and 8080 for HTTP proxy servers. + rdns - Should DNS queries be preformed on the remote side + (rather than the local side). The default is True. + Note: This has no effect with SOCKS4 servers. + username - Username to authenticate with to the server. + The default is no authentication. + password - Password to authenticate with to the server. + Only relevant when username is also provided. + """ + self.__proxy = (proxytype, addr, port, rdns, username, password) + + def __negotiatesocks5(self, destaddr, destport): + """__negotiatesocks5(self,destaddr,destport) + Negotiates a connection through a SOCKS5 server. + """ + # First we'll send the authentication packages we support. + if (self.__proxy[4]!=None) and (self.__proxy[5]!=None): + # The username/password details were supplied to the + # setproxy method so we support the USERNAME/PASSWORD + # authentication (in addition to the standard none). + self.sendall(struct.pack('BBBB', 0x05, 0x02, 0x00, 0x02)) + else: + # No username/password were entered, therefore we + # only support connections with no authentication. + self.sendall(struct.pack('BBB', 0x05, 0x01, 0x00)) + # We'll receive the server's response to determine which + # method was selected + chosenauth = self.__recvall(2) + if chosenauth[0:1] != chr(0x05).encode(): + self.close() + raise GeneralProxyError((1, _generalerrors[1])) + # Check the chosen authentication method + if chosenauth[1:2] == chr(0x00).encode(): + # No authentication is required + pass + elif chosenauth[1:2] == chr(0x02).encode(): + # Okay, we need to perform a basic username/password + # authentication. + self.sendall(chr(0x01).encode() + chr(len(self.__proxy[4])) + self.__proxy[4] + chr(len(self.__proxy[5])) + self.__proxy[5]) + authstat = self.__recvall(2) + if authstat[0:1] != chr(0x01).encode(): + # Bad response + self.close() + raise GeneralProxyError((1, _generalerrors[1])) + if authstat[1:2] != chr(0x00).encode(): + # Authentication failed + self.close() + raise Socks5AuthError((3, _socks5autherrors[3])) + # Authentication succeeded + else: + # Reaching here is always bad + self.close() + if chosenauth[1] == chr(0xFF).encode(): + raise Socks5AuthError((2, _socks5autherrors[2])) + else: + raise GeneralProxyError((1, _generalerrors[1])) + # Now we can request the actual connection + req = struct.pack('BBB', 0x05, 0x01, 0x00) + # If the given destination address is an IP address, we'll + # use the IPv4 address request even if remote resolving was specified. + try: + ipaddr = socket.inet_aton(destaddr) + req = req + chr(0x01).encode() + ipaddr + except socket.error: + # Well it's not an IP number, so it's probably a DNS name. + if self.__proxy[3]: + # Resolve remotely + ipaddr = None + req = req + chr(0x03).encode() + chr(len(destaddr)).encode() + destaddr + else: + # Resolve locally + ipaddr = socket.inet_aton(socket.gethostbyname(destaddr)) + req = req + chr(0x01).encode() + ipaddr + req = req + struct.pack(">H", destport) + self.sendall(req) + # Get the response + resp = self.__recvall(4) + if resp[0:1] != chr(0x05).encode(): + self.close() + raise GeneralProxyError((1, _generalerrors[1])) + elif resp[1:2] != chr(0x00).encode(): + # Connection failed + self.close() + if ord(resp[1:2])<=8: + raise Socks5Error((ord(resp[1:2]), _socks5errors[ord(resp[1:2])])) + else: + raise Socks5Error((9, _socks5errors[9])) + # Get the bound address/port + elif resp[3:4] == chr(0x01).encode(): + boundaddr = self.__recvall(4) + elif resp[3:4] == chr(0x03).encode(): + resp = resp + self.recv(1) + boundaddr = self.__recvall(ord(resp[4:5])) + else: + self.close() + raise GeneralProxyError((1,_generalerrors[1])) + boundport = struct.unpack(">H", self.__recvall(2))[0] + self.__proxysockname = (boundaddr, boundport) + if ipaddr != None: + self.__proxypeername = (socket.inet_ntoa(ipaddr), destport) + else: + self.__proxypeername = (destaddr, destport) + + def getproxysockname(self): + """getsockname() -> address info + Returns the bound IP address and port number at the proxy. + """ + return self.__proxysockname + + def getproxypeername(self): + """getproxypeername() -> address info + Returns the IP and port number of the proxy. + """ + return _orgsocket.getpeername(self) + + def getpeername(self): + """getpeername() -> address info + Returns the IP address and port number of the destination + machine (note: getproxypeername returns the proxy) + """ + return self.__proxypeername + + def __negotiatesocks4(self,destaddr,destport): + """__negotiatesocks4(self,destaddr,destport) + Negotiates a connection through a SOCKS4 server. + """ + # Check if the destination address provided is an IP address + rmtrslv = False + try: + ipaddr = socket.inet_aton(destaddr) + except socket.error: + # It's a DNS name. Check where it should be resolved. + if self.__proxy[3]: + ipaddr = struct.pack("BBBB", 0x00, 0x00, 0x00, 0x01) + rmtrslv = True + else: + ipaddr = socket.inet_aton(socket.gethostbyname(destaddr)) + # Construct the request packet + req = struct.pack(">BBH", 0x04, 0x01, destport) + ipaddr + # The username parameter is considered userid for SOCKS4 + if self.__proxy[4] != None: + req = req + self.__proxy[4] + req = req + chr(0x00).encode() + # DNS name if remote resolving is required + # NOTE: This is actually an extension to the SOCKS4 protocol + # called SOCKS4A and may not be supported in all cases. + if rmtrslv: + req = req + destaddr + chr(0x00).encode() + self.sendall(req) + # Get the response from the server + resp = self.__recvall(8) + if resp[0:1] != chr(0x00).encode(): + # Bad data + self.close() + raise GeneralProxyError((1,_generalerrors[1])) + if resp[1:2] != chr(0x5A).encode(): + # Server returned an error + self.close() + if ord(resp[1:2]) in (91, 92, 93): + self.close() + raise Socks4Error((ord(resp[1:2]), _socks4errors[ord(resp[1:2]) - 90])) + else: + raise Socks4Error((94, _socks4errors[4])) + # Get the bound address/port + self.__proxysockname = (socket.inet_ntoa(resp[4:]), struct.unpack(">H", resp[2:4])[0]) + if rmtrslv != None: + self.__proxypeername = (socket.inet_ntoa(ipaddr), destport) + else: + self.__proxypeername = (destaddr, destport) + + def __negotiatehttp(self, destaddr, destport): + """__negotiatehttp(self,destaddr,destport) + Negotiates a connection through an HTTP server. + """ + # If we need to resolve locally, we do this now + if not self.__proxy[3]: + addr = socket.gethostbyname(destaddr) + else: + addr = destaddr + self.sendall(("CONNECT " + addr + ":" + str(destport) + " HTTP/1.1\r\n" + "Host: " + destaddr + "\r\n\r\n").encode()) + # We read the response until we get the string "\r\n\r\n" + resp = self.recv(1) + while resp.find("\r\n\r\n".encode()) == -1: + resp = resp + self.recv(1) + # We just need the first line to check if the connection + # was successful + statusline = resp.splitlines()[0].split(" ".encode(), 2) + if statusline[0] not in ("HTTP/1.0".encode(), "HTTP/1.1".encode()): + self.close() + raise GeneralProxyError((1, _generalerrors[1])) + try: + statuscode = int(statusline[1]) + except ValueError: + self.close() + raise GeneralProxyError((1, _generalerrors[1])) + if statuscode != 200: + self.close() + raise HTTPError((statuscode, statusline[2])) + self.__proxysockname = ("0.0.0.0", 0) + self.__proxypeername = (addr, destport) + + def connect(self, destpair): + """connect(self, despair) + Connects to the specified destination through a proxy. + destpar - A tuple of the IP/DNS address and the port number. + (identical to socket's connect). + To select the proxy server use setproxy(). + """ + # Do a minimal input check first + if (not type(destpair) in (list,tuple)) or (len(destpair) < 2) or (type(destpair[0]) != type('')) or (type(destpair[1]) != int): + raise GeneralProxyError((5, _generalerrors[5])) + if self.__proxy[0] == PROXY_TYPE_SOCKS5: + if self.__proxy[2] != None: + portnum = self.__proxy[2] + else: + portnum = 1080 + _orgsocket.connect(self, (self.__proxy[1], portnum)) + self.__negotiatesocks5(destpair[0], destpair[1]) + elif self.__proxy[0] == PROXY_TYPE_SOCKS4: + if self.__proxy[2] != None: + portnum = self.__proxy[2] + else: + portnum = 1080 + _orgsocket.connect(self,(self.__proxy[1], portnum)) + self.__negotiatesocks4(destpair[0], destpair[1]) + elif self.__proxy[0] == PROXY_TYPE_HTTP: + if self.__proxy[2] != None: + portnum = self.__proxy[2] + else: + portnum = 8080 + _orgsocket.connect(self,(self.__proxy[1], portnum)) + self.__negotiatehttp(destpair[0], destpair[1]) + elif self.__proxy[0] == None: + _orgsocket.connect(self, (destpair[0], destpair[1])) + else: + raise GeneralProxyError((4, _generalerrors[4])) From 33cb1a621a508fdde4c750f91cbe50faa1d318b8 Mon Sep 17 00:00:00 2001 From: Jonathan Warren Date: Tue, 18 Dec 2012 13:12:09 -0500 Subject: [PATCH 2/5] added can-icon.ico --- images/can-icon.ico | Bin 0 -> 99678 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 images/can-icon.ico diff --git a/images/can-icon.ico b/images/can-icon.ico new file mode 100644 index 0000000000000000000000000000000000000000..903bf3dac1acf042b971b1b96ebc700852d66768 GIT binary patch literal 99678 zcmeF434B%6)%Nk@<>T}9wYIg^Qa}Vm1VmIE>Wl-Rq9P&=wN|aQ&Ql$zT15p!L`202 zQJE*1$B=|1j0q4zm_mTe2?0U~QwSJB*x&QtH!B_^Lx8C9t@-_S&b{ZHd+*u%S?gJA zuf6u(HEJAJqgIVy|GI|$POtIEf7PgQ2d_>Ky&tXf(K>hTxn=L0)Tr@~Q)<*`(+57)@T#buftx@AFz2z%US2@oA*Jt!S75|)b$5CcQMAZ6vOT0_dtbTlo<9$H?4iH+{h;r=r`UamI(B{bpAG(edzbMyUw?hcjcwby8?L*~ z-Ei%7?$wuHS{oa;;P^v*_8$-Y?WzuK+vQ(#`4x_G)g_m@%P+dvUE2Br_t6I*xP^=2 z9zEFS@BhnRnzg;E&9*Bp{*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@$;F?3{PFGY9X@=3-EU2a zM;>}8>n8p-YiBKOJ-%W^>&aECCSx;9#D1Iz{uAjvI-ma2^DjRC{P?S{{B>mS-o3jA zj|_Gv*K=?3dp}7J=#uFETjCpDRMx{kzTicVxBte4*H<1>xYRv7cjnBkM+XPLm)_#< zy!65gKO8xEa!uc%clzIYbKm}qJ?S^v5uLFubn;64hnL?U9)2-BHuog1v}9~_^xLOT ze|Ae^%{M03d)a(Fn=y_{UEjj-DH?LmV|!m3qshq|g7HoLeSJ5*`_4NZnL7pt20HRw z>yGpub(|U*`PTXI@k{0_{4f7AV@}s=d}Co-xC0A!VBrod+<}EVuy6;ixjXQ0#4l8| literal 0 HcmV?d00001 From 7c69c93f821408393dbeb06a48d6c7c99733ee20 Mon Sep 17 00:00:00 2001 From: Jonathan Warren Date: Tue, 18 Dec 2012 13:32:48 -0500 Subject: [PATCH 3/5] SOCKS --- bitmessagemain.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/bitmessagemain.py b/bitmessagemain.py index 7dc164ce..90724928 100644 --- a/bitmessagemain.py +++ b/bitmessagemain.py @@ -154,14 +154,8 @@ class outgoingSynSender(QThread): if (int(time.time())-timeLastSeen) > 172800 and len(knownNodes[self.streamNumber]) > 1000: # for nodes older than 48 hours old if we have more than 1000 hosts in our list, delete from the knownNodes data-structure. del knownNodes[self.streamNumber][HOST] print 'deleting ', HOST, 'from knownNodes because it is more than 48 hours old and we could not connect to it.' - - - """except Exception, err: - print 'Could NOT connect to', HOST, 'during outgoing attempt.', err - PORT, timeLastSeen = knownNodes[self.streamNumber][HOST] - if (int(time.time())-timeLastSeen) > 172800 and len(knownNodes[self.streamNumber]) > 1000: # for nodes older than 48 hours old if we have more than 1000 hosts in our list, delete from the knownNodes data-structure. - del knownNodes[self.streamNumber][HOST] - print 'deleting ', HOST, 'from knownNodes because it is more than 48 hours old and we could not connect to it.' """ + except Exception, err: + print 'An acception has occurred in the outgoingSynSender thread that was not caught by other exception types:', err time.sleep(1) #Only one singleListener thread will ever exist. It creates the receiveDataThread and sendDataThread for each incoming connection. Note that it cannot set the stream number because it is not known yet- the other node will have to tell us its stream number in a version message. If we don't care about their stream, we will close the connection (within the recversion function of the recieveData thread) From 1fdb21693dac17581f0ec9f8b45d7e25299a41d6 Mon Sep 17 00:00:00 2001 From: Jonathan Warren Date: Tue, 18 Dec 2012 14:37:37 -0500 Subject: [PATCH 4/5] minor change to UI --- about.py | 2 +- bitmessageui.py | 8 ++++---- iconglossary.py | 2 +- settings.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/about.py b/about.py index 0c0f20e1..5a331701 100644 --- a/about.py +++ b/about.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'about.ui' # -# Created: Mon Nov 19 13:33:47 2012 +# Created: Tue Dec 18 14:32:14 2012 # by: PyQt4 UI code generator 4.9.4 # # WARNING! All changes made in this file will be lost! diff --git a/bitmessageui.py b/bitmessageui.py index 2937cac6..f4513e11 100644 --- a/bitmessageui.py +++ b/bitmessageui.py @@ -2,8 +2,8 @@ # Form implementation generated from reading ui file 'bitmessageui.ui' # -# Created: Sun Nov 25 19:29:28 2012 -# by: PyQt4 UI code generator 4.9.5 +# Created: Tue Dec 18 14:32:02 2012 +# by: PyQt4 UI code generator 4.9.4 # # WARNING! All changes made in this file will be lost! @@ -362,13 +362,13 @@ class Ui_MainWindow(object): self.labelStartupTime.setGeometry(QtCore.QRect(320, 110, 331, 20)) self.labelStartupTime.setObjectName(_fromUtf8("labelStartupTime")) self.labelMessageCount = QtGui.QLabel(self.networkstatus) - self.labelMessageCount.setGeometry(QtCore.QRect(350, 130, 281, 16)) + self.labelMessageCount.setGeometry(QtCore.QRect(350, 130, 361, 16)) self.labelMessageCount.setObjectName(_fromUtf8("labelMessageCount")) self.labelPubkeyCount = QtGui.QLabel(self.networkstatus) self.labelPubkeyCount.setGeometry(QtCore.QRect(350, 170, 331, 16)) self.labelPubkeyCount.setObjectName(_fromUtf8("labelPubkeyCount")) self.labelBroadcastCount = QtGui.QLabel(self.networkstatus) - self.labelBroadcastCount.setGeometry(QtCore.QRect(350, 150, 171, 16)) + self.labelBroadcastCount.setGeometry(QtCore.QRect(350, 150, 351, 16)) self.labelBroadcastCount.setObjectName(_fromUtf8("labelBroadcastCount")) icon9 = QtGui.QIcon() icon9.addPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/networkstatus.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) diff --git a/iconglossary.py b/iconglossary.py index c8802ed9..8c7ad6c0 100644 --- a/iconglossary.py +++ b/iconglossary.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'iconglossary.ui' # -# Created: Mon Nov 05 16:56:02 2012 +# Created: Tue Dec 18 14:31:18 2012 # by: PyQt4 UI code generator 4.9.4 # # WARNING! All changes made in this file will be lost! diff --git a/settings.py b/settings.py index 833989ff..1a5a8fcb 100644 --- a/settings.py +++ b/settings.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'settings.ui' # -# Created: Mon Nov 19 13:33:39 2012 +# Created: Tue Dec 18 14:31:06 2012 # by: PyQt4 UI code generator 4.9.4 # # WARNING! All changes made in this file will be lost! From 6586bd2d6d3e27a4e3b49aa9d85dee47d39178a8 Mon Sep 17 00:00:00 2001 From: Jonathan Warren Date: Tue, 18 Dec 2012 16:36:37 -0500 Subject: [PATCH 5/5] further refined SOCKS exception messages --- bitmessagemain.py | 307 ++++++++++++++++++++-------------------------- 1 file changed, 136 insertions(+), 171 deletions(-) diff --git a/bitmessagemain.py b/bitmessagemain.py index 90724928..03613826 100644 --- a/bitmessagemain.py +++ b/bitmessagemain.py @@ -5,7 +5,7 @@ #Right now, PyBitmessage only support connecting to stream 1. It doesn't yet contain logic to expand into further streams. -softwareVersion = '0.1.2' +softwareVersion = '0.1.4' verbose = 2 maximumAgeOfAnObjectThatIAmWillingToAccept = 216000 #Equals two days and 12 hours. lengthOfTimeToLeaveObjectsInInventory = 237600 #Equals two days and 18 hours. This should be longer than maximumAgeOfAnObjectThatIAmWillingToAccept so that we don't process messages twice. @@ -147,7 +147,8 @@ class outgoingSynSender(QThread): #self.emit(SIGNAL("updateStatusBar(PyQt_PyObject)"),"SOCKS4 error: "+str(err)) except socket.error, err: if config.get('bitmessagesettings', 'socksproxytype')[0:5] == 'SOCKS': - self.emit(SIGNAL("updateStatusBar(PyQt_PyObject)"),"Problem: Bitmessage can not connect to the SOCKS server. "+str(err)) + print 'Bitmessage MIGHT be having trouble connecting to the SOCKS server. '+str(err) + #self.emit(SIGNAL("updateStatusBar(PyQt_PyObject)"),"Problem: Bitmessage can not connect to the SOCKS server. "+str(err)) else: print 'Could NOT connect to', HOST, 'during outgoing attempt.', err PORT, timeLastSeen = knownNodes[self.streamNumber][HOST] @@ -155,7 +156,7 @@ class outgoingSynSender(QThread): del knownNodes[self.streamNumber][HOST] print 'deleting ', HOST, 'from knownNodes because it is more than 48 hours old and we could not connect to it.' except Exception, err: - print 'An acception has occurred in the outgoingSynSender thread that was not caught by other exception types:', err + print 'An exception has occurred in the outgoingSynSender thread that was not caught by other exception types:', err time.sleep(1) #Only one singleListener thread will ever exist. It creates the receiveDataThread and sendDataThread for each incoming connection. Note that it cannot set the stream number because it is not known yet- the other node will have to tell us its stream number in a version message. If we don't care about their stream, we will close the connection (within the recversion function of the recieveData thread) @@ -339,10 +340,10 @@ class receiveDataThread(QThread): random.seed() objectHash, = random.sample(self.objectsThatWeHaveYetToGet, 1) if objectHash in inventory: - print 'Inventory (in memory) already has object that we received in an inv message.' + print 'Inventory (in memory) already has object the hash of which we received in an inv message.' del self.objectsThatWeHaveYetToGet[objectHash] elif isInSqlInventory(objectHash): - print 'Inventory (SQL on disk) already has object that we received in an inv message.' + print 'Inventory (SQL on disk) already has object the hash of which we received in an inv message.' del self.objectsThatWeHaveYetToGet[objectHash] else: print 'processData function making request for object:', repr(objectHash) @@ -457,17 +458,20 @@ class receiveDataThread(QThread): if self.payloadLength < 66: print 'The payload length of this broadcast packet is unreasonably low. Someone is probably trying funny business. Ignoring message.' return - + inventoryLock.acquire() inventoryHash = calculateInventoryHash(self.data[24:self.payloadLength+24]) if inventoryHash in inventory: print 'We have already received this broadcast object. Ignoring.' + inventoryLock.release() return elif isInSqlInventory(inventoryHash): print 'We have already received this broadcast object (it is stored on disk in the SQL inventory). Ignoring it.' + inventoryLock.release() return #It is valid so far. Let's let our peers know about it. objectType = 'broadcast' inventory[inventoryHash] = (objectType, self.streamNumber, self.data[24:self.payloadLength+24], embeddedTime) + inventoryLock.release() self.broadcastinv(inventoryHash) self.emit(SIGNAL("incrementNumberOfBroadcastsProcessed()")) @@ -580,20 +584,25 @@ class receiveDataThread(QThread): return readPosition += 4 inventoryHash = calculateInventoryHash(self.data[24:self.payloadLength+24]) - if inventoryHash in inventory: - print 'We have already received this msg message. Ignoring.' - return - elif isInSqlInventory(inventoryHash): - print 'We have already received this msg message (it is stored on disk in the SQL inventory). Ignoring it.' - return + streamNumberAsClaimedByMsg, streamNumberAsClaimedByMsgLength = decodeVarint(self.data[readPosition:readPosition+9]) if streamNumberAsClaimedByMsg != self.streamNumber: print 'The stream number encoded in this msg (' + streamNumberAsClaimedByMsg + ') message does not match the stream number on which it was received. Ignoring it.' return readPosition += streamNumberAsClaimedByMsgLength + inventoryLock.acquire() + if inventoryHash in inventory: + print 'We have already received this msg message. Ignoring.' + inventoryLock.release() + return + elif isInSqlInventory(inventoryHash): + print 'We have already received this msg message (it is stored on disk in the SQL inventory). Ignoring it.' + inventoryLock.release() + return #This msg message is valid. Let's let our peers know about it. objectType = 'msg' inventory[inventoryHash] = (objectType, self.streamNumber, self.data[24:self.payloadLength+24], embeddedTime) + inventoryLock.release() self.broadcastinv(inventoryHash) self.emit(SIGNAL("incrementNumberOfMessagesProcessed()")) @@ -846,21 +855,25 @@ class receiveDataThread(QThread): #We have received a pubkey def recpubkey(self): - inventoryHash = calculateInventoryHash(self.data[24:self.payloadLength+24]) - if inventoryHash in inventory: - print 'We have already received this pubkey. Ignoring it.' - return - elif isInSqlInventory(inventoryHash): - print 'We have already received this pubkey (it is stored on disk in the SQL inventory). Ignoring it.' - return - #We must check to make sure the proof of work is sufficient. if not self.isProofOfWorkSufficient(): print 'Proof of work in pubkey message insufficient.' return + inventoryHash = calculateInventoryHash(self.data[24:self.payloadLength+24]) + inventoryLock.acquire() + if inventoryHash in inventory: + print 'We have already received this pubkey. Ignoring it.' + inventoryLock.release() + return + elif isInSqlInventory(inventoryHash): + print 'We have already received this pubkey (it is stored on disk in the SQL inventory). Ignoring it.' + inventoryLock.release() + return + objectType = 'pubkey' inventory[inventoryHash] = (objectType, self.streamNumber, self.data[24:self.payloadLength+24], int(time.time())) + inventoryLock.release() self.broadcastinv(inventoryHash) self.emit(SIGNAL("incrementNumberOfPubkeysProcessed()")) @@ -906,127 +919,128 @@ class receiveDataThread(QThread): #We have received a getpubkey message def recgetpubkey(self): + if not self.isProofOfWorkSufficient(): + print 'Proof of work in getpubkey message insufficient.' + return + inventoryLock.acquire() inventoryHash = calculateInventoryHash(self.data[24:self.payloadLength+24]) if inventoryHash in inventory: print 'We have already received this getpubkey request. Ignoring it.' + inventoryLock.release() + return elif isInSqlInventory(inventoryHash): print 'We have already received this getpubkey request (it is stored on disk in the SQL inventory). Ignoring it.' - else: - objectType = 'pubkeyrequest' - inventory[inventoryHash] = (objectType, self.streamNumber, self.data[24:self.payloadLength+24], int(time.time())) - #First we must check to make sure the proof of work is sufficient. - #POW, = unpack('>Q',hashlib.sha512(hashlib.sha512(self.data[24:24+self.payloadLength]).digest()).digest()[4:12]) - #print 'POW:', POW - #if POW > 2**64 / ((self.payloadLength+payloadLengthExtraBytes) * averageProofOfWorkNonceTrialsPerByte): - # print 'POW value in getpubkey message is insufficient. Ignoring it.' - # return - if not self.isProofOfWorkSufficient(): - print 'Proof of work in getpubkey message insufficient.' - return - #Now let us make sure that the getpubkey request isn't too old or with a fake (future) time. - embeddedTime, = unpack('>I',self.data[32:36]) - if embeddedTime > int(time.time())+10800: - print 'The time in this getpubkey message is too new. Ignoring it. Time:', embeddedTime - return - if embeddedTime < int(time.time())-maximumAgeOfAnObjectThatIAmWillingToAccept: - print 'The time in this getpubkey message is too old. Ignoring it. Time:', embeddedTime - return - addressVersionNumber, addressVersionLength = decodeVarint(self.data[36:42]) - if addressVersionNumber > 1: - print 'The addressVersionNumber of the pubkey is too high. Can\'t understand. Ignoring it.' - return - streamNumber, streamNumberLength = decodeVarint(self.data[36+addressVersionLength:42+addressVersionLength]) - if streamNumber <> self.streamNumber: - print 'The streamNumber', streamNumber, 'doesn\'t match our stream number:', self.streamNumber - return - if self.data[36+addressVersionLength+streamNumberLength:56+addressVersionLength+streamNumberLength] in myAddressHashes: - print 'Found getpubkey requested hash in my list of hashes.' - #check to see whether we have already calculated the nonce and transmitted this key before - sqlLock.acquire()#released at the bottom of this payload generation section - t = (self.data[36+addressVersionLength+streamNumberLength:56+addressVersionLength+streamNumberLength],) #this prevents SQL injection - sqlSubmitQueue.put('SELECT * FROM pubkeys WHERE hash=?') + inventoryLock.release() + return + + objectType = 'pubkeyrequest' + inventory[inventoryHash] = (objectType, self.streamNumber, self.data[24:self.payloadLength+24], int(time.time())) + inventoryLock.release() + + #Now let us make sure that the getpubkey request isn't too old or with a fake (future) time. + embeddedTime, = unpack('>I',self.data[32:36]) + if embeddedTime > int(time.time())+10800: + print 'The time in this getpubkey message is too new. Ignoring it. Time:', embeddedTime + return + if embeddedTime < int(time.time())-maximumAgeOfAnObjectThatIAmWillingToAccept: + print 'The time in this getpubkey message is too old. Ignoring it. Time:', embeddedTime + return + addressVersionNumber, addressVersionLength = decodeVarint(self.data[36:42]) + if addressVersionNumber > 1: + print 'The addressVersionNumber of the pubkey is too high. Can\'t understand. Ignoring it.' + return + streamNumber, streamNumberLength = decodeVarint(self.data[36+addressVersionLength:42+addressVersionLength]) + if streamNumber <> self.streamNumber: + print 'The streamNumber', streamNumber, 'doesn\'t match our stream number:', self.streamNumber + return + if self.data[36+addressVersionLength+streamNumberLength:56+addressVersionLength+streamNumberLength] in myAddressHashes: + print 'Found getpubkey requested hash in my list of hashes.' + #check to see whether we have already calculated the nonce and transmitted this key before + sqlLock.acquire()#released at the bottom of this payload generation section + t = (self.data[36+addressVersionLength+streamNumberLength:56+addressVersionLength+streamNumberLength],) #this prevents SQL injection + sqlSubmitQueue.put('SELECT * FROM pubkeys WHERE hash=?') + sqlSubmitQueue.put(t) + queryreturn = sqlReturnQueue.get() + #print 'queryreturn', queryreturn + + if queryreturn == []: + print 'pubkey request is for me but the pubkey is not in our database of pubkeys. Making it.' + payload = '\x00\x00\x00\x01' #bitfield of features supported by me (see the wiki). + payload += self.data[36:36+addressVersionLength+streamNumberLength] + #print int(config.get(encodeAddress(addressVersionNumber,streamNumber,self.data[36+addressVersionLength+streamNumberLength:56+addressVersionLength+streamNumberLength]), 'n')) + nString = convertIntToString(int(config.get(encodeAddress(addressVersionNumber,streamNumber,self.data[36+addressVersionLength+streamNumberLength:56+addressVersionLength+streamNumberLength]), 'n'))) + eString = convertIntToString(config.getint(encodeAddress(addressVersionNumber,streamNumber,self.data[36+addressVersionLength+streamNumberLength:56+addressVersionLength+streamNumberLength]), 'e')) + payload += encodeVarint(len(nString)) + payload += nString + payload += encodeVarint(len(eString)) + payload += eString + + nonce = 0 + trialValue = 99999999999999999999 + target = 2**64 / ((len(payload)+payloadLengthExtraBytes+8) * averageProofOfWorkNonceTrialsPerByte) + print '(For pubkey message) Doing proof of work...' + initialHash = hashlib.sha512(payload).digest() + while trialValue > target: + nonce += 1 + trialValue, = unpack('>Q',hashlib.sha512(hashlib.sha512(pack('>Q',nonce) + initialHash).digest()).digest()[0:8]) + #trialValue, = unpack('>Q',hashlib.sha512(hashlib.sha512(pack('>Q',nonce) + payload).digest()).digest()[4:12]) + print '(For pubkey message) Found proof of work', trialValue, 'Nonce:', nonce + + payload = pack('>Q',nonce) + payload + t = (self.data[36+addressVersionLength+streamNumberLength:56+addressVersionLength+streamNumberLength],True,payload,int(time.time())+1209600) #after two weeks (1,209,600 seconds), we may remove our own pub key from our database. It will be regenerated and put back in the database if it is requested. + sqlSubmitQueue.put('''INSERT INTO pubkeys VALUES (?,?,?,?)''') sqlSubmitQueue.put(t) queryreturn = sqlReturnQueue.get() - #print 'queryreturn', queryreturn - if queryreturn == []: - print 'pubkey request is for me but the pubkey is not in our database of pubkeys. Making it.' - payload = '\x00\x00\x00\x01' #bitfield of features supported by me (see the wiki). - payload += self.data[36:36+addressVersionLength+streamNumberLength] - #print int(config.get(encodeAddress(addressVersionNumber,streamNumber,self.data[36+addressVersionLength+streamNumberLength:56+addressVersionLength+streamNumberLength]), 'n')) - nString = convertIntToString(int(config.get(encodeAddress(addressVersionNumber,streamNumber,self.data[36+addressVersionLength+streamNumberLength:56+addressVersionLength+streamNumberLength]), 'n'))) - eString = convertIntToString(config.getint(encodeAddress(addressVersionNumber,streamNumber,self.data[36+addressVersionLength+streamNumberLength:56+addressVersionLength+streamNumberLength]), 'e')) - payload += encodeVarint(len(nString)) - payload += nString - payload += encodeVarint(len(eString)) - payload += eString + #Now that we have the key either from getting it earlier or making it and storing it ourselves... + t = (self.data[36+addressVersionLength+streamNumberLength:56+addressVersionLength+streamNumberLength],) #this prevents SQL injection + sqlSubmitQueue.put('SELECT * FROM pubkeys WHERE hash=?') + sqlSubmitQueue.put(t) + queryreturn = sqlReturnQueue.get() - nonce = 0 - trialValue = 99999999999999999999 - target = 2**64 / ((len(payload)+payloadLengthExtraBytes+8) * averageProofOfWorkNonceTrialsPerByte) - print '(For pubkey message) Doing proof of work...' - initialHash = hashlib.sha512(payload).digest() - while trialValue > target: - nonce += 1 - trialValue, = unpack('>Q',hashlib.sha512(hashlib.sha512(pack('>Q',nonce) + initialHash).digest()).digest()[0:8]) - #trialValue, = unpack('>Q',hashlib.sha512(hashlib.sha512(pack('>Q',nonce) + payload).digest()).digest()[4:12]) - print '(For pubkey message) Found proof of work', trialValue, 'Nonce:', nonce - - payload = pack('>Q',nonce) + payload - t = (self.data[36+addressVersionLength+streamNumberLength:56+addressVersionLength+streamNumberLength],True,payload,int(time.time())+1209600) #after two weeks (1,209,600 seconds), we may remove our own pub key from our database. It will be regenerated and put back in the database if it is requested. - sqlSubmitQueue.put('''INSERT INTO pubkeys VALUES (?,?,?,?)''') + for row in queryreturn: + hash, havecorrectnonce, payload, timeLastRequested = row + if timeLastRequested < int(time.time())+604800: #if the last time anyone asked about this hash was this week, extend the time. + t = (int(time.time())+604800,hash) + sqlSubmitQueue.put('''UPDATE pubkeys set time=? WHERE hash=?''') sqlSubmitQueue.put(t) queryreturn = sqlReturnQueue.get() - #Now that we have the key either from getting it earlier or making it and storing it ourselves... - t = (self.data[36+addressVersionLength+streamNumberLength:56+addressVersionLength+streamNumberLength],) #this prevents SQL injection - sqlSubmitQueue.put('SELECT * FROM pubkeys WHERE hash=?') - sqlSubmitQueue.put(t) - queryreturn = sqlReturnQueue.get() + sqlLock.release() + inventoryHash = calculateInventoryHash(payload) + objectType = 'pubkey' + inventory[inventoryHash] = (objectType, self.streamNumber, payload, int(time.time())) + self.broadcastinv(inventoryHash) + + else: + print 'Hash in getpubkey is not mine.' + #..but lets see if we have it stored from when it came in from someone else. + t = (self.data[36+addressVersionLength+streamNumberLength:56+addressVersionLength+streamNumberLength],) #this prevents SQL injection + sqlLock.acquire() + sqlSubmitQueue.put('''SELECT hash, time FROM pubkeys WHERE hash=? AND havecorrectnonce='True' ''') + sqlSubmitQueue.put(t) + queryreturn = sqlReturnQueue.get() + sqlLock.release() + print 'queryreturn', queryreturn + if queryreturn <> []: + print 'we have the public key. sending it.' + #We have it. Let's send it. for row in queryreturn: - hash, havecorrectnonce, payload, timeLastRequested = row + hash, timeLastRequested = row if timeLastRequested < int(time.time())+604800: #if the last time anyone asked about this hash was this week, extend the time. t = (int(time.time())+604800,hash) sqlSubmitQueue.put('''UPDATE pubkeys set time=? WHERE hash=?''') sqlSubmitQueue.put(t) queryreturn = sqlReturnQueue.get() - - sqlLock.release() - - inventoryHash = calculateInventoryHash(payload) + inventoryHash = calculateInventoryHash(self.data[24:self.payloadLength+24]) objectType = 'pubkey' - inventory[inventoryHash] = (objectType, self.streamNumber, payload, int(time.time())) + inventory[inventoryHash] = (objectType, self.streamNumber, self.data[24:self.payloadLength+24], int(time.time())) self.broadcastinv(inventoryHash) - else: - print 'Hash in getpubkey is not mine.' - #..but lets see if we have it stored from when it came in from someone else. - t = (self.data[36+addressVersionLength+streamNumberLength:56+addressVersionLength+streamNumberLength],) #this prevents SQL injection - sqlLock.acquire() - sqlSubmitQueue.put('''SELECT hash, time FROM pubkeys WHERE hash=? AND havecorrectnonce='True' ''') - sqlSubmitQueue.put(t) - queryreturn = sqlReturnQueue.get() - sqlLock.release() - print 'queryreturn', queryreturn - if queryreturn <> []: - print 'we have the public key. sending it.' - #We have it. Let's send it. - for row in queryreturn: - hash, timeLastRequested = row - if timeLastRequested < int(time.time())+604800: #if the last time anyone asked about this hash was this week, extend the time. - t = (int(time.time())+604800,hash) - sqlSubmitQueue.put('''UPDATE pubkeys set time=? WHERE hash=?''') - sqlSubmitQueue.put(t) - queryreturn = sqlReturnQueue.get() - inventoryHash = calculateInventoryHash(self.data[24:self.payloadLength+24]) - objectType = 'pubkey' - inventory[inventoryHash] = (objectType, self.streamNumber, self.data[24:self.payloadLength+24], int(time.time())) - self.broadcastinv(inventoryHash) - else: - #We don't have it. We'll need to forward the getpubkey request to our peers. - print 'We don\' have the public key. Forwarding getpubkey message to peers.' - broadcastToSendDataQueues((self.streamNumber,'send',self.data[:self.payloadLength+24])) + #We don't have it. We'll need to forward the getpubkey request to our peers. + print 'We don\' have the public key. Forwarding getpubkey message to peers.' + broadcastToSendDataQueues((self.streamNumber,'send',self.data[:self.payloadLength+24])) #We have received an inv message def recinv(self): @@ -1249,7 +1263,7 @@ class receiveDataThread(QThread): addrsInMyStream = {} addrsInChildStreamLeft = {} addrsInChildStreamRight = {} - print 'knownNodes', knownNodes + #print 'knownNodes', knownNodes #We are going to share a maximum number of 1000 addrs with our peer. 500 from this stream, 250 from the left child stream, and 250 from the right child stream. @@ -2091,57 +2105,6 @@ class addressGenerator(QThread): self.emit(SIGNAL("writeNewAddressToTable(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"),self.label,address,str(self.streamNumber)) -'''class streamThread(QThread): - def __init__(self, parent = None): - QThread.__init__(self, parent) - self.mailbox = Queue.Queue() - streamQueues.append(self.mailbox) - self.sendDataQueues = [] - - def __del__(self): - self.wait() - - - def broadcastTosendDataQueues(self,data): - for q in self.sendDataQueues: - q.put(data) - - def setup(self,streamNumber): - self.streamNumber = streamNumber - - - - def run(self): - #self.listOfSendDataThreads = [] - for i in range(1,2): - x = sendDataThread() - #self.listOfSendDataThreads.append(x) - x.setup(i,self.sendDataQueues) - #x.daemon = False - x.start() - #print 'length of listOfSendDataThreads', len(self.listOfSendDataThreads) - - - while True: - print self.streamNumber - data = self.mailbox.get() - if data == 'shutdown': - self.broadcastTosendDataQueues('shutdown') - print 'Stream thread', self, 'shutting down now' - print 'len of streamQueues', len(streamQueues) - while len(self.sendDataQueues) > 0 : - pass - streamQueues.remove(self.mailbox) - return - print self, 'received a message:', data - returnedthing = str(self)+"dololly" - self.emit(SIGNAL("updatebox(PyQt_PyObject)"),returnedthing)''' - - #time.sleep(1) - #while True: - # print 'test' - # time.sleep(1) - class iconGlossaryDialog(QtGui.QDialog): def __init__(self,parent): QtGui.QWidget.__init__(self, parent) @@ -2149,6 +2112,7 @@ class iconGlossaryDialog(QtGui.QDialog): self.ui.setupUi(self) self.parent = parent self.ui.labelPortNumber.setText('You are using TCP port ' + str(config.getint('bitmessagesettings', 'port')) + '. (This can be changed in the settings).') + QtGui.QWidget.resize(self,QtGui.QWidget.sizeHint(self)) class helpDialog(QtGui.QDialog): def __init__(self,parent): @@ -3573,6 +3537,7 @@ broadcastSendersForWhichImWatching = {} statusIconColor = 'red' connectionsCount = {} #Used for the 'network status' tab. connectionsCountLock = threading.Lock() +inventoryLock = threading.Lock() #Guarantees that two receiveDataThreads don't receive and process the same message concurrently (probably sent by a malicious individual) eightBytesOfRandomDataUsedToDetectConnectionsToSelf = pack('>Q',random.randrange(1, 18446744073709551615)) connectedHostsList = {} #List of hosts to which we are connected. Used to guarantee that the outgoingSynSender thread won't connect to the same remote node twice. neededPubkeys = {}