Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ We also added new metrics to the swarm Grafana dashboard, showing:

This feature should be safe to enable for nodes running in data centers and for most nodes in home networks.
However, there are some (mostly home and corporate networks) that block all UDP traffic. If enabled, the current implementation
of the smart dialing logic will lead to a regression, since it preferes QUIC addresses over TCP addresses. Nodes would still be
of the smart dialing logic will lead to a regression, since it prefers QUIC addresses over TCP addresses. Nodes would still be
able to connect, but connection establishment of the TCP connection would be delayed by 250ms.

In a future release (see #1605 for details), we will introduce a feature called blackhole detection. By observing the outcome of
Expand Down
2 changes: 1 addition & 1 deletion core/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ type Network interface {

type MultiaddrDNSResolver interface {
// ResolveDNSAddr resolves the first /dnsaddr component in a multiaddr.
// Recurisvely resolves DNSADDRs up to the recursion limit
// Recursively resolves DNSADDRs up to the recursion limit
ResolveDNSAddr(ctx context.Context, expectedPeerID peer.ID, maddr ma.Multiaddr, recursionLimit, outputLimit int) ([]ma.Multiaddr, error)
// ResolveDNSComponent resolves the first /{dns,dns4,dns6} component in a multiaddr.
ResolveDNSComponent(ctx context.Context, maddr ma.Multiaddr, outputLimit int) ([]ma.Multiaddr, error)
Expand Down
6 changes: 3 additions & 3 deletions dashboards/resource-manager/resource-manager.json
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"description": "How many streams does each protocol have open.\n\nA protocol is similiar to a service except there may be many protocols for a single service. A service may have \nmultiple protocols for backwards compatibility. For example, bitswap the service is a single entity, but it supports bitswap protocols v1.1 and v1.2.\n\nA service is attached to a stream manually by the protocol developer. A service may be missing if there is no `StreamScope.SetService` call.",
"description": "How many streams does each protocol have open.\n\nA protocol is similar to a service except there may be many protocols for a single service. A service may have \nmultiple protocols for backwards compatibility. For example, bitswap the service is a single entity, but it supports bitswap protocols v1.1 and v1.2.\n\nA service is attached to a stream manually by the protocol developer. A service may be missing if there is no `StreamScope.SetService` call.",
"fieldConfig": {
"defaults": {
"color": {
Expand Down Expand Up @@ -751,7 +751,7 @@
"showLineNumbers": false,
"showMiniMap": false
},
"content": "# Libp2p Connections\n\nBroken down by [Resource Scope](https://github.com/libp2p/go-libp2p/blob/master/p2p/host/resource-manager/README.md#resource-scopes). \nScopes represent what is imposing limits on this resource. For connections, we have three main scopes:\n\n1. System. The total number of connections owned by the process. Includes both application usable connections + the number of transient connections.\n2. Transient. The total number of connections that are being upgraded into usable connections in the process.\n3. Peer. The total number of connections associated with this peer. When a connection has this scope it is usable by the application.\n\nAn example of a System connection is a connection you can open a libp2p stream on and send data.\nA transient connection is not yet usable for application data since it may be negotiating \na security handshake or a multiplexer.\n\nConnections start in the transient scope and move over to the System and Peer scopes once they are ready to be used.\n\nIt would be unusual to see a lot of transient connections. It would also be unusal to see a peer with a lot of connections.",
"content": "# Libp2p Connections\n\nBroken down by [Resource Scope](https://github.com/libp2p/go-libp2p/blob/master/p2p/host/resource-manager/README.md#resource-scopes). \nScopes represent what is imposing limits on this resource. For connections, we have three main scopes:\n\n1. System. The total number of connections owned by the process. Includes both application usable connections + the number of transient connections.\n2. Transient. The total number of connections that are being upgraded into usable connections in the process.\n3. Peer. The total number of connections associated with this peer. When a connection has this scope it is usable by the application.\n\nAn example of a System connection is a connection you can open a libp2p stream on and send data.\nA transient connection is not yet usable for application data since it may be negotiating \na security handshake or a multiplexer.\n\nConnections start in the transient scope and move over to the System and Peer scopes once they are ready to be used.\n\nIt would be unusual to see a lot of transient connections. It would also be unusual to see a peer with a lot of connections.",
"mode": "markdown"
},
"pluginVersion": "9.3.6",
Expand Down Expand Up @@ -1217,7 +1217,7 @@
"refId": "A"
}
],
"title": "Curent outbound connections per peer histogram. Across all instances",
"title": "Current outbound connections per peer histogram. Across all instances",
"type": "bargauge"
},
{
Expand Down
10 changes: 5 additions & 5 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ func ForceReachabilityPublic() Option {
}

// ForceReachabilityPrivate overrides automatic reachability detection in the AutoNAT subsystem,
// forceing the local node to believe it is behind a NAT and not reachable externally.
// forcing the local node to believe it is behind a NAT and not reachable externally.
func ForceReachabilityPrivate() Option {
return func(cfg *Config) error {
private := network.ReachabilityPrivate
Expand Down Expand Up @@ -511,8 +511,8 @@ func MultiaddrResolver(rslv network.MultiaddrDNSResolver) Option {
// This subsystem performs two functions:
//
// 1. On receiving an inbound Relay connection, it attempts to create a direct connection with the remote peer
// by initiating and co-ordinating a hole punch over the Relayed connection.
// 2. If a peer sees a request to co-ordinate a hole punch on an outbound Relay connection,
// by initiating and coordinating a hole punch over the Relayed connection.
// 2. If a peer sees a request to coordinate a hole punch on an outbound Relay connection,
// it will participate in the hole-punch to create a direct connection with the remote peer.
//
// If the hole punch is successful, all new streams will thereafter be created on the hole-punched connection.
Expand All @@ -523,7 +523,7 @@ func MultiaddrResolver(rslv network.MultiaddrDNSResolver) Option {
//
// It is not mandatory but nice to also enable the `AutoRelay` option (See `EnableAutoRelay`)
// so the peer can discover and connect to Relay servers if it discovers that it is NATT'd and has private reachability via AutoNAT.
// This will then enable it to advertise Relay addresses which can be used to accept inbound Relay connections to then co-ordinate
// This will then enable it to advertise Relay addresses which can be used to accept inbound Relay connections to then coordinate
// a hole punch.
//
// If `EnableAutoRelay` is configured and the user is confident that the peer has private reachability/is NATT'd,
Expand Down Expand Up @@ -600,7 +600,7 @@ func SwarmOpts(opts ...swarm.Option) Option {

// DisableIdentifyAddressDiscovery disables address discovery using peer provided observed addresses
// in identify. If you know your public addresses upfront, the recommended way is to use
// AddressFactory to provide the external adddress to the host and use this option to disable
// AddressFactory to provide the external address to the host and use this option to disable
// discovery from identify.
func DisableIdentifyAddressDiscovery() Option {
return func(cfg *Config) error {
Expand Down
4 changes: 2 additions & 2 deletions p2p/host/basic/basic_host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ func TestHostProtoMismatch(t *testing.T) {
defer h2.Close()

h1.SetStreamHandler("/super", func(s network.Stream) {
t.Error("shouldnt get here")
t.Error("shouldn't get here")
s.Reset()
})

Expand Down Expand Up @@ -902,7 +902,7 @@ func TestTrimHostAddrList(t *testing.T) {
out: []ma.Multiaddr{tcpPublic},
},
{
name: "Public and private preffered over local",
name: "Public and private preferred over local",
in: []ma.Multiaddr{tcpPublic, tcpPrivate, quicLocal},
threshold: len(tcpPublic.Bytes()) + len(tcpPrivate.Bytes()),
out: []ma.Multiaddr{tcpPublic, tcpPrivate},
Expand Down
2 changes: 1 addition & 1 deletion p2p/host/peerstore/pstoremem/addr_book.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ func (mab *memoryAddrBook) GetPeerRecord(p peer.ID) *record.Envelope {
if _, ok := mab.addrs.Addrs[p]; !ok {
return nil
}
// The record may have expired, but not gargage collected.
// The record may have expired, but not garbage collected.
if len(validAddrs(mab.clock.Now(), mab.addrs.Addrs[p])) == 0 {
return nil
}
Expand Down
6 changes: 3 additions & 3 deletions p2p/host/resource-manager/scope_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -744,13 +744,13 @@ func TestResourceScopeDAG(t *testing.T) {
checkResources(t, &s1.rc, network.ScopeStat{Memory: 3072})

if err := s4.ReserveMemory(1024, network.ReservationPriorityAlways); err == nil {
t.Fatal("expcted ReserveMemory to fail")
t.Fatal("expected ReserveMemory to fail")
}
if err := s5.ReserveMemory(1024, network.ReservationPriorityAlways); err == nil {
t.Fatal("expcted ReserveMemory to fail")
t.Fatal("expected ReserveMemory to fail")
}
if err := s6.ReserveMemory(1024, network.ReservationPriorityAlways); err == nil {
t.Fatal("expcted ReserveMemory to fail")
t.Fatal("expected ReserveMemory to fail")
}

checkResources(t, &s6.rc, network.ScopeStat{Memory: 1024})
Expand Down
4 changes: 2 additions & 2 deletions p2p/net/connmgr/connmgr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func TestConnTrimming(t *testing.T) {
for i := 0; i < 100; i++ {
c := conns[i]
if c.(*tconn).isClosed() {
t.Fatal("these shouldnt be closed")
t.Fatal("these shouldn't be closed")
}
}

Expand Down Expand Up @@ -911,7 +911,7 @@ func TestPeerInfoSorting(t *testing.T) {
pis := peerInfos{p1, p2, p3, p4}
pis.SortByValueAndStreams(makeSegmentsWithPeerInfos(pis), true)
// p3 is first because it is inactive (no streams).
// p4 is second because it has the most streams and we priortize killing
// p4 is second because it has the most streams and we prioritize killing
// connections with the higher number of streams.
require.Equal(t, peerInfos{p3, p4, p2, p1}, pis)
})
Expand Down
4 changes: 2 additions & 2 deletions p2p/net/mock/mock_peernet.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,13 @@ func (pn *peernet) removeConn(c *conn) {
pn.Lock()
cs, found := pn.connsByLink[c.link]
if !found || len(cs) < 1 {
panic(fmt.Sprintf("attempting to remove a conn that doesnt exist %p", c.link))
panic(fmt.Sprintf("attempting to remove a conn that doesn't exist %p", c.link))
}
delete(cs, c)

cs, found = pn.connsByPeer[c.remote]
if !found {
panic(fmt.Sprintf("attempting to remove a conn that doesnt exist %v", c.remote))
panic(fmt.Sprintf("attempting to remove a conn that doesn't exist %v", c.remote))
}
delete(cs, c)
pn.Unlock()
Expand Down
4 changes: 2 additions & 2 deletions p2p/net/mock/mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,13 @@ func TestNetworkSetup(t *testing.T) {
t.Errorf("should have 1 conn on initiator. Got: %d)", len(n2.Conns()))
}

// wait for reciever to see the conn.
// wait for receiver to see the conn.
for i := 0; i < 10 && len(n3.Conns()) == 0; i++ {
time.Sleep(time.Duration(10*i) * time.Millisecond)
}

if len(n3.Conns()) != 1 {
t.Errorf("should have 1 conn on reciever. Got: %d", len(n3.Conns()))
t.Errorf("should have 1 conn on receiver. Got: %d", len(n3.Conns()))
}

// p := PrinterTo(os.Stdout)
Expand Down
4 changes: 2 additions & 2 deletions p2p/net/nat/internal/nat/upnp.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func discoverSearchTarget(ctx context.Context, target string) (nats []NAT, errs
}

// discoverUPNP_GenIGDev is a fallback for routers that fail to respond to our
// targetted SSDP queries. It will query all devices and try to find any
// targeted SSDP queries. It will query all devices and try to find any
// InternetGatewayDevice.
func discoverUPNP_GenIGDev(ctx context.Context) (nats []NAT, errs []error) {
DeviceList, err := ssdp.Search(ssdp.All, 5, "")
Expand Down Expand Up @@ -84,7 +84,7 @@ func discoverUPNP_GenIGDev(ctx context.Context) (nats []NAT, errs []error) {
return
}

// serviceVisitor is a vistor function that visits all services of a root
// serviceVisitor is a visitor function that visits all services of a root
// device and collects NATs.
//
// It works on InternetGateway V1 and V2 devices. For V1 devices, V2 services should not be encountered, and the visitor will collect an error in that case.
Expand Down
2 changes: 1 addition & 1 deletion p2p/net/reuseport/reuseport_plan9.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const (

// reuseErrShouldRetry diagnoses whether to retry after a reuse error.
// if we failed to bind, we should retry. if bind worked and this is a
// real dial error (remote end didnt answer) then we should not retry.
// real dial error (remote end didn't answer) then we should not retry.
func reuseErrShouldRetry(err error) bool {
if err == nil {
return false // hey, it worked! no need to retry.
Expand Down
2 changes: 1 addition & 1 deletion p2p/net/reuseport/reuseport_posix.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

// reuseErrShouldRetry diagnoses whether to retry after a reuse error.
// if we failed to bind, we should retry. if bind worked and this is a
// real dial error (remote end didnt answer) then we should not retry.
// real dial error (remote end didn't answer) then we should not retry.
func reuseErrShouldRetry(err error) bool {
if err == nil {
return false // hey, it worked! no need to retry.
Expand Down
2 changes: 1 addition & 1 deletion p2p/net/swarm/connectedness_event_emitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

// connectednessEventEmitter emits PeerConnectednessChanged events.
// We ensure that for any peer we connected to we always sent atleast 1 NotConnected Event after
// We ensure that for any peer we connected to we always sent at least 1 NotConnected Event after
// the peer disconnects. This is because peers can observe a connection before they are notified
// of the connection by a peer connectedness changed event.
type connectednessEventEmitter struct {
Expand Down
2 changes: 1 addition & 1 deletion p2p/net/swarm/dial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestBasicDialPeerWithResolver(t *testing.T) {
s2 := swarms[1]

// Change the multiaddr from /ip4/127.0.0.1/... to /dns4/example.com/... so
// that the resovler has to resolve this
// that the resolver has to resolve this
var s2Addrs []ma.Multiaddr
for _, a := range s2.ListenAddresses() {
_, rest := ma.SplitFunc(a, func(c ma.Component) bool {
Expand Down
2 changes: 1 addition & 1 deletion p2p/net/swarm/swarm_addr.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (s *Swarm) InterfaceListenAddresses() ([]ma.Multiaddr, error) {
}

// Cache is not valid
// Perfrom double checked locking
// Perform double checked locking

s.listeners.Lock() // Lock start

Expand Down
4 changes: 2 additions & 2 deletions p2p/net/swarm/swarm_dial.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func (db *DialBackoff) cleanup() {
// direct connection.
//
// The idea is that the client of Swarm does not need to know what network
// the connection will happen over. Swarm can use whichever it choses.
// the connection will happen over. Swarm can use whichever it chooses.
// This allows us to use various transport protocols, do NAT traversal/relay,
// etc. to achieve connection.
func (s *Swarm) DialPeer(ctx context.Context, p peer.ID) (network.Conn, error) {
Expand Down Expand Up @@ -383,7 +383,7 @@ func chainResolvers(ctx context.Context, addrs []ma.Multiaddr, outputLimit int,
}

// resolveAddrs resolves DNS/DNSADDR components in the given peer's addresses.
// We want to resolve the DNS components to IP addresses becase we want the
// We want to resolve the DNS components to IP addresses because we want the
// swarm to manage ranking and dialing multiple connections, and a single DNS
// address can resolve to multiple IP addresses.
func (s *Swarm) resolveAddrs(ctx context.Context, pi peer.AddrInfo) []ma.Multiaddr {
Expand Down
2 changes: 1 addition & 1 deletion p2p/net/swarm/swarm_listen.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (s *Swarm) Listen(addrs ...ma.Multiaddr) error {
}

// ListenClose stop and delete listeners for all of the given addresses. If an
// any address belongs to one of the addreses a Listener provides, then the
// any address belongs to one of the addresses a Listener provides, then the
// Listener will close for *all* addresses it provides. For example if you close
// and address with `/quic`, then the QUIC listener will close and also close
// any `/quic-v1` address.
Expand Down
2 changes: 1 addition & 1 deletion p2p/protocol/autonatv2/autonat.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func (an *AutoNAT) updatePeer(p peer.ID) {
an.mx.Lock()
defer an.mx.Unlock()

// There are no ordering gurantees between identify and swarm events. Check peerstore
// There are no ordering guarantees between identify and swarm events. Check peerstore
// and swarm for the current state
protos, err := an.host.Peerstore().SupportsProtocols(p, DialProtocol)
connectedness := an.host.Network().Connectedness(p)
Expand Down
2 changes: 1 addition & 1 deletion p2p/protocol/autonatv2/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (ac *client) getReachability(ctx context.Context, p peer.ID, reqs []Request

resp := msg.GetDialResponse()
if resp.GetStatus() != pb.DialResponse_OK {
// E_DIAL_REFUSED has implication for deciding future address verificiation priorities
// E_DIAL_REFUSED has implication for deciding future address verification priorities
// wrap a distinct error for convenient errors.Is usage
if resp.GetStatus() == pb.DialResponse_E_DIAL_REFUSED {
return Result{AllAddrsRefused: true}, nil
Expand Down
26 changes: 13 additions & 13 deletions p2p/protocol/holepunch/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ const (

// Event Objects
type DirectDialEvt struct {
Success bool
EllapsedTime time.Duration
Error string `json:",omitempty"`
Success bool
ElapsedTime time.Duration `json:"EllapsedTime,omitempty"`
Error string `json:",omitempty"`
}

type ProtocolErrorEvt struct {
Expand All @@ -111,9 +111,9 @@ type StartHolePunchEvt struct {
}

type EndHolePunchEvt struct {
Success bool
EllapsedTime time.Duration
Error string `json:",omitempty"`
Success bool
ElapsedTime time.Duration `json:"EllapsedTime,omitempty"`
Error string `json:",omitempty"`
}

type HolePunchAttemptEvt struct {
Expand All @@ -133,8 +133,8 @@ func (t *tracer) DirectDialSuccessful(p peer.ID, dt time.Duration) {
Remote: p,
Type: DirectDialEvtT,
Evt: &DirectDialEvt{
Success: true,
EllapsedTime: dt,
Success: true,
ElapsedTime: dt,
},
})
}
Expand All @@ -156,9 +156,9 @@ func (t *tracer) DirectDialFailed(p peer.ID, dt time.Duration, err error) {
Remote: p,
Type: DirectDialEvtT,
Evt: &DirectDialEvt{
Success: false,
EllapsedTime: dt,
Error: err.Error(),
Success: false,
ElapsedTime: dt,
Error: err.Error(),
},
})
}
Expand Down Expand Up @@ -205,8 +205,8 @@ func (t *tracer) StartHolePunch(p peer.ID, obsAddrs []ma.Multiaddr, rtt time.Dur
func (t *tracer) EndHolePunch(p peer.ID, dt time.Duration, err error) {
if t != nil && t.et != nil {
evt := &EndHolePunchEvt{
Success: err == nil,
EllapsedTime: dt,
Success: err == nil,
ElapsedTime: dt,
}
if err != nil {
evt.Error = err.Error()
Expand Down
2 changes: 1 addition & 1 deletion p2p/security/noise/handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (s *secureSession) runHandshake(ctx context.Context) (err error) {
}
}

// We can re-use this buffer for all handshake messages.
// We can reuse this buffer for all handshake messages.
hbuf := pool.Get(2 << 10)
defer pool.Put(hbuf)

Expand Down
2 changes: 1 addition & 1 deletion p2p/security/noise/rw.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (s *secureSession) Read(buf []byte) (int, error) {
return 0, err
}

// If the buffer is atleast as big as the encrypted message size,
// If the buffer is at least as big as the encrypted message size,
// we can read AND decrypt in place.
if len(buf) >= nextMsgLen {
if err := s.readNextMsgInsecure(buf[:nextMsgLen]); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion p2p/security/noise/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type secureSession struct {

initiatorEarlyDataHandler, responderEarlyDataHandler EarlyDataHandler

// ConnectionState holds state information releated to the secureSession entity.
// ConnectionState holds state information related to the secureSession entity.
connectionState network.ConnectionState
}

Expand Down
2 changes: 1 addition & 1 deletion p2p/security/tls/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (t *Transport) setupConn(tlsConn *tls.Conn, remotePubKey ci.PubKey) (sec.Se

nextProto := tlsConn.ConnectionState().NegotiatedProtocol
// The special ALPN extension value "libp2p" is used by libp2p versions
// that don't support early muxer negotiation. If we see this sepcial
// that don't support early muxer negotiation. If we see this special
// value selected, that means we are handshaking with a version that does
// not support early muxer negotiation. In this case return empty nextProto
// to indicate no muxer is selected.
Expand Down
Loading