-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add kube proxy, ported from horcrux-proxy
- Loading branch information
Showing
11 changed files
with
1,126 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
cometlog "github.com/cometbft/cometbft/libs/log" | ||
"github.com/spf13/cobra" | ||
"github.com/strangelove-ventures/horcrux/signer" | ||
"github.com/strangelove-ventures/horcrux/signer/proxy" | ||
) | ||
|
||
const ( | ||
flagListen = "listen" | ||
flagAll = "all" | ||
) | ||
|
||
func proxyCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "proxy", | ||
Short: "Commands for running a horcrux proxy", | ||
} | ||
|
||
cmd.AddCommand(proxyStartCmd()) | ||
|
||
return cmd | ||
} | ||
|
||
func proxyStartCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "start", | ||
Short: "Start horcrux-proxy process", | ||
Args: cobra.NoArgs, | ||
SilenceUsage: true, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
out := cmd.OutOrStdout() | ||
|
||
logger := cometlog.NewTMLogger(cometlog.NewSyncWriter(out)).With("module", "validator") | ||
|
||
logger.Info("Horcrux Proxy") | ||
|
||
addr, _ := cmd.Flags().GetString(flagListen) | ||
all, _ := cmd.Flags().GetBool(flagAll) | ||
|
||
listener := proxy.NewSignerListenerEndpoint(logger, addr) | ||
if err := listener.Start(); err != nil { | ||
return fmt.Errorf("failed to start listener: %w", err) | ||
} | ||
|
||
sentries := make(map[string]*signer.ReconnRemoteSigner) | ||
|
||
if err := proxy.WatchForChangedSentries(cmd.Context(), logger, listener, sentries, all); err != nil { | ||
return err | ||
} | ||
|
||
proxy.WaitAndTerminate(logger, listener, sentries) | ||
|
||
return nil | ||
}, | ||
} | ||
|
||
cmd.Flags().StringP(flagListen, "l", "tcp://0.0.0.0:1234", "Privval listen address for the proxy") | ||
cmd.Flags().BoolP(flagAll, "a", false, "Connect to sentries on all nodes") | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.