mirror of
https://github.com/lijiejie/eyes.sh.git
synced 2026-09-26 19:41:52 +08:00
disable ip location search
This commit is contained in:
+12
-9
@@ -24,14 +24,17 @@ from django.db.models import Q
|
|||||||
|
|
||||||
|
|
||||||
def get_city_by_ip(ip):
|
def get_city_by_ip(ip):
|
||||||
try:
|
for _ in range(3):
|
||||||
doc = requests.get('https://whois.pconline.com.cn/ip.jsp?ip=%s' % ip,
|
try:
|
||||||
headers={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 '
|
doc = requests.get('https://whois.pconline.com.cn/ip.jsp?ip=%s' % ip,
|
||||||
'(KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36'}).text.strip()
|
headers={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 '
|
||||||
city = doc.split(' ')[0]
|
'(KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36'}).text.strip()
|
||||||
except Exception as e:
|
city = doc.split(' ')[0]
|
||||||
city = ''
|
if city == '503':
|
||||||
return city
|
continue
|
||||||
|
except Exception as e:
|
||||||
|
city = ''
|
||||||
|
return city
|
||||||
|
|
||||||
|
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
@@ -56,7 +59,7 @@ def index(request):
|
|||||||
user_domain = items[-2]
|
user_domain = items[-2]
|
||||||
user = User.objects.filter(user_domain=user_domain)
|
user = User.objects.filter(user_domain=user_domain)
|
||||||
if user:
|
if user:
|
||||||
city = get_city_by_ip(remote_addr)
|
city = '' # get_city_by_ip(remote_addr)
|
||||||
request_headers = ''
|
request_headers = ''
|
||||||
for key in request.META:
|
for key in request.META:
|
||||||
if key.startswith('REQUEST_') or key.startswith('HTTP_') or key.startswith('CONTENT_'):
|
if key.startswith('REQUEST_') or key.startswith('HTTP_') or key.startswith('CONTENT_'):
|
||||||
|
|||||||
+25
-8
@@ -69,7 +69,10 @@
|
|||||||
<th>{% translate '域名' %}</th>
|
<th>{% translate '域名' %}</th>
|
||||||
<th>Type</th>
|
<th>Type</th>
|
||||||
<th>IP</th>
|
<th>IP</th>
|
||||||
<th>{% translate '位置' %}</th>
|
<th>{% translate '位置' %}
|
||||||
|
<div class="spinner-grow spinner-grow-sm" role="status" id="spinner_location">
|
||||||
|
</div>
|
||||||
|
</th>
|
||||||
<th>{% translate '时间' %}</th>
|
<th>{% translate '时间' %}</th>
|
||||||
<th style="width: 120px;">{% translate '操作' %}</th>
|
<th style="width: 120px;">{% translate '操作' %}</th>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -113,7 +116,10 @@
|
|||||||
<th>ID</th>
|
<th>ID</th>
|
||||||
<th style="width: 350px;">URL</th>
|
<th style="width: 350px;">URL</th>
|
||||||
<th>IP</th>
|
<th>IP</th>
|
||||||
<th>{% translate '位置' %}</th>
|
<th>{% translate '位置' %}
|
||||||
|
<div class="spinner-grow spinner-grow-sm" role="status" id="spinner_location">
|
||||||
|
</div>
|
||||||
|
</th>
|
||||||
<th>{% translate '时间' %}</th>
|
<th>{% translate '时间' %}</th>
|
||||||
<th style="width: 170px;">{% translate '操作' %}</th>
|
<th style="width: 170px;">{% translate '操作' %}</th>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -121,7 +127,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
{% for log in logs %}
|
{% for log in logs %}
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">{{log.id}}</th>
|
<td scope="row">{{log.id}}</td>
|
||||||
<td> <span style="word-break:break-all">{{ log.path }} </span></td>
|
<td> <span style="word-break:break-all">{{ log.path }} </span></td>
|
||||||
<td><a href="?ip={{ log.remote_addr }}">{% if log.remote_addr %} {{ log.remote_addr }}</a> {% else %} {% endif %}</td>
|
<td><a href="?ip={{ log.remote_addr }}">{% if log.remote_addr %} {{ log.remote_addr }}</a> {% else %} {% endif %}</td>
|
||||||
<td> {% if log.city %} {{ log.city }} {% else %} {% endif %} </td>
|
<td> {% if log.city %} {{ log.city }} {% else %} {% endif %} </td>
|
||||||
@@ -492,25 +498,36 @@
|
|||||||
$('[data-toggle="popover"]').popover();
|
$('[data-toggle="popover"]').popover();
|
||||||
})
|
})
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
var loc = $(location).attr('pathname');
|
||||||
|
if (loc.endsWith('/web/')){
|
||||||
|
col_index = 2
|
||||||
|
}
|
||||||
|
if (loc.endsWith('/dns/')){
|
||||||
|
col_index = 3
|
||||||
|
}
|
||||||
var allIPs = new Set([]);
|
var allIPs = new Set([]);
|
||||||
$('.table tr').each(function(index) {
|
$('.table tr').each(function(index) {
|
||||||
if (index !== 0){
|
if (index !== 0 && $(this).children('td')[col_index]){
|
||||||
allIPs.add($(this).children('td')[3].innerText);
|
allIPs.add($(this).children('td')[col_index].innerText);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (allIPs.size !== 0 ){
|
if (allIPs.size !== 0 ){
|
||||||
$.post("/ip2location", {"ips": Array.from(allIPs).join(',')}, function(result){
|
$.post("/ip2location", {"ips": Array.from(allIPs).join(',')}, function(result){
|
||||||
var data = $.parseJSON(result);
|
var data = $.parseJSON(result);
|
||||||
$('.table tr').each(function(index) {
|
$('.table tr').each(function(index) {
|
||||||
if (index !== 0){
|
if (index !== 0 && $(this).children('td')[col_index]){
|
||||||
let ip = $(this).children('td')[3].innerText;
|
let ip = $(this).children('td')[col_index].innerText;
|
||||||
if (ip in data){
|
if (ip in data){
|
||||||
$(this).children('td')[4].innerText = data[ip];
|
$(this).children('td')[col_index+1].innerText = data[ip];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
$('#spinner_location').hide()
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
$('#spinner_location').hide()
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user