8 """ |
8 """ |
9 |
9 |
10 import os |
10 import os |
11 |
11 |
12 from PyQt4.QtCore import * |
12 from PyQt4.QtCore import * |
13 from PyQt4.QtGui import QMessageBox |
|
14 from PyQt4.QtNetwork import QTcpServer, QHostAddress, QHostInfo |
13 from PyQt4.QtNetwork import QTcpServer, QHostAddress, QHostInfo |
15 |
14 |
16 from E5Gui.E5Application import e5App |
15 from E5Gui.E5Application import e5App |
17 from E5Gui import E5MessageBox |
16 from E5Gui import E5MessageBox |
18 |
17 |
565 """ |
564 """ |
566 sock = self.nextPendingConnection() |
565 sock = self.nextPendingConnection() |
567 peerAddress = sock.peerAddress().toString() |
566 peerAddress = sock.peerAddress().toString() |
568 if peerAddress not in Preferences.getDebugger("AllowedHosts"): |
567 if peerAddress not in Preferences.getDebugger("AllowedHosts"): |
569 # the peer is not allowed to connect |
568 # the peer is not allowed to connect |
570 res = E5MessageBox.warning(None, |
569 res = E5MessageBox.yesNo(None, |
571 self.trUtf8("Connection from illegal host"), |
570 self.trUtf8("Connection from illegal host"), |
572 self.trUtf8("""<p>A connection was attempted by the""" |
571 self.trUtf8("""<p>A connection was attempted by the""" |
573 """ illegal host <b>{0}</b>. Accept this connection?</p>""")\ |
572 """ illegal host <b>{0}</b>. Accept this connection?</p>""")\ |
574 .format(peerAddress), |
573 .format(peerAddress), |
575 QMessageBox.StandardButtons(\ |
574 type_ = E5MessageBox.Warning) |
576 QMessageBox.No | \ |
575 if not res: |
577 QMessageBox.Yes), |
|
578 QMessageBox.No) |
|
579 if res == QMessageBox.No: |
|
580 sock.abort() |
576 sock.abort() |
581 return |
577 return |
582 else: |
578 else: |
583 allowedHosts = Preferences.getDebugger("AllowedHosts") |
579 allowedHosts = Preferences.getDebugger("AllowedHosts") |
584 allowedHosts.append(peerAddress) |
580 allowedHosts.append(peerAddress) |