8 """ |
8 """ |
9 |
9 |
10 import os |
10 import os |
11 |
11 |
12 from PyQt4.QtCore import pyqtSignal, QModelIndex |
12 from PyQt4.QtCore import pyqtSignal, QModelIndex |
13 from PyQt4.QtNetwork import QTcpServer, QHostAddress, QHostInfo |
13 from PyQt4.QtNetwork import QTcpServer, QHostAddress, QHostInfo, QNetworkInterface |
14 |
14 |
15 from E5Gui.E5Application import e5App |
15 from E5Gui.E5Application import e5App |
16 from E5Gui import E5MessageBox |
16 from E5Gui import E5MessageBox |
17 |
17 |
18 from .BreakPointModel import BreakPointModel |
18 from .BreakPointModel import BreakPointModel |
148 if self.networkInterface == "all": |
148 if self.networkInterface == "all": |
149 hostAddress = QHostAddress("0.0.0.0") # QHostAddress.Any) |
149 hostAddress = QHostAddress("0.0.0.0") # QHostAddress.Any) |
150 elif self.networkInterface == "allv6": |
150 elif self.networkInterface == "allv6": |
151 hostAddress = QHostAddress("::") # QHostAddress.AnyIPv6) |
151 hostAddress = QHostAddress("::") # QHostAddress.AnyIPv6) |
152 else: |
152 else: |
153 hostAddress = QHostAddress(Preferences.getDebugger("NetworkInterface")) |
153 hostAddress = QHostAddress(self.networkInterface) |
|
154 self.networkInterfaceName, self.networkInterfaceIndex = \ |
|
155 self.__getNetworkInterfaceAndIndex(self.networkInterface) |
|
156 |
154 if Preferences.getDebugger("PassiveDbgEnabled"): |
157 if Preferences.getDebugger("PassiveDbgEnabled"): |
155 socket = Preferences.getDebugger("PassiveDbgPort") # default: 42424 |
158 sock = Preferences.getDebugger("PassiveDbgPort") # default: 42424 |
156 self.listen(hostAddress, socket) |
159 self.listen(hostAddress, sock) |
157 self.passive = True |
160 self.passive = True |
158 self.passiveClientExited = False |
161 self.passiveClientExited = False |
159 else: |
162 else: |
|
163 if hostAddress.toString().lower().startswith("fe80"): |
|
164 hostAddress.setScopeId(self.networkInterfaceName) |
160 self.listen(hostAddress) |
165 self.listen(hostAddress) |
161 self.passive = False |
166 self.passive = False |
162 |
167 |
163 self.debuggerInterface = None |
168 self.debuggerInterface = None |
164 self.debugging = False |
169 self.debugging = False |
203 if localhost: |
208 if localhost: |
204 return "::1" |
209 return "::1" |
205 else: |
210 else: |
206 return "{0}@@v6".format(QHostInfo.localHostName()) |
211 return "{0}@@v6".format(QHostInfo.localHostName()) |
207 else: |
212 else: |
208 return self.networkInterface |
213 return "{0}@@i{1}".format(self.networkInterface, |
|
214 self.networkInterfaceIndex) |
|
215 |
|
216 def __getNetworkInterfaceAndIndex(self, address): |
|
217 """ |
|
218 Private method to determine the network interface and the interface index. |
|
219 |
|
220 @param address address to determine the info for (string) |
|
221 @return tuple of network interface name (string) and index (integer) |
|
222 """ |
|
223 if address not in ["all", "allv6"]: |
|
224 for networkInterface in QNetworkInterface.allInterfaces(): |
|
225 addressEntries = networkInterface.addressEntries() |
|
226 if len(addressEntries) > 0: |
|
227 for addressEntry in addressEntries: |
|
228 if addressEntry.ip().toString().lower() == address.lower(): |
|
229 return networkInterface.name(), networkInterface.index() |
|
230 |
|
231 return "", 0 |
209 |
232 |
210 def preferencesChanged(self): |
233 def preferencesChanged(self): |
211 """ |
234 """ |
212 Public slot to handle the preferencesChanged signal. |
235 Public slot to handle the preferencesChanged signal. |
213 """ |
236 """ |