Host or IP specified for Proxy Host Forward

This commit is contained in:
Jamie Curnow 2018-10-19 15:38:14 +10:00
parent 0b8a49469f
commit dba4340548
9 changed files with 54 additions and 24 deletions

View File

@ -354,7 +354,7 @@ module.exports = function () {
.insertAndFetch({
owner_user_id: 1,
domain_names: [host.hostname],
forward_ip: host.forward_server,
forward_host: host.forward_server,
forward_port: host.forward_port,
access_list_id: access_list_id,
certificate_id: certificate_id,

View File

@ -0,0 +1,36 @@
'use strict';
const migrate_name = 'forward_host';
const logger = require('../logger').migrate;
/**
* Migrate
*
* @see http://knexjs.org/#Schema
*
* @param {Object} knex
* @param {Promise} Promise
* @returns {Promise}
*/
exports.up = function (knex/*, Promise*/) {
logger.info('[' + migrate_name + '] Migrating Up...');
return knex.schema.table('proxy_host', function (proxy_host) {
proxy_host.renameColumn('forward_ip', 'forward_host');
})
.then(() => {
logger.info('[' + migrate_name + '] proxy_host Table altered');
});
};
/**
* Undo Migrate
*
* @param {Object} knex
* @param {Promise} Promise
* @returns {Promise}
*/
exports.down = function (knex, Promise) {
logger.warn('[' + migrate_name + '] You can\'t migrate down this one.');
return Promise.resolve(true);
};

View File

@ -18,9 +18,10 @@
"domain_names": {
"$ref": "../definitions.json#/definitions/domain_names"
},
"forward_ip": {
"forward_host": {
"type": "string",
"format": "ipv4"
"minLength": 1,
"maxLength": 50
},
"forward_port": {
"type": "integer",
@ -67,8 +68,8 @@
"domain_names": {
"$ref": "#/definitions/domain_names"
},
"forward_ip": {
"$ref": "#/definitions/forward_ip"
"forward_host": {
"$ref": "#/definitions/forward_host"
},
"forward_port": {
"$ref": "#/definitions/forward_port"
@ -131,15 +132,15 @@
"additionalProperties": false,
"required": [
"domain_names",
"forward_ip",
"forward_host",
"forward_port"
],
"properties": {
"domain_names": {
"$ref": "#/definitions/domain_names"
},
"forward_ip": {
"$ref": "#/definitions/forward_ip"
"forward_host": {
"$ref": "#/definitions/forward_host"
},
"forward_port": {
"$ref": "#/definitions/forward_port"
@ -193,8 +194,8 @@
"domain_names": {
"$ref": "#/definitions/domain_names"
},
"forward_ip": {
"$ref": "#/definitions/forward_ip"
"forward_host": {
"$ref": "#/definitions/forward_host"
},
"forward_port": {
"$ref": "#/definitions/forward_port"

View File

@ -1,7 +1,7 @@
{% include "_header_comment.conf" %}
server {
set $server {{ forward_ip }};
set $server "{{ forward_host }}";
set $port {{ forward_port }};
{% include "_listen.conf" %}

View File

@ -22,8 +22,8 @@
</div>
<div class="col-sm-8 col-md-8">
<div class="form-group">
<label class="form-label"><%- i18n('proxy-hosts', 'forward-ip') %><span class="form-required">*</span></label>
<input type="text" name="forward_ip" class="form-control text-monospace" placeholder="000.000.000.000" value="<%- forward_ip %>" autocomplete="off" maxlength="15" required>
<label class="form-label"><%- i18n('proxy-hosts', 'forward-host') %><span class="form-required">*</span></label>
<input type="text" name="forward_host" class="form-control text-monospace" placeholder="" value="<%- forward_host %>" autocomplete="off" maxlength="50" required>
</div>
</div>
<div class="col-sm-4 col-md-4">

View File

@ -9,7 +9,6 @@ const accessListItemTemplate = require('./access-list-item.ejs');
const Helpers = require('../../../lib/helpers');
require('jquery-serializejson');
require('jquery-mask-plugin');
require('selectize');
module.exports = Mn.View.extend({
@ -19,7 +18,7 @@ module.exports = Mn.View.extend({
ui: {
form: 'form',
domain_names: 'input[name="domain_names"]',
forward_ip: 'input[name="forward_ip"]',
forward_host: 'input[name="forward_host"]',
buttons: '.modal-footer button',
cancel: 'button.cancel',
save: 'button.save',
@ -123,12 +122,6 @@ module.exports = Mn.View.extend({
onRender: function () {
let view = this;
// IP Address
this.ui.forward_ip.mask('099.099.099.099', {
clearIfNotMatch: true,
placeholder: '000.000.000.000'
});
// Domain names
this.ui.domain_names.selectize({
delimiter: ',',

View File

@ -17,7 +17,7 @@
</div>
</td>
<td>
<div class="text-monospace"><%- forward_ip %>:<%- forward_port %></div>
<div class="text-monospace"><%- forward_host %>:<%- forward_port %></div>
</td>
<td>
<div><%- certificate && certificate_id ? i18n('ssl', certificate.provider) : i18n('ssl', 'none') %></div>

View File

@ -92,7 +92,7 @@
"empty": "There are no Proxy Hosts",
"add": "Add Proxy Host",
"form-title": "{id, select, undefined{New} other{Edit}} Proxy Host",
"forward-ip": "Forward IP",
"forward-host": "Forward Hostname / IP",
"forward-port": "Forward Port",
"delete": "Delete Proxy Host",
"delete-confirm": "Are you sure you want to delete the Proxy host for: <strong>{domains}</strong>?",

View File

@ -11,7 +11,7 @@ const model = Backbone.Model.extend({
created_on: null,
modified_on: null,
domain_names: [],
forward_ip: '',
forward_host: '',
forward_port: null,
access_list_id: 0,
certificate_id: 0,