Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More robust status command #38

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

More robust status command #38

wants to merge 2 commits into from

Conversation

Aptimex
Copy link

@Aptimex Aptimex commented Jul 6, 2024

Fixes #37

Adds a 3s timeout when trying to get info from a server via the status command, and still shows data about the rest of the working network instead of immediately exiting.

Copy link
Contributor

@luker983 luker983 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me! Could you please include a side-by-side of the behavior from the Issue and how it looks now as fixed by this PR?

@@ -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}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, should've had this from the beginning. Thanks.

if err != nil {
message := "failed to fetch node's configuration as peer"
log.Printf("%s: %v", message, err)
nodes["TIMEOUT"] = Node{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be overridden by other failed nodes (and isn't necessarily caused by a timeout).

Just an idea, but what do you think about adding a new field in the Node struct so the errors can be saved along the corresponding nodes? This way we don't lose info and can potentially display it in the visualization down the road.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this was just my quickest solution to get the rest of the connected network to display. It would definitely be preferable to actually save failure info specific to the node and display it nicely.

Copy link
Contributor

@luker983 luker983 Jul 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha. Does this line need to exist at all then?

nodes["TIMEOUT"] = ...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Annoyingly, yes, Can't remember exactly where, but without adding some kind of placeholder entry here it was causing another crash somewhere else.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I commented it out and it seems to work just fine.

The only place nodes is used is in the findChildren function and is always indexed by public key so it should have no effect.

@@ -111,8 +121,8 @@ func (c statusCmdConfig) Run() {
// Use node tree to build diagram tree.
t.AddChild(tree.NodeString(fmt.Sprintf(`client
relay: %v...
e2ee: %v...
relay: %v...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the trailing whitespace here was intentional to give the boxes some padding. Did you mean to remove the spaces or is it something like a side effect of editor/linter?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not intentional, editor did it automatically.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is odd, file permissions on the changed files went from 644755. From some quick searching this may be a side effect of using WSL if you didn't explicitly change them

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, probably WSL being weird. I didn't mean to change that.

@Aptimex
Copy link
Author

Aptimex commented Jul 18, 2024

Makes sense to me! Could you please include a side-by-side of the behavior from the Issue and how it looks now as fixed by this PR?

Before (one server setup but not connected):

./wiretap status
2024/07/17 21:25:48 failed to fetch node's configuration as peer: Get "http://::2:80/serverinfo?": dial tcp [::2]:80: connect: network is unreachable

After:

./wiretap status
2024/07/17 21:25:34 failed to fetch node's configuration as peer: Get "http://::2:80/serverinfo?": dial tcp [::2]:80: connect: network is unreachable

╭────────────────────────╮ 
│ Wiretap Network Status │                                                                                                                                                                                                                  
╰────────────┬───────────╯                                                                                                                                                                                                                  
             │                                                                                                                                                                                                                              
  ╭──────────┴──────────╮                                                                                                                                                                                                                   
  │client               │                                                                                                                                                                                                                   
  │                     │                                                                                                                                                                                                                   
  │  relay: EcX0bRmF... │                                                                                                                                                                                                                   
  │   e2ee: N7Fkb6rq... │                                                                                                                                                                                                                   
  │                     │                                                                                                                                                                                                                   
  ╰─────────────────────╯

@Aptimex
Copy link
Author

Aptimex commented Jul 18, 2024

Added a second commit to undo the whitespace and file permission changes.

@luker983
Copy link
Contributor

I don't have write access to this repository anymore, but I approve!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Status command fails on timeout
2 participants