Skip to content

Commit 97f0c56

Browse files
committed
Adding configuration option to listen for connections when operating with a SOCKS proxy.
1 parent eed8c66 commit 97f0c56

File tree

6 files changed

+69
-37
lines changed

6 files changed

+69
-37
lines changed

src/bitmessageqt/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1764,6 +1764,8 @@ def click_actionSettings(self):
17641764
self.settingsDialogInstance.ui.lineEditSocksUsername.text()))
17651765
shared.config.set('bitmessagesettings', 'sockspassword', str(
17661766
self.settingsDialogInstance.ui.lineEditSocksPassword.text()))
1767+
shared.config.set('bitmessagesettings', 'sockslisten', str(
1768+
self.settingsDialogInstance.ui.checkBoxSocksListen.isChecked()))
17671769
if float(self.settingsDialogInstance.ui.lineEditTotalDifficulty.text()) >= 1:
17681770
shared.config.set('bitmessagesettings', 'defaultnoncetrialsperbyte', str(int(float(
17691771
self.settingsDialogInstance.ui.lineEditTotalDifficulty.text()) * shared.networkDefaultProofOfWorkNonceTrialsPerByte)))
@@ -2691,13 +2693,16 @@ def __init__(self, parent):
26912693
shared.config.get('bitmessagesettings', 'port')))
26922694
self.ui.checkBoxAuthentication.setChecked(shared.config.getboolean(
26932695
'bitmessagesettings', 'socksauthentication'))
2696+
self.ui.checkBoxSocksListen.setChecked(shared.config.getboolean(
2697+
'bitmessagesettings', 'sockslisten'))
26942698
if str(shared.config.get('bitmessagesettings', 'socksproxytype')) == 'none':
26952699
self.ui.comboBoxProxyType.setCurrentIndex(0)
26962700
self.ui.lineEditSocksHostname.setEnabled(False)
26972701
self.ui.lineEditSocksPort.setEnabled(False)
26982702
self.ui.lineEditSocksUsername.setEnabled(False)
26992703
self.ui.lineEditSocksPassword.setEnabled(False)
27002704
self.ui.checkBoxAuthentication.setEnabled(False)
2705+
self.ui.checkBoxSocksListen.setEnabled(False)
27012706
elif str(shared.config.get('bitmessagesettings', 'socksproxytype')) == 'SOCKS4a':
27022707
self.ui.comboBoxProxyType.setCurrentIndex(1)
27032708
self.ui.lineEditTCPPort.setEnabled(False)
@@ -2754,11 +2759,13 @@ def comboBoxProxyTypeChanged(self, comboBoxIndex):
27542759
self.ui.lineEditSocksUsername.setEnabled(False)
27552760
self.ui.lineEditSocksPassword.setEnabled(False)
27562761
self.ui.checkBoxAuthentication.setEnabled(False)
2762+
self.ui.checkBoxSocksListen.setEnabled(False)
27572763
self.ui.lineEditTCPPort.setEnabled(True)
27582764
elif comboBoxIndex == 1 or comboBoxIndex == 2:
27592765
self.ui.lineEditSocksHostname.setEnabled(True)
27602766
self.ui.lineEditSocksPort.setEnabled(True)
27612767
self.ui.checkBoxAuthentication.setEnabled(True)
2768+
self.ui.checkBoxSocksListen.setEnabled(True)
27622769
if self.ui.checkBoxAuthentication.isChecked():
27632770
self.ui.lineEditSocksUsername.setEnabled(True)
27642771
self.ui.lineEditSocksPassword.setEnabled(True)

src/bitmessageqt/settings.py

Lines changed: 49 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
# Form implementation generated from reading ui file 'settings.ui'
44
#
5-
# Created: Mon Jun 10 11:31:56 2013
6-
# by: PyQt4 UI code generator 4.9.4
5+
# Created: Fri Jul 12 12:37:53 2013
6+
# by: PyQt4 UI code generator 4.10.1
77
#
88
# WARNING! All changes made in this file will be lost!
99

