src/eric7/Debugger/DebugServer.py

branch
eric7
changeset 9521
a663a8be64da
parent 9519
d7ab0653bc63
child 9549
67295777d9fe
child 9653
e67609152c5e
equal deleted inserted replaced
9520:e12589f1d408 9521:a663a8be64da
24 from .WatchPointModel import WatchPointModel 24 from .WatchPointModel import WatchPointModel
25 25
26 DebuggerInterfaces = { 26 DebuggerInterfaces = {
27 "Python": "DebuggerInterfacePython", 27 "Python": "DebuggerInterfacePython",
28 "None": "DebuggerInterfaceNone", 28 "None": "DebuggerInterfaceNone",
29 }
30
31 NetworkInterfaceMapping = {
32 "all": QHostAddress.SpecialAddress.Any,
33 "allv4": QHostAddress.SpecialAddress.AnyIPv4,
34 "allv6": QHostAddress.SpecialAddress.AnyIPv6,
35 "localv4": QHostAddress.SpecialAddress.LocalHost,
36 "localv6": QHostAddress.SpecialAddress.LocalHostIPv6,
29 } 37 }
30 38
31 39
32 class DebugServer(QTcpServer): 40 class DebugServer(QTcpServer):
33 """ 41 """
188 # arrays to track already reported issues 196 # arrays to track already reported issues
189 self.__reportedBreakpointIssues = [] 197 self.__reportedBreakpointIssues = []
190 self.__reportedWatchpointIssues = [] 198 self.__reportedWatchpointIssues = []
191 199
192 self.networkInterface = Preferences.getDebugger("NetworkInterface") 200 self.networkInterface = Preferences.getDebugger("NetworkInterface")
193 if self.networkInterface == "all": 201 hostAddress = (
194 hostAddress = QHostAddress("0.0.0.0") 202 QHostAddress(NetworkInterfaceMapping[self.networkInterface])
195 # QHostAddress.SpecialAddress.AnyIPv4) # secok 203 if self.networkInterface in NetworkInterfaceMapping
196 elif self.networkInterface == "allv6": 204 else QHostAddress(self.networkInterface)
197 hostAddress = QHostAddress("::") 205 )
198 # QHostAddress.SpecialAddress.AnyIPv6)
199 else:
200 hostAddress = QHostAddress(self.networkInterface)
201 ( 206 (
202 self.networkInterfaceName, 207 self.networkInterfaceName,
203 self.networkInterfaceIndex, 208 self.networkInterfaceIndex,
204 ) = self.__getNetworkInterfaceAndIndex(self.networkInterface) 209 ) = self.__getNetworkInterfaceAndIndex(self.networkInterface)
205 210
206 if not preventPassiveDebugging and Preferences.getDebugger("PassiveDbgEnabled"): 211 if not preventPassiveDebugging and Preferences.getDebugger("PassiveDbgEnabled"):
207 sock = Preferences.getDebugger("PassiveDbgPort") # default: 42424 212 port = Preferences.getDebugger("PassiveDbgPort") # default: 42424
208 self.listen(hostAddress, sock) 213 self.listen(hostAddress, port)
209 self.passive = True 214 self.passive = True
210 self.passiveClientExited = False 215 self.passiveClientExited = False
211 else: 216 else:
212 if hostAddress.toString().lower().startswith("fe80"): 217 if hostAddress.toString().lower().startswith("fe80"):
213 hostAddress.setScopeId(self.networkInterfaceName) 218 hostAddress.setScopeId(self.networkInterfaceName)
214 self.listen(hostAddress) 219 if Preferences.getDebugger("NetworkPortFixed"):
220 port = Preferences.getDebugger("NetworkPort")
221 res = self.listen(hostAddress, port)
222 if not res and Preferences.getDebugger("NetworkPortIncrement"):
223 maxPort = port + 100 # try a maximum of 100 ports
224 while not res and port < maxPort:
225 port += 1
226 res = self.listen(hostAddress, port)
227 else:
228 self.listen(hostAddress)
215 self.passive = False 229 self.passive = False
216 230
217 self.debuggerInterface = None 231 self.debuggerInterface = None
218 self.debugging = False 232 self.debugging = False
219 self.running = False 233 self.running = False
259 @param localhost flag indicating to return the address for localhost 273 @param localhost flag indicating to return the address for localhost
260 @type bool 274 @type bool
261 @return IP address or hostname 275 @return IP address or hostname
262 @rtype str 276 @rtype str
263 """ 277 """
264 if self.networkInterface == "all": 278 if self.networkInterface in ("allv4", "localv4"):
265 if localhost: 279 if localhost or self.networkInterface == "localv4":
266 return "127.0.0.1" 280 return "127.0.0.1"
267 else: 281 else:
268 return "{0}@@v4".format(QHostInfo.localHostName()) 282 return "{0}@@v4".format(QHostInfo.localHostName())
269 elif self.networkInterface == "allv6": 283 elif self.networkInterface in ("all", "allv6", "localv6"):
270 if localhost: 284 if localhost or self.networkInterface == "localv6":
271 return "::1" 285 return "::1"
272 else: 286 else:
273 return "{0}@@v6".format(QHostInfo.localHostName()) 287 return "{0}@@v6".format(QHostInfo.localHostName())
274 else: 288 else:
275 return "{0}@@i{1}".format(self.networkInterface, self.networkInterfaceIndex) 289 return "{0}@@i{1}".format(self.networkInterface, self.networkInterfaceIndex)

eric ide

mercurial