|
| 1 | +/* |
| 2 | + * mxisd - Matrix Identity Server Daemon |
| 3 | + * Copyright (C) 2019 Kamax Sarl |
| 4 | + * |
| 5 | + * https://www.kamax.io/ |
| 6 | + * |
| 7 | + * This program is free software: you can redistribute it and/or modify |
| 8 | + * it under the terms of the GNU Affero General Public License as |
| 9 | + * published by the Free Software Foundation, either version 3 of the |
| 10 | + * License, or (at your option) any later version. |
| 11 | + * |
| 12 | + * This program is distributed in the hope that it will be useful, |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | + * GNU Affero General Public License for more details. |
| 16 | + * |
| 17 | + * You should have received a copy of the GNU Affero General Public License |
| 18 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | + */ |
| 20 | + |
| 21 | +package io.kamax.mxisd.http.undertow.handler; |
| 22 | + |
| 23 | +import io.undertow.server.HttpServerExchange; |
| 24 | + |
| 25 | +import java.util.concurrent.ThreadLocalRandom; |
| 26 | + |
| 27 | +public class InternalInfoHandler extends BasicHttpHandler { |
| 28 | + |
| 29 | + /* |
| 30 | + * This endpoint should never be called as being entierly custom as per instructions of New Vector, |
| 31 | + * the author of that endpoint. |
| 32 | + * |
| 33 | + * Used for the first time at https://github.com/matrix-org/synapse/pull/4681/files#diff-a73c645c44a17da6ab70f256da6b60afR41 |
| 34 | + * |
| 35 | + * Full context: https://matrix.to/#/!YkZelGRiqijtzXZODa:matrix.org/$15510967621328WMKVu:kamax.io?via=matrix.org |
| 36 | + * Room name: #matrix-spec |
| 37 | + * Room alias: #matrix-spec:matrix.org |
| 38 | + */ |
| 39 | + public static final String Path = "/_matrix/identity/api/{version}/internal-info"; |
| 40 | + |
| 41 | + @Override |
| 42 | + public void handleRequest(HttpServerExchange exchange) throws Exception { |
| 43 | + // We will return a random status code in all possible error codes |
| 44 | + int type = ThreadLocalRandom.current().nextInt(4, 6) * 100; // Random 4 or 5, times 100 |
| 45 | + int status = type + ThreadLocalRandom.current().nextInt(0, 100); // Random 0 to 99 |
| 46 | + |
| 47 | + respond(exchange, status, "M_FORBIDDEN", "This endpoint is under quarantine and possibly wrongfully labeled stable."); |
| 48 | + } |
| 49 | + |
| 50 | +} |
0 commit comments