@@ -12,7 +12,16 @@
1212
try:
1313
_fromUtf8 = QtCore.QString.fromUtf8
1414
except AttributeError:
15-
_fromUtf8 = lambda s: s
15+
def _fromUtf8(s):
16+
return s
17+
18+
try:
19+
_encoding = QtGui.QApplication.UnicodeUTF8
20+
def _translate(context, text, disambig):
21+
return QtGui.QApplication.translate(context, text, disambig, _encoding)
22+
except AttributeError:
23+
def _translate(context, text, disambig):
24+
return QtGui.QApplication.translate(context, text, disambig)
1625

1726
class Ui_settingsDialog(object):
1827
def setupUi(self, settingsDialog):
@@ -122,6 +131,9 @@ def setupUi(self, settingsDialog):
122131
self.lineEditSocksPassword.setEchoMode(QtGui.QLineEdit.Password)
123132
self.lineEditSocksPassword.setObjectName(_fromUtf8("lineEditSocksPassword"))
124133
self.gridLayout_2.addWidget(self.lineEditSocksPassword, 2, 5, 1, 1)
134+
self.checkBoxSocksListen = QtGui.QCheckBox(self.groupBox_2)
135+
self.checkBoxSocksListen.setObjectName(_fromUtf8("checkBoxSocksListen"))
136+
self.gridLayout_2.addWidget(self.checkBoxSocksListen, 3, 1, 1, 4)
125137
self.gridLayout_4.addWidget(self.groupBox_2, 1, 0, 1, 1)
126138
spacerItem2 = QtGui.QSpacerItem(20, 70, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
127139
self.gridLayout_4.addItem(spacerItem2, 2, 0, 1, 1)
@@ -235,38 +247,40 @@ def setupUi(self, settingsDialog):
235247
settingsDialog.setTabOrder(self.lineEditSocksPort, self.checkBoxAuthentication)
236248
settingsDialog.setTabOrder(self.checkBoxAuthentication, self.lineEditSocksUsername)
237249
settingsDialog.setTabOrder(self.lineEditSocksUsername, self.lineEditSocksPassword)
238-
settingsDialog.setTabOrder(self.lineEditSocksPassword, self.buttonBox)
250+
settingsDialog.setTabOrder(self.lineEditSocksPassword, self.checkBoxSocksListen)
251+
settingsDialog.setTabOrder(self.checkBoxSocksListen, self.buttonBox)
239252

240253
def retranslateUi(self, settingsDialog):
241-
settingsDialog.setWindowTitle(QtGui.QApplication.translate("settingsDialog", "Settings", None, QtGui.QApplication.UnicodeUTF8))
242-
self.checkBoxStartOnLogon.setText(QtGui.QApplication.translate("settingsDialog", "Start Bitmessage on user login", None, QtGui.QApplication.UnicodeUTF8))
243-
self.checkBoxStartInTray.setText(QtGui.QApplication.translate("settingsDialog", "Start Bitmessage in the tray (don\'t show main window)", None, QtGui.QApplication.UnicodeUTF8))
244-
self.checkBoxMinimizeToTray.setText(QtGui.QApplication.translate("settingsDialog", "Minimize to tray", None, QtGui.QApplication.UnicodeUTF8))
245-
self.checkBoxShowTrayNotifications.setText(QtGui.QApplication.translate("settingsDialog", "Show notification when message received", None, QtGui.QApplication.UnicodeUTF8))
246-
self.checkBoxPortableMode.setText(QtGui.QApplication.translate("settingsDialog", "Run in Portable Mode", None, QtGui.QApplication.UnicodeUTF8))
247-
self.label_7.setText(QtGui.QApplication.translate("settingsDialog", "In Portable Mode, messages and config files are stored in the same directory as the program rather than the normal application-data folder. This makes it convenient to run Bitmessage from a USB thumb drive.", None, QtGui.QApplication.UnicodeUTF8))
248-
self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tabUserInterface), QtGui.QApplication.translate("settingsDialog", "User Interface", None, QtGui.QApplication.UnicodeUTF8))
249-
self.groupBox.setTitle(QtGui.QApplication.translate("settingsDialog", "Listening port", None, QtGui.QApplication.UnicodeUTF8))
250-
self.label.setText(QtGui.QApplication.translate("settingsDialog", "Listen for connections on port:", None, QtGui.QApplication.UnicodeUTF8))
251-
self.groupBox_2.setTitle(QtGui.QApplication.translate("settingsDialog", "Proxy server / Tor", None, QtGui.QApplication.UnicodeUTF8))
252-
self.label_2.setText(QtGui.QApplication.translate("settingsDialog", "Type:", None, QtGui.QApplication.UnicodeUTF8))
253-
self.comboBoxProxyType.setItemText(0, QtGui.QApplication.translate("settingsDialog", "none", None, QtGui.QApplication.UnicodeUTF8))
254-
self.comboBoxProxyType.setItemText(1, QtGui.QApplication.translate("settingsDialog", "SOCKS4a", None, QtGui.QApplication.UnicodeUTF8))
255-
self.comboBoxProxyType.setItemText(2, QtGui.QApplication.translate("settingsDialog", "SOCKS5", None, QtGui.QApplication.UnicodeUTF8))
256-
self.label_3.setText(QtGui.QApplication.translate("settingsDialog", "Server hostname:", None, QtGui.QApplication.UnicodeUTF8))
257-
self.label_4.setText(QtGui.QApplication.translate("settingsDialog", "Port:", None, QtGui.QApplication.UnicodeUTF8))
258-
self.checkBoxAuthentication.setText(QtGui.QApplication.translate("settingsDialog", "Authentication", None, QtGui.QApplication.UnicodeUTF8))
259-
self.label_5.setText(QtGui.QApplication.translate("settingsDialog", "Username:", None, QtGui.QApplication.UnicodeUTF8))
260-
self.label_6.setText(QtGui.QApplication.translate("settingsDialog", "Pass:", None, QtGui.QApplication.UnicodeUTF8))
261-
self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tabNetworkSettings), QtGui.QApplication.translate("settingsDialog", "Network Settings", None, QtGui.QApplication.UnicodeUTF8))
262-
self.label_8.setText(QtGui.QApplication.translate("settingsDialog", "When someone sends you a message, their computer must first complete some work. The difficulty of this work, by default, is 1. You may raise this default for new addresses you create by changing the values here. Any new addresses you create will require senders to meet the higher difficulty. There is one exception: if you add a friend or acquaintance to your address book, Bitmessage will automatically notify them when you next send a message that they need only complete the minimum amount of work: difficulty 1. ", None, QtGui.QApplication.UnicodeUTF8))
263-
self.label_9.setText(QtGui.QApplication.translate("settingsDialog", "Total difficulty:", None, QtGui.QApplication.UnicodeUTF8))
264-
self.label_11.setText(QtGui.QApplication.translate("settingsDialog", "Small message difficulty:", None, QtGui.QApplication.UnicodeUTF8))
265-
self.label_12.setText(QtGui.QApplication.translate("settingsDialog", "The \'Small message difficulty\' mostly only affects the difficulty of sending small messages. Doubling this value makes it almost twice as difficult to send a small message but doesn\'t really affect large messages.", None, QtGui.QApplication.UnicodeUTF8))
266-
self.label_10.setText(QtGui.QApplication.translate("settingsDialog", "The \'Total difficulty\' affects the absolute amount of work the sender must complete. Doubling this value doubles the amount of work.", None, QtGui.QApplication.UnicodeUTF8))
267-
self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tab), QtGui.QApplication.translate("settingsDialog", "Demanded difficulty", None, QtGui.QApplication.UnicodeUTF8))
268-
self.label_15.setText(QtGui.QApplication.translate("settingsDialog", "Here you may set the maximum amount of work you are willing to do to send a message to another person. Setting these values to 0 means that any value is acceptable.", None, QtGui.QApplication.UnicodeUTF8))
269-
self.label_13.setText(QtGui.QApplication.translate("settingsDialog", "Maximum acceptable total difficulty:", None, QtGui.QApplication.UnicodeUTF8))
270-
self.label_14.setText(QtGui.QApplication.translate("settingsDialog", "Maximum acceptable small message difficulty:", None, QtGui.QApplication.UnicodeUTF8))
271-
self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tab_2), QtGui.QApplication.translate("settingsDialog", "Max acceptable difficulty", None, QtGui.QApplication.UnicodeUTF8))
254+
settingsDialog.setWindowTitle(_translate("settingsDialog", "Settings", None))
255+
self.checkBoxStartOnLogon.setText(_translate("settingsDialog", "Start Bitmessage on user login", None))
256+
self.checkBoxStartInTray.setText(_translate("settingsDialog", "Start Bitmessage in the tray (don\'t show main window)", None))
257+
self.checkBoxMinimizeToTray.setText(_translate("settingsDialog", "Minimize to tray", None))
258+
self.checkBoxShowTrayNotifications.setText(_translate("settingsDialog", "Show notification when message received", None))
259+
self.checkBoxPortableMode.setText(_translate("settingsDialog", "Run in Portable Mode", None))
260+
self.label_7.setText(_translate("settingsDialog", "In Portable Mode, messages and config files are stored in the same directory as the program rather than the normal application-data folder. This makes it convenient to run Bitmessage from a USB thumb drive.", None))
261+
self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tabUserInterface), _translate("settingsDialog", "User Interface", None))
262+
self.groupBox.setTitle(_translate("settingsDialog", "Listening port", None))
263+
self.label.setText(_translate("settingsDialog", "Listen for connections on port:", None))
264+
self.groupBox_2.setTitle(_translate("settingsDialog", "Proxy server / Tor", None))
265+
self.label_2.setText(_translate("settingsDialog", "Type:", None))
266+
self.comboBoxProxyType.setItemText(0, _translate("settingsDialog", "none", None))
267+
self.comboBoxProxyType.setItemText(1, _translate("settingsDialog", "SOCKS4a", None))
268+
self.comboBoxProxyType.setItemText(2, _translate("settingsDialog", "SOCKS5", None))
269+
self.label_3.setText(_translate("settingsDialog", "Server hostname:", None))
270+
self.label_4.setText(_translate("settingsDialog", "Port:", None))
271+
self.checkBoxAuthentication.setText(_translate("settingsDialog", "Authentication", None))
272+
self.label_5.setText(_translate("settingsDialog", "Username:", None))
273+
self.label_6.setText(_translate("settingsDialog", "Pass:", None))
274+
self.checkBoxSocksListen.setText(_translate("settingsDialog", "Listen for incoming connections when using proxy", None))
275+
self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tabNetworkSettings), _translate("settingsDialog", "Network Settings", None))
276+
self.label_8.setText(_translate("settingsDialog", "When someone sends you a message, their computer must first complete some work. The difficulty of this work, by default, is 1. You may raise this default for new addresses you create by changing the values here. Any new addresses you create will require senders to meet the higher difficulty. There is one exception: if you add a friend or acquaintance to your address book, Bitmessage will automatically notify them when you next send a message that they need only complete the minimum amount of work: difficulty 1. ", None))
277+
self.label_9.setText(_translate("settingsDialog", "Total difficulty:", None))
278+
self.label_11.setText(_translate("settingsDialog", "Small message difficulty:", None))
279+
self.label_12.setText(_translate("settingsDialog", "The \'Small message difficulty\' mostly only affects the difficulty of sending small messages. Doubling this value makes it almost twice as difficult to send a small message but doesn\'t really affect large messages.", None))
280+
self.label_10.setText(_translate("settingsDialog", "The \'Total difficulty\' affects the absolute amount of work the sender must complete. Doubling this value doubles the amount of work.", None))
281+
self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tab), _translate("settingsDialog", "Demanded difficulty", None))
282+
self.label_15.setText(_translate("settingsDialog", "Here you may set the maximum amount of work you are willing to do to send a message to another person. Setting these values to 0 means that any value is acceptable.", None))
283+
self.label_13.setText(_translate("settingsDialog", "Maximum acceptable total difficulty:", None))
284+
self.label_14.setText(_translate("settingsDialog", "Maximum acceptable small message difficulty:", None))
285+
self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tab_2), _translate("settingsDialog", "Max acceptable difficulty", None))
272286

