cp dines
This commit is contained in:
parent
576af8aad0
commit
82eadf92f5
4 changed files with 25 additions and 32 deletions
|
@ -10,25 +10,16 @@ const path = require('path');
|
|||
const nodeRoot = path.dirname(require.main.filename);
|
||||
const publicPath = path.join(nodeRoot, 'client', 'public');
|
||||
const express = require('express');
|
||||
const logger = require('morgan');
|
||||
const crypto = require('crypto');
|
||||
|
||||
const expressConfig = {
|
||||
secret: crypto.randomBytes(20).toString('hex'),
|
||||
name: 'WebSSH2',
|
||||
resave: true,
|
||||
saveUninitialized: false,
|
||||
unset: 'destroy',
|
||||
ssh: {
|
||||
dotfiles: 'ignore',
|
||||
etag: false,
|
||||
extensions: ['htm', 'html'],
|
||||
index: false,
|
||||
maxAge: '1s',
|
||||
redirect: false,
|
||||
setHeaders(res) {
|
||||
res.set('x-timestamp', Date.now());
|
||||
},
|
||||
const staticFileConfig = {
|
||||
dotfiles: 'ignore',
|
||||
etag: false,
|
||||
extensions: ['htm', 'html'],
|
||||
index: false,
|
||||
maxAge: '1s',
|
||||
redirect: false,
|
||||
setHeaders(res) {
|
||||
res.set('x-timestamp', Date.now());
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -37,15 +28,15 @@ const server = require('http').createServer(app);
|
|||
const io = require('socket.io')(server, { transports: ['websocket'], ...config.socketio });
|
||||
|
||||
const appSocket = require('./socket');
|
||||
const { connect } = require('./routes');
|
||||
const { connectRoute: connect } = require('./routes');
|
||||
|
||||
app.disable('x-powered-by');
|
||||
app.use(express.urlencoded({ extended: true }));
|
||||
app.post('/ssh/host/:host?', connect);
|
||||
// To remove
|
||||
// Static files..
|
||||
app.post('/ssh', express.static(publicPath, expressConfig.ssh));
|
||||
app.use('/ssh', express.static(publicPath, expressConfig.ssh));
|
||||
app.post('/ssh', express.static(publicPath, staticFileConfig));
|
||||
app.use('/ssh', express.static(publicPath, staticFileConfig));
|
||||
///
|
||||
app.get('/ssh/host/:host?', connect);
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ const nodeRoot = path.dirname(require.main.filename);
|
|||
|
||||
const publicPath = path.join(nodeRoot, 'client', 'public');
|
||||
|
||||
exports.connect = function connect(req, res) {
|
||||
exports.connectRoute = function connectRoute(req, res) {
|
||||
res.sendFile(path.join(path.join(publicPath, 'client.htm')));
|
||||
|
||||
// let { host, port } = config.ssh;
|
||||
|
|
|
@ -2,9 +2,8 @@ const debugWebSSH2 = require('debug')('WebSSH2');
|
|||
const debug = require('debug');
|
||||
const { Client } = require('ssh2');
|
||||
const tls = require('tls');
|
||||
const forge = require('node-forge');
|
||||
|
||||
const { Runloop } = require('@runloop/api-client');
|
||||
const { convertPKCS8toPKCS1 } = require('./util');
|
||||
|
||||
// Function to create a TLS connection (simulating ProxyCommand with openssl s_client)
|
||||
function tlsProxyConnect(hostname, callback) {
|
||||
|
@ -206,11 +205,3 @@ module.exports = function appSocket(socket) {
|
|||
}
|
||||
setupConnection();
|
||||
};
|
||||
|
||||
function convertPKCS8toPKCS1(pkcs8Key) {
|
||||
const privateKeyInfo = forge.pki.privateKeyFromPem(pkcs8Key);
|
||||
|
||||
// Convert the private key to PKCS#1 format
|
||||
const pkcs1Pem = forge.pki.privateKeyToPem(privateKeyInfo);
|
||||
return pkcs1Pem;
|
||||
}
|
||||
|
|
11
app/server/util.js
Normal file
11
app/server/util.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
const forge = require('node-forge');
|
||||
|
||||
function convertPKCS8toPKCS1(pkcs8Key) {
|
||||
const privateKeyInfo = forge.pki.privateKeyFromPem(pkcs8Key);
|
||||
|
||||
// Convert the private key to PKCS#1 format
|
||||
const pkcs1Pem = forge.pki.privateKeyToPem(privateKeyInfo);
|
||||
return pkcs1Pem;
|
||||
}
|
||||
|
||||
module.exports = { convertPKCS8toPKCS1 };
|
Loading…
Reference in a new issue