@Override
    protected Optional<ErrorResponse> filter(DiscFilterRequest request) {
        InetAddress remoteAddr = InetAddresses.forString(request.getRemoteAddr());
        if (!remoteAddr.isLoopbackAddress() && !request.getRemoteAddr().equals(request.getLocalAddr())) {
            return Optional.of(new ErrorResponse(
                    Response.Status.UNAUTHORIZED,
                    String.format("%s %s denied for %s: Unauthorized host", request.getMethod(),
                                  request.getUri().getPath(), request.getRemoteAddr())));
        }
        return Optional.empty();
    }
@Test
    void filter() {
        // Reject from non-loopback
        assertUnauthorized(createRequest("1.2.3.4", null));

        // Allow requests from loopback addresses
        assertSuccess(createRequest("127.0.0.1", null));
        assertSuccess(createRequest("127.127.0.1", null));
        assertSuccess(createRequest("0:0:0:0:0:0:0:1", null));

        // Allow requests originating from self
        assertSuccess(createRequest("1.3.3.7", "1.3.3.7"));
    }