bug fix: DNS response too slow

This commit is contained in:
lijiejie
2024-06-02 23:56:15 +08:00
parent cfc0f90439
commit 14ded0d495
8 changed files with 122 additions and 49 deletions
+22 -2
View File
@@ -77,7 +77,7 @@
<tbody>
{% for log in logs %}
<tr>
<th scope="row">{{log.id}}</th>
<td scope="row">{{log.id}}</td>
<td style="word-break:break-all">{{ log.host }}</td>
<td>{{ log.type }}</td>
<td><a href="?ip={{ log.ip }}">{% if log.ip %} {{ log.ip }}</a> {% else %} &nbsp; {% endif %} </td>
@@ -491,7 +491,27 @@
$(function () {
$('[data-toggle="popover"]').popover();
})
$(document).ready(function() {
var allIPs = new Set([]);
$('.table tr').each(function(index) {
if (index !== 0){
allIPs.add($(this).children('td')[3].innerText);
}
});
if (allIPs.size !== 0 ){
$.post("/ip2location", {"ips": Array.from(allIPs).join(',')}, function(result){
var data = $.parseJSON(result);
$('.table tr').each(function(index) {
if (index !== 0){
let ip = $(this).children('td')[3].innerText;
if (ip in data){
$(this).children('td')[4].innerText = data[ip];
}
}
});
});
}
});
</script>
</body>