Skip to content

Commit

Permalink
docs: add docs of dashboard.visible
Browse files Browse the repository at this point in the history
  • Loading branch information
almeidapaulopt committed Dec 22, 2024
1 parent 6490c0a commit 19cedf8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 30 deletions.
10 changes: 10 additions & 0 deletions docs/content/docs/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,14 @@ labels:
tsdproxy.tlsvalidate: "false"
```

### tsdproxy.dash.visible

Defaults to true, set to false to hide on Dashboard.

```yaml
labels:
tsdproxy.enable: "true"
tsdproxy.dash.visible: "false"
```

{{% /steps %}}
8 changes: 5 additions & 3 deletions docs/content/docs/files.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ This configuration will create two groups of proxies:
- All access logs are enabled
- music.ts.net, video.ts.net and photos.ts.net.
- On the same host with different ports
- Sse 'default' Tailscale provider
- Use 'default' Tailscale provider
- Don't enable access logs
### Provider Configuration options
Expand All @@ -78,13 +78,15 @@ Files:
music: # Name of the proxy
URL: http://192.168.1.10:3789 # url of service to proxy
ProxyProvider: default # (optional) name of the proxy provider
TLSValidate: false # (optional, default true) disable TLS validationTailscale
TLSValidate: false # (optional, default true) disable TLS validation
Tailscale: # (optional) Tailscale configuration for this proxy
AuthKey: asdasdas # Tailscale authkey
AuthKey: asdasdas # (optional) Tailscale authkey
Ephemeral: true # (optional) Enable ephemeral mode
RunWebClient: false # (optional) Run web client
Verbose: false # (optional) Run in verbose mode
Funnel: false # (optional) Run in funnel mode
Dashboard:
Visible: false # (optional) doesn't show proxy in dashboard
```
{{% /steps %}}
37 changes: 10 additions & 27 deletions internal/targetproviders/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ func (c *Client) Close() {
}
}

// GetAllProxies implements TargetProvider GetAllProxies method.
func (c *Client) GetAllProxies() (map[string]*proxyconfig.Config, error) {
ctx := context.Background()
proxies := map[string]*proxyconfig.Config{}
func (c *Client) startAllProxies(ctx context.Context, eventsChan chan targetproviders.TargetEvent, errChan chan error) {
// Filter containers with enable set to true
//
containerFilter := filters.NewArgs()
Expand All @@ -87,33 +84,13 @@ func (c *Client) GetAllProxies() (map[string]*proxyconfig.Config, error) {
All: false,
})
if err != nil {
return nil, fmt.Errorf("error listing containers: %w", err)
errChan <- fmt.Errorf("error listing containers: %w", err)
return
}

var wg sync.WaitGroup
for _, container := range containers {
// create the proxy configs in parallel.
wg.Add(1)

go func() {
defer wg.Done()

ctn, err := c.docker.ContainerInspect(ctx, container.ID)
if err != nil {
c.log.Error().Err(err).Str("containerID", container.ID).Msg("error inspecting container")
} else {
pcfg, err := c.newProxyConfig(ctn)
if err == nil {
proxies[pcfg.Hostname] = pcfg
} else {
c.log.Error().Err(err).Msg("error initializing proxy for container")
}
}
}()
eventsChan <- c.getStartEvent(container.ID)
}
wg.Wait()

return proxies, nil
}

// newProxyConfig method returns a new proxyconfig.Config
Expand Down Expand Up @@ -147,7 +124,9 @@ func (c *Client) DeleteProxy(id string) error {
if _, ok := c.containers[id]; !ok {
return fmt.Errorf("container %s not found", id)
}

c.deleteContainer(id)

return nil
}

Expand Down Expand Up @@ -187,6 +166,8 @@ func (c *Client) WatchEvents(ctx context.Context, eventsChan chan targetprovider
}
}
}()

go c.startAllProxies(ctx, eventsChan, errChan)
}

// getStartEvent method returns a targetproviders.TargetEvent for a container start
Expand All @@ -203,6 +184,7 @@ func (c *Client) getStartEvent(id string) targetproviders.TargetEvent {
// getStopEvent method returns a targetproviders.TargetEvent for a container stop
func (c *Client) getStopEvent(id string) targetproviders.TargetEvent {
c.log.Info().Msgf("Container %s stopped", id)

return targetproviders.TargetEvent{
TargetProvider: c,

Check failure on line 189 in internal/targetproviders/docker/docker.go

View workflow job for this annotation

GitHub Actions / goreleaser

cannot use c (variable of type *Client) as targetproviders.TargetProvider value in struct literal: *Client does not implement targetproviders.TargetProvider (missing method GetAllProxies)
ID: id,
Expand All @@ -214,6 +196,7 @@ func (c *Client) getStopEvent(id string) targetproviders.TargetEvent {
func (c *Client) addContainer(cont *container, name string) {
c.mutex.Lock()
defer c.mutex.Unlock()

c.containers[name] = cont
}

Expand Down

0 comments on commit 19cedf8

Please sign in to comment.