Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Avoid confusion of definition between peers and remove stream handler for local peer #120

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions http-proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,13 @@ func NewProxyService(h host.Host, proxyAddr ma.Multiaddr, dest peer.ID) *ProxySe
// We let our host know that it needs to handle streams tagged with the
// protocol id that we have defined, and then handle them to
// our own streamHandling function.
h.SetStreamHandler(Protocol, streamHandler)
ps := "Proxy"
if len(dest) == 0 {
h.SetStreamHandler(Protocol, streamHandler)
ps = "Remote Peer"
}

fmt.Println("Proxy server is ready")
fmt.Printf("%s server is ready", ps)
fmt.Println("libp2p-peer addresses:")
for _, a := range h.Addrs() {
fmt.Printf("%s/ipfs/%s\n", a, peer.IDB58Encode(h.ID()))
Expand Down