Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions internal/command/wireguard/wireguard.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/superfly/flyctl/internal/config"
"github.com/superfly/flyctl/internal/flag"
"github.com/superfly/flyctl/internal/flyutil"
"github.com/superfly/flyctl/internal/metrics"
"github.com/superfly/flyctl/internal/render"
"github.com/superfly/flyctl/internal/state"
"github.com/superfly/flyctl/internal/wireguard"
Expand Down Expand Up @@ -62,21 +63,30 @@ func runWireguardWebsockets(ctx context.Context) error {
var (
configPath = state.ConfigFile(ctx)
err error
enabled bool
)
switch flag.FirstArg(ctx) {
case "enable":
enabled = true
viper.Set(flyctl.ConfigWireGuardWebsockets, true)
err = config.SetWireGuardWebsocketsEnabled(configPath, true)
case "disable":
enabled = false
viper.Set(flyctl.ConfigWireGuardWebsockets, false)
err = config.SetWireGuardWebsocketsEnabled(configPath, false)
default:
fmt.Fprintf(io.Out, "bad arg: flyctl wireguard websockets (enable|disable)\n")
return nil
}
if err != nil {
return errors.Wrap(err, "error saving config file")
}

// Send metrics about WebSocket configuration change
metrics.Send(ctx, "wireguard_websocket_config", map[string]interface{}{
"websocket_enabled": enabled,
})

tryKillingAgent := func() error {
client, err := agent.DefaultClient(ctx)
if err == agent.ErrAgentNotRunning {
Expand Down
Loading