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

Add verbose mode to ipfs swarm connect #3746

Open
whyrusleeping opened this issue Mar 6, 2017 · 15 comments
Open

Add verbose mode to ipfs swarm connect #3746

whyrusleeping opened this issue Mar 6, 2017 · 15 comments
Labels
kind/enhancement A net-new feature or improvement to an existing feature status/in-progress In progress

Comments

@whyrusleeping
Copy link
Member

It would be nice to get a log of what the dialer is trying and how each thing succeeds or fails:

$ ipfs swarm connect /foo/bar
Trying /ip4/1.2.3.4/tcp/12312
Trying /ip4/127.0.0.1/tcp/4444
From /ip4/1.2.3.4/tcp/12312: Error, connection refused
...
...
etc
@whyrusleeping whyrusleeping added the help wanted Seeking public contribution on this issue label Mar 6, 2017
@whyrusleeping whyrusleeping added this to the Ipfs 0.4.8 milestone Mar 6, 2017
@Kubuxu Kubuxu added the kind/enhancement A net-new feature or improvement to an existing feature label Mar 15, 2017
@kevina kevina self-assigned this Mar 20, 2017
@kevina
Copy link
Contributor

kevina commented Mar 20, 2017

This should be easy. @whyrusleeping do you want me to do this?

@whyrusleeping
Copy link
Member Author

@kevina Sure, go ahead. It may require digging into some libp2p stuff, but it shouldnt be too difficult

@whyrusleeping whyrusleeping modified the milestones: Ipfs 0.4.9, Ipfs 0.4.8 Mar 24, 2017
@whyrusleeping whyrusleeping modified the milestones: Ipfs 0.4.10, Ipfs 0.4.9 May 2, 2017
@kevina
Copy link
Contributor

kevina commented May 11, 2017

I think the best way to do this would be to use WithValue/Value in context to set the value to either a channel or a writer where Connect can send debug output to if it is defined. This should be sufficient to allow passing the information you want but I am not that familiar with that part of the code.

@whyrusleeping thoughts.

@whyrusleeping
Copy link
Member Author

@kevina I like the context approach. Its probably important here to clearly define what the interfaces should look like. Other than that, go for it.

@kevina
Copy link
Contributor

kevina commented May 11, 2017

As far as the API goes the output is now:

{"Strings":["connect QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ success"]}

Since the doesn't have any structure already, if the --verbose option is given there will simply be more values in that list. This will unfortunately not stream the information as it happens, I can do that but then the output will need to be different, maybe something like

{"Message": "Trying /ip4/1.2.3.4/tcp/12312"}
{"Message": ...}
{"Strings":["connect QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ success"]}

That is each debug output will be send as a separate json value with the final value being the normal output.

For the value added to the context I think I will call it "DebugChannel" and have the value be a string channel. (Or I could make it a generic interface{} channel but I hate all that extra casting.) If the value exists then debug strings will be sent to it.

@kevina
Copy link
Contributor

kevina commented May 18, 2017

@whyrusleeping could I get some feedback on this

@whyrusleeping
Copy link
Member Author

I dislike the current api. Its really not a good format, and isnt machine parseable at all. I think we can get away with changing it here.

A better format moving forward could look like repeated messages of type:

{
  "address": "addr dialed",
  "event": "begin|success|error",
  "message": "error if error",
  "extra": "maybe details such as 'reuseport' or other dial options here?",
}

What do you think? cc @Kubuxu @lgierth

@Kubuxu
Copy link
Member

Kubuxu commented May 18, 2017

SGWM,
we should make a note that more events might be added

@kevina kevina added status/in-progress In progress and removed status/in-progress In progress help wanted Seeking public contribution on this issue labels May 25, 2017
@kevina
Copy link
Contributor

kevina commented Jun 7, 2017

@whyrusleeping

  1. This took some digging to figure out where to emit the status messages, I found two likely candidates: (1) go-libp2p-swarm/swarm_dial.go:dialAddr and (2) go-libp2p-conn/dial.go:Dial which do you think would be better.

  2. Also I think the message should also include the peer ID so the message type should be:

    {
     "peer": "peer id",
     "address": "addr dialed",
      "event": "begin|success|error",
      "message": "error if error",
      "extra": "maybe details such as 'reuseport' or other dial options here?",
    }
    

    agreed? the other alternative is to report a fuller address that included the peer id.

  3. what exactly should we report if there is no dial attempt because we already have a connection maybe something like: {peer: peer1, event: success, message: "already have connection"} or do we what something more structured. RoutedHost.Connect() won't will just return if there is already a connection without calling the dialer so we won't have an ip address readily available.

@ghost
Copy link

ghost commented Jun 12, 2017

This took some digging to figure out where to emit the status messages, I found two likely candidates: (1) go-libp2p-swarm/swarm_dial.go:dialAddr and (2) go-libp2p-conn/dial.go:Dial which do you think would be better.

Better put it in go-libp2p-swarm -- it's further up the dependency tree

"peer": "peer id",

Let's call this peerID or peer_id

"extra": "maybe details such as 'reuseport' or other dial options here?",

Let's add fields when we need them, opaque unspecced values == bad :)

@ghost
Copy link

ghost commented Jun 12, 2017

Better put it in go-libp2p-swarm -- it's further up the dependency tree

Actually it would be best if this could happen as close to the respective command code as possible

@kevina
Copy link
Contributor

kevina commented Jun 20, 2017

@lgierth sorry, I completely missed your comments. But I am a little confused. What are you trying to tell me when you say "Actually it would be best if this could happen as close to the respective command code as possible."?

@kevina
Copy link
Contributor

kevina commented Jun 20, 2017

"extra": "maybe details such as 'reuseport' or other dial options here?",

Let's add fields when we need them, opaque unspecced values == bad :)

Okay, that was @whyrusleeping idea.

@whyrusleeping
Copy link
Member Author

hrm... yeah. in retrospect maybe that wasnt the best idea on my part.

@magik6k magik6k modified the milestones: Ipfs 0.4.11, Ipfs 0.4.10 Jul 28, 2017
@whyrusleeping
Copy link
Member Author

@kevina any update here?

@Kubuxu Kubuxu modified the milestones: Ipfs 0.4.12, go-ipfs 0.4.13 Nov 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement A net-new feature or improvement to an existing feature status/in-progress In progress
Projects
None yet
Development

No branches or pull requests

4 participants