-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathip.html
More file actions
64 lines (64 loc) · 3.61 KB
/
ip.html
File metadata and controls
64 lines (64 loc) · 3.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<!DOCTYPE html>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="shortcut icon" type="image/gif" href="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" />
<title>Index of /ip.html</title>
<form method="POST">
<center>
<textarea name="rawips" rows="20" cols="45" onkeyup="javascript:convert()" onblur="javascript:convert()" spellcheck="false" placeholder="请把包含 IP 地址的文本粘贴到此处"></textarea>
<textarea name="jsonips" rows="20" cols="45" spellcheck="false" style="background-color:#F3F3F3;" readonly="true" placeholder="格式化后的 IP 地址将显示在此"></textarea>
<br>
<input type="radio" name="ipfamily" id="ipv4" value="v4" onclick="javascript:convert()" checked="checked">IPv4
<input type="radio" name="ipfamily" id="ipv6" value="v6" onclick="javascript:convert()">IPv6
</center>
<div align="center">
<input type="submit" name="submit" disabled value="写入到本地 json 文件" style="padding:8px;margin-top:40px;"/>
<p name="message_shown">{{.Message}}</p>
<p name="error_message" style="display:none">写入功能仅在通过网络打开时可用
<br /><a href="http://127.0.0.1:8087/ip.html">默认地址</a>
</p>
</div>
</form>
<script>
var proxyprovided = (typeof(IPHTMLVISABLE) != "undefined");
window.onload = function () {
var message = document.getElementsByName('message_shown');
var error = document.getElementsByName('error_message');
if (proxyprovided) {
message[0].style.display = '';
error[0].style.display = 'none';
} else {
message[0].style.display = 'none';
error[0].style.display = '';
}
}
function enable_submit(value) {
var buttons = document.getElementsByName('submit');
if (buttons.length > 0 && proxyprovided) {
buttons[0].disabled = !value;
}
}
function convert() {
var text1 = document.getElementsByTagName('textarea')[0];
var text2 = document.getElementsByTagName('textarea')[1];
if (text1.value != "") {
regex = /([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})/g;
if (document.getElementById('ipv6').checked) {
regex = /((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))/g
}
var matches = text1.value.match(regex)
if (matches != null) {
matches = matches.sort().filter(function(el,i,a){if(i==a.indexOf(el))return 1;return 0})
text2.value = "\"" + matches.join("\",\n\"") + "\",";
enable_submit(true);
// text2.select();
} else {
enable_submit(false);
text2.value = "没有检测到 IP 地址";
}
} else {
enable_submit(false);
text2.value = "";
}
}
</script>