added reverse proxy mode

This commit is contained in:
Anders Jensen
2018-08-24 21:20:53 +02:00
parent 37753a23e4
commit 7aed811b78
5 changed files with 117 additions and 20 deletions

View File

@@ -47,7 +47,7 @@ The _allow remote_ option is to allow remote add and stream of torrents.
* [x] Add RAR streaming support
* [ ] Better feedback in interface about streams
* [ ] Better feedback when using API
* [ ] Reverse proxy improvement (e.g. port different than bind port)
* [x] Reverse proxy improvement (e.g. port different than bind port)
# Version Info
@@ -55,6 +55,7 @@ The _allow remote_ option is to allow remote add and stream of torrents.
* Rewrote large parts of the code
* Now using [thomas](https://github.com/JohnDoee/thomas) as file-reading core - this adds support for multi-rar streaming.
* Faster streaming by reading directly from disk
* Reverse proxy mode
## Version 0.9.0
* Few bugfixes

View File

@@ -81,6 +81,8 @@ DEFAULT_PREFS = {
'use_ssl': False,
'remote_username': 'stream',
'remote_password': ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(16)),
'reverse_proxy_enabled': False,
'reverse_proxy_base_url': '',
'serve_method': 'standalone',
'ssl_source': 'daemon',
'ssl_priv_key_path': '',
@@ -675,12 +677,17 @@ class Core(CorePluginBase):
else:
raise NotImplementedError()
if self.config['reverse_proxy_enabled'] and self.config['reverse_proxy_base_url']:
self.base_url = self.config['reverse_proxy_base_url']
else:
self.base_url += '://'
if ':' in ip:
self.base_url += ip
else:
self.base_url += '%s:%s' % (ip, port)
self.base_url = self.base_url.rstrip('/')
@defer.inlineCallbacks
def disable(self):
self.site.stopFactory()

View File

@@ -166,6 +166,70 @@
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox54">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<widget class="GtkCheckButton" id="input_reverse_proxy_enabled">
<property name="label" translatable="yes">Enable Reverse Proxy</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox55">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<widget class="GtkLabel" id="reverse_proxy_base_url_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Reverse Proxy Base Url: </property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="input_reverse_proxy_base_url">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="primary_icon_activatable">False</property>
<property name="secondary_icon_activatable">False</property>
<property name="primary_icon_sensitive">True</property>
<property name="secondary_icon_sensitive">True</property>
</widget>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<!-- <child>
<widget class="GtkRadioButton" id="input_serve_webui">
<property name="label" translatable="yes">Serve files via WebUI</property>
@@ -371,7 +435,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
<property name="position">5</property>
</packing>
</child>
</widget>

View File

@@ -35,7 +35,10 @@ PreferencePage = Ext.extend(Ext.Panel, {
title: 'Streaming',
border: false,
layout: 'form',
header: false,
autoScroll: true,
autoHeight: true,
width: 320,
_fields: {},
initComponent: function() {
@@ -50,10 +53,12 @@ PreferencePage = Ext.extend(Ext.Panel, {
title: 'Settings',
style: 'margin-bottom: 0px; padding-bottom: 0px; padding-top: 5px',
autoHeight: true,
labelWidth: 1,
labelAlign: 'top',
labelWidth: 150,
width: 300,
defaultType: 'textfield',
defaults: {
width: 180,
width: 280,
}
});
@@ -69,10 +74,12 @@ PreferencePage = Ext.extend(Ext.Panel, {
title: 'File Serving Settings',
style: 'margin-bottom: 0px; padding-bottom: 0px; padding-top: 5px',
autoHeight: true,
labelWidth: 110,
labelAlign: 'top',
labelWidth: 150,
width: 280,
defaultType: 'textfield',
defaults: {
width: 180,
width: 260,
}
});
@@ -89,13 +96,22 @@ PreferencePage = Ext.extend(Ext.Panel, {
maxValue: 99999,
}));
var field = fieldset.add({
xtype: 'togglefield',
name: 'reverse_proxy_base_url',
fieldLabel: 'Reverse Proxy Config',
});
om.bind('reverse_proxy_enabled', field.toggle);
om.bind('reverse_proxy_base_url', field.input);
fieldset = this.add({
xtype: 'fieldset',
border: false,
autoHeight: true,
defaultType: 'radio',
style: 'margin-bottom: 5px; margin-top: 0; padding-bottom: 5px; padding-top: 0;',
width: 240,
width: 280,
labelWidth: 1
});
@@ -130,7 +146,7 @@ PreferencePage = Ext.extend(Ext.Panel, {
autoHeight: true,
defaultType: 'radio',
style: 'margin-left: 24px; margin-bottom: 5px; margin-top: 0; padding-bottom: 5px; padding-top: 0;',
width: 240,
width: 280,
labelWidth: 1
});
@@ -164,12 +180,12 @@ PreferencePage = Ext.extend(Ext.Panel, {
om.bind('ssl_priv_key_path', fieldset.add({
name: 'ssl_priv_key_path',
fieldLabel: 'Private key file path'
fieldLabel: 'Private key file path',
}));
om.bind('ssl_cert_path', fieldset.add({
name: 'ssl_cert_path',
fieldLabel: 'Certificate and chains file path'
fieldLabel: 'Certificate and chains file path',
}));
fieldset = this.add({
@@ -178,10 +194,12 @@ PreferencePage = Ext.extend(Ext.Panel, {
title: 'Advanced settings',
style: 'margin-bottom: 0px; padding-bottom: 0px; padding-top: 5px',
autoHeight: true,
labelWidth: 1,
labelAlign: 'top',
labelWidth: 150,
width: 280,
defaultType: 'textfield',
defaults: {
width: 180,
width: 260,
}
});
@@ -189,7 +207,8 @@ PreferencePage = Ext.extend(Ext.Panel, {
xtype: 'checkbox',
name: 'allow_remote',
boxLabel: 'Allow remote control',
style: 'margin-left: 12px;'
style: 'margin-left: 12px;',
width: 150
}));
fieldset = this.add({
@@ -197,10 +216,12 @@ PreferencePage = Ext.extend(Ext.Panel, {
border: false,
style: 'margin-bottom: 0px; padding-bottom: 0px; padding-top: 5px',
autoHeight: true,
labelWidth: 110,
labelAlign: 'top',
labelWidth: 150,
width: 260,
defaultType: 'textfield',
defaults: {
width: 180,
width: 240,
}
});
@@ -232,7 +253,7 @@ PreferencePage = Ext.extend(Ext.Panel, {
labelWidth: 1,
defaultType: 'textfield',
defaults: {
width: 180,
width: 200,
}
});

View File

@@ -142,9 +142,11 @@ class GtkUI(GtkPluginBase):
"auto_open_stream_urls": self.glade.get_widget("input_auto_open_stream_urls").get_active(),
"allow_remote": self.glade.get_widget("input_allow_remote").get_active(),
"download_only_streamed": self.glade.get_widget("input_download_only_streamed").get_active(),
"reverse_proxy_enabled": self.glade.get_widget("input_reverse_proxy_enabled").get_active(),
# "download_in_order": self.glade.get_widget("input_download_in_order").get_active(),
"use_ssl": self.glade.get_widget("input_use_ssl").get_active(),
# "remote_username": self.glade.get_widget("input_remote_username").get_text(),
"reverse_proxy_base_url": self.glade.get_widget("input_reverse_proxy_base_url").get_text(),
"remote_password": self.glade.get_widget("input_remote_password").get_text(),
"ssl_priv_key_path": self.glade.get_widget("input_ssl_priv_key_path").get_text(),
"ssl_cert_path": self.glade.get_widget("input_ssl_cert_path").get_text(),
@@ -175,9 +177,11 @@ class GtkUI(GtkPluginBase):
self.glade.get_widget("input_allow_remote").set_active(config["allow_remote"])
self.glade.get_widget("input_use_ssl").set_active(config["use_ssl"])
self.glade.get_widget("input_download_only_streamed").set_active(config["download_only_streamed"])
self.glade.get_widget("input_reverse_proxy_enabled").set_active(config["reverse_proxy_enabled"])
# self.glade.get_widget("input_download_in_order").set_active(config["download_in_order"])
# self.glade.get_widget("input_download_everything").set_active(not config["download_in_order"] and not config["download_only_streamed"])
# self.glade.get_widget("input_remote_username").set_text(config["remote_username"])
self.glade.get_widget("input_reverse_proxy_base_url").set_text(config["reverse_proxy_base_url"])
self.glade.get_widget("input_remote_password").set_text(config["remote_password"])
self.glade.get_widget("input_ssl_priv_key_path").set_text(config["ssl_priv_key_path"])
self.glade.get_widget("input_ssl_cert_path").set_text(config["ssl_cert_path"])