migrations

This commit is contained in:
William Mantly 2020-04-11 14:48:45 -04:00
parent 5266aec2b1
commit 1bf358565a
4 changed files with 21 additions and 3 deletions

17
nodejs/migrations/1.js Normal file
View File

@ -0,0 +1,17 @@
'use ';
const client = require('../utils/redis');
(async function(){
await client.rename('proxy_hosts', 'proxy_host');
let hosts = await client.SMEMBERS('proxy_host');
for(let host of hosts){
let user = await client.HGET('proxy_host_'+host, 'username');
await client.HSET('proxy_host_'+host, 'created_by', user);
let created_on = client.HGET('proxy_host_'+host, 'updated');
await client.HSET('proxy_host_'+host, 'created_on', created_on);
await client.HDEL('proxy_host_'+host, 'username');
await client.HDEL('proxy_host_'+host, 'updated')
}
})()

View File

@ -10,7 +10,7 @@ const Host = require('../utils/redis_model')({
'updated_on': {default: function(){return (new Date).getTime()}, always: true},
'host': {isRequired: true, type: 'string', min: 3, max: 500},
'ip': {isRequired: true, type: 'string', min: 3, max: 500},
'targetport': {isRequired: true, type: 'number', min:0, max:65535},
'targetPort': {isRequired: true, type: 'number', min:0, max:65535},
'forcessl': {isRequired: false, default: true, type: 'boolean'},
'targetssl': {isRequired: false, default: false, type: 'boolean'},
}

View File

@ -21,4 +21,5 @@ module.exports = {
HSET: promisify(_client.HSET).bind(_client),
HGETALL: promisify(_client.HGETALL).bind(_client),
SMEMBERS: promisify(_client.SMEMBERS).bind(_client),
RENAME: promisify(_client.RENAME).bind(_client),
};

View File

@ -73,7 +73,7 @@
if($form.attr('isValid') === 'true'){
var formdata = $form.serializeObject();
if(formdata.targetport) formdata.targetport = Number(formdata.targetport);
if(formdata.targetPort) formdata.targetPort = Number(formdata.targetPort);
if(formdata.targetssl) formdata.targetssl = formdata.targetssl == 'true' ? true : false;
if(formdata.forcessl) formdata.forcessl = formdata.forcessl == 'true' ? true : false;
@ -159,7 +159,7 @@
<div class="form-group">
<label class="control-label">Target TCP Port</label>
<input type="number" name="targetport" class="form-control" value="80" min="0" max="65535" />
<input type="number" name="targetPort" class="form-control" value="80" min="0" max="65535" />
</div>
<div class="form-group">