mirror of
https://github.com/signalapp/Signal-Server.git
synced 2026-12-02 14:06:53 +00:00
Add a health check handler to the Noise-over-WebSocket pipeline
This commit is contained in:
1 parent
907ff89011
commit
097bedcb9b
3 files changed
+24
-6
No files matched your search
+2
-1
@@ -41,6 +41,7 @@ public class NoiseWebSocketTunnelServer implements Managed {
|
||||
|
||||
static final String AUTHENTICATED_SERVICE_PATH = "/authenticated";
|
||||
static final String ANONYMOUS_SERVICE_PATH = "/anonymous";
|
||||
static final String HEALTH_CHECK_PATH = "/health-check";
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(NoiseWebSocketTunnelServer.class);
|
||||
|
||||
@@ -96,7 +97,7 @@ public class NoiseWebSocketTunnelServer implements Managed {
|
||||
.addLast(new HttpObjectAggregator(Noise.MAX_PACKET_LEN))
|
||||
// The WebSocket opening handshake handler will remove itself from the pipeline once it has received a valid WebSocket upgrade
|
||||
// request and passed it down the pipeline
|
||||
.addLast(new WebSocketOpeningHandshakeHandler(AUTHENTICATED_SERVICE_PATH, ANONYMOUS_SERVICE_PATH))
|
||||
.addLast(new WebSocketOpeningHandshakeHandler(AUTHENTICATED_SERVICE_PATH, ANONYMOUS_SERVICE_PATH, HEALTH_CHECK_PATH))
|
||||
.addLast(new WebSocketServerProtocolHandler("/", true))
|
||||
.addLast(new RejectUnsupportedMessagesHandler())
|
||||
// The WebSocket handshake complete listener will replace itself with an appropriate Noise handshake handler once
|
||||
|
||||
+8
-1
@@ -19,10 +19,15 @@ class WebSocketOpeningHandshakeHandler extends ChannelInboundHandlerAdapter {
|
||||
|
||||
private final String authenticatedPath;
|
||||
private final String anonymousPath;
|
||||
private final String healthCheckPath;
|
||||
|
||||
WebSocketOpeningHandshakeHandler(final String authenticatedPath,
|
||||
final String anonymousPath,
|
||||
final String healthCheckPath) {
|
||||
|
||||
WebSocketOpeningHandshakeHandler(final String authenticatedPath, final String anonymousPath) {
|
||||
this.authenticatedPath = authenticatedPath;
|
||||
this.anonymousPath = anonymousPath;
|
||||
this.healthCheckPath = healthCheckPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,6 +48,8 @@ class WebSocketOpeningHandshakeHandler extends ChannelInboundHandlerAdapter {
|
||||
} else {
|
||||
closeConnectionWithStatus(context, request, HttpResponseStatus.UPGRADE_REQUIRED);
|
||||
}
|
||||
} else if (healthCheckPath.equals(request.uri())) {
|
||||
closeConnectionWithStatus(context, request, HttpResponseStatus.NO_CONTENT);
|
||||
} else {
|
||||
closeConnectionWithStatus(context, request, HttpResponseStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user