mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-07 13:41:15 -07:00
Improved IP address handling (includes IPv6)
This commit is contained in:
parent
d875f21647
commit
ca472ff597
14 changed files with 178 additions and 220 deletions
|
@ -14,7 +14,12 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body" id="modal-text">
|
<div class="modal-body" id="modal-text">
|
||||||
<div class="col-sm-12">
|
<div class="col-sm-12">
|
||||||
<h4><strong>Location Details</strong><span id="ip_loading" style="padding-left: 5px;"><i class="fa fa-refresh fa-spin"></i></span></h4>
|
<h4>
|
||||||
|
<strong>Location Details</strong>
|
||||||
|
% if data:
|
||||||
|
<span id="ip_loading" style="padding-left: 5px;"><i class="fa fa-refresh fa-spin"></i></span>
|
||||||
|
% endif
|
||||||
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
<div id="ip_error" class="col-sm-12 text-muted"></div>
|
<div id="ip_error" class="col-sm-12 text-muted"></div>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
|
@ -35,7 +40,12 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-12">
|
<div class="col-sm-12">
|
||||||
<h4><strong>Connection Details</strong><span id="isp_loading" style="padding-left: 5px;"><i class="fa fa-refresh fa-spin"></i></span></h4>
|
<h4>
|
||||||
|
<strong>Connection Details</strong>
|
||||||
|
% if data:
|
||||||
|
<span id="isp_loading" style="padding-left: 5px;"><i class="fa fa-refresh fa-spin"></i></span>
|
||||||
|
% endif
|
||||||
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
<div id="isp_error" class="col-sm-12 text-muted"></div>
|
<div id="isp_error" class="col-sm-12 text-muted"></div>
|
||||||
<div class="col-sm-12">
|
<div class="col-sm-12">
|
||||||
|
|
1
data/interfaces/default/js/ipaddr.min.js
vendored
Normal file
1
data/interfaces/default/js/ipaddr.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -266,20 +266,45 @@ function getPlatformImagePath(platformName) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$.cachedScript = function (url) {
|
||||||
|
return $.ajax({
|
||||||
|
dataType: "script",
|
||||||
|
cache: true,
|
||||||
|
url: url
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
function isPrivateIP(ip_address) {
|
function isPrivateIP(ip_address) {
|
||||||
if (ip_address.indexOf(".") > -1) {
|
var defer = $.Deferred();
|
||||||
// get IPv4 mapped address (xxx.xxx.xxx.xxx) from IPv6 addresss (::ffff:xxx.xxx.xxx.xxx)
|
|
||||||
var parts = ip_address.split(":");
|
$.cachedScript('js/ipaddr.min.js').done(function () {
|
||||||
var parts = parts[parts.length - 1].split('.');
|
if (ipaddr.isValid(ip_address)) {
|
||||||
if ((parts[0] === '127' && parts[1] === '0' && parts[2] === '0' && parts[3] === '1') || (parts[0] === '10') ||
|
var addr = ipaddr.process(ip_address)
|
||||||
(parts[0] === '172' && (parseInt(parts[1], 10) >= 16 && parseInt(parts[1], 10) <= 31)) || (parts[0] ===
|
|
||||||
'192' && parts[1] === '168')) {
|
if (addr.kind() === 'ipv4') {
|
||||||
return true;
|
var rangeList = [
|
||||||
}
|
ipaddr.parseCIDR('127.0.0.0/8'),
|
||||||
return false;
|
ipaddr.parseCIDR('10.0.0.0/8'),
|
||||||
|
ipaddr.parseCIDR('172.16.0.0/12'),
|
||||||
|
ipaddr.parseCIDR('192.168.0.0/16')
|
||||||
|
]
|
||||||
} else {
|
} else {
|
||||||
return true;
|
var rangeList = [
|
||||||
|
ipaddr.parseCIDR('fd00::/8')
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ipaddr.subnetMatch(addr, rangeList, -1) >= 0) {
|
||||||
|
defer.resolve();
|
||||||
|
} else {
|
||||||
|
defer.reject();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
defer.resolve('n/a');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return defer.promise();
|
||||||
}
|
}
|
||||||
|
|
||||||
function humanTime(seconds) {
|
function humanTime(seconds) {
|
||||||
|
|
|
@ -94,16 +94,12 @@ history_table_options = {
|
||||||
"data": "ip_address",
|
"data": "ip_address",
|
||||||
"createdCell": function (td, cellData, rowData, row, col) {
|
"createdCell": function (td, cellData, rowData, row, col) {
|
||||||
if (cellData) {
|
if (cellData) {
|
||||||
if (isPrivateIP(cellData)) {
|
isPrivateIP(cellData).then(function () {
|
||||||
if (cellData != '') {
|
$(td).html(cellData || 'n/a');
|
||||||
$(td).html(cellData);
|
}, function () {
|
||||||
} else {
|
|
||||||
$(td).html('n/a');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
external_ip = '<span class="external-ip-tooltip" data-toggle="tooltip" title="External IP"><i class="fa fa-map-marker fa-fw"></i></span>';
|
external_ip = '<span class="external-ip-tooltip" data-toggle="tooltip" title="External IP"><i class="fa fa-map-marker fa-fw"></i></span>';
|
||||||
$(td).html('<a href="javascript:void(0)" data-toggle="modal" data-target="#ip-info-modal">'+ external_ip + cellData + '</a>');
|
$(td).html('<a href="javascript:void(0)" data-toggle="modal" data-target="#ip-info-modal">'+ external_ip + cellData + '</a>');
|
||||||
}
|
});
|
||||||
} else {
|
} else {
|
||||||
$(td).html('n/a');
|
$(td).html('n/a');
|
||||||
}
|
}
|
||||||
|
@ -253,13 +249,12 @@ history_table_options = {
|
||||||
$('#ajaxMsg').fadeOut();
|
$('#ajaxMsg').fadeOut();
|
||||||
|
|
||||||
// Create the tooltips.
|
// Create the tooltips.
|
||||||
$('.current-activity-tooltip').tooltip({ container: 'body' });
|
$('body').tooltip({
|
||||||
$('.expand-history-tooltip').tooltip({ container: 'body' });
|
selector: '[data-toggle="tooltip"]',
|
||||||
$('.external-ip-tooltip').tooltip({ container: 'body' });
|
container: 'body'
|
||||||
$('.transcode-tooltip').tooltip({ container: 'body' });
|
});
|
||||||
$('.media-type-tooltip').tooltip({ container: 'body' });
|
$('body').popover({
|
||||||
$('.watched-tooltip').tooltip({ container: 'body' });
|
selector: '[data-toggle="popover"]',
|
||||||
$('.thumb-tooltip').popover({
|
|
||||||
html: true,
|
html: true,
|
||||||
container: 'body',
|
container: 'body',
|
||||||
trigger: 'hover',
|
trigger: 'hover',
|
||||||
|
@ -331,22 +326,13 @@ $('.history_table').on('click', '> tbody > tr > td.modal-control', function () {
|
||||||
var row = history_table.row( tr );
|
var row = history_table.row( tr );
|
||||||
var rowData = row.data();
|
var rowData = row.data();
|
||||||
|
|
||||||
function showStreamDetails() {
|
$.get('get_stream_data', {
|
||||||
$.ajax({
|
|
||||||
url: 'get_stream_data',
|
|
||||||
data: {
|
|
||||||
row_id: rowData['id'],
|
row_id: rowData['id'],
|
||||||
session_key: rowData['session_key'],
|
session_key: rowData['session_key'],
|
||||||
user: rowData['friendly_name']
|
user: rowData['friendly_name']
|
||||||
},
|
}).then(function (jqXHR) {
|
||||||
cache: false,
|
$("#info-modal").html(jqXHR);
|
||||||
async: true,
|
|
||||||
complete: function(xhr, status) {
|
|
||||||
$("#info-modal").html(xhr.responseText);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
showStreamDetails();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Parent table ip address modal
|
// Parent table ip address modal
|
||||||
|
@ -355,21 +341,11 @@ $('.history_table').on('click', '> tbody > tr > td.modal-control-ip', function (
|
||||||
var row = history_table.row( tr );
|
var row = history_table.row( tr );
|
||||||
var rowData = row.data();
|
var rowData = row.data();
|
||||||
|
|
||||||
function getUserLocation(ip_address) {
|
$.get('get_ip_address_details', {
|
||||||
if (isPrivateIP(ip_address)) {
|
ip_address: rowData['ip_address']
|
||||||
return "n/a"
|
}).then(function (jqXHR) {
|
||||||
} else {
|
$("#ip-info-modal").html(jqXHR);
|
||||||
$.ajax({
|
|
||||||
url: 'get_ip_address_details',
|
|
||||||
data: {ip_address: ip_address},
|
|
||||||
async: true,
|
|
||||||
complete: function(xhr, status) {
|
|
||||||
$("#ip-info-modal").html(xhr.responseText);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
getUserLocation(rowData['ip_address']);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Parent table delete mode
|
// Parent table delete mode
|
||||||
|
@ -545,18 +521,12 @@ function createChildTable(row, rowData) {
|
||||||
var childRow = history_child_table[rowData['reference_id']].row(tr);
|
var childRow = history_child_table[rowData['reference_id']].row(tr);
|
||||||
var childRowData = childRow.data();
|
var childRowData = childRow.data();
|
||||||
|
|
||||||
function showStreamDetails() {
|
$.get('get_stream_data', {
|
||||||
$.ajax({
|
row_id: childRowData['id'],
|
||||||
url: 'get_stream_data',
|
user: childRowData['friendly_name']
|
||||||
data: { row_id: childRowData['id'], user: childRowData['friendly_name'] },
|
}).then(function (jqXHR) {
|
||||||
cache: false,
|
$("#info-modal").html(jqXHR);
|
||||||
async: true,
|
|
||||||
complete: function (xhr, status) {
|
|
||||||
$("#info-modal").html(xhr.responseText);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
showStreamDetails();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Child table ip address modal
|
// Child table ip address modal
|
||||||
|
@ -565,21 +535,11 @@ function createChildTable(row, rowData) {
|
||||||
var childRow = history_child_table[rowData['reference_id']].row(tr);
|
var childRow = history_child_table[rowData['reference_id']].row(tr);
|
||||||
var childRowData = childRow.data();
|
var childRowData = childRow.data();
|
||||||
|
|
||||||
function getUserLocation(ip_address) {
|
$.get('get_ip_address_details', {
|
||||||
if (isPrivateIP(ip_address)) {
|
ip_address: childRowData['ip_address']
|
||||||
return "n/a"
|
}).then(function (jqXHR) {
|
||||||
} else {
|
$("#ip-info-modal").html(jqXHR);
|
||||||
$.ajax({
|
|
||||||
url: 'get_ip_address_details',
|
|
||||||
data: { ip_address: ip_address },
|
|
||||||
async: true,
|
|
||||||
complete: function (xhr, status) {
|
|
||||||
$("#ip-info-modal").html(xhr.responseText);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
getUserLocation(childRowData['ip_address']);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Child table delete mode
|
// Child table delete mode
|
||||||
|
|
|
@ -131,9 +131,12 @@ history_table_modal_options = {
|
||||||
$('#ajaxMsg').fadeOut();
|
$('#ajaxMsg').fadeOut();
|
||||||
|
|
||||||
// Create the tooltips.
|
// Create the tooltips.
|
||||||
$('.transcode-tooltip').tooltip({ container: 'body' });
|
$('body').tooltip({
|
||||||
$('.media-type-tooltip').tooltip({ container: 'body' });
|
selector: '[data-toggle="tooltip"]',
|
||||||
$('.thumb-tooltip').popover({
|
container: 'body'
|
||||||
|
});
|
||||||
|
$('body').popover({
|
||||||
|
selector: '[data-toggle="popover"]',
|
||||||
html: true,
|
html: true,
|
||||||
container: '#history-modal',
|
container: '#history-modal',
|
||||||
trigger: 'hover',
|
trigger: 'hover',
|
||||||
|
|
|
@ -217,11 +217,12 @@ libraries_list_table_options = {
|
||||||
$('#ajaxMsg').fadeOut();
|
$('#ajaxMsg').fadeOut();
|
||||||
|
|
||||||
// Create the tooltips.
|
// Create the tooltips.
|
||||||
$('.purge-tooltip').tooltip({ container: 'body' });
|
$('body').tooltip({
|
||||||
$('.edit-tooltip').tooltip({ container: 'body' });
|
selector: '[data-toggle="tooltip"]',
|
||||||
$('.transcode-tooltip').tooltip({ container: 'body' });
|
container: 'body'
|
||||||
$('.media-type-tooltip').tooltip({ container: 'body' });
|
});
|
||||||
$('.thumb-tooltip').popover({
|
$('body').popover({
|
||||||
|
selector: '[data-toggle="popover"]',
|
||||||
html: true,
|
html: true,
|
||||||
container: 'body',
|
container: 'body',
|
||||||
trigger: 'hover',
|
trigger: 'hover',
|
||||||
|
|
|
@ -49,16 +49,12 @@ login_log_table_options = {
|
||||||
"data": "ip_address",
|
"data": "ip_address",
|
||||||
"createdCell": function (td, cellData, rowData, row, col) {
|
"createdCell": function (td, cellData, rowData, row, col) {
|
||||||
if (cellData) {
|
if (cellData) {
|
||||||
if (isPrivateIP(cellData)) {
|
isPrivateIP(cellData).then(function () {
|
||||||
if (cellData != '') {
|
$(td).html(cellData || 'n/a');
|
||||||
$(td).html(cellData);
|
}, function () {
|
||||||
} else {
|
|
||||||
$(td).html('n/a');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
external_ip = '<span class="external-ip-tooltip" data-toggle="tooltip" title="External IP"><i class="fa fa-map-marker fa-fw"></i></span>';
|
external_ip = '<span class="external-ip-tooltip" data-toggle="tooltip" title="External IP"><i class="fa fa-map-marker fa-fw"></i></span>';
|
||||||
$(td).html('<a href="javascript:void(0)" data-toggle="modal" data-target="#ip-info-modal">' + external_ip + cellData + '</a>');
|
$(td).html('<a href="javascript:void(0)" data-toggle="modal" data-target="#ip-info-modal">' + external_ip + cellData + '</a>');
|
||||||
}
|
});
|
||||||
} else {
|
} else {
|
||||||
$(td).html('n/a');
|
$(td).html('n/a');
|
||||||
}
|
}
|
||||||
|
@ -92,7 +88,10 @@ login_log_table_options = {
|
||||||
$('#ajaxMsg').fadeOut();
|
$('#ajaxMsg').fadeOut();
|
||||||
|
|
||||||
// Create the tooltips.
|
// Create the tooltips.
|
||||||
$('.external-ip-tooltip').tooltip({ container: 'body' });
|
$('body').tooltip({
|
||||||
|
selector: '[data-toggle="tooltip"]',
|
||||||
|
container: 'body'
|
||||||
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
"preDrawCallback": function (settings) {
|
"preDrawCallback": function (settings) {
|
||||||
|
@ -106,19 +105,9 @@ $('.login_log_table').on('click', '> tbody > tr > td.modal-control-ip', function
|
||||||
var row = login_log_table.row(tr);
|
var row = login_log_table.row(tr);
|
||||||
var rowData = row.data();
|
var rowData = row.data();
|
||||||
|
|
||||||
function getUserLocation(ip_address) {
|
$.get('get_ip_address_details', {
|
||||||
if (isPrivateIP(ip_address)) {
|
ip_address: rowData['ip_address']
|
||||||
return "n/a"
|
}).then(function (jqXHR) {
|
||||||
} else {
|
$("#ip-info-modal").html(jqXHR);
|
||||||
$.ajax({
|
|
||||||
url: 'get_ip_address_details',
|
|
||||||
data: { ip_address: ip_address },
|
|
||||||
async: true,
|
|
||||||
complete: function (xhr, status) {
|
|
||||||
$("#ip-info-modal").html(xhr.responseText);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
getUserLocation(rowData['ip_address']);
|
|
||||||
});
|
});
|
|
@ -237,9 +237,12 @@ media_info_table_options = {
|
||||||
$('#ajaxMsg').fadeOut();
|
$('#ajaxMsg').fadeOut();
|
||||||
|
|
||||||
// Create the tooltips.
|
// Create the tooltips.
|
||||||
$('.expand-media-info-tooltip').tooltip({ container: 'body' });
|
$('body').tooltip({
|
||||||
$('.media-type-tooltip').tooltip({ container: 'body' });
|
selector: '[data-toggle="tooltip"]',
|
||||||
$('.thumb-tooltip').popover({
|
container: 'body'
|
||||||
|
});
|
||||||
|
$('body').popover({
|
||||||
|
selector: '[data-toggle="popover"]',
|
||||||
html: true,
|
html: true,
|
||||||
container: 'body',
|
container: 'body',
|
||||||
trigger: 'hover',
|
trigger: 'hover',
|
||||||
|
|
|
@ -33,16 +33,12 @@ user_ip_table_options = {
|
||||||
"data": "ip_address",
|
"data": "ip_address",
|
||||||
"createdCell": function (td, cellData, rowData, row, col) {
|
"createdCell": function (td, cellData, rowData, row, col) {
|
||||||
if (cellData) {
|
if (cellData) {
|
||||||
if (isPrivateIP(cellData)) {
|
isPrivateIP(cellData).then(function () {
|
||||||
if (cellData != '') {
|
$(td).html(cellData || 'n/a');
|
||||||
$(td).html(cellData);
|
}, function () {
|
||||||
} else {
|
|
||||||
$(td).html('n/a');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
external_ip = '<span class="external-ip-tooltip" data-toggle="tooltip" title="External IP"><i class="fa fa-map-marker fa-fw"></i></span>';
|
external_ip = '<span class="external-ip-tooltip" data-toggle="tooltip" title="External IP"><i class="fa fa-map-marker fa-fw"></i></span>';
|
||||||
$(td).html('<a href="javascript:void(0)" data-toggle="modal" data-target="#ip-info-modal">' + external_ip + cellData + '</a>');
|
$(td).html('<a href="javascript:void(0)" data-toggle="modal" data-target="#ip-info-modal">' + external_ip + cellData + '</a>');
|
||||||
}
|
});
|
||||||
} else {
|
} else {
|
||||||
$(td).html('n/a');
|
$(td).html('n/a');
|
||||||
}
|
}
|
||||||
|
@ -65,7 +61,7 @@ user_ip_table_options = {
|
||||||
"targets": [3],
|
"targets": [3],
|
||||||
"data": "player",
|
"data": "player",
|
||||||
"createdCell": function (td, cellData, rowData, row, col) {
|
"createdCell": function (td, cellData, rowData, row, col) {
|
||||||
if (cellData) {
|
if (cellData !== '') {
|
||||||
var transcode_dec = '';
|
var transcode_dec = '';
|
||||||
if (rowData['transcode_decision'] === 'transcode') {
|
if (rowData['transcode_decision'] === 'transcode') {
|
||||||
transcode_dec = '<span class="transcode-tooltip" data-toggle="tooltip" title="Transcode"><i class="fa fa-server fa-fw"></i></span>';
|
transcode_dec = '<span class="transcode-tooltip" data-toggle="tooltip" title="Transcode"><i class="fa fa-server fa-fw"></i></span>';
|
||||||
|
@ -74,9 +70,7 @@ user_ip_table_options = {
|
||||||
} else if (rowData['transcode_decision'] === 'direct play') {
|
} else if (rowData['transcode_decision'] === 'direct play') {
|
||||||
transcode_dec = '<span class="transcode-tooltip" data-toggle="tooltip" title="Direct Play"><i class="fa fa-play-circle fa-fw"></i></span>';
|
transcode_dec = '<span class="transcode-tooltip" data-toggle="tooltip" title="Direct Play"><i class="fa fa-play-circle fa-fw"></i></span>';
|
||||||
}
|
}
|
||||||
$(td).html('<div><a href="#" data-target="#info-modal" data-toggle="modal"><div style="float: left;">' + transcode_dec + ' ' + cellData + '</div></a></div>');
|
$(td).html('<div><a href="#" data-target="#info-modal" data-toggle="modal"><div style="float: left;">' + transcode_dec + ' ' + cellData + '</div></a></div>');
|
||||||
} else {
|
|
||||||
$(td).html('n/a');
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"width": "15%",
|
"width": "15%",
|
||||||
|
@ -129,11 +123,12 @@ user_ip_table_options = {
|
||||||
$('#ajaxMsg').fadeOut();
|
$('#ajaxMsg').fadeOut();
|
||||||
|
|
||||||
// Create the tooltips.
|
// Create the tooltips.
|
||||||
$('.external-ip-tooltip').tooltip({ container: 'body' });
|
$('body').tooltip({
|
||||||
$('.transcode-tooltip').tooltip({ container: 'body' });
|
selector: '[data-toggle="tooltip"]',
|
||||||
$('.media-type-tooltip').tooltip({ container: 'body' });
|
container: 'body'
|
||||||
$('.watched-tooltip').tooltip({ container: 'body' });
|
});
|
||||||
$('.thumb-tooltip').popover({
|
$('body').popover({
|
||||||
|
selector: '[data-toggle="popover"]',
|
||||||
html: true,
|
html: true,
|
||||||
container: 'body',
|
container: 'body',
|
||||||
trigger: 'hover',
|
trigger: 'hover',
|
||||||
|
@ -179,20 +174,9 @@ $('.user_ip_table').on('click', 'td.modal-control-ip', function () {
|
||||||
var row = user_ip_table.row( tr );
|
var row = user_ip_table.row( tr );
|
||||||
var rowData = row.data();
|
var rowData = row.data();
|
||||||
|
|
||||||
function getUserLocation(ip_address) {
|
$.get('get_ip_address_details', {
|
||||||
if (isPrivateIP(ip_address)) {
|
ip_address: rowData['ip_address']
|
||||||
return "n/a"
|
}).then(function (jqXHR) {
|
||||||
} else {
|
$("#ip-info-modal").html(jqXHR);
|
||||||
$.ajax({
|
|
||||||
url: 'get_ip_address_details',
|
|
||||||
data: {ip_address: ip_address},
|
|
||||||
async: true,
|
|
||||||
complete: function(xhr, status) {
|
|
||||||
$("#ip-info-modal").html(xhr.responseText);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getUserLocation(rowData['ip_address']);
|
|
||||||
});
|
});
|
|
@ -105,15 +105,12 @@ users_list_table_options = {
|
||||||
"data": "ip_address",
|
"data": "ip_address",
|
||||||
"createdCell": function (td, cellData, rowData, row, col) {
|
"createdCell": function (td, cellData, rowData, row, col) {
|
||||||
if (cellData) {
|
if (cellData) {
|
||||||
if (isPrivateIP(cellData)) {
|
isPrivateIP(cellData).then(function () {
|
||||||
if (cellData != '') {
|
$(td).html(cellData || 'n/a');
|
||||||
$(td).html(cellData);
|
}, function () {
|
||||||
} else {
|
external_ip = '<span class="external-ip-tooltip" data-toggle="tooltip" title="External IP"><i class="fa fa-map-marker fa-fw"></i></span>';
|
||||||
$(td).html('n/a');
|
$(td).html('<a href="javascript:void(0)" data-toggle="modal" data-target="#ip-info-modal">' + external_ip + cellData + '</a>');
|
||||||
}
|
});
|
||||||
} else {
|
|
||||||
$(td).html('<a href="javascript:void(0)" data-toggle="modal" data-target="#ip-info-modal"><span data-toggle="ip-tooltip" data-placement="left" title="IP Address Info" id="ip-info"><i class="fa fa-map-marker"></i></span> ' + cellData + '</a>');
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$(td).html('n/a');
|
$(td).html('n/a');
|
||||||
}
|
}
|
||||||
|
@ -220,12 +217,12 @@ users_list_table_options = {
|
||||||
$('#ajaxMsg').fadeOut();
|
$('#ajaxMsg').fadeOut();
|
||||||
|
|
||||||
// Create the tooltips.
|
// Create the tooltips.
|
||||||
$('.purge-tooltip').tooltip({ container: 'body' });
|
$('body').tooltip({
|
||||||
$('.edit-tooltip').tooltip({ container: 'body' });
|
selector: '[data-toggle="tooltip"]',
|
||||||
$('.transcode-tooltip').tooltip({ container: 'body' });
|
container: 'body'
|
||||||
$('.media-type-tooltip').tooltip({ container: 'body' });
|
});
|
||||||
$('.watched-tooltip').tooltip({ container: 'body' });
|
$('body').popover({
|
||||||
$('.thumb-tooltip').popover({
|
selector: '[data-toggle="popover"]',
|
||||||
html: true,
|
html: true,
|
||||||
container: 'body',
|
container: 'body',
|
||||||
trigger: 'hover',
|
trigger: 'hover',
|
||||||
|
@ -262,18 +259,12 @@ $('#users_list_table').on('click', 'td.modal-control', function () {
|
||||||
var row = users_list_table.row(tr);
|
var row = users_list_table.row(tr);
|
||||||
var rowData = row.data();
|
var rowData = row.data();
|
||||||
|
|
||||||
function showStreamDetails() {
|
$.get('get_stream_data', {
|
||||||
$.ajax({
|
row_id: rowData['id'],
|
||||||
url: 'get_stream_data',
|
user: rowData['friendly_name']
|
||||||
data: { row_id: rowData['id'], user: rowData['friendly_name'] },
|
}).then(function (jqXHR) {
|
||||||
cache: false,
|
$("#info-modal").html(jqXHR);
|
||||||
async: true,
|
|
||||||
complete: function (xhr, status) {
|
|
||||||
$("#info-modal").html(xhr.responseText);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
showStreamDetails();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#users_list_table').on('click', 'td.modal-control-ip', function () {
|
$('#users_list_table').on('click', 'td.modal-control-ip', function () {
|
||||||
|
@ -281,22 +272,11 @@ $('#users_list_table').on('click', 'td.modal-control-ip', function () {
|
||||||
var row = users_list_table.row(tr);
|
var row = users_list_table.row(tr);
|
||||||
var rowData = row.data();
|
var rowData = row.data();
|
||||||
|
|
||||||
function getUserLocation(ip_address) {
|
$.get('get_ip_address_details', {
|
||||||
if (isPrivateIP(ip_address)) {
|
ip_address: rowData['ip_address']
|
||||||
return "n/a"
|
}).then(function (jqXHR) {
|
||||||
} else {
|
$("#ip-info-modal").html(jqXHR);
|
||||||
$.ajax({
|
|
||||||
url: 'get_ip_address_details',
|
|
||||||
data: { ip_address: ip_address },
|
|
||||||
async: true,
|
|
||||||
complete: function (xhr, status) {
|
|
||||||
$("#ip-info-modal").html(xhr.responseText);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getUserLocation(rowData['ip_address']);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#users_list_table').on('change', 'td.edit-control > .edit-user-toggles > input, td.edit-user-control > .edit-user-name > input', function () {
|
$('#users_list_table').on('change', 'td.edit-control > .edit-user-toggles > input, td.edit-user-control > .edit-user-name > input', function () {
|
||||||
|
|
|
@ -2720,7 +2720,9 @@ $(document).ready(function() {
|
||||||
getPlexPyURL().then(function (url) {
|
getPlexPyURL().then(function (url) {
|
||||||
var parser = document.createElement('a');
|
var parser = document.createElement('a');
|
||||||
parser.href = url;
|
parser.href = url;
|
||||||
$('#api_qr_private').toggle(isPrivateIP(parser.hostname));
|
isPrivateIP(parser.hostname).then(function (valid) {
|
||||||
|
$('#api_qr_private').toggle((valid !== 'n/a'));
|
||||||
|
});
|
||||||
|
|
||||||
var encoded_string = url + '|' + $('#api_key').val();
|
var encoded_string = url + '|' + $('#api_key').val();
|
||||||
$('#api_qr_string').html(encoded_string);
|
$('#api_qr_string').html(encoded_string);
|
||||||
|
|
|
@ -502,28 +502,32 @@ def sanitize(string):
|
||||||
else:
|
else:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
def is_ip_public(host):
|
def is_public_ip(host):
|
||||||
ip_address = get_ip(host)
|
ip = is_valid_ip(get_ip(host))
|
||||||
ip = IP(ip_address)
|
if ip and ip.iptype() == 'PUBLIC':
|
||||||
if ip.iptype() == 'PUBLIC':
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_ip(host):
|
def get_ip(host):
|
||||||
ip_address = ''
|
ip_address = ''
|
||||||
|
if is_valid_ip(host):
|
||||||
|
return host
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
socket.inet_aton(host)
|
ip_address = socket.getaddrinfo(host, None)[0][4][0]
|
||||||
ip_address = host
|
|
||||||
except socket.error:
|
|
||||||
try:
|
|
||||||
ip_address = socket.gethostbyname(host)
|
|
||||||
logger.debug(u"IP Checker :: Resolved %s to %s." % (host, ip_address))
|
logger.debug(u"IP Checker :: Resolved %s to %s." % (host, ip_address))
|
||||||
except:
|
except:
|
||||||
logger.error(u"IP Checker :: Bad IP or hostname provided.")
|
logger.error(u"IP Checker :: Bad IP or hostname provided.")
|
||||||
|
|
||||||
return ip_address
|
return ip_address
|
||||||
|
|
||||||
|
def is_valid_ip(address):
|
||||||
|
try:
|
||||||
|
return IP(address)
|
||||||
|
except TypeError:
|
||||||
|
return False
|
||||||
|
except ValueError:
|
||||||
|
return False
|
||||||
|
|
||||||
def install_geoip_db():
|
def install_geoip_db():
|
||||||
maxmind_url = 'http://geolite.maxmind.com/download/geoip/database/'
|
maxmind_url = 'http://geolite.maxmind.com/download/geoip/database/'
|
||||||
geolite2_gz = 'GeoLite2-City.mmdb.gz'
|
geolite2_gz = 'GeoLite2-City.mmdb.gz'
|
||||||
|
|
|
@ -92,14 +92,14 @@ class PublicIPFilter(logging.Filter):
|
||||||
# Currently only checking for ipv4 addresses
|
# Currently only checking for ipv4 addresses
|
||||||
ipv4 = re.findall(r'[0-9]+(?:\.[0-9]+){3}(?!\d*-[a-z0-9]{6})', record.msg)
|
ipv4 = re.findall(r'[0-9]+(?:\.[0-9]+){3}(?!\d*-[a-z0-9]{6})', record.msg)
|
||||||
for ip in ipv4:
|
for ip in ipv4:
|
||||||
if helpers.is_ip_public(ip):
|
if helpers.is_public_ip(ip):
|
||||||
record.msg = record.msg.replace(ip, ip.partition('.')[0] + '.***.***.***')
|
record.msg = record.msg.replace(ip, ip.partition('.')[0] + '.***.***.***')
|
||||||
|
|
||||||
args = []
|
args = []
|
||||||
for arg in record.args:
|
for arg in record.args:
|
||||||
ipv4 = re.findall(r'[0-9]+(?:\.[0-9]+){3}(?!\d*-[a-z0-9]{6})', arg) if isinstance(arg, basestring) else []
|
ipv4 = re.findall(r'[0-9]+(?:\.[0-9]+){3}(?!\d*-[a-z0-9]{6})', arg) if isinstance(arg, basestring) else []
|
||||||
for ip in ipv4:
|
for ip in ipv4:
|
||||||
if helpers.is_ip_public(ip):
|
if helpers.is_public_ip(ip):
|
||||||
arg = arg.replace(ip, ip.partition('.')[0] + '.***.***.***')
|
arg = arg.replace(ip, ip.partition('.')[0] + '.***.***.***')
|
||||||
args.append(arg)
|
args.append(arg)
|
||||||
record.args = tuple(args)
|
record.args = tuple(args)
|
||||||
|
|
|
@ -1719,11 +1719,7 @@ class WebInterface(object):
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@requireAuth()
|
@requireAuth()
|
||||||
def get_ip_address_details(self, ip_address=None, **kwargs):
|
def get_ip_address_details(self, ip_address=None, **kwargs):
|
||||||
import socket
|
if not helpers.is_valid_ip(ip_address):
|
||||||
|
|
||||||
try:
|
|
||||||
socket.inet_aton(ip_address)
|
|
||||||
except socket.error:
|
|
||||||
ip_address = None
|
ip_address = None
|
||||||
|
|
||||||
return serve_template(templatename="ip_address_modal.html", title="IP Address Details", data=ip_address)
|
return serve_template(templatename="ip_address_modal.html", title="IP Address Details", data=ip_address)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue