chore: move root path for all resources under /ssh

This commit is contained in:
Bill Church 2020-03-14 09:06:10 -04:00
parent 9a96637cb4
commit dd33a8b6b0
5 changed files with 22 additions and 18 deletions

View file

@ -5,7 +5,7 @@
<style> <style>
html, body {background-color: #000;height: 100%;margin: 0;}.dropup-content {display: none;} html, body {background-color: #000;height: 100%;margin: 0;}.dropup-content {display: none;}
</style> </style>
<link rel="stylesheet" href="/webssh2.css" /> <link rel="stylesheet" href="/ssh/webssh2.css" />
</head> </head>
<body> <body>
<div class="box"> <div class="box">
@ -20,6 +20,6 @@
<div id="status"></div> <div id="status"></div>
</div> </div>
</div> </div>
<script src="/webssh2.bundle.js" defer></script> <script src="/ssh/webssh2.bundle.js" defer></script>
</body> </body>
</html> </html>

File diff suppressed because one or more lines are too long

View file

@ -5,7 +5,7 @@
<style> <style>
html, body {background-color: #000;height: 100%;margin: 0;}.dropup-content {display: none;} html, body {background-color: #000;height: 100%;margin: 0;}.dropup-content {display: none;}
</style> </style>
<link rel="stylesheet" href="/webssh2.css" /> <link rel="stylesheet" href="/ssh/webssh2.css" />
</head> </head>
<body> <body>
<div class="box"> <div class="box">
@ -20,6 +20,6 @@
<div id="status"></div> <div id="status"></div>
</div> </div>
</div> </div>
<script src="/webssh2.bundle.js" defer></script> <script src="/ssh/webssh2.bundle.js" defer></script>
</body> </body>
</html> </html>

View file

@ -40,16 +40,20 @@ function resizeScreen () {
socket.emit('resize', { cols: term.cols, rows: term.rows }) socket.emit('resize', { cols: term.cols, rows: term.rows })
} }
if (document.location.pathname) { // if (document.location.pathname) {
var parts = document.location.pathname.split('/') // var parts = document.location.pathname.split('/')
var base = parts.slice(0, parts.length - 1).join('/') + '/' // var base = parts.slice(0, parts.length - 1).join('/') + '/'
var resource = base.substring(1) + 'socket.io' // var resource = base.substring(1) + 'socket.io'
socket = io.connect(null, { // console.log('document.location.pathname resource: ' + resource)
resource: resource
// socket = io.connect(null, {
// resource: resource,
// path: "/ssh/socket.io"
// })
// } else {
socket = io.connect({
path: "/ssh/socket.io"
}) })
} else {
socket = io.connect()
}
term.onData(function (data) { term.onData(function (data) {
socket.emit('data', data) socket.emit('data', data)
@ -173,7 +177,7 @@ function drawMenu (data) {
// reauthenticate // reauthenticate
function reauthSession () { // eslint-disable-line function reauthSession () { // eslint-disable-line
console.log('re-authenticating') console.log('re-authenticating')
window.location.href = '/reauth' window.location.href = '/ssh/reauth'
return false return false
} }

View file

@ -114,7 +114,7 @@ var server = require('http').Server(app)
var myutil = require('./util') var myutil = require('./util')
myutil.setDefaultCredentials(config.user.name, config.user.password, config.user.privatekey); myutil.setDefaultCredentials(config.user.name, config.user.password, config.user.privatekey);
var validator = require('validator') var validator = require('validator')
var io = require('socket.io')(server, { serveClient: false }) var io = require('socket.io')(server, { serveClient: false, path: '/ssh/socket.io' })
var socket = require('./socket') var socket = require('./socket')
var expressOptions = require('./expressOptions') var expressOptions = require('./expressOptions')
@ -126,9 +126,9 @@ if (config.accesslog) app.use(logger('common'))
app.disable('x-powered-by') app.disable('x-powered-by')
// static files // static files
app.use(express.static(publicPath, expressOptions)) app.use('/ssh', express.static(publicPath, expressOptions))
app.get('/reauth', function (req, res, next) { app.get('/ssh/reauth', function (req, res, next) {
var r = req.headers.referer || '/' var r = req.headers.referer || '/'
res.status(401).send('<!DOCTYPE html><html><head><meta http-equiv="refresh" content="0; url=' + r + '"></head><body bgcolor="#000"></body></html>') res.status(401).send('<!DOCTYPE html><html><head><meta http-equiv="refresh" content="0; url=' + r + '"></head><body bgcolor="#000"></body></html>')
}) })