src/bitmessageqt/settings.ui

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,13 @@
247247
</property>
248248
</widget>
249249
</item>
250+
<item row="3" column="1" colspan="4">
251+
<widget class="QCheckBox" name="checkBoxSocksListen">
252+
<property name="text">
253+
<string>Listen for incoming connections when using proxy</string>
254+
</property>
255+
</widget>
256+
</item>
250257
</layout>
251258
</widget>
252259
</item>
@@ -508,6 +515,7 @@
508515
<tabstop>checkBoxAuthentication</tabstop>
509516
<tabstop>lineEditSocksUsername</tabstop>
510517
<tabstop>lineEditSocksPassword</tabstop>
518+
<tabstop>checkBoxSocksListen</tabstop>
511519
<tabstop>buttonBox</tabstop>
512520
</tabstops>
513521
<resources/>

src/class_singleListener.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def run(self):
2424
# We don't want to accept incoming connections if the user is using a
2525
# SOCKS proxy. If they eventually select proxy 'none' then this will
2626
# start listening for connections.
27-
while shared.config.get('bitmessagesettings', 'socksproxytype')[0:5] == 'SOCKS':
27+
while shared.config.get('bitmessagesettings', 'socksproxytype')[0:5] == 'SOCKS' and not shared.config.getboolean('bitmessagesettings', 'sockslisten'):
2828
time.sleep(300)
2929

