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.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 |
134 self.watchSpecialChanged = \ |
134 self.watchSpecialChanged = \ |
135 self.trUtf8("changed", "must be same as in EditWatchpointDialog") |
135 self.trUtf8("changed", "must be same as in EditWatchpointDialog") |
136 |
136 |
137 self.networkInterface = Preferences.getDebugger("NetworkInterface") |
137 self.networkInterface = Preferences.getDebugger("NetworkInterface") |
138 if self.networkInterface == "all": |
138 if self.networkInterface == "all": |
139 hostAddress = QHostAddress("0.0.0.0")#QHostAddress.Any) |
139 hostAddress = QHostAddress("0.0.0.0") # QHostAddress.Any) |
140 elif self.networkInterface == "allv6": |
140 elif self.networkInterface == "allv6": |
141 hostAddress = QHostAddress("::")#QHostAddress.AnyIPv6) |
141 hostAddress = QHostAddress("::") # QHostAddress.AnyIPv6) |
142 else: |
142 else: |
143 hostAddress = QHostAddress(Preferences.getDebugger("NetworkInterface")) |
143 hostAddress = QHostAddress(self.networkInterface) |
|
144 self.networkInterfaceName, self.networkInterfaceIndex = \ |
|
145 self.__getNetworkInterfaceAndIndex(self.networkInterface) |
|
146 |
144 if Preferences.getDebugger("PassiveDbgEnabled"): |
147 if Preferences.getDebugger("PassiveDbgEnabled"): |
145 socket = Preferences.getDebugger("PassiveDbgPort") # default: 42424 |
148 sock = Preferences.getDebugger("PassiveDbgPort") # default: 42424 |
146 self.listen(hostAddress, socket) |
149 self.listen(hostAddress, sock) |
147 self.passive = True |
150 self.passive = True |
148 self.passiveClientExited = False |
151 self.passiveClientExited = False |
149 else: |
152 else: |
|
153 if hostAddress.toString().lower().startswith("fe80"): |
|
154 hostAddress.setScopeId(self.networkInterfaceName) |
150 self.listen(hostAddress) |
155 self.listen(hostAddress) |
151 self.passive = False |
156 self.passive = False |
152 |
157 |
153 self.debuggerInterface = None |
158 self.debuggerInterface = None |
154 self.debugging = False |
159 self.debugging = False |
193 if localhost: |
198 if localhost: |
194 return "::1" |
199 return "::1" |
195 else: |
200 else: |
196 return "{0}@@v6".format(QHostInfo.localHostName()) |
201 return "{0}@@v6".format(QHostInfo.localHostName()) |
197 else: |
202 else: |
198 return self.networkInterface |
203 return "{0}@@i{1}".format(self.networkInterface, |
|
204 self.networkInterfaceIndex) |
|
205 |
|
206 def __getNetworkInterfaceAndIndex(self, address): |
|
207 """ |
|
208 Private method to determine the network interface and the interface index. |
|
209 |
|
210 @param address address to determine the info for (string) |
|
211 @return tuple of network interface name (string) and index (integer) |
|
212 """ |
|
213 if address not in ["all", "allv6"]: |
|
214 for networkInterface in QNetworkInterface.allInterfaces(): |
|
215 addressEntries = networkInterface.addressEntries() |
|
216 if len(addressEntries) > 0: |
|
217 for addressEntry in addressEntries: |
|
218 if addressEntry.ip().toString().lower() == address.lower(): |
|
219 return networkInterface.name(), networkInterface.index() |
|
220 |
|
221 return "", 0 |
199 |
222 |
200 def preferencesChanged(self): |
223 def preferencesChanged(self): |
201 """ |
224 """ |
202 Public slot to handle the preferencesChanged signal. |
225 Public slot to handle the preferencesChanged signal. |
203 """ |
226 """ |