Add DNS diagnostics across dataplane and client
This commit is contained in:
@@ -4,7 +4,7 @@ import type { ConnectivityDiagnosticsUseCase } from '../../features/diagnostics/
|
||||
import { sendJson } from '../response.js';
|
||||
|
||||
interface ConnectivityDiagnosticsRouteDependencies {
|
||||
diagnostics: Pick<ConnectivityDiagnosticsUseCase, 'run' | 'updateSettings'>;
|
||||
diagnostics: Pick<ConnectivityDiagnosticsUseCase, 'run' | 'dnsCatalog' | 'runDns' | 'updateSettings'>;
|
||||
readBody(req: IncomingMessage): Promise<Record<string, unknown>>;
|
||||
sendState(res: ServerResponse): Promise<void>;
|
||||
}
|
||||
@@ -14,6 +14,15 @@ export function createConnectivityDiagnosticsRoute(
|
||||
) {
|
||||
return {
|
||||
async handle(req: IncomingMessage, res: ServerResponse) {
|
||||
if (req.url === '/api/diagnostics/dns' && req.method === 'GET') {
|
||||
sendJson(res, 200, await dependencies.diagnostics.dnsCatalog());
|
||||
return true;
|
||||
}
|
||||
if (req.url === '/api/diagnostics/dns' && req.method === 'POST') {
|
||||
const { domainId, resolverId = null } = await dependencies.readBody(req);
|
||||
sendJson(res, 200, await dependencies.diagnostics.runDns(domainId, resolverId));
|
||||
return true;
|
||||
}
|
||||
if (req.url === '/api/diagnostics/connectivity' && req.method === 'POST') {
|
||||
const { target = null } = await dependencies.readBody(req);
|
||||
const result = await dependencies.diagnostics.run(target);
|
||||
|
||||
Reference in New Issue
Block a user