mirror of
https://github.com/libp2p/go-libp2p.git
synced 2025-09-26 20:21:26 +08:00
switch from github.com/libp2p/go-libp2p-core to core
This commit is contained in:
@@ -5,18 +5,17 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/connmgr"
|
"github.com/libp2p/go-libp2p/core/connmgr"
|
||||||
"github.com/libp2p/go-libp2p-core/crypto"
|
"github.com/libp2p/go-libp2p/core/crypto"
|
||||||
"github.com/libp2p/go-libp2p-core/host"
|
"github.com/libp2p/go-libp2p/core/host"
|
||||||
"github.com/libp2p/go-libp2p-core/metrics"
|
"github.com/libp2p/go-libp2p/core/metrics"
|
||||||
"github.com/libp2p/go-libp2p-core/network"
|
"github.com/libp2p/go-libp2p/core/network"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
"github.com/libp2p/go-libp2p-core/peerstore"
|
"github.com/libp2p/go-libp2p/core/peerstore"
|
||||||
"github.com/libp2p/go-libp2p-core/pnet"
|
"github.com/libp2p/go-libp2p/core/pnet"
|
||||||
"github.com/libp2p/go-libp2p-core/routing"
|
"github.com/libp2p/go-libp2p/core/routing"
|
||||||
"github.com/libp2p/go-libp2p-core/sec"
|
"github.com/libp2p/go-libp2p/core/sec"
|
||||||
"github.com/libp2p/go-libp2p-core/transport"
|
"github.com/libp2p/go-libp2p/core/transport"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p/p2p/host/autonat"
|
"github.com/libp2p/go-libp2p/p2p/host/autonat"
|
||||||
"github.com/libp2p/go-libp2p/p2p/host/autorelay"
|
"github.com/libp2p/go-libp2p/p2p/host/autorelay"
|
||||||
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
|
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
|
||||||
|
@@ -4,15 +4,15 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/connmgr"
|
"github.com/libp2p/go-libp2p/core/connmgr"
|
||||||
"github.com/libp2p/go-libp2p-core/crypto"
|
"github.com/libp2p/go-libp2p/core/crypto"
|
||||||
"github.com/libp2p/go-libp2p-core/host"
|
"github.com/libp2p/go-libp2p/core/host"
|
||||||
"github.com/libp2p/go-libp2p-core/network"
|
"github.com/libp2p/go-libp2p/core/network"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
"github.com/libp2p/go-libp2p-core/peerstore"
|
"github.com/libp2p/go-libp2p/core/peerstore"
|
||||||
"github.com/libp2p/go-libp2p-core/pnet"
|
"github.com/libp2p/go-libp2p/core/pnet"
|
||||||
"github.com/libp2p/go-libp2p-core/sec"
|
"github.com/libp2p/go-libp2p/core/sec"
|
||||||
"github.com/libp2p/go-libp2p-core/transport"
|
"github.com/libp2p/go-libp2p/core/transport"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@@ -3,11 +3,9 @@ package config
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/libp2p/go-libp2p/core/host"
|
||||||
|
"github.com/libp2p/go-libp2p/core/network"
|
||||||
msmux "github.com/libp2p/go-libp2p/p2p/muxer/muxer-multistream"
|
msmux "github.com/libp2p/go-libp2p/p2p/muxer/muxer-multistream"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/network"
|
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/host"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// MuxC is a stream multiplex transport constructor.
|
// MuxC is a stream multiplex transport constructor.
|
||||||
|
@@ -3,13 +3,12 @@ package config
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/libp2p/go-libp2p/core/host"
|
||||||
|
"github.com/libp2p/go-libp2p/core/network"
|
||||||
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
|
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
|
||||||
"github.com/libp2p/go-libp2p/p2p/muxer/yamux"
|
"github.com/libp2p/go-libp2p/p2p/muxer/yamux"
|
||||||
swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing"
|
swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/host"
|
|
||||||
"github.com/libp2p/go-libp2p-core/network"
|
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMuxerSimple(t *testing.T) {
|
func TestMuxerSimple(t *testing.T) {
|
||||||
|
@@ -6,13 +6,11 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/network"
|
"github.com/libp2p/go-libp2p/core/connmgr"
|
||||||
|
"github.com/libp2p/go-libp2p/core/host"
|
||||||
"github.com/libp2p/go-libp2p-core/pnet"
|
"github.com/libp2p/go-libp2p/core/network"
|
||||||
|
"github.com/libp2p/go-libp2p/core/pnet"
|
||||||
"github.com/libp2p/go-libp2p-core/connmgr"
|
"github.com/libp2p/go-libp2p/core/transport"
|
||||||
"github.com/libp2p/go-libp2p-core/host"
|
|
||||||
"github.com/libp2p/go-libp2p-core/transport"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var errorType = reflect.TypeOf((*error)(nil)).Elem()
|
var errorType = reflect.TypeOf((*error)(nil)).Elem()
|
||||||
|
@@ -3,13 +3,12 @@ package config
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/libp2p/go-libp2p/core/crypto"
|
||||||
|
"github.com/libp2p/go-libp2p/core/host"
|
||||||
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
|
"github.com/libp2p/go-libp2p/core/sec"
|
||||||
|
"github.com/libp2p/go-libp2p/core/sec/insecure"
|
||||||
csms "github.com/libp2p/go-libp2p/p2p/net/conn-security-multistream"
|
csms "github.com/libp2p/go-libp2p/p2p/net/conn-security-multistream"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/crypto"
|
|
||||||
"github.com/libp2p/go-libp2p-core/host"
|
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
|
||||||
"github.com/libp2p/go-libp2p-core/sec"
|
|
||||||
"github.com/libp2p/go-libp2p-core/sec/insecure"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// SecC is a security transport constructor.
|
// SecC is a security transport constructor.
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/libp2p/go-libp2p-core/connmgr"
|
"github.com/libp2p/go-libp2p/core/connmgr"
|
||||||
"github.com/libp2p/go-libp2p-core/host"
|
"github.com/libp2p/go-libp2p/core/host"
|
||||||
"github.com/libp2p/go-libp2p-core/network"
|
"github.com/libp2p/go-libp2p/core/network"
|
||||||
"github.com/libp2p/go-libp2p-core/pnet"
|
"github.com/libp2p/go-libp2p/core/pnet"
|
||||||
"github.com/libp2p/go-libp2p-core/transport"
|
"github.com/libp2p/go-libp2p/core/transport"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TptC is the type for libp2p transport constructors. You probably won't ever
|
// TptC is the type for libp2p transport constructors. You probably won't ever
|
||||||
|
@@ -3,11 +3,10 @@ package config
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
|
"github.com/libp2p/go-libp2p/core/transport"
|
||||||
"github.com/libp2p/go-libp2p/p2p/transport/tcp"
|
"github.com/libp2p/go-libp2p/p2p/transport/tcp"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
|
||||||
"github.com/libp2p/go-libp2p-core/transport"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -2,10 +2,11 @@
|
|||||||
package core
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/libp2p/go-libp2p-core/host"
|
"github.com/libp2p/go-libp2p/core/host"
|
||||||
"github.com/libp2p/go-libp2p-core/network"
|
"github.com/libp2p/go-libp2p/core/network"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
"github.com/libp2p/go-libp2p-core/protocol"
|
"github.com/libp2p/go-libp2p/core/protocol"
|
||||||
|
|
||||||
"github.com/multiformats/go-multiaddr"
|
"github.com/multiformats/go-multiaddr"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -6,8 +6,9 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
|
|
||||||
logging "github.com/ipfs/go-log/v2"
|
logging "github.com/ipfs/go-log/v2"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
|
||||||
"github.com/multiformats/go-multiaddr"
|
"github.com/multiformats/go-multiaddr"
|
||||||
manet "github.com/multiformats/go-multiaddr/net"
|
manet "github.com/multiformats/go-multiaddr/net"
|
||||||
)
|
)
|
||||||
|
@@ -5,8 +5,9 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/libp2p/go-libp2p/core/test"
|
||||||
|
|
||||||
logging "github.com/ipfs/go-log/v2"
|
logging "github.com/ipfs/go-log/v2"
|
||||||
"github.com/libp2p/go-libp2p-core/test"
|
|
||||||
"github.com/multiformats/go-multiaddr"
|
"github.com/multiformats/go-multiaddr"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -4,7 +4,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Decayer is implemented by connection managers supporting decaying tags. A
|
// Decayer is implemented by connection managers supporting decaying tags. A
|
||||||
@@ -22,10 +22,10 @@ import (
|
|||||||
// Such a pluggable design affords a great deal of flexibility and versatility.
|
// Such a pluggable design affords a great deal of flexibility and versatility.
|
||||||
// Behaviours that are straightforward to implement include:
|
// Behaviours that are straightforward to implement include:
|
||||||
//
|
//
|
||||||
// * Decay a tag by -1, or by half its current value, on every tick.
|
// - Decay a tag by -1, or by half its current value, on every tick.
|
||||||
// * Every time a value is bumped, sum it to its current value.
|
// - Every time a value is bumped, sum it to its current value.
|
||||||
// * Exponentially boost a score with every bump.
|
// - Exponentially boost a score with every bump.
|
||||||
// * Sum the incoming score, but keep it within min, max bounds.
|
// - Sum the incoming score, but keep it within min, max bounds.
|
||||||
//
|
//
|
||||||
// Commonly used DecayFns and BumpFns are provided in this package.
|
// Commonly used DecayFns and BumpFns are provided in this package.
|
||||||
type Decayer interface {
|
type Decayer interface {
|
||||||
|
@@ -3,9 +3,9 @@ package connmgr
|
|||||||
import (
|
import (
|
||||||
ma "github.com/multiformats/go-multiaddr"
|
ma "github.com/multiformats/go-multiaddr"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/control"
|
"github.com/libp2p/go-libp2p/core/control"
|
||||||
"github.com/libp2p/go-libp2p-core/network"
|
"github.com/libp2p/go-libp2p/core/network"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ConnectionGater can be implemented by a type that supports active
|
// ConnectionGater can be implemented by a type that supports active
|
||||||
@@ -17,25 +17,25 @@ import (
|
|||||||
// of a connection being established/upgraded. Specific functions will be called
|
// of a connection being established/upgraded. Specific functions will be called
|
||||||
// throughout the process, to allow you to intercept the connection at that stage.
|
// throughout the process, to allow you to intercept the connection at that stage.
|
||||||
//
|
//
|
||||||
// InterceptPeerDial is called on an imminent outbound peer dial request, prior
|
// InterceptPeerDial is called on an imminent outbound peer dial request, prior
|
||||||
// to the addresses of that peer being available/resolved. Blocking connections
|
// to the addresses of that peer being available/resolved. Blocking connections
|
||||||
// at this stage is typical for blacklisting scenarios.
|
// at this stage is typical for blacklisting scenarios.
|
||||||
//
|
//
|
||||||
// InterceptAddrDial is called on an imminent outbound dial to a peer on a
|
// InterceptAddrDial is called on an imminent outbound dial to a peer on a
|
||||||
// particular address. Blocking connections at this stage is typical for
|
// particular address. Blocking connections at this stage is typical for
|
||||||
// address filtering.
|
// address filtering.
|
||||||
//
|
//
|
||||||
// InterceptAccept is called as soon as a transport listener receives an
|
// InterceptAccept is called as soon as a transport listener receives an
|
||||||
// inbound connection request, before any upgrade takes place. Transports who
|
// inbound connection request, before any upgrade takes place. Transports who
|
||||||
// accept already secure and/or multiplexed connections (e.g. possibly QUIC)
|
// accept already secure and/or multiplexed connections (e.g. possibly QUIC)
|
||||||
// MUST call this method regardless, for correctness/consistency.
|
// MUST call this method regardless, for correctness/consistency.
|
||||||
//
|
//
|
||||||
// InterceptSecured is called for both inbound and outbound connections,
|
// InterceptSecured is called for both inbound and outbound connections,
|
||||||
// after a security handshake has taken place and we've authenticated the peer.
|
// after a security handshake has taken place and we've authenticated the peer.
|
||||||
//
|
//
|
||||||
// InterceptUpgraded is called for inbound and outbound connections, after
|
// InterceptUpgraded is called for inbound and outbound connections, after
|
||||||
// libp2p has finished upgrading the connection entirely to a secure,
|
// libp2p has finished upgrading the connection entirely to a secure,
|
||||||
// multiplexed channel.
|
// multiplexed channel.
|
||||||
//
|
//
|
||||||
// This interface can be used to implement *strict/active* connection management
|
// This interface can be used to implement *strict/active* connection management
|
||||||
// policies, such as hard limiting of connections once a maximum count has been
|
// policies, such as hard limiting of connections once a maximum count has been
|
||||||
|
@@ -10,8 +10,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/network"
|
"github.com/libp2p/go-libp2p/core/network"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SupportsDecay evaluates if the provided ConnManager supports decay, and if
|
// SupportsDecay evaluates if the provided ConnManager supports decay, and if
|
||||||
|
@@ -3,8 +3,8 @@ package connmgr
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/network"
|
"github.com/libp2p/go-libp2p/core/network"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NullConnMgr is a ConnMgr that provides no functionality.
|
// NullConnMgr is a ConnMgr that provides no functionality.
|
||||||
|
@@ -10,8 +10,8 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
pb "github.com/libp2p/go-libp2p-core/crypto/pb"
|
pb "github.com/libp2p/go-libp2p/core/crypto/pb"
|
||||||
"github.com/libp2p/go-libp2p-core/internal/catch"
|
"github.com/libp2p/go-libp2p/core/internal/catch"
|
||||||
|
|
||||||
"github.com/minio/sha256-simd"
|
"github.com/minio/sha256-simd"
|
||||||
)
|
)
|
||||||
|
@@ -8,8 +8,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
pb "github.com/libp2p/go-libp2p-core/crypto/pb"
|
pb "github.com/libp2p/go-libp2p/core/crypto/pb"
|
||||||
"github.com/libp2p/go-libp2p-core/internal/catch"
|
"github.com/libp2p/go-libp2p/core/internal/catch"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Ed25519PrivateKey is an ed25519 private key.
|
// Ed25519PrivateKey is an ed25519 private key.
|
||||||
|
@@ -5,7 +5,7 @@ import (
|
|||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
pb "github.com/libp2p/go-libp2p-core/crypto/pb"
|
pb "github.com/libp2p/go-libp2p/core/crypto/pb"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestBasicSignAndVerify(t *testing.T) {
|
func TestBasicSignAndVerify(t *testing.T) {
|
||||||
|
@@ -8,8 +8,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/crypto"
|
"github.com/libp2p/go-libp2p/core/crypto"
|
||||||
crypto_pb "github.com/libp2p/go-libp2p-core/crypto/pb"
|
crypto_pb "github.com/libp2p/go-libp2p/core/crypto/pb"
|
||||||
)
|
)
|
||||||
|
|
||||||
var message = []byte("Libp2p is the _best_!")
|
var message = []byte("Libp2p is the _best_!")
|
||||||
|
@@ -12,7 +12,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
pb "github.com/libp2p/go-libp2p-core/crypto/pb"
|
pb "github.com/libp2p/go-libp2p/core/crypto/pb"
|
||||||
|
|
||||||
"github.com/gogo/protobuf/proto"
|
"github.com/gogo/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
@@ -9,10 +9,10 @@ import (
|
|||||||
"crypto/ed25519"
|
"crypto/ed25519"
|
||||||
"crypto/rsa"
|
"crypto/rsa"
|
||||||
|
|
||||||
btcec "github.com/btcsuite/btcd/btcec/v2"
|
"github.com/btcsuite/btcd/btcec/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// KeyPairFromStdKey wraps standard library (and secp256k1) private keys in libp2p/go-libp2p-core/crypto keys
|
// KeyPairFromStdKey wraps standard library (and secp256k1) private keys in libp2p/go-libp2p/core/crypto keys
|
||||||
func KeyPairFromStdKey(priv crypto.PrivateKey) (PrivKey, PubKey, error) {
|
func KeyPairFromStdKey(priv crypto.PrivateKey) (PrivKey, PubKey, error) {
|
||||||
if priv == nil {
|
if priv == nil {
|
||||||
return nil, nil, ErrNilPrivateKey
|
return nil, nil, ErrNilPrivateKey
|
||||||
@@ -40,7 +40,7 @@ func KeyPairFromStdKey(priv crypto.PrivateKey) (PrivKey, PubKey, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// PrivKeyToStdKey converts libp2p/go-libp2p-core/crypto private keys to standard library (and secp256k1) private keys
|
// PrivKeyToStdKey converts libp2p/go-libp2p/core/crypto private keys to standard library (and secp256k1) private keys
|
||||||
func PrivKeyToStdKey(priv PrivKey) (crypto.PrivateKey, error) {
|
func PrivKeyToStdKey(priv PrivKey) (crypto.PrivateKey, error) {
|
||||||
if priv == nil {
|
if priv == nil {
|
||||||
return nil, ErrNilPrivateKey
|
return nil, ErrNilPrivateKey
|
||||||
@@ -60,7 +60,7 @@ func PrivKeyToStdKey(priv PrivKey) (crypto.PrivateKey, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// PubKeyToStdKey converts libp2p/go-libp2p-core/crypto private keys to standard library (and secp256k1) public keys
|
// PubKeyToStdKey converts libp2p/go-libp2p/core/crypto private keys to standard library (and secp256k1) public keys
|
||||||
func PubKeyToStdKey(pub PubKey) (crypto.PublicKey, error) {
|
func PubKeyToStdKey(pub PubKey) (crypto.PublicKey, error) {
|
||||||
if pub == nil {
|
if pub == nil {
|
||||||
return nil, ErrNilPublicKey
|
return nil, ErrNilPublicKey
|
||||||
|
@@ -10,13 +10,13 @@ import (
|
|||||||
"crypto/rsa"
|
"crypto/rsa"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
|
|
||||||
btcec "github.com/btcsuite/btcd/btcec/v2"
|
"github.com/libp2p/go-libp2p/core/internal/catch"
|
||||||
openssl "github.com/libp2p/go-openssl"
|
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/internal/catch"
|
"github.com/btcsuite/btcd/btcec/v2"
|
||||||
|
"github.com/libp2p/go-openssl"
|
||||||
)
|
)
|
||||||
|
|
||||||
// KeyPairFromStdKey wraps standard library (and secp256k1) private keys in libp2p/go-libp2p-core/crypto keys
|
// KeyPairFromStdKey wraps standard library (and secp256k1) private keys in libp2p/go-libp2p/core/crypto keys
|
||||||
func KeyPairFromStdKey(priv crypto.PrivateKey) (_priv PrivKey, _pub PubKey, err error) {
|
func KeyPairFromStdKey(priv crypto.PrivateKey) (_priv PrivKey, _pub PubKey, err error) {
|
||||||
if priv == nil {
|
if priv == nil {
|
||||||
return nil, nil, ErrNilPrivateKey
|
return nil, nil, ErrNilPrivateKey
|
||||||
@@ -50,7 +50,7 @@ func KeyPairFromStdKey(priv crypto.PrivateKey) (_priv PrivKey, _pub PubKey, err
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// PrivKeyToStdKey converts libp2p/go-libp2p-core/crypto private keys to standard library (and secp256k1) private keys
|
// PrivKeyToStdKey converts libp2p/go-libp2p/core/crypto private keys to standard library (and secp256k1) private keys
|
||||||
func PrivKeyToStdKey(priv PrivKey) (_priv crypto.PrivateKey, err error) {
|
func PrivKeyToStdKey(priv PrivKey) (_priv crypto.PrivateKey, err error) {
|
||||||
if priv == nil {
|
if priv == nil {
|
||||||
return nil, ErrNilPrivateKey
|
return nil, ErrNilPrivateKey
|
||||||
@@ -74,7 +74,7 @@ func PrivKeyToStdKey(priv PrivKey) (_priv crypto.PrivateKey, err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// PubKeyToStdKey converts libp2p/go-libp2p-core/crypto private keys to standard library (and secp256k1) public keys
|
// PubKeyToStdKey converts libp2p/go-libp2p/core/crypto private keys to standard library (and secp256k1) public keys
|
||||||
func PubKeyToStdKey(pub PubKey) (key crypto.PublicKey, err error) {
|
func PubKeyToStdKey(pub PubKey) (key crypto.PublicKey, err error) {
|
||||||
if pub == nil {
|
if pub == nil {
|
||||||
return nil, ErrNilPublicKey
|
return nil, ErrNilPublicKey
|
||||||
|
@@ -13,11 +13,12 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
btcec "github.com/btcsuite/btcd/btcec/v2"
|
. "github.com/libp2p/go-libp2p/core/crypto"
|
||||||
|
pb "github.com/libp2p/go-libp2p/core/crypto/pb"
|
||||||
|
"github.com/libp2p/go-libp2p/core/test"
|
||||||
|
|
||||||
|
"github.com/btcsuite/btcd/btcec/v2"
|
||||||
btcececdsa "github.com/btcsuite/btcd/btcec/v2/ecdsa"
|
btcececdsa "github.com/btcsuite/btcd/btcec/v2/ecdsa"
|
||||||
. "github.com/libp2p/go-libp2p-core/crypto"
|
|
||||||
pb "github.com/libp2p/go-libp2p-core/crypto/pb"
|
|
||||||
"github.com/libp2p/go-libp2p-core/test"
|
|
||||||
"github.com/minio/sha256-simd"
|
"github.com/minio/sha256-simd"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -6,7 +6,7 @@ package crypto
|
|||||||
import (
|
import (
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
pb "github.com/libp2p/go-libp2p-core/crypto/pb"
|
pb "github.com/libp2p/go-libp2p/core/crypto/pb"
|
||||||
|
|
||||||
"github.com/libp2p/go-openssl"
|
"github.com/libp2p/go-openssl"
|
||||||
)
|
)
|
||||||
|
@@ -2,7 +2,7 @@ syntax = "proto2";
|
|||||||
|
|
||||||
package crypto.pb;
|
package crypto.pb;
|
||||||
|
|
||||||
option go_package = "github.com/libp2p/go-libp2p-core/crypto/pb";
|
option go_package = "github.com/libp2p/go-libp2p/core/crypto/pb";
|
||||||
|
|
||||||
enum KeyType {
|
enum KeyType {
|
||||||
RSA = 0;
|
RSA = 0;
|
||||||
|
@@ -11,8 +11,8 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
pb "github.com/libp2p/go-libp2p-core/crypto/pb"
|
pb "github.com/libp2p/go-libp2p/core/crypto/pb"
|
||||||
"github.com/libp2p/go-libp2p-core/internal/catch"
|
"github.com/libp2p/go-libp2p/core/internal/catch"
|
||||||
|
|
||||||
"github.com/minio/sha256-simd"
|
"github.com/minio/sha256-simd"
|
||||||
)
|
)
|
||||||
|
@@ -4,8 +4,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
pb "github.com/libp2p/go-libp2p-core/crypto/pb"
|
pb "github.com/libp2p/go-libp2p/core/crypto/pb"
|
||||||
"github.com/libp2p/go-libp2p-core/internal/catch"
|
"github.com/libp2p/go-libp2p/core/internal/catch"
|
||||||
|
|
||||||
btcec "github.com/btcsuite/btcd/btcec/v2"
|
btcec "github.com/btcsuite/btcd/btcec/v2"
|
||||||
btcececdsa "github.com/btcsuite/btcd/btcec/v2/ecdsa"
|
btcececdsa "github.com/btcsuite/btcd/btcec/v2/ecdsa"
|
||||||
|
@@ -5,7 +5,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Advertiser is an interface for advertising services
|
// Advertiser is an interface for advertising services
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
package event
|
package event
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/libp2p/go-libp2p-core/record"
|
"github.com/libp2p/go-libp2p/core/record"
|
||||||
|
|
||||||
ma "github.com/multiformats/go-multiaddr"
|
ma "github.com/multiformats/go-multiaddr"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -2,10 +2,10 @@
|
|||||||
// that libp2p subsystems may emit.
|
// that libp2p subsystems may emit.
|
||||||
//
|
//
|
||||||
// Source code is arranged as follows:
|
// Source code is arranged as follows:
|
||||||
// * doc.go: this file.
|
// - doc.go: this file.
|
||||||
// * bus.go: abstractions for the event bus.
|
// - bus.go: abstractions for the event bus.
|
||||||
// * rest: event structs, sensibly categorised in files by entity, and following this naming convention:
|
// - rest: event structs, sensibly categorised in files by entity, and following this naming convention:
|
||||||
// Evt[Entity (noun)][Event (verb past tense / gerund)]
|
// Evt[Entity (noun)][Event (verb past tense / gerund)]
|
||||||
// The past tense is used to convey that something happened, whereas the gerund form of the verb (-ing)
|
// The past tense is used to convey that something happened, whereas the gerund form of the verb (-ing)
|
||||||
// expresses that a process is in progress. Examples: EvtConnEstablishing, EvtConnEstablished.
|
// expresses that a process is in progress. Examples: EvtConnEstablishing, EvtConnEstablished.
|
||||||
package event
|
package event
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
package event
|
package event
|
||||||
|
|
||||||
import "github.com/libp2p/go-libp2p-core/peer"
|
import "github.com/libp2p/go-libp2p/core/peer"
|
||||||
|
|
||||||
// EvtPeerIdentificationCompleted is emitted when the initial identification round for a peer is completed.
|
// EvtPeerIdentificationCompleted is emitted when the initial identification round for a peer is completed.
|
||||||
type EvtPeerIdentificationCompleted struct {
|
type EvtPeerIdentificationCompleted struct {
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
package event
|
package event
|
||||||
|
|
||||||
import "github.com/libp2p/go-libp2p-core/network"
|
import "github.com/libp2p/go-libp2p/core/network"
|
||||||
|
|
||||||
// EvtNATDeviceTypeChanged is an event struct to be emitted when the type of the NAT device changes for a Transport Protocol.
|
// EvtNATDeviceTypeChanged is an event struct to be emitted when the type of the NAT device changes for a Transport Protocol.
|
||||||
//
|
//
|
||||||
|
@@ -1,48 +1,48 @@
|
|||||||
package event
|
package event
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/libp2p/go-libp2p-core/network"
|
"github.com/libp2p/go-libp2p/core/network"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
)
|
)
|
||||||
|
|
||||||
// EvtPeerConnectednessChanged should be emitted every time the "connectedness" to a
|
// EvtPeerConnectednessChanged should be emitted every time the "connectedness" to a
|
||||||
// given peer changes. Specifically, this event is emitted in the following
|
// given peer changes. Specifically, this event is emitted in the following
|
||||||
// cases:
|
// cases:
|
||||||
//
|
//
|
||||||
// * Connectedness = Connected: Every time we transition from having no
|
// - Connectedness = Connected: Every time we transition from having no
|
||||||
// connections to a peer to having at least one connection to the peer.
|
// connections to a peer to having at least one connection to the peer.
|
||||||
// * Connectedness = NotConnected: Every time we transition from having at least
|
// - Connectedness = NotConnected: Every time we transition from having at least
|
||||||
// one connection to a peer to having no connections to the peer.
|
// one connection to a peer to having no connections to the peer.
|
||||||
//
|
//
|
||||||
// Additional connectedness states may be added in the future. This list should
|
// Additional connectedness states may be added in the future. This list should
|
||||||
// not be considered exhaustive.
|
// not be considered exhaustive.
|
||||||
//
|
//
|
||||||
// Take note:
|
// Take note:
|
||||||
//
|
//
|
||||||
// * It's possible to have _multiple_ connections to a given peer.
|
// - It's possible to have _multiple_ connections to a given peer.
|
||||||
// * Both libp2p and networks are asynchronous.
|
// - Both libp2p and networks are asynchronous.
|
||||||
//
|
//
|
||||||
// This means that all of the following situations are possible:
|
// This means that all of the following situations are possible:
|
||||||
//
|
//
|
||||||
// A connection is cut and is re-established:
|
// A connection is cut and is re-established:
|
||||||
//
|
//
|
||||||
// * Peer A observes a transition from Connected -> NotConnected -> Connected
|
// - Peer A observes a transition from Connected -> NotConnected -> Connected
|
||||||
// * Peer B observes a transition from Connected -> NotConnected -> Connected
|
// - Peer B observes a transition from Connected -> NotConnected -> Connected
|
||||||
//
|
//
|
||||||
// Explanation: Both peers observe the connection die. This is the "nice" case.
|
// Explanation: Both peers observe the connection die. This is the "nice" case.
|
||||||
//
|
//
|
||||||
// A connection is cut and is re-established.
|
// A connection is cut and is re-established.
|
||||||
//
|
//
|
||||||
// * Peer A observes a transition from Connected -> NotConnected -> Connected.
|
// - Peer A observes a transition from Connected -> NotConnected -> Connected.
|
||||||
// * Peer B observes no transition.
|
// - Peer B observes no transition.
|
||||||
//
|
//
|
||||||
// Explanation: Peer A re-establishes the dead connection. Peer B observes the
|
// Explanation: Peer A re-establishes the dead connection. Peer B observes the
|
||||||
// new connection form before it observes the old connection die.
|
// new connection form before it observes the old connection die.
|
||||||
//
|
//
|
||||||
// A connection is cut:
|
// A connection is cut:
|
||||||
//
|
//
|
||||||
// * Peer A observes no transition.
|
// - Peer A observes no transition.
|
||||||
// * Peer B observes no transition.
|
// - Peer B observes no transition.
|
||||||
//
|
//
|
||||||
// Explanation: There were two connections and one was cut. This connection
|
// Explanation: There were two connections and one was cut. This connection
|
||||||
// might have been in active use but neither peer will observe a change in
|
// might have been in active use but neither peer will observe a change in
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
package event
|
package event
|
||||||
|
|
||||||
import (
|
import (
|
||||||
peer "github.com/libp2p/go-libp2p-core/peer"
|
peer "github.com/libp2p/go-libp2p/core/peer"
|
||||||
protocol "github.com/libp2p/go-libp2p-core/protocol"
|
protocol "github.com/libp2p/go-libp2p/core/protocol"
|
||||||
)
|
)
|
||||||
|
|
||||||
// EvtPeerProtocolsUpdated should be emitted when a peer we're connected to adds or removes protocols from their stack.
|
// EvtPeerProtocolsUpdated should be emitted when a peer we're connected to adds or removes protocols from their stack.
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
package event
|
package event
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/libp2p/go-libp2p-core/network"
|
"github.com/libp2p/go-libp2p/core/network"
|
||||||
)
|
)
|
||||||
|
|
||||||
// EvtLocalReachabilityChanged is an event struct to be emitted when the local's
|
// EvtLocalReachabilityChanged is an event struct to be emitted when the local's
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
package host
|
package host
|
||||||
|
|
||||||
import "github.com/libp2p/go-libp2p-core/peer"
|
import "github.com/libp2p/go-libp2p/core/peer"
|
||||||
|
|
||||||
// InfoFromHost returns a peer.AddrInfo struct with the Host's ID and all of its Addrs.
|
// InfoFromHost returns a peer.AddrInfo struct with the Host's ID and all of its Addrs.
|
||||||
func InfoFromHost(h Host) *peer.AddrInfo {
|
func InfoFromHost(h Host) *peer.AddrInfo {
|
||||||
|
@@ -6,13 +6,13 @@ package host
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/connmgr"
|
"github.com/libp2p/go-libp2p/core/connmgr"
|
||||||
"github.com/libp2p/go-libp2p-core/event"
|
"github.com/libp2p/go-libp2p/core/event"
|
||||||
"github.com/libp2p/go-libp2p-core/introspection"
|
"github.com/libp2p/go-libp2p/core/introspection"
|
||||||
"github.com/libp2p/go-libp2p-core/network"
|
"github.com/libp2p/go-libp2p/core/network"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
"github.com/libp2p/go-libp2p-core/peerstore"
|
"github.com/libp2p/go-libp2p/core/peerstore"
|
||||||
"github.com/libp2p/go-libp2p-core/protocol"
|
"github.com/libp2p/go-libp2p/core/protocol"
|
||||||
|
|
||||||
ma "github.com/multiformats/go-multiaddr"
|
ma "github.com/multiformats/go-multiaddr"
|
||||||
)
|
)
|
||||||
|
@@ -3,7 +3,7 @@ package introspection
|
|||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/introspection/pb"
|
"github.com/libp2p/go-libp2p/core/introspection/pb"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Introspector is the interface to be satisfied by components that are capable
|
// Introspector is the interface to be satisfied by components that are capable
|
||||||
|
@@ -397,11 +397,12 @@ func (m *ResultCounter) GetErr() uint32 {
|
|||||||
//
|
//
|
||||||
// time past -> present an event 16 min ago
|
// time past -> present an event 16 min ago
|
||||||
// ======================================================X================>>
|
// ======================================================X================>>
|
||||||
// | | 1m
|
//
|
||||||
// | |---| 5m
|
// | | 1m
|
||||||
// | |-------------| 15m
|
// | |---| 5m
|
||||||
// |------------X---------------| 30m
|
// | |-------------| 15m
|
||||||
// |------------------------------------------X---------------| 60m
|
// |------------X---------------| 30m
|
||||||
|
// |------------------------------------------X---------------| 60m
|
||||||
type SlidingCounter struct {
|
type SlidingCounter struct {
|
||||||
Over_1M uint32 `protobuf:"varint,1,opt,name=over_1m,json=over1m,proto3" json:"over_1m,omitempty"`
|
Over_1M uint32 `protobuf:"varint,1,opt,name=over_1m,json=over1m,proto3" json:"over_1m,omitempty"`
|
||||||
Over_5M uint32 `protobuf:"varint,2,opt,name=over_5m,json=over5m,proto3" json:"over_5m,omitempty"`
|
Over_5M uint32 `protobuf:"varint,2,opt,name=over_5m,json=over5m,proto3" json:"over_5m,omitempty"`
|
||||||
|
@@ -6,8 +6,8 @@ import (
|
|||||||
|
|
||||||
"github.com/libp2p/go-flow-metrics"
|
"github.com/libp2p/go-flow-metrics"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
"github.com/libp2p/go-libp2p-core/protocol"
|
"github.com/libp2p/go-libp2p/core/protocol"
|
||||||
)
|
)
|
||||||
|
|
||||||
// BandwidthCounter tracks incoming and outgoing data transferred by the local peer.
|
// BandwidthCounter tracks incoming and outgoing data transferred by the local peer.
|
||||||
|
@@ -6,8 +6,8 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
"github.com/libp2p/go-libp2p-core/protocol"
|
"github.com/libp2p/go-libp2p/core/protocol"
|
||||||
|
|
||||||
"github.com/libp2p/go-flow-metrics"
|
"github.com/libp2p/go-flow-metrics"
|
||||||
|
|
||||||
|
@@ -2,8 +2,8 @@
|
|||||||
package metrics
|
package metrics
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
"github.com/libp2p/go-libp2p-core/protocol"
|
"github.com/libp2p/go-libp2p/core/protocol"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Stats represents a point-in-time snapshot of bandwidth metrics.
|
// Stats represents a point-in-time snapshot of bandwidth metrics.
|
||||||
|
@@ -4,8 +4,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
ic "github.com/libp2p/go-libp2p-core/crypto"
|
ic "github.com/libp2p/go-libp2p/core/crypto"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
|
|
||||||
ma "github.com/multiformats/go-multiaddr"
|
ma "github.com/multiformats/go-multiaddr"
|
||||||
)
|
)
|
||||||
@@ -13,7 +13,8 @@ import (
|
|||||||
// Conn is a connection to a remote peer. It multiplexes streams.
|
// Conn is a connection to a remote peer. It multiplexes streams.
|
||||||
// Usually there is no need to use a Conn directly, but it may
|
// Usually there is no need to use a Conn directly, but it may
|
||||||
// be useful to get information about the peer on the other side:
|
// be useful to get information about the peer on the other side:
|
||||||
// stream.Conn().RemotePeer()
|
//
|
||||||
|
// stream.Conn().RemotePeer()
|
||||||
type Conn interface {
|
type Conn interface {
|
||||||
io.Closer
|
io.Closer
|
||||||
|
|
||||||
|
@@ -10,8 +10,8 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
"github.com/libp2p/go-libp2p-core/peerstore"
|
"github.com/libp2p/go-libp2p/core/peerstore"
|
||||||
|
|
||||||
ma "github.com/multiformats/go-multiaddr"
|
ma "github.com/multiformats/go-multiaddr"
|
||||||
)
|
)
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
package network
|
package network
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
"github.com/libp2p/go-libp2p-core/protocol"
|
"github.com/libp2p/go-libp2p/core/protocol"
|
||||||
"github.com/multiformats/go-multiaddr"
|
"github.com/multiformats/go-multiaddr"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -15,16 +15,17 @@ import (
|
|||||||
// Management Scopes, whereby resource usage is constrained by a DAG of scopes,
|
// Management Scopes, whereby resource usage is constrained by a DAG of scopes,
|
||||||
// The following diagram illustrates the structure of the resource constraint DAG:
|
// The following diagram illustrates the structure of the resource constraint DAG:
|
||||||
// System
|
// System
|
||||||
// +------------> Transient.............+................+
|
//
|
||||||
// | . .
|
// +------------> Transient.............+................+
|
||||||
// +------------> Service------------- . ----------+ .
|
// | . .
|
||||||
// | . | .
|
// +------------> Service------------- . ----------+ .
|
||||||
// +-------------> Protocol----------- . ----------+ .
|
// | . | .
|
||||||
// | . | .
|
// +-------------> Protocol----------- . ----------+ .
|
||||||
// +--------------> Peer \ | .
|
// | . | .
|
||||||
// +------------> Connection | .
|
// +--------------> Peer \ | .
|
||||||
// | \ \
|
// +------------> Connection | .
|
||||||
// +---------------------------> Stream
|
// | \ \
|
||||||
|
// +---------------------------> Stream
|
||||||
//
|
//
|
||||||
// The basic resources accounted by the ResourceManager include memory, streams, connections,
|
// The basic resources accounted by the ResourceManager include memory, streams, connections,
|
||||||
// and file descriptors. These account for both space and time used by
|
// and file descriptors. These account for both space and time used by
|
||||||
@@ -59,16 +60,16 @@ import (
|
|||||||
// scopes can form trees, with nested spans.
|
// scopes can form trees, with nested spans.
|
||||||
//
|
//
|
||||||
// Typical Usage:
|
// Typical Usage:
|
||||||
// - Low level components of the system (transports, muxers) all have access to the resource
|
// - Low level components of the system (transports, muxers) all have access to the resource
|
||||||
// manager and create connection and stream scopes through it. These scopes are accessible
|
// manager and create connection and stream scopes through it. These scopes are accessible
|
||||||
// to the user, albeit with a narrower interface, through Conn and Stream objects who have
|
// to the user, albeit with a narrower interface, through Conn and Stream objects who have
|
||||||
// a Scope method.
|
// a Scope method.
|
||||||
// - Services typically center around streams, where the programmer can attach streams to a
|
// - Services typically center around streams, where the programmer can attach streams to a
|
||||||
// particular service. They can also directly reserve memory for a service by accessing the
|
// particular service. They can also directly reserve memory for a service by accessing the
|
||||||
// service scope using the ResourceManager interface.
|
// service scope using the ResourceManager interface.
|
||||||
// - Applications that want to account for their network resource usage can reserve memory,
|
// - Applications that want to account for their network resource usage can reserve memory,
|
||||||
// typically using a span, directly in the System or a Service scope; they can also
|
// typically using a span, directly in the System or a Service scope; they can also
|
||||||
// opt to use appropriate steam scopes for streams that they create or own.
|
// opt to use appropriate steam scopes for streams that they create or own.
|
||||||
//
|
//
|
||||||
// User Serviceable Parts: the user has the option to specify their own implementation of the
|
// User Serviceable Parts: the user has the option to specify their own implementation of the
|
||||||
// interface. We provide a canonical implementation in the go-libp2p-resource-manager package.
|
// interface. We provide a canonical implementation in the go-libp2p-resource-manager package.
|
||||||
@@ -76,7 +77,8 @@ import (
|
|||||||
// or dynamic.
|
// or dynamic.
|
||||||
//
|
//
|
||||||
// WARNING The ResourceManager interface is considered experimental and subject to change
|
// WARNING The ResourceManager interface is considered experimental and subject to change
|
||||||
// in subsequent releases.
|
//
|
||||||
|
// in subsequent releases.
|
||||||
type ResourceManager interface {
|
type ResourceManager interface {
|
||||||
ResourceScopeViewer
|
ResourceScopeViewer
|
||||||
|
|
||||||
@@ -172,12 +174,13 @@ type ResourceScope interface {
|
|||||||
// when the programmer calls Done.
|
// when the programmer calls Done.
|
||||||
//
|
//
|
||||||
// Example:
|
// Example:
|
||||||
// s, err := someScope.BeginSpan()
|
|
||||||
// if err != nil { ... }
|
|
||||||
// defer s.Done()
|
|
||||||
//
|
//
|
||||||
// if err := s.ReserveMemory(...); err != nil { ... }
|
// s, err := someScope.BeginSpan()
|
||||||
// // ... use memory
|
// if err != nil { ... }
|
||||||
|
// defer s.Done()
|
||||||
|
//
|
||||||
|
// if err := s.ReserveMemory(...); err != nil { ... }
|
||||||
|
// // ... use memory
|
||||||
type ResourceScopeSpan interface {
|
type ResourceScopeSpan interface {
|
||||||
ResourceScope
|
ResourceScope
|
||||||
// Done ends the span and releases associated resources.
|
// Done ends the span and releases associated resources.
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
package network
|
package network
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/libp2p/go-libp2p-core/protocol"
|
"github.com/libp2p/go-libp2p/core/protocol"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Stream represents a bidirectional channel between two agents in
|
// Stream represents a bidirectional channel between two agents in
|
||||||
|
@@ -3,7 +3,8 @@ package peer
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/internal/catch"
|
"github.com/libp2p/go-libp2p/core/internal/catch"
|
||||||
|
|
||||||
ma "github.com/multiformats/go-multiaddr"
|
ma "github.com/multiformats/go-multiaddr"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -5,7 +5,7 @@ import (
|
|||||||
|
|
||||||
ma "github.com/multiformats/go-multiaddr"
|
ma "github.com/multiformats/go-multiaddr"
|
||||||
|
|
||||||
. "github.com/libp2p/go-libp2p-core/peer"
|
. "github.com/libp2p/go-libp2p/core/peer"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@@ -5,10 +5,11 @@ package peer_pb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
fmt "fmt"
|
fmt "fmt"
|
||||||
proto "github.com/gogo/protobuf/proto"
|
|
||||||
io "io"
|
io "io"
|
||||||
math "math"
|
math "math"
|
||||||
math_bits "math/bits"
|
math_bits "math/bits"
|
||||||
|
|
||||||
|
proto "github.com/gogo/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Reference imports to suppress errors if they are not otherwise used.
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
@@ -28,7 +29,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
|||||||
//
|
//
|
||||||
// PeerRecords are designed to be serialized to bytes and placed inside of
|
// PeerRecords are designed to be serialized to bytes and placed inside of
|
||||||
// SignedEnvelopes before sharing with other peers.
|
// SignedEnvelopes before sharing with other peers.
|
||||||
// See https://github.com/libp2p/go-libp2p-core/record/pb/envelope.proto for
|
// See https://github.com/libp2p/go-libp2p/core/record/pb/envelope.proto for
|
||||||
// the SignedEnvelope definition.
|
// the SignedEnvelope definition.
|
||||||
type PeerRecord struct {
|
type PeerRecord struct {
|
||||||
// peer_id contains a libp2p peer id in its binary representation.
|
// peer_id contains a libp2p peer id in its binary representation.
|
||||||
|
@@ -8,7 +8,7 @@ package peer.pb;
|
|||||||
//
|
//
|
||||||
// PeerRecords are designed to be serialized to bytes and placed inside of
|
// PeerRecords are designed to be serialized to bytes and placed inside of
|
||||||
// SignedEnvelopes before sharing with other peers.
|
// SignedEnvelopes before sharing with other peers.
|
||||||
// See https://github.com/libp2p/go-libp2p-core/record/pb/envelope.proto for
|
// See https://github.com/libp2p/go-libp2p/core/record/pb/envelope.proto for
|
||||||
// the SignedEnvelope definition.
|
// the SignedEnvelope definition.
|
||||||
message PeerRecord {
|
message PeerRecord {
|
||||||
|
|
||||||
|
@@ -7,7 +7,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
ic "github.com/libp2p/go-libp2p-core/crypto"
|
ic "github.com/libp2p/go-libp2p/core/crypto"
|
||||||
b58 "github.com/mr-tron/base58/base58"
|
b58 "github.com/mr-tron/base58/base58"
|
||||||
mc "github.com/multiformats/go-multicodec"
|
mc "github.com/multiformats/go-multicodec"
|
||||||
mh "github.com/multiformats/go-multihash"
|
mh "github.com/multiformats/go-multihash"
|
||||||
|
@@ -3,8 +3,8 @@ package peer_test
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
. "github.com/libp2p/go-libp2p-core/test"
|
. "github.com/libp2p/go-libp2p/core/test"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPeerSerdePB(t *testing.T) {
|
func TestPeerSerdePB(t *testing.T) {
|
||||||
|
@@ -7,9 +7,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
ic "github.com/libp2p/go-libp2p-core/crypto"
|
ic "github.com/libp2p/go-libp2p/core/crypto"
|
||||||
. "github.com/libp2p/go-libp2p-core/peer"
|
. "github.com/libp2p/go-libp2p/core/peer"
|
||||||
"github.com/libp2p/go-libp2p-core/test"
|
"github.com/libp2p/go-libp2p/core/test"
|
||||||
|
|
||||||
b58 "github.com/mr-tron/base58/base58"
|
b58 "github.com/mr-tron/base58/base58"
|
||||||
mh "github.com/multiformats/go-multihash"
|
mh "github.com/multiformats/go-multihash"
|
||||||
|
@@ -5,9 +5,9 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/internal/catch"
|
"github.com/libp2p/go-libp2p/core/internal/catch"
|
||||||
pb "github.com/libp2p/go-libp2p-core/peer/pb"
|
pb "github.com/libp2p/go-libp2p/core/peer/pb"
|
||||||
"github.com/libp2p/go-libp2p-core/record"
|
"github.com/libp2p/go-libp2p/core/record"
|
||||||
|
|
||||||
ma "github.com/multiformats/go-multiaddr"
|
ma "github.com/multiformats/go-multiaddr"
|
||||||
|
|
||||||
@@ -40,14 +40,14 @@ var PeerRecordEnvelopePayloadType = []byte{0x03, 0x01}
|
|||||||
// a PeerRecord with a timestamp-based Seq value. The other PeerRecord fields should
|
// a PeerRecord with a timestamp-based Seq value. The other PeerRecord fields should
|
||||||
// be set by the caller:
|
// be set by the caller:
|
||||||
//
|
//
|
||||||
// rec := peer.NewPeerRecord()
|
// rec := peer.NewPeerRecord()
|
||||||
// rec.PeerID = aPeerID
|
// rec.PeerID = aPeerID
|
||||||
// rec.Addrs = someAddrs
|
// rec.Addrs = someAddrs
|
||||||
//
|
//
|
||||||
// Alternatively, you can construct a PeerRecord struct directly and use the TimestampSeq
|
// Alternatively, you can construct a PeerRecord struct directly and use the TimestampSeq
|
||||||
// helper to set the Seq field:
|
// helper to set the Seq field:
|
||||||
//
|
//
|
||||||
// rec := peer.PeerRecord{PeerID: aPeerID, Addrs: someAddrs, Seq: peer.TimestampSeq()}
|
// rec := peer.PeerRecord{PeerID: aPeerID, Addrs: someAddrs, Seq: peer.TimestampSeq()}
|
||||||
//
|
//
|
||||||
// Failing to set the Seq field will not result in an error, however, a PeerRecord with a
|
// Failing to set the Seq field will not result in an error, however, a PeerRecord with a
|
||||||
// Seq value of zero may be ignored or rejected by other peers.
|
// Seq value of zero may be ignored or rejected by other peers.
|
||||||
@@ -59,28 +59,27 @@ var PeerRecordEnvelopePayloadType = []byte{0x03, 0x01}
|
|||||||
// To share a PeerRecord, first call Sign to wrap the record in a Envelope
|
// To share a PeerRecord, first call Sign to wrap the record in a Envelope
|
||||||
// and sign it with the local peer's private key:
|
// and sign it with the local peer's private key:
|
||||||
//
|
//
|
||||||
// rec := &PeerRecord{PeerID: myPeerId, Addrs: myAddrs}
|
// rec := &PeerRecord{PeerID: myPeerId, Addrs: myAddrs}
|
||||||
// envelope, err := rec.Sign(myPrivateKey)
|
// envelope, err := rec.Sign(myPrivateKey)
|
||||||
//
|
//
|
||||||
// The resulting record.Envelope can be marshalled to a []byte and shared
|
// The resulting record.Envelope can be marshalled to a []byte and shared
|
||||||
// publicly. As a convenience, the MarshalSigned method will produce the
|
// publicly. As a convenience, the MarshalSigned method will produce the
|
||||||
// Envelope and marshal it to a []byte in one go:
|
// Envelope and marshal it to a []byte in one go:
|
||||||
//
|
//
|
||||||
// rec := &PeerRecord{PeerID: myPeerId, Addrs: myAddrs}
|
// rec := &PeerRecord{PeerID: myPeerId, Addrs: myAddrs}
|
||||||
// recordBytes, err := rec.MarshalSigned(myPrivateKey)
|
// recordBytes, err := rec.MarshalSigned(myPrivateKey)
|
||||||
//
|
//
|
||||||
// To validate and unmarshal a signed PeerRecord from a remote peer,
|
// To validate and unmarshal a signed PeerRecord from a remote peer,
|
||||||
// "consume" the containing envelope, which will return both the
|
// "consume" the containing envelope, which will return both the
|
||||||
// routing.Envelope and the inner Record. The Record must be cast to
|
// routing.Envelope and the inner Record. The Record must be cast to
|
||||||
// a PeerRecord pointer before use:
|
// a PeerRecord pointer before use:
|
||||||
//
|
//
|
||||||
// envelope, untypedRecord, err := ConsumeEnvelope(envelopeBytes, PeerRecordEnvelopeDomain)
|
// envelope, untypedRecord, err := ConsumeEnvelope(envelopeBytes, PeerRecordEnvelopeDomain)
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// handleError(err)
|
// handleError(err)
|
||||||
// return
|
// return
|
||||||
// }
|
// }
|
||||||
// peerRec := untypedRecord.(*PeerRecord)
|
// peerRec := untypedRecord.(*PeerRecord)
|
||||||
//
|
|
||||||
type PeerRecord struct {
|
type PeerRecord struct {
|
||||||
// PeerID is the ID of the peer this record pertains to.
|
// PeerID is the ID of the peer this record pertains to.
|
||||||
PeerID ID
|
PeerID ID
|
||||||
|
@@ -4,10 +4,10 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/crypto"
|
"github.com/libp2p/go-libp2p/core/crypto"
|
||||||
. "github.com/libp2p/go-libp2p-core/peer"
|
. "github.com/libp2p/go-libp2p/core/peer"
|
||||||
"github.com/libp2p/go-libp2p-core/record"
|
"github.com/libp2p/go-libp2p/core/record"
|
||||||
"github.com/libp2p/go-libp2p-core/test"
|
"github.com/libp2p/go-libp2p/core/test"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPeerRecordConstants(t *testing.T) {
|
func TestPeerRecordConstants(t *testing.T) {
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
package peerstore
|
package peerstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AddrInfos returns an AddrInfo for each specified peer ID, in-order.
|
// AddrInfos returns an AddrInfo for each specified peer ID, in-order.
|
||||||
|
@@ -9,9 +9,9 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
ic "github.com/libp2p/go-libp2p-core/crypto"
|
ic "github.com/libp2p/go-libp2p/core/crypto"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
"github.com/libp2p/go-libp2p-core/record"
|
"github.com/libp2p/go-libp2p/core/record"
|
||||||
|
|
||||||
ma "github.com/multiformats/go-multiaddr"
|
ma "github.com/multiformats/go-multiaddr"
|
||||||
)
|
)
|
||||||
@@ -142,10 +142,9 @@ type AddrBook interface {
|
|||||||
// certified addresses, callers should use the GetCertifiedAddrBook helper or
|
// certified addresses, callers should use the GetCertifiedAddrBook helper or
|
||||||
// type-assert on the CertifiedAddrBook interface:
|
// type-assert on the CertifiedAddrBook interface:
|
||||||
//
|
//
|
||||||
// if cab, ok := aPeerstore.(CertifiedAddrBook); ok {
|
// if cab, ok := aPeerstore.(CertifiedAddrBook); ok {
|
||||||
// cab.ConsumePeerRecord(signedPeerRecord, aTTL)
|
// cab.ConsumePeerRecord(signedPeerRecord, aTTL)
|
||||||
// }
|
// }
|
||||||
//
|
|
||||||
type CertifiedAddrBook interface {
|
type CertifiedAddrBook interface {
|
||||||
// ConsumePeerRecord adds addresses from a signed peer.PeerRecord (contained in
|
// ConsumePeerRecord adds addresses from a signed peer.PeerRecord (contained in
|
||||||
// a record.Envelope), which will expire after the given TTL.
|
// a record.Envelope), which will expire after the given TTL.
|
||||||
|
@@ -6,9 +6,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/crypto"
|
"github.com/libp2p/go-libp2p/core/crypto"
|
||||||
"github.com/libp2p/go-libp2p-core/internal/catch"
|
"github.com/libp2p/go-libp2p/core/internal/catch"
|
||||||
pb "github.com/libp2p/go-libp2p-core/record/pb"
|
pb "github.com/libp2p/go-libp2p/core/record/pb"
|
||||||
|
|
||||||
pool "github.com/libp2p/go-buffer-pool"
|
pool "github.com/libp2p/go-buffer-pool"
|
||||||
|
|
||||||
@@ -94,15 +94,15 @@ func Seal(rec Record, privateKey crypto.PrivKey) (*Envelope, error) {
|
|||||||
// You can type assert on the returned Record to convert it to an instance of the concrete
|
// You can type assert on the returned Record to convert it to an instance of the concrete
|
||||||
// Record type:
|
// Record type:
|
||||||
//
|
//
|
||||||
// envelope, rec, err := ConsumeEnvelope(envelopeBytes, peer.PeerRecordEnvelopeDomain)
|
// envelope, rec, err := ConsumeEnvelope(envelopeBytes, peer.PeerRecordEnvelopeDomain)
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// handleError(envelope, err) // envelope may be non-nil, even if errors occur!
|
// handleError(envelope, err) // envelope may be non-nil, even if errors occur!
|
||||||
// return
|
// return
|
||||||
// }
|
// }
|
||||||
// peerRec, ok := rec.(*peer.PeerRecord)
|
// peerRec, ok := rec.(*peer.PeerRecord)
|
||||||
// if ok {
|
// if ok {
|
||||||
// doSomethingWithPeerRecord(peerRec)
|
// doSomethingWithPeerRecord(peerRec)
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// Important: you MUST check the error value before using the returned Envelope. In some error
|
// Important: you MUST check the error value before using the returned Envelope. In some error
|
||||||
// cases, including when the envelope signature is invalid, both the Envelope and an error will
|
// cases, including when the envelope signature is invalid, both the Envelope and an error will
|
||||||
@@ -140,12 +140,12 @@ func ConsumeEnvelope(data []byte, domain string) (envelope *Envelope, rec Record
|
|||||||
// responsibility to determine whether the given Record type is able to unmarshal the payload
|
// responsibility to determine whether the given Record type is able to unmarshal the payload
|
||||||
// correctly.
|
// correctly.
|
||||||
//
|
//
|
||||||
// rec := &MyRecordType{}
|
// rec := &MyRecordType{}
|
||||||
// envelope, err := ConsumeTypedEnvelope(envelopeBytes, rec)
|
// envelope, err := ConsumeTypedEnvelope(envelopeBytes, rec)
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// handleError(envelope, err)
|
// handleError(envelope, err)
|
||||||
// }
|
// }
|
||||||
// doSomethingWithRecord(rec)
|
// doSomethingWithRecord(rec)
|
||||||
//
|
//
|
||||||
// Important: you MUST check the error value before using the returned Envelope. In some error
|
// Important: you MUST check the error value before using the returned Envelope. In some error
|
||||||
// cases, including when the envelope signature is invalid, both the Envelope and an error will
|
// cases, including when the envelope signature is invalid, both the Envelope and an error will
|
||||||
|
@@ -5,10 +5,10 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
crypto "github.com/libp2p/go-libp2p-core/crypto"
|
crypto "github.com/libp2p/go-libp2p/core/crypto"
|
||||||
. "github.com/libp2p/go-libp2p-core/record"
|
. "github.com/libp2p/go-libp2p/core/record"
|
||||||
pb "github.com/libp2p/go-libp2p-core/record/pb"
|
pb "github.com/libp2p/go-libp2p/core/record/pb"
|
||||||
"github.com/libp2p/go-libp2p-core/test"
|
"github.com/libp2p/go-libp2p/core/test"
|
||||||
|
|
||||||
"github.com/gogo/protobuf/proto"
|
"github.com/gogo/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
@@ -5,11 +5,12 @@ package record_pb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
fmt "fmt"
|
fmt "fmt"
|
||||||
proto "github.com/gogo/protobuf/proto"
|
|
||||||
pb "github.com/libp2p/go-libp2p-core/crypto/pb"
|
|
||||||
io "io"
|
io "io"
|
||||||
math "math"
|
math "math"
|
||||||
math_bits "math/bits"
|
math_bits "math/bits"
|
||||||
|
|
||||||
|
proto "github.com/gogo/protobuf/proto"
|
||||||
|
pb "github.com/libp2p/go-libp2p/core/crypto/pb"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Reference imports to suppress errors if they are not otherwise used.
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
|
@@ -4,7 +4,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/internal/catch"
|
"github.com/libp2p/go-libp2p/core/internal/catch"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -59,15 +59,14 @@ type Record interface {
|
|||||||
// a pointer type. Registration should be done in the init function of the package
|
// a pointer type. Registration should be done in the init function of the package
|
||||||
// where the Record type is defined:
|
// where the Record type is defined:
|
||||||
//
|
//
|
||||||
// package hello_record
|
// package hello_record
|
||||||
// import record "github.com/libp2p/go-libp2p-core/record"
|
// import record "github.com/libp2p/go-libp2p/core/record"
|
||||||
//
|
//
|
||||||
// func init() {
|
// func init() {
|
||||||
// record.RegisterType(&HelloRecord{})
|
// record.RegisterType(&HelloRecord{})
|
||||||
// }
|
// }
|
||||||
//
|
|
||||||
// type HelloRecord struct { } // etc..
|
|
||||||
//
|
//
|
||||||
|
// type HelloRecord struct { } // etc..
|
||||||
func RegisterType(prototype Record) {
|
func RegisterType(prototype Record) {
|
||||||
payloadTypeRegistry[string(prototype.Codec())] = getValueType(prototype)
|
payloadTypeRegistry[string(prototype.Codec())] = getValueType(prototype)
|
||||||
}
|
}
|
||||||
|
@@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
)
|
)
|
||||||
|
|
||||||
// QueryEventType indicates the query event's type.
|
// QueryEventType indicates the query event's type.
|
||||||
|
@@ -3,7 +3,7 @@ package routing
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (qe *QueryEvent) MarshalJSON() ([]byte, error) {
|
func (qe *QueryEvent) MarshalJSON() ([]byte, error) {
|
||||||
|
@@ -5,8 +5,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
ci "github.com/libp2p/go-libp2p-core/crypto"
|
ci "github.com/libp2p/go-libp2p/core/crypto"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
|
|
||||||
cid "github.com/ipfs/go-cid"
|
cid "github.com/ipfs/go-cid"
|
||||||
)
|
)
|
||||||
|
@@ -9,12 +9,12 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
ci "github.com/libp2p/go-libp2p/core/crypto"
|
||||||
"github.com/libp2p/go-libp2p-core/sec"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
"github.com/libp2p/go-msgio"
|
"github.com/libp2p/go-libp2p/core/sec"
|
||||||
|
pb "github.com/libp2p/go-libp2p/core/sec/insecure/pb"
|
||||||
|
|
||||||
ci "github.com/libp2p/go-libp2p-core/crypto"
|
"github.com/libp2p/go-msgio"
|
||||||
pb "github.com/libp2p/go-libp2p-core/sec/insecure/pb"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ID is the multistream-select protocol ID that should be used when identifying
|
// ID is the multistream-select protocol ID that should be used when identifying
|
||||||
|
@@ -6,11 +6,11 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/libp2p/go-libp2p/core/crypto"
|
||||||
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
|
"github.com/libp2p/go-libp2p/core/sec"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/crypto"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
|
||||||
"github.com/libp2p/go-libp2p-core/sec"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Run a set of sessions through the session setup and verification.
|
// Run a set of sessions through the session setup and verification.
|
||||||
|
@@ -5,11 +5,12 @@ package plaintext_pb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
fmt "fmt"
|
fmt "fmt"
|
||||||
proto "github.com/gogo/protobuf/proto"
|
|
||||||
pb "github.com/libp2p/go-libp2p-core/crypto/pb"
|
|
||||||
io "io"
|
io "io"
|
||||||
math "math"
|
math "math"
|
||||||
math_bits "math/bits"
|
math_bits "math/bits"
|
||||||
|
|
||||||
|
proto "github.com/gogo/protobuf/proto"
|
||||||
|
pb "github.com/libp2p/go-libp2p/core/crypto/pb"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Reference imports to suppress errors if they are not otherwise used.
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
|
@@ -2,7 +2,7 @@ syntax = "proto2";
|
|||||||
|
|
||||||
package plaintext.pb;
|
package plaintext.pb;
|
||||||
|
|
||||||
import "github.com/libp2p/go-libp2p-core/crypto/pb/crypto.proto";
|
import "github.com/libp2p/go-libp2p/core/crypto/pb/crypto.proto";
|
||||||
|
|
||||||
message Exchange {
|
message Exchange {
|
||||||
optional bytes id = 1;
|
optional bytes id = 1;
|
||||||
|
@@ -5,8 +5,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/network"
|
"github.com/libp2p/go-libp2p/core/network"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SecureConn is an authenticated, encrypted connection.
|
// SecureConn is an authenticated, encrypted connection.
|
||||||
|
@@ -4,7 +4,7 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
ci "github.com/libp2p/go-libp2p-core/crypto"
|
ci "github.com/libp2p/go-libp2p/core/crypto"
|
||||||
)
|
)
|
||||||
|
|
||||||
var globalSeed int64
|
var globalSeed int64
|
||||||
|
@@ -4,7 +4,7 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
|
|
||||||
mh "github.com/multiformats/go-multihash"
|
mh "github.com/multiformats/go-multihash"
|
||||||
)
|
)
|
||||||
|
@@ -6,8 +6,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/network"
|
"github.com/libp2p/go-libp2p/core/network"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
|
|
||||||
ma "github.com/multiformats/go-multiaddr"
|
ma "github.com/multiformats/go-multiaddr"
|
||||||
manet "github.com/multiformats/go-multiaddr/net"
|
manet "github.com/multiformats/go-multiaddr/net"
|
||||||
|
@@ -5,6 +5,7 @@ package libp2p
|
|||||||
import (
|
import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
|
|
||||||
|
"github.com/libp2p/go-libp2p/core/crypto"
|
||||||
"github.com/libp2p/go-libp2p/p2p/host/peerstore/pstoremem"
|
"github.com/libp2p/go-libp2p/p2p/host/peerstore/pstoremem"
|
||||||
rcmgr "github.com/libp2p/go-libp2p/p2p/host/resource-manager"
|
rcmgr "github.com/libp2p/go-libp2p/p2p/host/resource-manager"
|
||||||
"github.com/libp2p/go-libp2p/p2p/muxer/yamux"
|
"github.com/libp2p/go-libp2p/p2p/muxer/yamux"
|
||||||
@@ -15,8 +16,6 @@ import (
|
|||||||
"github.com/libp2p/go-libp2p/p2p/transport/tcp"
|
"github.com/libp2p/go-libp2p/p2p/transport/tcp"
|
||||||
ws "github.com/libp2p/go-libp2p/p2p/transport/websocket"
|
ws "github.com/libp2p/go-libp2p/p2p/transport/websocket"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/crypto"
|
|
||||||
|
|
||||||
"github.com/multiformats/go-multiaddr"
|
"github.com/multiformats/go-multiaddr"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
12
go.mod
12
go.mod
@@ -4,6 +4,7 @@ go 1.18
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/benbjohnson/clock v1.3.0
|
github.com/benbjohnson/clock v1.3.0
|
||||||
|
github.com/btcsuite/btcd/btcec/v2 v2.2.0
|
||||||
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c
|
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c
|
||||||
github.com/flynn/noise v1.0.0
|
github.com/flynn/noise v1.0.0
|
||||||
github.com/gogo/protobuf v1.3.2
|
github.com/gogo/protobuf v1.3.2
|
||||||
@@ -19,13 +20,14 @@ require (
|
|||||||
github.com/jbenet/go-temp-err-catcher v0.1.0
|
github.com/jbenet/go-temp-err-catcher v0.1.0
|
||||||
github.com/klauspost/compress v1.15.1
|
github.com/klauspost/compress v1.15.1
|
||||||
github.com/libp2p/go-buffer-pool v0.1.0
|
github.com/libp2p/go-buffer-pool v0.1.0
|
||||||
|
github.com/libp2p/go-flow-metrics v0.1.0
|
||||||
github.com/libp2p/go-libp2p-asn-util v0.2.0
|
github.com/libp2p/go-libp2p-asn-util v0.2.0
|
||||||
github.com/libp2p/go-libp2p-core v0.19.1
|
|
||||||
github.com/libp2p/go-libp2p-testing v0.11.0
|
github.com/libp2p/go-libp2p-testing v0.11.0
|
||||||
github.com/libp2p/go-mplex v0.7.0
|
github.com/libp2p/go-mplex v0.7.0
|
||||||
github.com/libp2p/go-msgio v0.2.0
|
github.com/libp2p/go-msgio v0.2.0
|
||||||
github.com/libp2p/go-nat v0.1.0
|
github.com/libp2p/go-nat v0.1.0
|
||||||
github.com/libp2p/go-netroute v0.2.0
|
github.com/libp2p/go-netroute v0.2.0
|
||||||
|
github.com/libp2p/go-openssl v0.0.7
|
||||||
github.com/libp2p/go-reuseport v0.2.0
|
github.com/libp2p/go-reuseport v0.2.0
|
||||||
github.com/libp2p/go-yamux/v3 v3.1.2
|
github.com/libp2p/go-yamux/v3 v3.1.2
|
||||||
github.com/libp2p/zeroconf/v2 v2.1.1
|
github.com/libp2p/zeroconf/v2 v2.1.1
|
||||||
@@ -33,10 +35,12 @@ require (
|
|||||||
github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd
|
github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd
|
||||||
github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b
|
github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b
|
||||||
github.com/minio/sha256-simd v1.0.0
|
github.com/minio/sha256-simd v1.0.0
|
||||||
|
github.com/mr-tron/base58 v1.2.0
|
||||||
github.com/multiformats/go-base32 v0.0.4
|
github.com/multiformats/go-base32 v0.0.4
|
||||||
github.com/multiformats/go-multiaddr v0.6.0
|
github.com/multiformats/go-multiaddr v0.6.0
|
||||||
github.com/multiformats/go-multiaddr-dns v0.3.1
|
github.com/multiformats/go-multiaddr-dns v0.3.1
|
||||||
github.com/multiformats/go-multiaddr-fmt v0.1.0
|
github.com/multiformats/go-multiaddr-fmt v0.1.0
|
||||||
|
github.com/multiformats/go-multicodec v0.5.0
|
||||||
github.com/multiformats/go-multihash v0.2.0
|
github.com/multiformats/go-multihash v0.2.0
|
||||||
github.com/multiformats/go-multistream v0.3.3
|
github.com/multiformats/go-multistream v0.3.3
|
||||||
github.com/multiformats/go-varint v0.0.6
|
github.com/multiformats/go-varint v0.0.6
|
||||||
@@ -54,7 +58,6 @@ require (
|
|||||||
require (
|
require (
|
||||||
github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 // indirect
|
github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 // indirect
|
||||||
github.com/beorn7/perks v1.0.1 // indirect
|
github.com/beorn7/perks v1.0.1 // indirect
|
||||||
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
|
|
||||||
github.com/cespare/xxhash v1.1.0 // indirect
|
github.com/cespare/xxhash v1.1.0 // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||||
github.com/cheekybits/genny v1.0.0 // indirect
|
github.com/cheekybits/genny v1.0.0 // indirect
|
||||||
@@ -80,8 +83,7 @@ require (
|
|||||||
github.com/klauspost/cpuid/v2 v2.0.14 // indirect
|
github.com/klauspost/cpuid/v2 v2.0.14 // indirect
|
||||||
github.com/koron/go-ssdp v0.0.3 // indirect
|
github.com/koron/go-ssdp v0.0.3 // indirect
|
||||||
github.com/libp2p/go-cidranger v1.1.0 // indirect
|
github.com/libp2p/go-cidranger v1.1.0 // indirect
|
||||||
github.com/libp2p/go-flow-metrics v0.0.3 // indirect
|
github.com/libp2p/go-libp2p-core v0.19.1 // indirect
|
||||||
github.com/libp2p/go-openssl v0.0.7 // indirect
|
|
||||||
github.com/marten-seemann/qtls-go1-16 v0.1.5 // indirect
|
github.com/marten-seemann/qtls-go1-16 v0.1.5 // indirect
|
||||||
github.com/marten-seemann/qtls-go1-17 v0.1.2 // indirect
|
github.com/marten-seemann/qtls-go1-17 v0.1.2 // indirect
|
||||||
github.com/marten-seemann/qtls-go1-18 v0.1.2 // indirect
|
github.com/marten-seemann/qtls-go1-18 v0.1.2 // indirect
|
||||||
@@ -90,10 +92,8 @@ require (
|
|||||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
|
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
|
||||||
github.com/miekg/dns v1.1.50 // indirect
|
github.com/miekg/dns v1.1.50 // indirect
|
||||||
github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc // indirect
|
github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc // indirect
|
||||||
github.com/mr-tron/base58 v1.2.0 // indirect
|
|
||||||
github.com/multiformats/go-base36 v0.1.0 // indirect
|
github.com/multiformats/go-base36 v0.1.0 // indirect
|
||||||
github.com/multiformats/go-multibase v0.1.1 // indirect
|
github.com/multiformats/go-multibase v0.1.1 // indirect
|
||||||
github.com/multiformats/go-multicodec v0.5.0 // indirect
|
|
||||||
github.com/nxadm/tail v1.4.8 // indirect
|
github.com/nxadm/tail v1.4.8 // indirect
|
||||||
github.com/onsi/ginkgo v1.16.5 // indirect
|
github.com/onsi/ginkgo v1.16.5 // indirect
|
||||||
github.com/opencontainers/runtime-spec v1.0.2 // indirect
|
github.com/opencontainers/runtime-spec v1.0.2 // indirect
|
||||||
|
4
go.sum
4
go.sum
@@ -299,8 +299,8 @@ github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6
|
|||||||
github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg=
|
github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg=
|
||||||
github.com/libp2p/go-cidranger v1.1.0 h1:ewPN8EZ0dd1LSnrtuwd4709PXVcITVeuwbag38yPW7c=
|
github.com/libp2p/go-cidranger v1.1.0 h1:ewPN8EZ0dd1LSnrtuwd4709PXVcITVeuwbag38yPW7c=
|
||||||
github.com/libp2p/go-cidranger v1.1.0/go.mod h1:KWZTfSr+r9qEo9OkI9/SIEeAtw+NNoU0dXIXt15Okic=
|
github.com/libp2p/go-cidranger v1.1.0/go.mod h1:KWZTfSr+r9qEo9OkI9/SIEeAtw+NNoU0dXIXt15Okic=
|
||||||
github.com/libp2p/go-flow-metrics v0.0.3 h1:8tAs/hSdNvUiLgtlSy3mxwxWP4I9y/jlkPFT7epKdeM=
|
github.com/libp2p/go-flow-metrics v0.1.0 h1:0iPhMI8PskQwzh57jB9WxIuIOQ0r+15PChFGkx3Q3WM=
|
||||||
github.com/libp2p/go-flow-metrics v0.0.3/go.mod h1:HeoSNUrOJVK1jEpDqVEiUOIXqhbnS27omG0uWU5slZs=
|
github.com/libp2p/go-flow-metrics v0.1.0/go.mod h1:4Xi8MX8wj5aWNDAZttg6UPmc0ZrnFNsMtpsYUClFtro=
|
||||||
github.com/libp2p/go-libp2p-asn-util v0.2.0 h1:rg3+Os8jbnO5DxkC7K/Utdi+DkY3q/d1/1q+8WeNAsw=
|
github.com/libp2p/go-libp2p-asn-util v0.2.0 h1:rg3+Os8jbnO5DxkC7K/Utdi+DkY3q/d1/1q+8WeNAsw=
|
||||||
github.com/libp2p/go-libp2p-asn-util v0.2.0/go.mod h1:WoaWxbHKBymSN41hWSq/lGKJEca7TNm58+gGJi2WsLI=
|
github.com/libp2p/go-libp2p-asn-util v0.2.0/go.mod h1:WoaWxbHKBymSN41hWSq/lGKJEca7TNm58+gGJi2WsLI=
|
||||||
github.com/libp2p/go-libp2p-core v0.19.1 h1:zaZQQCeCrFMtxFa1wHy6AhsVynyNmZAvwgWqSSPT3WE=
|
github.com/libp2p/go-libp2p-core v0.19.1 h1:zaZQQCeCrFMtxFa1wHy6AhsVynyNmZAvwgWqSSPT3WE=
|
||||||
|
@@ -2,8 +2,7 @@ package libp2p
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/libp2p/go-libp2p/config"
|
"github.com/libp2p/go-libp2p/config"
|
||||||
|
"github.com/libp2p/go-libp2p/core/host"
|
||||||
"github.com/libp2p/go-libp2p-core/host"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config describes a set of settings for a libp2p node.
|
// Config describes a set of settings for a libp2p node.
|
||||||
|
@@ -7,14 +7,13 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/libp2p/go-libp2p/core/connmgr"
|
||||||
|
"github.com/libp2p/go-libp2p/core/crypto"
|
||||||
|
"github.com/libp2p/go-libp2p/core/host"
|
||||||
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
|
"github.com/libp2p/go-libp2p/core/transport"
|
||||||
"github.com/libp2p/go-libp2p/p2p/transport/tcp"
|
"github.com/libp2p/go-libp2p/p2p/transport/tcp"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/connmgr"
|
|
||||||
"github.com/libp2p/go-libp2p-core/crypto"
|
|
||||||
"github.com/libp2p/go-libp2p-core/host"
|
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
|
||||||
"github.com/libp2p/go-libp2p-core/transport"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -1,8 +1,7 @@
|
|||||||
package libp2p
|
package libp2p
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/libp2p/go-libp2p-core/protocol"
|
"github.com/libp2p/go-libp2p/core/protocol"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p/p2p/host/autonat"
|
"github.com/libp2p/go-libp2p/p2p/host/autonat"
|
||||||
rcmgr "github.com/libp2p/go-libp2p/p2p/host/resource-manager"
|
rcmgr "github.com/libp2p/go-libp2p/p2p/host/resource-manager"
|
||||||
relayv1 "github.com/libp2p/go-libp2p/p2p/protocol/circuitv1/relay"
|
relayv1 "github.com/libp2p/go-libp2p/p2p/protocol/circuitv1/relay"
|
||||||
|
17
options.go
17
options.go
@@ -8,15 +8,14 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/connmgr"
|
|
||||||
"github.com/libp2p/go-libp2p-core/crypto"
|
|
||||||
"github.com/libp2p/go-libp2p-core/metrics"
|
|
||||||
"github.com/libp2p/go-libp2p-core/network"
|
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
|
||||||
"github.com/libp2p/go-libp2p-core/peerstore"
|
|
||||||
"github.com/libp2p/go-libp2p-core/pnet"
|
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p/config"
|
"github.com/libp2p/go-libp2p/config"
|
||||||
|
"github.com/libp2p/go-libp2p/core/connmgr"
|
||||||
|
"github.com/libp2p/go-libp2p/core/crypto"
|
||||||
|
"github.com/libp2p/go-libp2p/core/metrics"
|
||||||
|
"github.com/libp2p/go-libp2p/core/network"
|
||||||
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
|
"github.com/libp2p/go-libp2p/core/peerstore"
|
||||||
|
"github.com/libp2p/go-libp2p/core/pnet"
|
||||||
"github.com/libp2p/go-libp2p/p2p/host/autorelay"
|
"github.com/libp2p/go-libp2p/p2p/host/autorelay"
|
||||||
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
|
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
|
||||||
relayv2 "github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/relay"
|
relayv2 "github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/relay"
|
||||||
@@ -330,7 +329,7 @@ func AutoNATServiceRateLimit(global, perPeer int, interval time.Duration) Option
|
|||||||
// to actively reject inbound/outbound connections based on the lifecycle stage
|
// to actively reject inbound/outbound connections based on the lifecycle stage
|
||||||
// of the connection.
|
// of the connection.
|
||||||
//
|
//
|
||||||
// For more information, refer to go-libp2p-core.ConnectionGater.
|
// For more information, refer to go-libp2p/core.ConnectionGater.
|
||||||
func ConnectionGater(cg connmgr.ConnectionGater) Option {
|
func ConnectionGater(cg connmgr.ConnectionGater) Option {
|
||||||
return func(cfg *Config) error {
|
return func(cfg *Config) error {
|
||||||
if cfg.ConnectionGater != nil {
|
if cfg.ConnectionGater != nil {
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
package libp2p
|
package libp2p
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/libp2p/go-libp2p-core/connmgr"
|
"github.com/libp2p/go-libp2p/core/connmgr"
|
||||||
"github.com/libp2p/go-libp2p-core/control"
|
"github.com/libp2p/go-libp2p/core/control"
|
||||||
"github.com/libp2p/go-libp2p-core/network"
|
"github.com/libp2p/go-libp2p/core/network"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
|
|
||||||
ma "github.com/multiformats/go-multiaddr"
|
ma "github.com/multiformats/go-multiaddr"
|
||||||
)
|
)
|
||||||
|
@@ -6,8 +6,8 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/discovery"
|
"github.com/libp2p/go-libp2p/core/discovery"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
|
|
||||||
ma "github.com/multiformats/go-multiaddr"
|
ma "github.com/multiformats/go-multiaddr"
|
||||||
)
|
)
|
||||||
|
@@ -10,8 +10,8 @@ import (
|
|||||||
bhost "github.com/libp2p/go-libp2p/p2p/host/blank"
|
bhost "github.com/libp2p/go-libp2p/p2p/host/blank"
|
||||||
swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing"
|
swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/discovery"
|
"github.com/libp2p/go-libp2p/core/discovery"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
|
|
||||||
mockClock "github.com/benbjohnson/clock"
|
mockClock "github.com/benbjohnson/clock"
|
||||||
)
|
)
|
||||||
|
@@ -5,10 +5,10 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
lru "github.com/hashicorp/golang-lru"
|
"github.com/libp2p/go-libp2p/core/host"
|
||||||
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/host"
|
lru "github.com/hashicorp/golang-lru"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// BackoffConnector is a utility to connect to peers, but only if we have not recently tried connecting to them already
|
// BackoffConnector is a utility to connect to peers, but only if we have not recently tried connecting to them already
|
||||||
|
@@ -7,12 +7,11 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/libp2p/go-libp2p/core/host"
|
||||||
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
bhost "github.com/libp2p/go-libp2p/p2p/host/blank"
|
bhost "github.com/libp2p/go-libp2p/p2p/host/blank"
|
||||||
swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing"
|
swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/host"
|
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -8,11 +8,12 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
logging "github.com/ipfs/go-log/v2"
|
"github.com/libp2p/go-libp2p/core/host"
|
||||||
"github.com/libp2p/go-libp2p-core/host"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
|
||||||
"github.com/libp2p/zeroconf/v2"
|
"github.com/libp2p/zeroconf/v2"
|
||||||
|
|
||||||
|
logging "github.com/ipfs/go-log/v2"
|
||||||
ma "github.com/multiformats/go-multiaddr"
|
ma "github.com/multiformats/go-multiaddr"
|
||||||
manet "github.com/multiformats/go-multiaddr/net"
|
manet "github.com/multiformats/go-multiaddr/net"
|
||||||
)
|
)
|
||||||
|
@@ -6,7 +6,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p"
|
"github.com/libp2p/go-libp2p"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@@ -5,9 +5,9 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/discovery"
|
"github.com/libp2p/go-libp2p/core/discovery"
|
||||||
"github.com/libp2p/go-libp2p-core/host"
|
"github.com/libp2p/go-libp2p/core/host"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
)
|
)
|
||||||
|
|
||||||
type clock interface {
|
type clock interface {
|
||||||
|
@@ -4,9 +4,9 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/discovery"
|
"github.com/libp2p/go-libp2p/core/discovery"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
"github.com/libp2p/go-libp2p-core/routing"
|
"github.com/libp2p/go-libp2p/core/routing"
|
||||||
|
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
mh "github.com/multiformats/go-multihash"
|
mh "github.com/multiformats/go-multihash"
|
||||||
|
@@ -13,9 +13,9 @@ import (
|
|||||||
swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing"
|
swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing"
|
||||||
|
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
"github.com/libp2p/go-libp2p-core/discovery"
|
"github.com/libp2p/go-libp2p/core/discovery"
|
||||||
"github.com/libp2p/go-libp2p-core/host"
|
"github.com/libp2p/go-libp2p/core/host"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
)
|
)
|
||||||
|
|
||||||
type mockRoutingTable struct {
|
type mockRoutingTable struct {
|
||||||
|
@@ -4,8 +4,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/discovery"
|
"github.com/libp2p/go-libp2p/core/discovery"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
|
|
||||||
logging "github.com/ipfs/go-log/v2"
|
logging "github.com/ipfs/go-log/v2"
|
||||||
)
|
)
|
||||||
|
@@ -7,13 +7,12 @@ import (
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/libp2p/go-libp2p/core/event"
|
||||||
|
"github.com/libp2p/go-libp2p/core/host"
|
||||||
|
"github.com/libp2p/go-libp2p/core/network"
|
||||||
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
"github.com/libp2p/go-libp2p/p2p/host/eventbus"
|
"github.com/libp2p/go-libp2p/p2p/host/eventbus"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/event"
|
|
||||||
"github.com/libp2p/go-libp2p-core/host"
|
|
||||||
"github.com/libp2p/go-libp2p-core/network"
|
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
|
||||||
|
|
||||||
logging "github.com/ipfs/go-log/v2"
|
logging "github.com/ipfs/go-log/v2"
|
||||||
ma "github.com/multiformats/go-multiaddr"
|
ma "github.com/multiformats/go-multiaddr"
|
||||||
manet "github.com/multiformats/go-multiaddr/net"
|
manet "github.com/multiformats/go-multiaddr/net"
|
||||||
|
@@ -5,15 +5,14 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/libp2p/go-libp2p/core/event"
|
||||||
|
"github.com/libp2p/go-libp2p/core/host"
|
||||||
|
"github.com/libp2p/go-libp2p/core/network"
|
||||||
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
pb "github.com/libp2p/go-libp2p/p2p/host/autonat/pb"
|
pb "github.com/libp2p/go-libp2p/p2p/host/autonat/pb"
|
||||||
bhost "github.com/libp2p/go-libp2p/p2p/host/blank"
|
bhost "github.com/libp2p/go-libp2p/p2p/host/blank"
|
||||||
swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing"
|
swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/event"
|
|
||||||
"github.com/libp2p/go-libp2p-core/host"
|
|
||||||
"github.com/libp2p/go-libp2p-core/network"
|
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
|
||||||
|
|
||||||
"github.com/libp2p/go-msgio/protoio"
|
"github.com/libp2p/go-msgio/protoio"
|
||||||
ma "github.com/multiformats/go-multiaddr"
|
ma "github.com/multiformats/go-multiaddr"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@@ -5,13 +5,12 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/libp2p/go-libp2p/core/host"
|
||||||
|
"github.com/libp2p/go-libp2p/core/network"
|
||||||
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
pb "github.com/libp2p/go-libp2p/p2p/host/autonat/pb"
|
pb "github.com/libp2p/go-libp2p/p2p/host/autonat/pb"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/host"
|
|
||||||
"github.com/libp2p/go-libp2p-core/network"
|
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
|
||||||
"github.com/libp2p/go-msgio/protoio"
|
"github.com/libp2p/go-msgio/protoio"
|
||||||
|
|
||||||
ma "github.com/multiformats/go-multiaddr"
|
ma "github.com/multiformats/go-multiaddr"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -3,7 +3,8 @@ package autonat
|
|||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/host"
|
"github.com/libp2p/go-libp2p/core/host"
|
||||||
|
|
||||||
ma "github.com/multiformats/go-multiaddr"
|
ma "github.com/multiformats/go-multiaddr"
|
||||||
manet "github.com/multiformats/go-multiaddr/net"
|
manet "github.com/multiformats/go-multiaddr/net"
|
||||||
)
|
)
|
||||||
|
@@ -6,12 +6,11 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
|
"github.com/libp2p/go-libp2p/core/transport"
|
||||||
blankhost "github.com/libp2p/go-libp2p/p2p/host/blank"
|
blankhost "github.com/libp2p/go-libp2p/p2p/host/blank"
|
||||||
swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing"
|
swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
|
||||||
"github.com/libp2p/go-libp2p-core/transport"
|
|
||||||
|
|
||||||
"github.com/multiformats/go-multiaddr"
|
"github.com/multiformats/go-multiaddr"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -4,8 +4,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/network"
|
"github.com/libp2p/go-libp2p/core/network"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
|
|
||||||
ma "github.com/multiformats/go-multiaddr"
|
ma "github.com/multiformats/go-multiaddr"
|
||||||
)
|
)
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
package autonat
|
package autonat
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/libp2p/go-libp2p-core/network"
|
"github.com/libp2p/go-libp2p/core/network"
|
||||||
|
|
||||||
ma "github.com/multiformats/go-multiaddr"
|
ma "github.com/multiformats/go-multiaddr"
|
||||||
manet "github.com/multiformats/go-multiaddr/net"
|
manet "github.com/multiformats/go-multiaddr/net"
|
||||||
|
@@ -4,8 +4,8 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/host"
|
"github.com/libp2p/go-libp2p/core/host"
|
||||||
"github.com/libp2p/go-libp2p-core/network"
|
"github.com/libp2p/go-libp2p/core/network"
|
||||||
)
|
)
|
||||||
|
|
||||||
// config holds configurable options for the autonat subsystem.
|
// config holds configurable options for the autonat subsystem.
|
||||||
|
@@ -1,10 +1,9 @@
|
|||||||
package autonat
|
package autonat
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
pb "github.com/libp2p/go-libp2p/p2p/host/autonat/pb"
|
pb "github.com/libp2p/go-libp2p/p2p/host/autonat/pb"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
|
||||||
|
|
||||||
ma "github.com/multiformats/go-multiaddr"
|
ma "github.com/multiformats/go-multiaddr"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -7,12 +7,11 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/libp2p/go-libp2p/core/network"
|
||||||
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
|
"github.com/libp2p/go-libp2p/core/peerstore"
|
||||||
pb "github.com/libp2p/go-libp2p/p2p/host/autonat/pb"
|
pb "github.com/libp2p/go-libp2p/p2p/host/autonat/pb"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/network"
|
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
|
||||||
"github.com/libp2p/go-libp2p-core/peerstore"
|
|
||||||
|
|
||||||
"github.com/libp2p/go-msgio/protoio"
|
"github.com/libp2p/go-msgio/protoio"
|
||||||
ma "github.com/multiformats/go-multiaddr"
|
ma "github.com/multiformats/go-multiaddr"
|
||||||
)
|
)
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user