Basic peer overview

main
Gerard Braad 2023-06-22 17:45:01 +08:00
parent 0f65b1f0ff
commit ec979053dd
2 changed files with 65 additions and 36 deletions

View File

@ -1,6 +1,6 @@
import React from 'react'; import React, { ReactComponentElement, ReactNode } from 'react';
import { TailscaleBackendState, TailscaleStatus, TailscaleUp } from './types'; import { TailscaleBackendState, TailscalePeer, TailscaleStatus, TailscaleUp } from './types';
import { Card, CardTitle, CardBody } from '@patternfly/react-core'; import { Card, CardTitle, CardBody } from '@patternfly/react-core';
type ApplicationProps = { type ApplicationProps = {
@ -26,19 +26,39 @@ export class Application extends React.Component<ApplicationProps, ApplicationSt
} }
render() { render() {
return ( return (
<Card> <Card>
<CardTitle>Tailscale</CardTitle> <CardTitle>Tailscale</CardTitle>
<CardBody> <CardBody>
<pre>
{ {
this.state.Status != null this.state.Status != null
? this.state.Status.Self.HostName + " " + this.state.Status.Self.TailscaleIPs[0] ? <>
<Peer { ...this.state.Status.Self } />
<hr />
{
Object.entries(this.state.Status.Peer).map(peer =>
{
return <Peer {...peer[1]} />
}
)
}
</>
: <p>Loading...</p> : <p>Loading...</p>
} }
</pre>
</CardBody> </CardBody>
</Card> </Card>
); );
} }
} }
class Peer extends React.Component<TailscalePeer> {
render() {
return (<div>
<p>
<pre>{ this.props.TailscaleIPs[0] } { ' '.repeat(15 - this.props.TailscaleIPs[0].length) } { this.props.HostName }</pre>
</p>
</div>);
}
}

View File

@ -26,8 +26,19 @@ export type TailscalePeer = {
UserID: string; UserID: string;
TailscaleIPs: string[] TailscaleIPs: string[]
Tags?: string[]; Tags?: string[];
Online: boolean;
Capabilities?: string[]; Capabilities?: string[];
Relay: string;
RxBytes: number;
TxBytes: number;
Created: Date;
LastWrite: Date;
LastSeen: Date;
LastHandshake: Date;
Online: boolean;
KeepAlive: boolean;
ExitNode: boolean;
ExitNodeOption: boolean;
Active: boolean;
} }
export interface TailscaleExitNodeStatus { export interface TailscaleExitNodeStatus {
@ -40,16 +51,14 @@ export type TailscaleStatus = {
BackendState: TailscaleBackendState; BackendState: TailscaleBackendState;
AuthURL: string; AuthURL: string;
Self: TailscalePeer, Self: TailscalePeer,
User: Record<string, TailscaleUser> | null;
CurrentTailnet: { CurrentTailnet: {
Name: string; Name: string;
MagicDNSSuffix: string; MagicDNSSuffix: string;
MagicDNSEnabled: boolean; MagicDNSEnabled: boolean;
} | null; } | null;
ExitNodeStatus: TailscaleExitNodeStatus | null; ExitNodeStatus: TailscaleExitNodeStatus | null;
Peer: { User: Record<string, TailscaleUser> | null;
[key: string]: TailscalePeer Peer: Record<string, TailscalePeer> | null;
};
}; };
export type TailscaleUser = { export type TailscaleUser = {