cp dines
This commit is contained in:
parent
bb1430caf3
commit
f9f44b7ab5
1 changed files with 26 additions and 29 deletions
|
@ -4,6 +4,7 @@
|
|||
// app.js
|
||||
|
||||
// eslint-disable-next-line import/order
|
||||
const config = require('./config');
|
||||
const path = require('path');
|
||||
|
||||
const nodeRoot = path.dirname(require.main.filename);
|
||||
|
@ -22,39 +23,35 @@ const staticFileConfig = {
|
|||
},
|
||||
};
|
||||
|
||||
const app = express();
|
||||
const server = require('http').createServer(app);
|
||||
const io = require('socket.io')(server, {
|
||||
transports: ['websocket'],
|
||||
serveClient: false,
|
||||
path: '/ssh/socket.io',
|
||||
origins: ['localhost:2224'],
|
||||
cors: { origin: '*' },
|
||||
});
|
||||
function startServer() {
|
||||
const app = express();
|
||||
const server = require('http').createServer(app);
|
||||
const io = require('socket.io')(server, {
|
||||
transports: ['websocket'],
|
||||
serveClient: false,
|
||||
path: '/ssh/socket.io',
|
||||
origins: ['localhost:2224'],
|
||||
cors: { origin: '*' },
|
||||
});
|
||||
|
||||
const appSocket = require('./socket');
|
||||
const { connectRoute: connect } = require('./routes');
|
||||
const appSocket = require('./socket');
|
||||
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, staticFileConfig));
|
||||
app.use('/ssh', express.static(publicPath, staticFileConfig));
|
||||
///
|
||||
app.get('/ssh/host/:host?', connect);
|
||||
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, staticFileConfig));
|
||||
app.use('/ssh', express.static(publicPath, staticFileConfig));
|
||||
// ===========================
|
||||
app.get('/ssh/host/:host?', connect);
|
||||
|
||||
io.on('connection', appSocket);
|
||||
io.on('connection', appSocket);
|
||||
}
|
||||
|
||||
startServer();
|
||||
|
||||
// // clean stop
|
||||
// function stopApp(reason) {
|
||||
// shutdownMode = false;
|
||||
// if (reason) console.info(`Stopping: ${reason}`);
|
||||
// clearInterval(shutdownInterval);
|
||||
// io.close();
|
||||
// server.close();
|
||||
// }
|
||||
module.exports = { server, config };
|
||||
|
||||
// const onConnection = (socket) => {
|
||||
|
|
Loading…
Reference in a new issue