##// END OF EJS Templates
relax ipconfig matching on Windows...
MinRK -
Show More
@@ -23,6 +23,7 b' PUBLIC_IPS : A list of public IP addresses that point to this machine.'
23 #-----------------------------------------------------------------------------
23 #-----------------------------------------------------------------------------
24
24
25 import os
25 import os
26 import re
26 import socket
27 import socket
27
28
28 from .data import uniq_stable
29 from .data import uniq_stable
@@ -118,6 +119,7 b' def _load_ips_ip():'
118 addrs.append(blocks[1].split('/')[0])
119 addrs.append(blocks[1].split('/')[0])
119 _populate_from_list(addrs)
120 _populate_from_list(addrs)
120
121
122 _ipconfig_ipv4_pat = re.compile(r'ipv4.*(\d+\.\d+\.\d+\.\d+)$', re.IGNORECASE)
121
123
122 def _load_ips_ipconfig():
124 def _load_ips_ipconfig():
123 """load ip addresses from `ipconfig` output (Windows)"""
125 """load ip addresses from `ipconfig` output (Windows)"""
@@ -128,9 +130,9 b' def _load_ips_ipconfig():'
128 lines = out.splitlines()
130 lines = out.splitlines()
129 addrs = ['127.0.0.1']
131 addrs = ['127.0.0.1']
130 for line in lines:
132 for line in lines:
131 line = line.lower().split()
133 m = _ipconfig_ipv4_pat.match(line.strip())
132 if line[:2] == ['ipv4', 'address']:
134 if m:
133 addrs.append(line.split()[-1])
135 addrs.append(m.group(1))
134 _populate_from_list(addrs)
136 _populate_from_list(addrs)
135
137
136
138
General Comments 0
You need to be logged in to leave comments. Login now