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
|
// app.js
|
||||||
|
|
||||||
// eslint-disable-next-line import/order
|
// eslint-disable-next-line import/order
|
||||||
|
const config = require('./config');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
const nodeRoot = path.dirname(require.main.filename);
|
const nodeRoot = path.dirname(require.main.filename);
|
||||||
|
@ -22,39 +23,35 @@ const staticFileConfig = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const app = express();
|
function startServer() {
|
||||||
const server = require('http').createServer(app);
|
const app = express();
|
||||||
const io = require('socket.io')(server, {
|
const server = require('http').createServer(app);
|
||||||
|
const io = require('socket.io')(server, {
|
||||||
transports: ['websocket'],
|
transports: ['websocket'],
|
||||||
serveClient: false,
|
serveClient: false,
|
||||||
path: '/ssh/socket.io',
|
path: '/ssh/socket.io',
|
||||||
origins: ['localhost:2224'],
|
origins: ['localhost:2224'],
|
||||||
cors: { origin: '*' },
|
cors: { origin: '*' },
|
||||||
});
|
});
|
||||||
|
|
||||||
const appSocket = require('./socket');
|
const appSocket = require('./socket');
|
||||||
const { connectRoute: connect } = require('./routes');
|
const { connectRoute: connect } = require('./routes');
|
||||||
|
|
||||||
app.disable('x-powered-by');
|
app.disable('x-powered-by');
|
||||||
app.use(express.urlencoded({ extended: true }));
|
app.use(express.urlencoded({ extended: true }));
|
||||||
app.post('/ssh/host/:host?', connect);
|
app.post('/ssh/host/:host?', connect);
|
||||||
// To remove
|
// ======== To remove ========
|
||||||
// Static files..
|
// Static files..
|
||||||
app.post('/ssh', express.static(publicPath, staticFileConfig));
|
app.post('/ssh', express.static(publicPath, staticFileConfig));
|
||||||
app.use('/ssh', express.static(publicPath, staticFileConfig));
|
app.use('/ssh', express.static(publicPath, staticFileConfig));
|
||||||
///
|
// ===========================
|
||||||
app.get('/ssh/host/:host?', connect);
|
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 };
|
module.exports = { server, config };
|
||||||
|
|
||||||
// const onConnection = (socket) => {
|
// const onConnection = (socket) => {
|
||||||
|
|
Loading…
Reference in a new issue