vagrant up
This commit is contained in:
@ -21,13 +21,18 @@ async function listAll(){
|
||||
|
||||
|
||||
async function add(data){
|
||||
|
||||
try{
|
||||
await client.SADD('hosts', data.host);
|
||||
await client.HSET('host_' + data.host, 'ip', data.ip);
|
||||
await client.HSET('host_' + data.host, 'updated', (new Date).getTime());
|
||||
await client.HSET('host_' + data.host, 'username', data.username);
|
||||
await client.HSET('host_' + data.host, 'targetPort', data.targetPort);
|
||||
if(data.forceSSL !== undefined){
|
||||
await client.HSET('host_' + data.host, 'force_ssl', !!data.forceSSL);
|
||||
await client.HSET('host_' + data.host, 'forcessl', !!data.forceSSL);
|
||||
}
|
||||
if(data.targetSSL !== undefined){
|
||||
await client.HSET('host_' + data.host, 'targetssl', !!data.targetSSL);
|
||||
}
|
||||
} catch (error){
|
||||
|
||||
|
@ -27,17 +27,19 @@ router.get('/', async function(req, res){
|
||||
router.post('/', async function(req, res){
|
||||
let ip = req.body.ip;
|
||||
let host = req.body.host;
|
||||
let targetPort = req.body.targetPort;
|
||||
|
||||
if(!host || !ip){
|
||||
if(!host || !ip || !targetPort ){
|
||||
return res.status(400).json({
|
||||
message: `Missing fields: ${!host ? 'host' : ''} ${!ip ? 'ip' : ''}`
|
||||
message: `Missing fields: ${!host ? 'host' : ''} ${!ip ? 'ip' : ''} ${!targetPort ? 'targetPort' : ''}`
|
||||
});
|
||||
}
|
||||
|
||||
try{
|
||||
await Host.add({host, ip,
|
||||
await Host.add({host, ip, targetPort,
|
||||
username: req.user.username,
|
||||
forceSSL: req.body.forceSSL
|
||||
forceSSL: req.body.forceSSL,
|
||||
targetSSL: req.body.targetSSL,
|
||||
});
|
||||
|
||||
return res.json({
|
||||
|
Reference in New Issue
Block a user