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

Respect proxy config for SPV and P2P seeder connections #2184

Merged
merged 1 commit into from Sep 8, 2022

Conversation

jrick
Copy link
Member

@jrick jrick commented Sep 7, 2022

No description provided.

p2p/peering.go Outdated
@@ -181,7 +181,7 @@ func newNetAddress(addr net.Addr, services wire.ServiceFlag) (*wire.NetAddress,
return nil, fmt.Errorf("newNetAddress: unsupported address "+
"type %T", addr)
}
if ip.IsLoopback() || ip.IsPrivate() {
if !ip.IsGlobalUnicast() {
Copy link
Member

Choose a reason for hiding this comment

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

I think you'd want to not bother sending private addresses back either which this doesn't do.

package main

import (
	"fmt"
	"net"
)

func main() {
	ipv4Private1 := net.ParseIP("10.0.0.1")
	ipv4Private2 := net.ParseIP("172.16.0.1")
	ipv4Private3 := net.ParseIP("192.168.0.1")
	ipv6Private1 := net.ParseIP("fc00::1")

	p := func(ip net.IP) {
		fmt.Printf("%v (IsGlobalUnicast: %v, IsPrivate: %v)\n", ip, ip.IsGlobalUnicast(), ip.IsPrivate())
	}

	p(ipv4Private1)
	p(ipv4Private2)
	p(ipv4Private3)
	p(ipv6Private1)
}

Output:

10.0.0.1 (IsGlobalUnicast: true, IsPrivate: true)
172.16.0.1 (IsGlobalUnicast: true, IsPrivate: true)
192.168.0.1 (IsGlobalUnicast: true, IsPrivate: true)
fc00::1 (IsGlobalUnicast: true, IsPrivate: true)

Copy link
Member

Choose a reason for hiding this comment

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

Meh, you already updated it in the next commit.

Copy link
Member

@davecgh davecgh left a comment

Choose a reason for hiding this comment

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

Re-reviewed as of the latest IsGlobalUnicast returns true for private ips.

Remove the address of the local peer from the handshake.  This is to
prevent leaking internal network details and if a proxy is in use.
Peers are also no longer informed of their external address if the
address is loopback or a private or shared address.
@jrick jrick merged commit 18d4c02 into decred:master Sep 8, 2022
@jrick jrick deleted the spvproxy branch September 8, 2022 13:18
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.

None yet

3 participants