3030
with shared.printLock:
@@ -43,7 +43,7 @@ def run(self):
4343
# We don't want to accept incoming connections if the user is using
4444
# a SOCKS proxy. If the user eventually select proxy 'none' then
4545
# this will start listening for connections.
46-
while shared.config.get('bitmessagesettings', 'socksproxytype')[0:5] == 'SOCKS':
46+
while shared.config.get('bitmessagesettings', 'socksproxytype')[0:5] == 'SOCKS' and not shared.config.getboolean('bitmessagesettings', 'sockslisten'):
4747
time.sleep(10)
4848
while len(shared.connectedHostsList) > 220:
4949
with shared.printLock:

src/class_sqlThread.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ def run(self):
8080
shared.config.set('bitmessagesettings', 'socksauthentication', 'false')
8181
shared.config.set('bitmessagesettings', 'socksusername', '')
8282
shared.config.set('bitmessagesettings', 'sockspassword', '')
83+
shared.config.set('bitmessagesettings', 'sockslisten', 'false')
8384
shared.config.set('bitmessagesettings', 'keysencrypted', 'false')
8485
shared.config.set('bitmessagesettings', 'messagesencrypted', 'false')
8586
with open(shared.appdata + 'keys.dat', 'wb') as configfile:

src/helper_startup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ def loadConfig():
5050
shared.config.set('bitmessagesettings', 'socksport', '9050')
5151
shared.config.set(
5252
'bitmessagesettings', 'socksauthentication', 'false')
53+
shared.config.set(
54+
'bitmessagesettings', 'sockslisten', 'false')
5355
shared.config.set('bitmessagesettings', 'socksusername', '')
5456
shared.config.set('bitmessagesettings', 'sockspassword', '')
5557
shared.config.set('bitmessagesettings', 'keysencrypted', 'false')

0 commit comments

Comments
 (0)