Skip to content

Commit

Permalink
feat: detect p2p
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Gianelloni <[email protected]>
  • Loading branch information
wolf31o2 committed Nov 10, 2023
1 parent d6d25c2 commit 750fc73
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,35 @@ func getHomeText(ctx context.Context, promMetrics *PromMetrics) string {
}
}

// Determine if we're P2P
p2p := true
if cfg.Node.Network == "mainnet" {
cmd, err := processMetrics.CmdlineWithContext(ctx)
if err == nil {
if !strings.Contains(cmd, "p2p") && strings.Contains(cmd, "--config") {
cmdArray := strings.Split(cmd, " ")
for p, arg := range cmdArray {
if arg == "--config" {
nodeConfigFile := cmdArray[p+1]
buf, err := os.ReadFile(nodeConfigFile)
if err == nil {
type nodeConfig struct {
EnableP2P bool `json:"EnableP2P"`
}
var nc nodeConfig
err = json.Unmarshal(buf, &nc)
if err != nil {
p2p = false
} else {
p2p = nc.EnableP2P
}
}
}
}
}
}
}

// Set role
if cfg.Node.BlockProducer {
if role != "Core" {
Expand Down Expand Up @@ -695,8 +724,6 @@ func getHomeText(ctx context.Context, promMetrics *PromMetrics) string {
strings.Repeat("-", width-13),
))

// TODO: actually check for p2p
p2p := true
if p2p {
// Row 1
sb.WriteString(fmt.Sprintf(
Expand Down

0 comments on commit 750fc73

Please sign in to comment.