mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
fix: Use encrypted field to check for TLS.
This commit is contained in:
parent
bc088f494d
commit
82f90709a6
@ -1,4 +1,5 @@
|
|||||||
import { EventEmitter } from 'events';
|
import { EventEmitter } from 'events';
|
||||||
|
import type { TLSSocket } from 'tls';
|
||||||
import type { WebSocket } from 'ws';
|
import type { WebSocket } from 'ws';
|
||||||
import { getLoggerFor } from '../logging/LogUtil';
|
import { getLoggerFor } from '../logging/LogUtil';
|
||||||
import type { HttpRequest } from '../server/HttpRequest';
|
import type { HttpRequest } from '../server/HttpRequest';
|
||||||
@ -47,7 +48,7 @@ class WebSocketListener extends EventEmitter {
|
|||||||
// Store the HTTP host and protocol
|
// Store the HTTP host and protocol
|
||||||
const forwarded = parseForwarded(headers);
|
const forwarded = parseForwarded(headers);
|
||||||
this.host = forwarded.host ?? headers.host ?? 'localhost';
|
this.host = forwarded.host ?? headers.host ?? 'localhost';
|
||||||
this.protocol = forwarded.proto === 'https' || (socket as any).secure ? 'https:' : 'http:';
|
this.protocol = forwarded.proto === 'https' || (socket as TLSSocket).encrypted ? 'https:' : 'http:';
|
||||||
}
|
}
|
||||||
|
|
||||||
private stop(): void {
|
private stop(): void {
|
||||||
|
@ -25,7 +25,7 @@ describe('An UnsecureWebSocketsProtocol', (): void => {
|
|||||||
'sec-websocket-protocol': 'solid-0.1, other/1.0.0',
|
'sec-websocket-protocol': 'solid-0.1, other/1.0.0',
|
||||||
},
|
},
|
||||||
socket: {
|
socket: {
|
||||||
secure: true,
|
encrypted: true,
|
||||||
},
|
},
|
||||||
} as any as HttpRequest;
|
} as any as HttpRequest;
|
||||||
await protocol.handle({ webSocket, upgradeRequest } as any);
|
await protocol.handle({ webSocket, upgradeRequest } as any);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user