Skip to content

Commit

Permalink
move tailscale to own go file, will be refactored into generic servic…
Browse files Browse the repository at this point in the history
…e discovery module in the future
  • Loading branch information
czerwonk committed May 18, 2023
1 parent 4cfd8cf commit 36691ac
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
16 changes: 0 additions & 16 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (

"github.com/digineo/go-ping"
mon "github.com/digineo/go-ping/monitor"
"tailscale.com/client/tailscale"

"github.com/czerwonk/ping_exporter/config"

Expand Down Expand Up @@ -59,21 +58,6 @@ var (
rttMode = kingpin.Flag("metrics.rttunit", "Export ping results as either seconds (default), or milliseconds (deprecated), or both (for migrations). Valid choices: [s, ms, both]").Default("s").String()
)

func tsDiscover() {
tailscale.I_Acknowledge_This_API_Is_Unstable = true

client := tailscale.NewClient(*tailnet, tailscale.APIKey(os.Getenv("TS_API_KEY")))

devices, err := client.Devices(context.Background(), tailscale.DeviceAllFields)
if err != nil {
log.Fatal(err)
}

for _, dev := range devices {
*targets = append(*targets, dev.Hostname)
}
}

func main() {
kingpin.Parse()

Expand Down
24 changes: 24 additions & 0 deletions tailscale.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package main

import (
"context"
"os"

log "github.com/sirupsen/logrus"
"tailscale.com/client/tailscale"
)

func tsDiscover() {
tailscale.I_Acknowledge_This_API_Is_Unstable = true

client := tailscale.NewClient(*tailnet, tailscale.APIKey(os.Getenv("TS_API_KEY")))

devices, err := client.Devices(context.Background(), tailscale.DeviceAllFields)
if err != nil {
log.Fatal(err)
}

for _, dev := range devices {
*targets = append(*targets, dev.Hostname)
}
}

0 comments on commit 36691ac

Please sign in to comment.