mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-06 21:21:15 -07:00
Merge pull request #529 from drzoidberg33/machine-id-fix
Fix bad SSL connections.
This commit is contained in:
commit
39884b71fe
7 changed files with 1717 additions and 17 deletions
|
@ -355,9 +355,9 @@ available_notification_agents = sorted(notifiers.available_notification_agents()
|
|||
</div>
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" id="pms_ssl" name="pms_ssl" value="1" ${config['pms_ssl']}> Force SSL
|
||||
<input type="checkbox" id="pms_ssl" name="pms_ssl" value="1" ${config['pms_ssl']}> Use SSL
|
||||
</label>
|
||||
<p class="help-block">Force PlexPy to connect to your Plex Server via SSL. Your server needs to have remote access enabled.</p>
|
||||
<p class="help-block">If you have secure connections enabled on your Plex Server, communicate with it securely.</p>
|
||||
</div>
|
||||
|
||||
<input type="hidden" id="pms_identifier" name="pms_identifier" value="${config['pms_identifier']}">
|
||||
|
@ -490,7 +490,7 @@ available_notification_agents = sorted(notifiers.available_notification_agents()
|
|||
<input type="checkbox" class="monitor-settings" id="monitoring_use_websocket" name="monitoring_use_websocket" value="1" ${config['monitoring_use_websocket']}> Use Websocket (requires restart) [experimental]
|
||||
</label>
|
||||
<p class="help-block">Instead of polling the server at regular intervals let the server tell us when something happens.<br />
|
||||
This is currently experimental. Encrypted websocket is not currently supported.</p>
|
||||
This is currently experimental.</p>
|
||||
</div>
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
|
|
|
@ -83,7 +83,7 @@ from plexpy import common
|
|||
<div class="col-xs-4">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" id="pms_ssl" name="pms_ssl" value="1"> Force SSL
|
||||
<input type="checkbox" id="pms_ssl" name="pms_ssl" value="1"> Use SSL
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -244,7 +244,7 @@ from plexpy import common
|
|||
},
|
||||
render: {
|
||||
option: function (item, escape) {
|
||||
return '<div data-use_ssl="' + item.httpsRequired + '" data-local="' + item.local + '" data-ci="' + item.clientIdentifier + '" data-ip="' + item.ip + '" data-port="' + item.port + '">' + item.value + '</div>';
|
||||
return '<div data-use_ssl="' + item.httpsRequired + '" data-local="' + item.local + '" data-ci="' + item.clientIdentifier + '" data-ip="' + item.ip + '" data-port="' + item.port + '" data-label="' + item.label + '">' + item.value + ' (' + item.label + ')</div>';
|
||||
},
|
||||
item: function (item, escape) {
|
||||
// first item is rendered before initialization bug?
|
||||
|
@ -254,7 +254,7 @@ from plexpy import common
|
|||
.filter('[value="' + item.value + '"]').data());
|
||||
|
||||
}
|
||||
return '<div data-use_ssl="' + item.httpsRequired + '" data-local="' + item.local + '" data-ci="' + item.clientIdentifier + '" data-ip="' + item.ip + '" data-port="' + item.port + '">' + item.value + '</div>';
|
||||
return '<div data-use_ssl="' + item.httpsRequired + '" data-local="' + item.local + '" data-ci="' + item.clientIdentifier + '" data-ip="' + item.ip + '" data-port="' + item.port + '" data-label="' + item.label + '">' + item.value + ' (' + item.label + ')</div>';
|
||||
}
|
||||
},
|
||||
onChange: function (item) {
|
||||
|
@ -378,8 +378,8 @@ from plexpy import common
|
|||
var pms_ip = $("#pms_ip").val().trim();
|
||||
var pms_port = $("#pms_port").val().trim();
|
||||
var pms_identifier = $("#pms_identifier").val();
|
||||
var pms_ssl = $("#pms_ssl").val();
|
||||
var pms_is_remote = $("#pms_is_remote").val();
|
||||
var pms_ssl = $("#pms_ssl").is(':checked') ? 1 : 0;
|
||||
var pms_is_remote = $("#pms_is_remote").is(':checked') ? 1 : 0;
|
||||
if ((pms_ip !== '') || (pms_port !== '')) {
|
||||
$("#pms-verify-status").html('<i class="fa fa-refresh fa-spin"></i> Validating server...');
|
||||
$('#pms-verify-status').fadeIn('fast');
|
||||
|
|
1652
lib/IPy.py
Normal file
1652
lib/IPy.py
Normal file
File diff suppressed because it is too large
Load diff
|
@ -15,6 +15,7 @@
|
|||
|
||||
from operator import itemgetter
|
||||
from xml.dom import minidom
|
||||
from IPy import IP
|
||||
|
||||
import unicodedata
|
||||
import plexpy
|
||||
|
@ -28,7 +29,7 @@ import os
|
|||
import json
|
||||
import xmltodict
|
||||
import math
|
||||
|
||||
import socket
|
||||
|
||||
def multikeysort(items, columns):
|
||||
comparers = [((itemgetter(col[1:].strip()), -1) if col.startswith('-') else (itemgetter(col.strip()), 1)) for col in columns]
|
||||
|
@ -455,4 +456,27 @@ def sanitize(string):
|
|||
if string:
|
||||
return unicode(string).replace('<','<').replace('>','>')
|
||||
else:
|
||||
return ''
|
||||
return ''
|
||||
|
||||
def is_ip_public(host):
|
||||
ip_address = get_ip(host)
|
||||
ip = IP(ip_address)
|
||||
if ip.iptype() == 'PUBLIC':
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def get_ip(host):
|
||||
from plexpy import logger
|
||||
ip_address = ''
|
||||
try:
|
||||
socket.inet_aton(host)
|
||||
ip_address = host
|
||||
except socket.error:
|
||||
try:
|
||||
ip_address = socket.gethostbyname(host)
|
||||
logger.debug(u"IP Checker :: Resolved %s to %s." % (host, ip_address))
|
||||
except:
|
||||
logger.error(u"IP Checker :: Bad IP or hostname provided.")
|
||||
|
||||
return ip_address
|
||||
|
|
|
@ -86,7 +86,7 @@ def get_real_pms_url():
|
|||
plexpy.CONFIG.__setattr__('PMS_URL', item['uri'])
|
||||
plexpy.CONFIG.write()
|
||||
logger.info(u"PlexPy PlexTV :: Server URL retrieved.")
|
||||
if not plexpy.CONFIG.PMS_IS_REMOTE and item['local'] == '1':
|
||||
if not plexpy.CONFIG.PMS_IS_REMOTE and item['local'] == '1' and 'plex.direct' in item['uri']:
|
||||
plexpy.CONFIG.__setattr__('PMS_URL', item['uri'])
|
||||
plexpy.CONFIG.write()
|
||||
logger.info(u"PlexPy PlexTV :: Server URL retrieved.")
|
||||
|
@ -493,6 +493,16 @@ class PlexTV(object):
|
|||
connections = d.getElementsByTagName('Connection')
|
||||
|
||||
for c in connections:
|
||||
# If this is a remote server don't show any local IPs.
|
||||
if helpers.get_xml_attr(d, 'publicAddressMatches') == '0' and \
|
||||
helpers.get_xml_attr(c, 'local') == '1':
|
||||
continue
|
||||
|
||||
# If this is a local server don't show any remote IPs.
|
||||
if helpers.get_xml_attr(d, 'publicAddressMatches') == '1' and \
|
||||
helpers.get_xml_attr(c, 'local') == '0':
|
||||
continue
|
||||
|
||||
server = {'httpsRequired': helpers.get_xml_attr(d, 'httpsRequired'),
|
||||
'clientIdentifier': helpers.get_xml_attr(d, 'clientIdentifier'),
|
||||
'label': helpers.get_xml_attr(d, 'name'),
|
||||
|
|
|
@ -37,10 +37,13 @@ def start_thread():
|
|||
def run():
|
||||
from websocket import create_connection
|
||||
|
||||
uri = 'ws://%s:%s/:/websockets/notifications' % (
|
||||
plexpy.CONFIG.PMS_IP,
|
||||
plexpy.CONFIG.PMS_PORT
|
||||
)
|
||||
if plexpy.CONFIG.PMS_SSL and plexpy.CONFIG.PMS_URL[:5] == 'https':
|
||||
uri = plexpy.CONFIG.PMS_URL.replace('https://', 'wss://') + '/:/websockets/notifications'
|
||||
else:
|
||||
uri = 'ws://%s:%s/:/websockets/notifications' % (
|
||||
plexpy.CONFIG.PMS_IP,
|
||||
plexpy.CONFIG.PMS_PORT
|
||||
)
|
||||
|
||||
# Set authentication token (if one is available)
|
||||
if plexpy.CONFIG.PMS_TOKEN:
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# along with PlexPy. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from plexpy import logger, notifiers, plextv, pmsconnect, common, log_reader, datafactory, graphs, users, libraries
|
||||
from plexpy.helpers import checked, radio
|
||||
from plexpy.helpers import checked, radio, get_ip
|
||||
|
||||
from mako.lookup import TemplateLookup
|
||||
from mako import exceptions
|
||||
|
@ -1187,6 +1187,16 @@ class WebInterface(object):
|
|||
(kwargs['monitor_remote_access'] != plexpy.CONFIG.MONITOR_REMOTE_ACCESS):
|
||||
reschedule = True
|
||||
|
||||
# If we change the SSL setting for PMS, make sure we grab the new url.
|
||||
if 'pms_ssl' in kwargs and \
|
||||
(kwargs['pms_ssl'] != plexpy.CONFIG.PMS_SSL):
|
||||
server_changed = True
|
||||
|
||||
# If we change the PMS remote setting, make sure we grab the new url.
|
||||
if 'pms_is_remote' in kwargs and \
|
||||
(kwargs['pms_is_remote'] != plexpy.CONFIG.PMS_IS_REMOTE):
|
||||
server_changed = True
|
||||
|
||||
# Remove config with 'hscard-' prefix and change home_stats_cards to list
|
||||
if 'home_stats_cards' in kwargs:
|
||||
for k in kwargs.keys():
|
||||
|
@ -1402,9 +1412,10 @@ class WebInterface(object):
|
|||
if not identifier and hostname and port:
|
||||
plex_tv = plextv.PlexTV()
|
||||
servers = plex_tv.discover()
|
||||
ip_address = get_ip(hostname)
|
||||
|
||||
for server in servers:
|
||||
if server['ip'] == hostname and server['port'] == port:
|
||||
if (server['ip'] == hostname or server['ip'] == ip_address) and server['port'] == port:
|
||||
identifier = server['clientIdentifier']
|
||||
break
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue