feat: add tunnel monitor web ui
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -2,12 +2,17 @@ package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"sync"
|
||||
"syscall"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"reichard.io/conduit/config"
|
||||
"reichard.io/conduit/store"
|
||||
"reichard.io/conduit/tunnel"
|
||||
"reichard.io/conduit/web"
|
||||
)
|
||||
|
||||
var tunnelCmd = &cobra.Command{
|
||||
@@ -20,22 +25,39 @@ var tunnelCmd = &cobra.Command{
|
||||
log.Fatal("failed to get client config:", err)
|
||||
}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
// Create Tunnel Store
|
||||
tunnelStore := store.NewTunnelStore(100)
|
||||
|
||||
// Create Forwarder
|
||||
tunnelForwarder, err := tunnel.NewForwarder(cfg.TunnelTarget, store.NewTunnelStore(100))
|
||||
tunnelForwarder, err := tunnel.NewForwarder(cfg.TunnelTarget, tunnelStore)
|
||||
if err != nil {
|
||||
log.Fatal("failed to create tunnel forwarder:", err)
|
||||
}
|
||||
go tunnelForwarder.Start(ctx)
|
||||
wg.Go(func() { tunnelForwarder.Start(ctx) })
|
||||
|
||||
// Create Tunnel
|
||||
tunnel, err := tunnel.NewClientTunnel(cfg, tunnelForwarder)
|
||||
if err != nil {
|
||||
log.Fatal("failed to create tunnel:", err)
|
||||
}
|
||||
tunnel.Start(ctx)
|
||||
wg.Go(func() { tunnel.Start(ctx) })
|
||||
|
||||
// Create Server
|
||||
webServer := web.NewWebServer(tunnelStore)
|
||||
wg.Go(func() { webServer.Start(ctx) })
|
||||
|
||||
// Wait Interrupt
|
||||
sigChan := make(chan os.Signal, 1)
|
||||
signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)
|
||||
<-sigChan
|
||||
|
||||
log.Println("Shutting Down...")
|
||||
cancel()
|
||||
wg.Wait()
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user