clean up, prevent broken session sockets
This commit is contained in:
parent
295a9cfd1b
commit
dbffa4262a
11
app.js
11
app.js
@ -57,21 +57,11 @@ config = Object.assign({
|
||||
}, config)
|
||||
|
||||
// Constants
|
||||
const oauthAuth = '{server}/oauth2/authorize?response_type=code&state={state}&redirect_uri={redirect}&client_id={client}&scope=image'
|
||||
const port = parseInt(config['Streaming']['port'])
|
||||
const streamServer = config['Streaming']['streamServer']
|
||||
const streamServerHost = config['Streaming']['serverHost']
|
||||
const streamAppName = streamServer.match(/\/([\w-_]+)\/$/)[1]
|
||||
|
||||
function teval (str, obj) {
|
||||
let res = str + ''
|
||||
for (let key in obj) {
|
||||
if (res.indexOf('{' + key + '}') === -1) continue
|
||||
res = res.replace('{' + key + '}', obj[key])
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
// Database
|
||||
const dbPromise = Promise.resolve()
|
||||
.then(() => sqlite.open(path.join(process.cwd(), config['Streaming']['database']), { Promise, cache: true }))
|
||||
@ -486,6 +476,7 @@ wss.on('connection', (ws, request, client) => {
|
||||
// Handle upgrade, parse included session
|
||||
server.on('upgrade', (request, socket, head) => {
|
||||
sessionParser(request, {}, () => {
|
||||
if (!request.session || !request.session.id) return socket.destroy()
|
||||
if (request.session && request.session.passport) {
|
||||
request.user = request.session.passport.user
|
||||
}
|
||||
|
Reference in New Issue
Block a user