cp dines
This commit is contained in:
parent
5d62a0bc1d
commit
4c60362e85
2 changed files with 18 additions and 65 deletions
|
@ -35,20 +35,10 @@ const expressConfig = {
|
|||
const app = express();
|
||||
const server = require('http').createServer(app);
|
||||
const io = require('socket.io')(server, { transports: ['websocket'], ...config.socketio });
|
||||
const session = require('express-session')(expressConfig);
|
||||
|
||||
const appSocket = require('./socket');
|
||||
// const { setDefaultCredentials } = require('./util');
|
||||
const { webssh2debug } = require('./logging');
|
||||
const { connect } = require('./routes');
|
||||
|
||||
// setDefaultCredentials(config.user);
|
||||
|
||||
// safe shutdown
|
||||
|
||||
let shutdownMode = false;
|
||||
let shutdownInterval;
|
||||
let connectionCount = 0;
|
||||
// eslint-disable-next-line consistent-return
|
||||
function safeShutdownGuard(req, res, next) {
|
||||
if (!shutdownMode) return next();
|
||||
|
@ -56,8 +46,7 @@ function safeShutdownGuard(req, res, next) {
|
|||
}
|
||||
// express
|
||||
app.use(safeShutdownGuard);
|
||||
// app.use(session);
|
||||
if (config.accesslog) app.use(logger('common'));
|
||||
|
||||
app.disable('x-powered-by');
|
||||
app.use(express.urlencoded({ extended: true }));
|
||||
app.post('/ssh/host/:host?', connect);
|
||||
|
@ -83,21 +72,21 @@ io.on('connection', appSocket);
|
|||
|
||||
module.exports = { server, config };
|
||||
|
||||
const onConnection = (socket) => {
|
||||
console.log('connected');
|
||||
connectionCount += 1;
|
||||
socket.on('disconnect', () => {
|
||||
connectionCount -= 1;
|
||||
if (connectionCount <= 0 && shutdownMode) {
|
||||
stopApp('All clients disconnected');
|
||||
}
|
||||
});
|
||||
socket.on('geometry', (cols, rows) => {
|
||||
// TODO need to rework how we pass settings to ssh2, this is less than ideal
|
||||
//socket.request.session.ssh.cols = cols; //TODO make this part of the terminal config on connect
|
||||
//socket.request.session.ssh.rows = rows;
|
||||
//webssh2debug(socket, `SOCKET GEOMETRY: termCols = ${cols}, termRows = ${rows}`);
|
||||
});
|
||||
};
|
||||
// const onConnection = (socket) => {
|
||||
// console.log('connected');
|
||||
// connectionCount += 1;
|
||||
// socket.on('disconnect', () => {
|
||||
// connectionCount -= 1;
|
||||
// if (connectionCount <= 0 && shutdownMode) {
|
||||
// stopApp('All clients disconnected');
|
||||
// }
|
||||
// });
|
||||
// socket.on('geometry', (cols, rows) => {
|
||||
// // TODO need to rework how we pass settings to ssh2, this is less than ideal
|
||||
// //socket.request.session.ssh.cols = cols; //TODO make this part of the terminal config on connect
|
||||
// //socket.request.session.ssh.rows = rows; WHAT IS THis it seems to work without it
|
||||
// //webssh2debug(socket, `SOCKET GEOMETRY: termCols = ${cols}, termRows = ${rows}`);
|
||||
// });
|
||||
// };
|
||||
|
||||
io.on('connection', onConnection);
|
||||
// io.on('connection', onConnection);
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
<head><title>Post Test</title></head>
|
||||
<html>
|
||||
<body>
|
||||
<h1>Credentials over HTTP POST test</h1>
|
||||
<p>This is a test to demonstrate sending credentials over POST instead of requiring HTTP Basic. If you use this, be sure to secure the app/site with HTTPS!</p>
|
||||
<form method="POST" action="http://localhost:2222/ssh/host/192.168.0.1">
|
||||
<p>
|
||||
<label for="username">Username</label>
|
||||
<input name="username">
|
||||
</p>
|
||||
<label for="userpassword">Password</label>
|
||||
<input name="userpassword" type="password">
|
||||
</p>
|
||||
<p>
|
||||
<label for="header">Header text</label>
|
||||
<input name="header" value="This is a test">
|
||||
<p>
|
||||
<label for="headerBackground">Header Background Color</label>
|
||||
<input name="headerBackground" value="red">
|
||||
</p>
|
||||
<fieldset>
|
||||
<legend>Cursor Blink:</legend>
|
||||
<div>
|
||||
<input type="radio" id="false" name="cursorBlink" value="false"
|
||||
checked>
|
||||
<label for="false">False</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="radio" id="true" name="cursorBlink" value="true">
|
||||
<label for="true">True</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
<button>Login</button>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in a new issue