64 networkInterfaces = QNetworkInterface.allInterfaces() |
64 networkInterfaces = QNetworkInterface.allInterfaces() |
65 for networkInterface in networkInterfaces: |
65 for networkInterface in networkInterfaces: |
66 addressEntries = networkInterface.addressEntries() |
66 addressEntries = networkInterface.addressEntries() |
67 if len(addressEntries) > 0: |
67 if len(addressEntries) > 0: |
68 for addressEntry in addressEntries: |
68 for addressEntry in addressEntries: |
69 if ":" in addressEntry.ip().toString() and \ |
69 if ( |
70 not socket.has_ipv6: |
70 ":" in addressEntry.ip().toString() and |
|
71 not socket.has_ipv6 |
|
72 ): |
71 continue # IPv6 not supported by Python |
73 continue # IPv6 not supported by Python |
72 interfaces.append( |
74 interfaces.append( |
73 "{0} ({1})".format( |
75 "{0} ({1})".format( |
74 networkInterface.humanReadableName(), |
76 networkInterface.humanReadableName(), |
75 addressEntry.ip().toString())) |
77 addressEntry.ip().toString())) |
86 self.all6InterfacesButton.setChecked(True) |
88 self.all6InterfacesButton.setChecked(True) |
87 else: |
89 else: |
88 self.selectedInterfaceButton.setChecked(True) |
90 self.selectedInterfaceButton.setChecked(True) |
89 index = -1 |
91 index = -1 |
90 for i in range(len(interfaces)): |
92 for i in range(len(interfaces)): |
91 if QRegExp(".*{0}.*".format(interface))\ |
93 if ( |
92 .exactMatch(interfaces[i]): |
94 QRegExp(".*{0}.*".format(interface)) |
|
95 .exactMatch(interfaces[i]) |
|
96 ): |
93 index = i |
97 index = i |
94 break |
98 break |
95 self.interfacesCombo.setCurrentIndex(index) |
99 self.interfacesCombo.setCurrentIndex(index) |
96 |
100 |
97 self.allowedHostsList.addItems( |
101 self.allowedHostsList.addItems( |
269 None, |
273 None, |
270 self.tr("Add allowed host"), |
274 self.tr("Add allowed host"), |
271 self.tr("Enter the IP address of an allowed host"), |
275 self.tr("Enter the IP address of an allowed host"), |
272 QLineEdit.Normal) |
276 QLineEdit.Normal) |
273 if ok and allowedHost: |
277 if ok and allowedHost: |
274 if QHostAddress(allowedHost).protocol() in \ |
278 if QHostAddress(allowedHost).protocol() in [ |
275 [QAbstractSocket.IPv4Protocol, QAbstractSocket.IPv6Protocol]: |
279 QAbstractSocket.IPv4Protocol, QAbstractSocket.IPv6Protocol |
|
280 ]: |
276 self.allowedHostsList.addItem(allowedHost) |
281 self.allowedHostsList.addItem(allowedHost) |
277 else: |
282 else: |
278 E5MessageBox.critical( |
283 E5MessageBox.critical( |
279 self, |
284 self, |
280 self.tr("Add allowed host"), |
285 self.tr("Add allowed host"), |
302 self.tr("Edit allowed host"), |
307 self.tr("Edit allowed host"), |
303 self.tr("Enter the IP address of an allowed host"), |
308 self.tr("Enter the IP address of an allowed host"), |
304 QLineEdit.Normal, |
309 QLineEdit.Normal, |
305 allowedHost) |
310 allowedHost) |
306 if ok and allowedHost: |
311 if ok and allowedHost: |
307 if QHostAddress(allowedHost).protocol() in \ |
312 if QHostAddress(allowedHost).protocol() in [ |
308 [QAbstractSocket.IPv4Protocol, QAbstractSocket.IPv6Protocol]: |
313 QAbstractSocket.IPv4Protocol, QAbstractSocket.IPv6Protocol |
|
314 ]: |
309 self.allowedHostsList.currentItem().setText(allowedHost) |
315 self.allowedHostsList.currentItem().setText(allowedHost) |
310 else: |
316 else: |
311 E5MessageBox.critical( |
317 E5MessageBox.critical( |
312 self, |
318 self, |
313 self.tr("Edit allowed host"), |
319 self.tr("Edit allowed host"), |