MCPcopy Create free account
hub / github.com/chasingboy/Xtools / select_ipv4

Function select_ipv4

utils.py:126–140  ·  view source on GitHub ↗
(view)

Source from the content-addressed store, hash-verified

124
125
126def select_ipv4(view):
127 pattern = r'(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|[1-9])\.(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)\.(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)\.(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)((([\-](1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|[1-9])|/(1\d|2\d|3[0-2]|[1-9]))(\.(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)\.(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)\.(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d))?)?)'
128 regions = view.find_all(pattern)
129
130 lan_ips = []
131 wan_ips = []
132 for region in regions:
133 text = view.substr(region)
134 temp = text.split('-')[0].split('/')[0]
135 if is_lan(temp):
136 lan_ips.append(text)
137 else:
138 wan_ips.append(text)
139
140 return unique_sort_ipv4(lan_ips),unique_sort_ipv4(wan_ips)
141
142
143def is_lan(ip):

Callers 2

runMethod · 0.85
runMethod · 0.85

Calls 2

is_lanFunction · 0.85
unique_sort_ipv4Function · 0.85

Tested by

no test coverage detected