mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2026-05-20 19:20:14 +00:00
chore: move tailscale api response struct to tailscale service
This commit is contained in:
@@ -88,7 +88,6 @@ type Config struct {
|
|||||||
LabelProvider string `description:"Label provider to use for ACLs (auto, docker, kubernetes or none to disable). auto detects the environment." yaml:"labelProvider"`
|
LabelProvider string `description:"Label provider to use for ACLs (auto, docker, kubernetes or none to disable). auto detects the environment." yaml:"labelProvider"`
|
||||||
Log LogConfig `description:"Logging configuration." yaml:"log"`
|
Log LogConfig `description:"Logging configuration." yaml:"log"`
|
||||||
Tailscale TailscaleConfig `description:"Tailscale configuration." yaml:"tailscale"`
|
Tailscale TailscaleConfig `description:"Tailscale configuration." yaml:"tailscale"`
|
||||||
LabelProvider string `description:"Label provider to use (docker, kubernetes, auto)." yaml:"labelProvider"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type DatabaseConfig struct {
|
type DatabaseConfig struct {
|
||||||
@@ -244,14 +243,6 @@ type OIDCClientConfig struct {
|
|||||||
Name string `description:"Client name in UI." yaml:"name"`
|
Name string `description:"Client name in UI." yaml:"name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TailscaleWhoisResponse struct {
|
|
||||||
UserID string
|
|
||||||
LoginName string
|
|
||||||
DisplayName string
|
|
||||||
NodeName string
|
|
||||||
Tags []string
|
|
||||||
}
|
|
||||||
|
|
||||||
type ACLsConfig struct {
|
type ACLsConfig struct {
|
||||||
Policy string `description:"ACL policy for allow-by-default or deny-by-default, available options are allow and deny, default is allow." yaml:"policy"`
|
Policy string `description:"ACL policy for allow-by-default or deny-by-default, available options are allow and deny, default is allow." yaml:"policy"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,14 @@ import (
|
|||||||
"tailscale.com/tsnet"
|
"tailscale.com/tsnet"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type TailscaleWhoisResponse struct {
|
||||||
|
UserID string
|
||||||
|
LoginName string
|
||||||
|
DisplayName string
|
||||||
|
NodeName string
|
||||||
|
Tags []string
|
||||||
|
}
|
||||||
|
|
||||||
type TailscaleService struct {
|
type TailscaleService struct {
|
||||||
log *logger.Logger
|
log *logger.Logger
|
||||||
wg *sync.WaitGroup
|
wg *sync.WaitGroup
|
||||||
@@ -89,7 +97,7 @@ func (ts *TailscaleService) watchAndClose() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ts *TailscaleService) Whois(ctx context.Context, addr string) (*model.TailscaleWhoisResponse, error) {
|
func (ts *TailscaleService) Whois(ctx context.Context, addr string) (*TailscaleWhoisResponse, error) {
|
||||||
who, err := ts.lc.WhoIs(ctx, addr)
|
who, err := ts.lc.WhoIs(ctx, addr)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -99,7 +107,7 @@ func (ts *TailscaleService) Whois(ctx context.Context, addr string) (*model.Tail
|
|||||||
return nil, fmt.Errorf("failed to get client whois: %w", err)
|
return nil, fmt.Errorf("failed to get client whois: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
res := model.TailscaleWhoisResponse{
|
res := TailscaleWhoisResponse{
|
||||||
UserID: who.UserProfile.ID.String(),
|
UserID: who.UserProfile.ID.String(),
|
||||||
LoginName: who.UserProfile.LoginName,
|
LoginName: who.UserProfile.LoginName,
|
||||||
DisplayName: who.UserProfile.DisplayName,
|
DisplayName: who.UserProfile.DisplayName,
|
||||||
|
|||||||
Reference in New Issue
Block a user