-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
examples:https-proxy:on a separate machine #248
Comments
Probably. You'll have open tcp/12000 on machine A's firewall (and this will only work if those machines are on the same network as you're using private IP addresses). |
I have the same err, func makeRandomHost(port int) host.Host {
priv, pub, err := crypto.GenerateKeyPair(crypto.RSA, 2048)
if err != nil {
log.Fatalln(err)
}
pid, err := peer.IDFromPublicKey(pub)
if err != nil {
log.Fatalln(err)
}
// listen, err := ma.NewMultiaddr(fmt.Sprintf("/ip4/127.0.0.1/tcp/%d", port))
// if err != nil {
// log.Fatalln(err)
// }
ps := ps.NewPeerstore()
ps.AddPrivKey(pid, priv)
ps.AddPubKey(pid, pub)
//listen nil
n, err := swarm.NewNetwork(context.Background(),
nil, pid, ps, nil)
if err != nil {
log.Fatalln(err)
}
return bhost.New(n)
} on makeRandomHost // If we have a destination peer we will start a local server
if *destPeer != "" {
// We use p2pport+1 in order to not collide if the user
// is running the remote peer locally on that port
host := makeRandomHost(*p2pport + 1)
// Make sure our host knows how to reach destPeer
destPeerID := addAddrToPeerstore(host, *destPeer)
proxyAddr, err := ma.NewMultiaddr(fmt.Sprintf("/ip4/127.0.0.1/tcp/%d", *port))
if err != nil {
log.Fatalln(err)
}
// Create the proxy service and start the http server
proxy := NewProxyService(host, proxyAddr, destPeerID)
proxy.Serve() // serve hangs forever
} else {
host := makeRandomHost(*p2pport)
//here is add
addr, _ := ma.NewMultiaddr(fmt.Sprintf("/ip4/127.0.0.1/tcp/%d", *p2pport))
err := host.Network().Listen(addr)
if err != nil {
panic(err)
}
// In this case we only need to make sure our host
// knows how to handle incoming proxied requests from
// another peer.
_ = NewProxyService(host, nil, "")
<-make(chan struct{}) // hang forever
} |
yes, it's not a firewall problem. First time, i just change proxy.go on remote peer(remote machine)
to
use |
I see. Yeah, that's either a bug or something that should be documented clearly. It looks like you can't dial out of an interface you're not listening on. |
Scratch that, it should still work (we have a fallback dialer). |
Could you try changing only the listen address, not the proxy address, and see what happens? |
@Stebalien |
By the same, |
@whyrusleeping is this intended? |
@Stebalien Its not necessarily intended. I just generally restrict demo applications to only listen on localhost |
i run
./http_proxy
on machine A, output:then, run
on machine B, output:
now, type
on machine B, it's not work. output:
is this network problem? how can i fix it? thank u!
The text was updated successfully, but these errors were encountered: