Documentation
¶
Index ¶
- Constants
- Variables
- func CtxAsBool(ctx context.Context, key contextKey) bool
- func CtxAsInt(ctx context.Context, key contextKey) int
- func CtxAsString(ctx context.Context, key contextKey) string
- func ExecuteClusterRemoteCmd(ctx context.Context, w io.Writer, hosts []RemoteCmdHost, remoteCmd string)
- func NewClient(ctx context.Context) *tailscale.Client
- func NewOauthClient(ctx context.Context) *tailscale.Client
- func ParseColumns(s string) mapset.Set[string]
- func ParseFilter(filter string) map[string]mapset.Set[string]
- func RenderASCIITableView(ctx context.Context, tableView *GeneralTableView, w io.Writer) error
- func RenderIPs(ctx context.Context, tableView *GeneralTableView, w io.Writer) error
- func RenderJson(ctx context.Context, tableView *GeneralTableView, w io.Writer) error
- func RenderLogLine(ctx context.Context, w io.Writer, idx int, isStdErr bool, ...)
- func RenderRemoteSummary(ctx context.Context, w io.Writer, success, errors uint32, ...) error
- func RenderTableView(ctx context.Context, tableView *GeneralTableView, w io.Writer) error
- type CachedRepository
- type ConfigCtx
- type ContextView
- type DB2
- func (d *DB2[T]) Close() error
- func (d *DB2[T]) Erase() error
- func (d *DB2[T]) Exists(ctx context.Context) (bool, error)
- func (d *DB2[T]) File() string
- func (d *DB2[T]) IndexOpaqueItems(ctx context.Context, bucketName string, items []T) error
- func (d *DB2[T]) LookupOpaqueItem(ctx context.Context, bucketName, primaryKey string) (*T, error)
- func (d *DB2[T]) Open() error
- func (d *DB2[T]) SearchOpaqueItems(ctx context.Context, bucketName string, query DBQuery) ([]T, error)
- func (d *DB2[T]) TailnetScope() string
- type DB2Stats
- type DBQuery
- type DevicesTable
- type DevicesView
- type GeneralTableView
- type Indexer
- type InnerRepo
- type MockedDeviceRepo
- type PrefixFilter
- type RemoteCmdHost
- type RemoteDeviceRepo
- type SelfView
- type SliceCfg
- type SortDirection
- type SortSpec
- type TailnetView
- type TailscaleAPICfgCtx
- type TailscaleCLICfgCtx
- type WrappedDevice
Constants ¶
const ( AppLongName = "Tailscale IPs" AppShortName = "tips" )
const ( // These two buckets contain FULL data. DevicesBucket = "bucket:devices.full" StatsBucket = "bucket:stats" StatsKey = "key:stats" )
const ( NoHdr = "No" MachineHdr = "Machine" AddressHdr = "Address" TagsHdr = "Tags" UserHdr = "User" VersionHdr = "Version" LastSeenHdr = "LastSeen" ExitNodeHdr = "Exit Node" )
const (
// PrimaryFilterAll basically means glob: *, but since this expands in the terminal we use @
PrimaryFilterAll = "@"
)
Variables ¶
var ( AppVersion = "0.0.1" UserAgent = fmt.Sprintf("%s/%s", AppShortName, AppVersion) )
var ( // CtxKeyConfig holds all config settings that were resolved from the environment/config file/cli flags CtxKeyConfig = contextKey("configuration") CtxKeyUserQuery = contextKey("user-query") )
var (
DefaultHeader = []string{NoHdr, MachineHdr, AddressHdr, TagsHdr, UserHdr, VersionHdr, ExitNodeHdr, LastSeenHdr}
)
Functions ¶
func CtxAsString ¶
func ExecuteClusterRemoteCmd ¶
func RenderASCIITableView ¶
func RenderJson ¶
func RenderLogLine ¶
func RenderRemoteSummary ¶
func RenderTableView ¶
Types ¶
type CachedRepository ¶
type CachedRepository struct {
// contains filtered or unexported fields
}
func NewCachedRepo ¶
func NewCachedRepo(innerRepo InnerRepo) *CachedRepository
func (*CachedRepository) DevicesResource ¶
func (c *CachedRepository) DevicesResource(ctx context.Context) ([]*WrappedDevice, error)
type ConfigCtx ¶
type ConfigCtx struct {
Basic bool
CacheTimeout time.Duration
Columns mapset.Set[string]
Concurrency int
Filters map[string]mapset.Set[string]
IPsOutput bool
IPsDelimiter string
JsonOutput bool
NoCache bool
NoColor bool
PrefixFilter *PrefixFilter
RemoteCmd string
Slice *SliceCfg
SortOrder []SortSpec
Tailnet string
CachedElapsed time.Duration
TailscaleAPI TailscaleAPICfgCtx
TailscaleCLI TailscaleCLICfgCtx
Page int
TestMode bool
}
func CtxAsConfig ¶
func NewConfigCtx ¶
func NewConfigCtx() *ConfigCtx
func (*ConfigCtx) IsRemoteCommand ¶
type ContextView ¶
type DB2 ¶
type DB2[T Indexer] struct { // contains filtered or unexported fields }
func (*DB2[T]) IndexOpaqueItems ¶
func (*DB2[T]) LookupOpaqueItem ¶
func (*DB2[T]) SearchOpaqueItems ¶
func (d *DB2[T]) SearchOpaqueItems(ctx context.Context, bucketName string, query DBQuery) ([]T, error)
SearchOpaqueItems can generically search with 3 different ways. 1. Using one or more primary keys, in which case this is a direct lookup (not technically a search) 2. Using the * (all/everything) construct, this is just a full table scan really. 3. Using a prefix scan, this is a seek to a segment of the index and should be fast assuming good selectivity.
func (*DB2[T]) TailnetScope ¶
type DBQuery ¶ added in v0.0.4
type DBQuery struct {
PrefixFilters *PrefixFilter
PrimaryKeys []string
}
type DevicesTable ¶
type DevicesTable struct {
TailnetView
Devices *DevicesView
}
type GeneralTableView ¶
type GeneralTableView struct {
ContextView
TailnetView
SelfView
Headers []string
Rows [][]string
}
func ProcessDevicesTable ¶
func ProcessDevicesTable(ctx context.Context, devList []*WrappedDevice) (*GeneralTableView, error)
ProcessDevicesTable will apply sorting (if required), slicing (if required) and the massage/transformation of data to produce a final `*DevicesTable` that has everything required to render.
type InnerRepo ¶
type InnerRepo interface {
DevicesResource(ctx context.Context) ([]*WrappedDevice, error)
}
type MockedDeviceRepo ¶
type MockedDeviceRepo struct {
}
func NewMockedDeviceRepo ¶
func NewMockedDeviceRepo() *MockedDeviceRepo
func (*MockedDeviceRepo) DevicesResource ¶
func (r *MockedDeviceRepo) DevicesResource(ctx context.Context) ([]*WrappedDevice, error)
type PrefixFilter ¶ added in v0.0.4
type PrefixFilter struct {
// contains filtered or unexported fields
}
func ParsePrefixFilter ¶ added in v0.0.4
func ParsePrefixFilter(s string) *PrefixFilter
func (*PrefixFilter) Count ¶ added in v0.0.4
func (p *PrefixFilter) Count() int
func (*PrefixFilter) IsAll ¶ added in v0.0.4
func (p *PrefixFilter) IsAll() bool
func (*PrefixFilter) PrefixAt ¶ added in v0.0.4
func (p *PrefixFilter) PrefixAt(idx int) string
type RemoteCmdHost ¶
type RemoteDeviceRepo ¶
type RemoteDeviceRepo struct {
// contains filtered or unexported fields
}
func NewRemoteDeviceRepo ¶
func NewRemoteDeviceRepo(client *tailscale.Client) *RemoteDeviceRepo
func (*RemoteDeviceRepo) DevicesResource ¶
func (r *RemoteDeviceRepo) DevicesResource(ctx context.Context) ([]*WrappedDevice, error)
type SliceCfg ¶
func ParseSlice ¶
type SortSpec ¶
type SortSpec struct {
Field string
Direction SortDirection
}
func ParseSortString ¶
Parse the sort string and return a slice of SortSpec
type TailnetView ¶
TailnetView has everything known about a Tailnet
type TailscaleAPICfgCtx ¶
type TailscaleAPICfgCtx struct {
Timeout time.Duration
// ApiKey for regular authentication
ApiKey string
// OAuthClientID for OAuth based login.
OAuthClientID string
// OAuthClientSecret for Oauth based login.
OAuthClientSecret string
// ElapsedTime records the time this API call took. It's meant to be mutated during the API call and populated then.
ElapsedTime time.Duration
}
type TailscaleCLICfgCtx ¶
type TailscaleCLICfgCtx struct {
}
type WrappedDevice ¶
type WrappedDevice struct {
tailscale.Device
EnrichedInfo *tailscale_cli.DeviceInfo `json:"enrichedInfo"`
}
WrappedDevice is a type that wraps the core `tailscale.Device` type. It also holds the joined `tailscale_cli.DeviceInfo` that may or may not be present when fetched from within the tailnet. It also implements the `Indexer` interface, so it may be stored in the DB.
func (*WrappedDevice) Key ¶
func (w *WrappedDevice) Key() string