connect tailscale node status through platform gateway
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -10,4 +10,14 @@ export class TailscaleController {
|
|||||||
listNodes() {
|
listNodes() {
|
||||||
return this.tailscaleService.listNodes();
|
return this.tailscaleService.listNodes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Get('routes')
|
||||||
|
listRoutes() {
|
||||||
|
return this.tailscaleService.listRoutes();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('acl')
|
||||||
|
getAcl() {
|
||||||
|
return this.tailscaleService.getAcl();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,60 @@ export class TailscaleService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async listRoutes() {
|
||||||
|
if (!this.gatewayUrl || !this.gatewayToken) {
|
||||||
|
return {
|
||||||
|
routes: [],
|
||||||
|
source: 'platform-gateway',
|
||||||
|
error: 'PLATFORM_GATEWAY_URL 또는 PLATFORM_GATEWAY_TOKEN이 설정되어 있지 않습니다.',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const body = await this.request<unknown>('/api/admin/tailscale/routes');
|
||||||
|
const routes = isRecord(body) && Array.isArray(body.routes) ? body.routes : [];
|
||||||
|
return {
|
||||||
|
routes,
|
||||||
|
source: 'platform-gateway',
|
||||||
|
fetchedAt: new Date().toISOString(),
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
return {
|
||||||
|
routes: [],
|
||||||
|
source: 'platform-gateway',
|
||||||
|
error: error instanceof Error ? error.message : 'Platform Gateway Tailscale Route API 요청이 실패했습니다.',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async getAcl() {
|
||||||
|
if (!this.gatewayUrl || !this.gatewayToken) {
|
||||||
|
return {
|
||||||
|
policy: { groups: {}, tagOwners: {}, acls: [] },
|
||||||
|
source: 'platform-gateway',
|
||||||
|
error: 'PLATFORM_GATEWAY_URL 또는 PLATFORM_GATEWAY_TOKEN이 설정되어 있지 않습니다.',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const body = await this.request<unknown>('/api/admin/tailscale/acl');
|
||||||
|
const policy = isRecord(body) && isRecord(body.policy)
|
||||||
|
? body.policy
|
||||||
|
: { groups: {}, tagOwners: {}, acls: [] };
|
||||||
|
return {
|
||||||
|
policy,
|
||||||
|
source: 'platform-gateway',
|
||||||
|
fetchedAt: new Date().toISOString(),
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
return {
|
||||||
|
policy: { groups: {}, tagOwners: {}, acls: [] },
|
||||||
|
source: 'platform-gateway',
|
||||||
|
error: error instanceof Error ? error.message : 'Platform Gateway Tailscale ACL API 요청이 실패했습니다.',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async request<T>(path: string): Promise<T> {
|
private async request<T>(path: string): Promise<T> {
|
||||||
const response = await fetch(`${this.gatewayUrl}${path}`, {
|
const response = await fetch(`${this.gatewayUrl}${path}`, {
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
Reference in New Issue
Block a user