Skip to content

Commit

Permalink
Merge pull request #38 from Aptimex/main
Browse files Browse the repository at this point in the history
More robust status command
  • Loading branch information
Segudmu authored Jul 24, 2024
2 parents 882e4fb + 1a7dadb commit f53fd29
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"net/http"
"net/netip"
"strings"
"time"

"wiretap/peer"
serverapi "wiretap/transport/api"
Expand All @@ -27,7 +28,7 @@ type request struct {

// MakeRequest attempts to send an API query to the Wiretap server.
func makeRequest(req request) ([]byte, error) {
client := &http.Client{}
client := &http.Client{Timeout: 3 * time.Second}
reqBody := bytes.NewBuffer(req.Body)

r, err := http.NewRequest(req.Method, req.URL, reqBody)
Expand Down
15 changes: 10 additions & 5 deletions src/cmd/status.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"net/netip"
"strings"
"log"

"github.com/fatih/color"
"github.com/m1gwings/treedrawer/tree"
Expand Down Expand Up @@ -77,11 +78,15 @@ func (c statusCmdConfig) Run() {
e2ee_peer_list := clientConfigE2EE.GetPeers()
for _, ep := range e2ee_peer_list {
relayConfig, e2eeConfig, err := api.ServerInfo(netip.AddrPortFrom(ep.GetApiAddr(), uint16(ApiPort)))
check("failed to fetch node's configuration as peer", err)
nodes[relayConfig.GetPublicKey()] = Node{
peerConfig: ep,
relayConfig: relayConfig,
e2eeConfig: e2eeConfig,
if err != nil {
message := "failed to fetch node's configuration as peer"
log.Printf("%s: %v", message, err)
} else {
nodes[relayConfig.GetPublicKey()] = Node{
peerConfig: ep,
relayConfig: relayConfig,
e2eeConfig: e2eeConfig,
}
}
}

Expand Down

0 comments on commit f53fd29

Please sign in to comment.