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

Example of echo server using routed hosts with local and ipfs bootstrap #278

Closed
wants to merge 1 commit into from
Closed

Example of echo server using routed hosts with local and ipfs bootstrap #278

wants to merge 1 commit into from

Conversation

jvsteiner
Copy link
Contributor

Hi, many thanks to @Stebalien for helping me understand the libp2p family of libraries. I incorporated some of what I've learned in this example code. I think it should work pretty well, but currently it's not set up to use a real world-reachable ip address, due to what I believe are issues with NAT. If you would like to have anything additional added, I'd be happy to help.

Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks!


This example is intended to follow up the basic host and echo examples by adding use of the ipfs distributed hash table to lookup peers.

Functionally, this example works similarly to the echo example, however setup of the host includes wrapping it with a Kademila hash table, so it can find peers using only their ID.
Copy link
Member

Choose a reason for hiding this comment

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

Nit: "their IDs"

2018/02/19 12:22:32 listening for connections
```

The listener libp2p host will print its randomly generated Base58 encoded ID string, which combined with the ipfs DHT, can be used to reach the host, despite lacking other connection details. You can also pass the `-global` flag to bootstrap using the same peers as ipfs.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe: "By default, this example will bootstrap off your local IPFS peer (assuming one is running). If you'd rather bootstrap off the same peers go-ipfs uses, pass the -global flag."

That is, something to indicate the default behaviour.

Copy link
Contributor Author

@jvsteiner jvsteiner Feb 22, 2018

Choose a reason for hiding this comment

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

note: I couldn't get it to work reliably if the first host was bootstrapped locally, and the second was bootstrapped globally, so I adjusted appropriately.

log.Printf("read reply: %q\n", out)
}

// doEcho reads a line of data a stream and writes it back
Copy link
Member

Choose a reason for hiding this comment

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

nit: "from a stream".

@jvsteiner
Copy link
Contributor Author

updated

@ghost ghost assigned Stebalien Feb 22, 2018
@ghost ghost added the status/in-progress In progress label Feb 22, 2018
@Stebalien
Copy link
Member

So, @whyrusleeping, opinions... this example adds a dependency on the DHT. I'm wondering if we should just move all the examples out of this repo into a separate go-libp2p-examples package (possibly leaving either a README or a git submodule behind). Thoughts?

@whyrusleeping
Copy link
Contributor

I'm happy to move them to a separate repo, as long as we make sure to point to it from here

@jvsteiner
Copy link
Contributor Author

I see some CI checks failed, not sure if this is related to my code - either way, if there's anything I can do to improve this, let me know!

@Stebalien
Copy link
Member

Those problems are my bad. I don't know exactly what happened but I'll fix and rebase.

@Stebalien
Copy link
Member

I've filed an issue for breaking out the examples. We can do that separately. #292

@Stebalien
Copy link
Member

So... actually, it turns out that go-libp2p-kad-dht depends on this repo (for some test cases) so we have a circular dependency (hence the gx issue). It looks like we'll have to move this into a separate repo (although, really, we should move out the basic host and the mock network instead...).

This may take a while.

@jvsteiner
Copy link
Contributor Author

added NAT traversal, and using bhost.NewHost constructor

@agahEbrahimi
Copy link

Is it possible to broadcast a message onto the whole network to see if they have a certain resource so you can then have a direct channel between you and the node closest to you with that resource?

@Stebalien
Copy link
Member

@agahEbrahimi please try to keep comments on-topic. As that appears to be a question about ipfs, you should probably ask it on https://discuss.ipfs.io.

@Stebalien
Copy link
Member

Ok, I've finally created go-libp2p-examples. Mind re-opening this PR there?

@jvsteiner
Copy link
Contributor Author

sure, I'll try to get to it this week!

@jvsteiner jvsteiner closed this Jul 28, 2018
@jvsteiner jvsteiner deleted the examples-routed-host branch July 28, 2018 19:26
@ghost ghost removed the status/in-progress In progress label Jul 28, 2018
marten-seemann added a commit that referenced this pull request Apr 21, 2022
stop using goprocess to control teardown
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.

4 participants