switch from github.com/libp2p/go-libp2p-core to core
This commit is contained in:
parent
ba15ef6de0
commit
4623690009
|
@ -5,18 +5,17 @@ import (
|
|||
"fmt"
|
||||
"time"
|
||||
|
||||
"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/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-core/routing"
|
||||
"github.com/libp2p/go-libp2p-core/sec"
|
||||
"github.com/libp2p/go-libp2p-core/transport"
|
||||
|
||||
"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/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/core/routing"
|
||||
"github.com/libp2p/go-libp2p/core/sec"
|
||||
"github.com/libp2p/go-libp2p/core/transport"
|
||||
"github.com/libp2p/go-libp2p/p2p/host/autonat"
|
||||
"github.com/libp2p/go-libp2p/p2p/host/autorelay"
|
||||
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
|
||||
|
|
|
@ -4,15 +4,15 @@ import (
|
|||
"fmt"
|
||||
"reflect"
|
||||
|
||||
"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/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-core/sec"
|
||||
"github.com/libp2p/go-libp2p-core/transport"
|
||||
"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/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/core/sec"
|
||||
"github.com/libp2p/go-libp2p/core/transport"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
@ -3,11 +3,9 @@ package config
|
|||
import (
|
||||
"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"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/host"
|
||||
)
|
||||
|
||||
// MuxC is a stream multiplex transport constructor.
|
||||
|
|
|
@ -3,13 +3,12 @@ package config
|
|||
import (
|
||||
"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"
|
||||
"github.com/libp2p/go-libp2p/p2p/muxer/yamux"
|
||||
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) {
|
||||
|
|
|
@ -6,13 +6,11 @@ import (
|
|||
"reflect"
|
||||
"runtime"
|
||||
|
||||
"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/host"
|
||||
"github.com/libp2p/go-libp2p-core/transport"
|
||||
"github.com/libp2p/go-libp2p/core/connmgr"
|
||||
"github.com/libp2p/go-libp2p/core/host"
|
||||
"github.com/libp2p/go-libp2p/core/network"
|
||||
"github.com/libp2p/go-libp2p/core/pnet"
|
||||
"github.com/libp2p/go-libp2p/core/transport"
|
||||
)
|
||||
|
||||
var errorType = reflect.TypeOf((*error)(nil)).Elem()
|
||||
|
|
|
@ -3,13 +3,12 @@ package config
|
|||
import (
|
||||
"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"
|
||||
|
||||
"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.
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"github.com/libp2p/go-libp2p-core/connmgr"
|
||||
"github.com/libp2p/go-libp2p-core/host"
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
"github.com/libp2p/go-libp2p-core/pnet"
|
||||
"github.com/libp2p/go-libp2p-core/transport"
|
||||
"github.com/libp2p/go-libp2p/core/connmgr"
|
||||
"github.com/libp2p/go-libp2p/core/host"
|
||||
"github.com/libp2p/go-libp2p/core/network"
|
||||
"github.com/libp2p/go-libp2p/core/pnet"
|
||||
"github.com/libp2p/go-libp2p/core/transport"
|
||||
)
|
||||
|
||||
// TptC is the type for libp2p transport constructors. You probably won't ever
|
||||
|
|
|
@ -3,11 +3,10 @@ package config
|
|||
import (
|
||||
"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-core/peer"
|
||||
"github.com/libp2p/go-libp2p-core/transport"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
|
|
|
@ -2,10 +2,11 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"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-core/protocol"
|
||||
"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/core/protocol"
|
||||
|
||||
"github.com/multiformats/go-multiaddr"
|
||||
)
|
||||
|
||||
|
|
|
@ -6,8 +6,9 @@ import (
|
|||
"net"
|
||||
"strings"
|
||||
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/multiformats/go-multiaddr"
|
||||
manet "github.com/multiformats/go-multiaddr/net"
|
||||
)
|
||||
|
|
|
@ -5,8 +5,9 @@ import (
|
|||
"net"
|
||||
"testing"
|
||||
|
||||
"github.com/libp2p/go-libp2p/core/test"
|
||||
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
"github.com/libp2p/go-libp2p-core/test"
|
||||
"github.com/multiformats/go-multiaddr"
|
||||
)
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"io"
|
||||
"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
|
||||
|
@ -22,10 +22,10 @@ import (
|
|||
// Such a pluggable design affords a great deal of flexibility and versatility.
|
||||
// Behaviours that are straightforward to implement include:
|
||||
//
|
||||
// * 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.
|
||||
// * Exponentially boost a score with every bump.
|
||||
// * Sum the incoming score, but keep it within min, max bounds.
|
||||
// - 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.
|
||||
// - Exponentially boost a score with every bump.
|
||||
// - Sum the incoming score, but keep it within min, max bounds.
|
||||
//
|
||||
// Commonly used DecayFns and BumpFns are provided in this package.
|
||||
type Decayer interface {
|
||||
|
|
|
@ -3,9 +3,9 @@ package connmgr
|
|||
import (
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/control"
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p/core/control"
|
||||
"github.com/libp2p/go-libp2p/core/network"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
)
|
||||
|
||||
// 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
|
||||
// throughout the process, to allow you to intercept the connection at that stage.
|
||||
//
|
||||
// InterceptPeerDial is called on an imminent outbound peer dial request, prior
|
||||
// to the addresses of that peer being available/resolved. Blocking connections
|
||||
// at this stage is typical for blacklisting scenarios.
|
||||
// InterceptPeerDial is called on an imminent outbound peer dial request, prior
|
||||
// to the addresses of that peer being available/resolved. Blocking connections
|
||||
// at this stage is typical for blacklisting scenarios.
|
||||
//
|
||||
// InterceptAddrDial is called on an imminent outbound dial to a peer on a
|
||||
// particular address. Blocking connections at this stage is typical for
|
||||
// address filtering.
|
||||
// InterceptAddrDial is called on an imminent outbound dial to a peer on a
|
||||
// particular address. Blocking connections at this stage is typical for
|
||||
// address filtering.
|
||||
//
|
||||
// InterceptAccept is called as soon as a transport listener receives an
|
||||
// inbound connection request, before any upgrade takes place. Transports who
|
||||
// accept already secure and/or multiplexed connections (e.g. possibly QUIC)
|
||||
// MUST call this method regardless, for correctness/consistency.
|
||||
// InterceptAccept is called as soon as a transport listener receives an
|
||||
// inbound connection request, before any upgrade takes place. Transports who
|
||||
// accept already secure and/or multiplexed connections (e.g. possibly QUIC)
|
||||
// MUST call this method regardless, for correctness/consistency.
|
||||
//
|
||||
// InterceptSecured is called for both inbound and outbound connections,
|
||||
// after a security handshake has taken place and we've authenticated the peer.
|
||||
// InterceptSecured is called for both inbound and outbound connections,
|
||||
// after a security handshake has taken place and we've authenticated the peer.
|
||||
//
|
||||
// InterceptUpgraded is called for inbound and outbound connections, after
|
||||
// libp2p has finished upgrading the connection entirely to a secure,
|
||||
// multiplexed channel.
|
||||
// InterceptUpgraded is called for inbound and outbound connections, after
|
||||
// libp2p has finished upgrading the connection entirely to a secure,
|
||||
// multiplexed channel.
|
||||
//
|
||||
// This interface can be used to implement *strict/active* connection management
|
||||
// policies, such as hard limiting of connections once a maximum count has been
|
||||
|
|
|
@ -10,8 +10,8 @@ import (
|
|||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p/core/network"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
)
|
||||
|
||||
// SupportsDecay evaluates if the provided ConnManager supports decay, and if
|
||||
|
|
|
@ -3,8 +3,8 @@ package connmgr
|
|||
import (
|
||||
"context"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p/core/network"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
)
|
||||
|
||||
// NullConnMgr is a ConnMgr that provides no functionality.
|
||||
|
|
|
@ -10,8 +10,8 @@ import (
|
|||
"io"
|
||||
"math/big"
|
||||
|
||||
pb "github.com/libp2p/go-libp2p-core/crypto/pb"
|
||||
"github.com/libp2p/go-libp2p-core/internal/catch"
|
||||
pb "github.com/libp2p/go-libp2p/core/crypto/pb"
|
||||
"github.com/libp2p/go-libp2p/core/internal/catch"
|
||||
|
||||
"github.com/minio/sha256-simd"
|
||||
)
|
||||
|
|
|
@ -8,8 +8,8 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
|
||||
pb "github.com/libp2p/go-libp2p-core/crypto/pb"
|
||||
"github.com/libp2p/go-libp2p-core/internal/catch"
|
||||
pb "github.com/libp2p/go-libp2p/core/crypto/pb"
|
||||
"github.com/libp2p/go-libp2p/core/internal/catch"
|
||||
)
|
||||
|
||||
// Ed25519PrivateKey is an ed25519 private key.
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"crypto/rand"
|
||||
"testing"
|
||||
|
||||
pb "github.com/libp2p/go-libp2p-core/crypto/pb"
|
||||
pb "github.com/libp2p/go-libp2p/core/crypto/pb"
|
||||
)
|
||||
|
||||
func TestBasicSignAndVerify(t *testing.T) {
|
||||
|
|
|
@ -8,8 +8,8 @@ import (
|
|||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/crypto"
|
||||
crypto_pb "github.com/libp2p/go-libp2p-core/crypto/pb"
|
||||
"github.com/libp2p/go-libp2p/core/crypto"
|
||||
crypto_pb "github.com/libp2p/go-libp2p/core/crypto/pb"
|
||||
)
|
||||
|
||||
var message = []byte("Libp2p is the _best_!")
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
|
||||
pb "github.com/libp2p/go-libp2p-core/crypto/pb"
|
||||
pb "github.com/libp2p/go-libp2p/core/crypto/pb"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
)
|
||||
|
|
|
@ -9,10 +9,10 @@ import (
|
|||
"crypto/ed25519"
|
||||
"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) {
|
||||
if priv == nil {
|
||||
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) {
|
||||
if priv == nil {
|
||||
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) {
|
||||
if pub == nil {
|
||||
return nil, ErrNilPublicKey
|
||||
|
|
|
@ -10,13 +10,13 @@ import (
|
|||
"crypto/rsa"
|
||||
"crypto/x509"
|
||||
|
||||
btcec "github.com/btcsuite/btcd/btcec/v2"
|
||||
openssl "github.com/libp2p/go-openssl"
|
||||
"github.com/libp2p/go-libp2p/core/internal/catch"
|
||||
|
||||
"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) {
|
||||
if priv == nil {
|
||||
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) {
|
||||
if priv == nil {
|
||||
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) {
|
||||
if pub == nil {
|
||||
return nil, ErrNilPublicKey
|
||||
|
|
|
@ -13,11 +13,12 @@ import (
|
|||
"reflect"
|
||||
"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"
|
||||
. "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"
|
||||
)
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ package crypto
|
|||
import (
|
||||
"sync"
|
||||
|
||||
pb "github.com/libp2p/go-libp2p-core/crypto/pb"
|
||||
pb "github.com/libp2p/go-libp2p/core/crypto/pb"
|
||||
|
||||
"github.com/libp2p/go-openssl"
|
||||
)
|
||||
|
|
|
@ -2,7 +2,7 @@ syntax = "proto2";
|
|||
|
||||
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 {
|
||||
RSA = 0;
|
||||
|
|
|
@ -11,8 +11,8 @@ import (
|
|||
"errors"
|
||||
"io"
|
||||
|
||||
pb "github.com/libp2p/go-libp2p-core/crypto/pb"
|
||||
"github.com/libp2p/go-libp2p-core/internal/catch"
|
||||
pb "github.com/libp2p/go-libp2p/core/crypto/pb"
|
||||
"github.com/libp2p/go-libp2p/core/internal/catch"
|
||||
|
||||
"github.com/minio/sha256-simd"
|
||||
)
|
||||
|
|
|
@ -4,8 +4,8 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
|
||||
pb "github.com/libp2p/go-libp2p-core/crypto/pb"
|
||||
"github.com/libp2p/go-libp2p-core/internal/catch"
|
||||
pb "github.com/libp2p/go-libp2p/core/crypto/pb"
|
||||
"github.com/libp2p/go-libp2p/core/internal/catch"
|
||||
|
||||
btcec "github.com/btcsuite/btcd/btcec/v2"
|
||||
btcececdsa "github.com/btcsuite/btcd/btcec/v2/ecdsa"
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
)
|
||||
|
||||
// Advertiser is an interface for advertising services
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package event
|
||||
|
||||
import (
|
||||
"github.com/libp2p/go-libp2p-core/record"
|
||||
"github.com/libp2p/go-libp2p/core/record"
|
||||
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
)
|
||||
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
// that libp2p subsystems may emit.
|
||||
//
|
||||
// Source code is arranged as follows:
|
||||
// * doc.go: this file.
|
||||
// * bus.go: abstractions for the event bus.
|
||||
// * rest: event structs, sensibly categorised in files by entity, and following this naming convention:
|
||||
// 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)
|
||||
// expresses that a process is in progress. Examples: EvtConnEstablishing, EvtConnEstablished.
|
||||
// - doc.go: this file.
|
||||
// - bus.go: abstractions for the event bus.
|
||||
// - rest: event structs, sensibly categorised in files by entity, and following this naming convention:
|
||||
// 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)
|
||||
// expresses that a process is in progress. Examples: EvtConnEstablishing, EvtConnEstablished.
|
||||
package event
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
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.
|
||||
type EvtPeerIdentificationCompleted struct {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
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.
|
||||
//
|
||||
|
|
|
@ -1,48 +1,48 @@
|
|||
package event
|
||||
|
||||
import (
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p/core/network"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
)
|
||||
|
||||
// EvtPeerConnectednessChanged should be emitted every time the "connectedness" to a
|
||||
// given peer changes. Specifically, this event is emitted in the following
|
||||
// cases:
|
||||
//
|
||||
// * Connectedness = Connected: Every time we transition from having no
|
||||
// connections to a peer to having at least one connection to the peer.
|
||||
// * Connectedness = NotConnected: Every time we transition from having at least
|
||||
// one connection to a peer to having no connections to the peer.
|
||||
// - Connectedness = Connected: Every time we transition from having no
|
||||
// connections to a peer to having at least one connection to the peer.
|
||||
// - Connectedness = NotConnected: Every time we transition from having at least
|
||||
// one connection to a peer to having no connections to the peer.
|
||||
//
|
||||
// Additional connectedness states may be added in the future. This list should
|
||||
// not be considered exhaustive.
|
||||
//
|
||||
// Take note:
|
||||
//
|
||||
// * It's possible to have _multiple_ connections to a given peer.
|
||||
// * Both libp2p and networks are asynchronous.
|
||||
// - It's possible to have _multiple_ connections to a given peer.
|
||||
// - Both libp2p and networks are asynchronous.
|
||||
//
|
||||
// This means that all of the following situations are possible:
|
||||
//
|
||||
// A connection is cut and is re-established:
|
||||
//
|
||||
// * Peer A observes a transition from Connected -> NotConnected -> Connected
|
||||
// * Peer B 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
|
||||
//
|
||||
// Explanation: Both peers observe the connection die. This is the "nice" case.
|
||||
//
|
||||
// A connection is cut and is re-established.
|
||||
//
|
||||
// * Peer A observes a transition from Connected -> NotConnected -> Connected.
|
||||
// * Peer B observes no transition.
|
||||
// - Peer A observes a transition from Connected -> NotConnected -> Connected.
|
||||
// - Peer B observes no transition.
|
||||
//
|
||||
// Explanation: Peer A re-establishes the dead connection. Peer B observes the
|
||||
// new connection form before it observes the old connection die.
|
||||
//
|
||||
// A connection is cut:
|
||||
//
|
||||
// * Peer A observes no transition.
|
||||
// * Peer B observes no transition.
|
||||
// - Peer A observes no transition.
|
||||
// - Peer B observes no transition.
|
||||
//
|
||||
// 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
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package event
|
||||
|
||||
import (
|
||||
peer "github.com/libp2p/go-libp2p-core/peer"
|
||||
protocol "github.com/libp2p/go-libp2p-core/protocol"
|
||||
peer "github.com/libp2p/go-libp2p/core/peer"
|
||||
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.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package event
|
||||
|
||||
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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
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.
|
||||
func InfoFromHost(h Host) *peer.AddrInfo {
|
||||
|
|
|
@ -6,13 +6,13 @@ package host
|
|||
import (
|
||||
"context"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/connmgr"
|
||||
"github.com/libp2p/go-libp2p-core/event"
|
||||
"github.com/libp2p/go-libp2p-core/introspection"
|
||||
"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/protocol"
|
||||
"github.com/libp2p/go-libp2p/core/connmgr"
|
||||
"github.com/libp2p/go-libp2p/core/event"
|
||||
"github.com/libp2p/go-libp2p/core/introspection"
|
||||
"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/protocol"
|
||||
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
)
|
||||
|
|
|
@ -3,7 +3,7 @@ package introspection
|
|||
import (
|
||||
"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
|
||||
|
|
|
@ -397,11 +397,12 @@ func (m *ResultCounter) GetErr() uint32 {
|
|||
//
|
||||
// time past -> present an event 16 min ago
|
||||
// ======================================================X================>>
|
||||
// | | 1m
|
||||
// | |---| 5m
|
||||
// | |-------------| 15m
|
||||
// |------------X---------------| 30m
|
||||
// |------------------------------------------X---------------| 60m
|
||||
//
|
||||
// | | 1m
|
||||
// | |---| 5m
|
||||
// | |-------------| 15m
|
||||
// |------------X---------------| 30m
|
||||
// |------------------------------------------X---------------| 60m
|
||||
type SlidingCounter struct {
|
||||
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"`
|
||||
|
|
|
@ -6,8 +6,8 @@ import (
|
|||
|
||||
"github.com/libp2p/go-flow-metrics"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p-core/protocol"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
"github.com/libp2p/go-libp2p/core/protocol"
|
||||
)
|
||||
|
||||
// BandwidthCounter tracks incoming and outgoing data transferred by the local peer.
|
||||
|
|
|
@ -6,8 +6,8 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p-core/protocol"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
"github.com/libp2p/go-libp2p/core/protocol"
|
||||
|
||||
"github.com/libp2p/go-flow-metrics"
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
package metrics
|
||||
|
||||
import (
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p-core/protocol"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
"github.com/libp2p/go-libp2p/core/protocol"
|
||||
)
|
||||
|
||||
// Stats represents a point-in-time snapshot of bandwidth metrics.
|
||||
|
|
|
@ -4,8 +4,8 @@ import (
|
|||
"context"
|
||||
"io"
|
||||
|
||||
ic "github.com/libp2p/go-libp2p-core/crypto"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
ic "github.com/libp2p/go-libp2p/core/crypto"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
)
|
||||
|
@ -13,7 +13,8 @@ import (
|
|||
// Conn is a connection to a remote peer. It multiplexes streams.
|
||||
// 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:
|
||||
// stream.Conn().RemotePeer()
|
||||
//
|
||||
// stream.Conn().RemotePeer()
|
||||
type Conn interface {
|
||||
io.Closer
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ import (
|
|||
"io"
|
||||
"time"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p-core/peerstore"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
"github.com/libp2p/go-libp2p/core/peerstore"
|
||||
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package network
|
||||
|
||||
import (
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p-core/protocol"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
"github.com/libp2p/go-libp2p/core/protocol"
|
||||
"github.com/multiformats/go-multiaddr"
|
||||
)
|
||||
|
||||
|
@ -15,16 +15,17 @@ import (
|
|||
// Management Scopes, whereby resource usage is constrained by a DAG of scopes,
|
||||
// The following diagram illustrates the structure of the resource constraint DAG:
|
||||
// System
|
||||
// +------------> Transient.............+................+
|
||||
// | . .
|
||||
// +------------> Service------------- . ----------+ .
|
||||
// | . | .
|
||||
// +-------------> Protocol----------- . ----------+ .
|
||||
// | . | .
|
||||
// +--------------> Peer \ | .
|
||||
// +------------> Connection | .
|
||||
// | \ \
|
||||
// +---------------------------> Stream
|
||||
//
|
||||
// +------------> Transient.............+................+
|
||||
// | . .
|
||||
// +------------> Service------------- . ----------+ .
|
||||
// | . | .
|
||||
// +-------------> Protocol----------- . ----------+ .
|
||||
// | . | .
|
||||
// +--------------> Peer \ | .
|
||||
// +------------> Connection | .
|
||||
// | \ \
|
||||
// +---------------------------> Stream
|
||||
//
|
||||
// The basic resources accounted by the ResourceManager include memory, streams, connections,
|
||||
// and file descriptors. These account for both space and time used by
|
||||
|
@ -59,16 +60,16 @@ import (
|
|||
// scopes can form trees, with nested spans.
|
||||
//
|
||||
// Typical Usage:
|
||||
// - 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
|
||||
// to the user, albeit with a narrower interface, through Conn and Stream objects who have
|
||||
// a Scope method.
|
||||
// - 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
|
||||
// service scope using the ResourceManager interface.
|
||||
// - 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
|
||||
// opt to use appropriate steam scopes for streams that they create or own.
|
||||
// - 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
|
||||
// to the user, albeit with a narrower interface, through Conn and Stream objects who have
|
||||
// a Scope method.
|
||||
// - 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
|
||||
// service scope using the ResourceManager interface.
|
||||
// - 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
|
||||
// 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
|
||||
// interface. We provide a canonical implementation in the go-libp2p-resource-manager package.
|
||||
|
@ -76,7 +77,8 @@ import (
|
|||
// or dynamic.
|
||||
//
|
||||
// WARNING The ResourceManager interface is considered experimental and subject to change
|
||||
// in subsequent releases.
|
||||
//
|
||||
// in subsequent releases.
|
||||
type ResourceManager interface {
|
||||
ResourceScopeViewer
|
||||
|
||||
|
@ -172,12 +174,13 @@ type ResourceScope interface {
|
|||
// when the programmer calls Done.
|
||||
//
|
||||
// Example:
|
||||
// s, err := someScope.BeginSpan()
|
||||
// if err != nil { ... }
|
||||
// defer s.Done()
|
||||
//
|
||||
// if err := s.ReserveMemory(...); err != nil { ... }
|
||||
// // ... use memory
|
||||
// s, err := someScope.BeginSpan()
|
||||
// if err != nil { ... }
|
||||
// defer s.Done()
|
||||
//
|
||||
// if err := s.ReserveMemory(...); err != nil { ... }
|
||||
// // ... use memory
|
||||
type ResourceScopeSpan interface {
|
||||
ResourceScope
|
||||
// Done ends the span and releases associated resources.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package network
|
||||
|
||||
import (
|
||||
"github.com/libp2p/go-libp2p-core/protocol"
|
||||
"github.com/libp2p/go-libp2p/core/protocol"
|
||||
)
|
||||
|
||||
// Stream represents a bidirectional channel between two agents in
|
||||
|
|
|
@ -3,7 +3,8 @@ package peer
|
|||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/internal/catch"
|
||||
"github.com/libp2p/go-libp2p/core/internal/catch"
|
||||
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
)
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
|
||||
. "github.com/libp2p/go-libp2p-core/peer"
|
||||
. "github.com/libp2p/go-libp2p/core/peer"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
@ -5,10 +5,11 @@ package peer_pb
|
|||
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
io "io"
|
||||
math "math"
|
||||
math_bits "math/bits"
|
||||
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
)
|
||||
|
||||
// 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
|
||||
// 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.
|
||||
type PeerRecord struct {
|
||||
// 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
|
||||
// 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.
|
||||
message PeerRecord {
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"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"
|
||||
mc "github.com/multiformats/go-multicodec"
|
||||
mh "github.com/multiformats/go-multihash"
|
||||
|
|
|
@ -3,8 +3,8 @@ package peer_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
. "github.com/libp2p/go-libp2p-core/test"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
. "github.com/libp2p/go-libp2p/core/test"
|
||||
)
|
||||
|
||||
func TestPeerSerdePB(t *testing.T) {
|
||||
|
|
|
@ -7,9 +7,9 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
ic "github.com/libp2p/go-libp2p-core/crypto"
|
||||
. "github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p-core/test"
|
||||
ic "github.com/libp2p/go-libp2p/core/crypto"
|
||||
. "github.com/libp2p/go-libp2p/core/peer"
|
||||
"github.com/libp2p/go-libp2p/core/test"
|
||||
|
||||
b58 "github.com/mr-tron/base58/base58"
|
||||
mh "github.com/multiformats/go-multihash"
|
||||
|
|
|
@ -5,9 +5,9 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/internal/catch"
|
||||
pb "github.com/libp2p/go-libp2p-core/peer/pb"
|
||||
"github.com/libp2p/go-libp2p-core/record"
|
||||
"github.com/libp2p/go-libp2p/core/internal/catch"
|
||||
pb "github.com/libp2p/go-libp2p/core/peer/pb"
|
||||
"github.com/libp2p/go-libp2p/core/record"
|
||||
|
||||
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
|
||||
// be set by the caller:
|
||||
//
|
||||
// rec := peer.NewPeerRecord()
|
||||
// rec.PeerID = aPeerID
|
||||
// rec.Addrs = someAddrs
|
||||
// rec := peer.NewPeerRecord()
|
||||
// rec.PeerID = aPeerID
|
||||
// rec.Addrs = someAddrs
|
||||
//
|
||||
// Alternatively, you can construct a PeerRecord struct directly and use the TimestampSeq
|
||||
// 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
|
||||
// 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
|
||||
// and sign it with the local peer's private key:
|
||||
//
|
||||
// rec := &PeerRecord{PeerID: myPeerId, Addrs: myAddrs}
|
||||
// envelope, err := rec.Sign(myPrivateKey)
|
||||
// rec := &PeerRecord{PeerID: myPeerId, Addrs: myAddrs}
|
||||
// envelope, err := rec.Sign(myPrivateKey)
|
||||
//
|
||||
// The resulting record.Envelope can be marshalled to a []byte and shared
|
||||
// publicly. As a convenience, the MarshalSigned method will produce the
|
||||
// Envelope and marshal it to a []byte in one go:
|
||||
//
|
||||
// rec := &PeerRecord{PeerID: myPeerId, Addrs: myAddrs}
|
||||
// recordBytes, err := rec.MarshalSigned(myPrivateKey)
|
||||
// rec := &PeerRecord{PeerID: myPeerId, Addrs: myAddrs}
|
||||
// recordBytes, err := rec.MarshalSigned(myPrivateKey)
|
||||
//
|
||||
// To validate and unmarshal a signed PeerRecord from a remote peer,
|
||||
// "consume" the containing envelope, which will return both the
|
||||
// routing.Envelope and the inner Record. The Record must be cast to
|
||||
// a PeerRecord pointer before use:
|
||||
//
|
||||
// envelope, untypedRecord, err := ConsumeEnvelope(envelopeBytes, PeerRecordEnvelopeDomain)
|
||||
// if err != nil {
|
||||
// handleError(err)
|
||||
// return
|
||||
// }
|
||||
// peerRec := untypedRecord.(*PeerRecord)
|
||||
//
|
||||
// envelope, untypedRecord, err := ConsumeEnvelope(envelopeBytes, PeerRecordEnvelopeDomain)
|
||||
// if err != nil {
|
||||
// handleError(err)
|
||||
// return
|
||||
// }
|
||||
// peerRec := untypedRecord.(*PeerRecord)
|
||||
type PeerRecord struct {
|
||||
// PeerID is the ID of the peer this record pertains to.
|
||||
PeerID ID
|
||||
|
|
|
@ -4,10 +4,10 @@ import (
|
|||
"bytes"
|
||||
"testing"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/crypto"
|
||||
. "github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p-core/record"
|
||||
"github.com/libp2p/go-libp2p-core/test"
|
||||
"github.com/libp2p/go-libp2p/core/crypto"
|
||||
. "github.com/libp2p/go-libp2p/core/peer"
|
||||
"github.com/libp2p/go-libp2p/core/record"
|
||||
"github.com/libp2p/go-libp2p/core/test"
|
||||
)
|
||||
|
||||
func TestPeerRecordConstants(t *testing.T) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package peerstore
|
||||
|
||||
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.
|
||||
|
|
|
@ -9,9 +9,9 @@ import (
|
|||
"math"
|
||||
"time"
|
||||
|
||||
ic "github.com/libp2p/go-libp2p-core/crypto"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p-core/record"
|
||||
ic "github.com/libp2p/go-libp2p/core/crypto"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
"github.com/libp2p/go-libp2p/core/record"
|
||||
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
)
|
||||
|
@ -142,10 +142,9 @@ type AddrBook interface {
|
|||
// certified addresses, callers should use the GetCertifiedAddrBook helper or
|
||||
// type-assert on the CertifiedAddrBook interface:
|
||||
//
|
||||
// if cab, ok := aPeerstore.(CertifiedAddrBook); ok {
|
||||
// cab.ConsumePeerRecord(signedPeerRecord, aTTL)
|
||||
// }
|
||||
//
|
||||
// if cab, ok := aPeerstore.(CertifiedAddrBook); ok {
|
||||
// cab.ConsumePeerRecord(signedPeerRecord, aTTL)
|
||||
// }
|
||||
type CertifiedAddrBook interface {
|
||||
// ConsumePeerRecord adds addresses from a signed peer.PeerRecord (contained in
|
||||
// a record.Envelope), which will expire after the given TTL.
|
||||
|
|
|
@ -6,9 +6,9 @@ import (
|
|||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/crypto"
|
||||
"github.com/libp2p/go-libp2p-core/internal/catch"
|
||||
pb "github.com/libp2p/go-libp2p-core/record/pb"
|
||||
"github.com/libp2p/go-libp2p/core/crypto"
|
||||
"github.com/libp2p/go-libp2p/core/internal/catch"
|
||||
pb "github.com/libp2p/go-libp2p/core/record/pb"
|
||||
|
||||
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
|
||||
// Record type:
|
||||
//
|
||||
// envelope, rec, err := ConsumeEnvelope(envelopeBytes, peer.PeerRecordEnvelopeDomain)
|
||||
// if err != nil {
|
||||
// handleError(envelope, err) // envelope may be non-nil, even if errors occur!
|
||||
// return
|
||||
// }
|
||||
// peerRec, ok := rec.(*peer.PeerRecord)
|
||||
// if ok {
|
||||
// doSomethingWithPeerRecord(peerRec)
|
||||
// }
|
||||
// envelope, rec, err := ConsumeEnvelope(envelopeBytes, peer.PeerRecordEnvelopeDomain)
|
||||
// if err != nil {
|
||||
// handleError(envelope, err) // envelope may be non-nil, even if errors occur!
|
||||
// return
|
||||
// }
|
||||
// peerRec, ok := rec.(*peer.PeerRecord)
|
||||
// if ok {
|
||||
// doSomethingWithPeerRecord(peerRec)
|
||||
// }
|
||||
//
|
||||
// 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
|
||||
|
@ -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
|
||||
// correctly.
|
||||
//
|
||||
// rec := &MyRecordType{}
|
||||
// envelope, err := ConsumeTypedEnvelope(envelopeBytes, rec)
|
||||
// if err != nil {
|
||||
// handleError(envelope, err)
|
||||
// }
|
||||
// doSomethingWithRecord(rec)
|
||||
// rec := &MyRecordType{}
|
||||
// envelope, err := ConsumeTypedEnvelope(envelopeBytes, rec)
|
||||
// if err != nil {
|
||||
// handleError(envelope, err)
|
||||
// }
|
||||
// doSomethingWithRecord(rec)
|
||||
//
|
||||
// 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
|
||||
|
|
|
@ -5,10 +5,10 @@ import (
|
|||
"errors"
|
||||
"testing"
|
||||
|
||||
crypto "github.com/libp2p/go-libp2p-core/crypto"
|
||||
. "github.com/libp2p/go-libp2p-core/record"
|
||||
pb "github.com/libp2p/go-libp2p-core/record/pb"
|
||||
"github.com/libp2p/go-libp2p-core/test"
|
||||
crypto "github.com/libp2p/go-libp2p/core/crypto"
|
||||
. "github.com/libp2p/go-libp2p/core/record"
|
||||
pb "github.com/libp2p/go-libp2p/core/record/pb"
|
||||
"github.com/libp2p/go-libp2p/core/test"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
)
|
||||
|
|
|
@ -5,11 +5,12 @@ package record_pb
|
|||
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
pb "github.com/libp2p/go-libp2p-core/crypto/pb"
|
||||
io "io"
|
||||
math "math"
|
||||
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.
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"errors"
|
||||
"reflect"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/internal/catch"
|
||||
"github.com/libp2p/go-libp2p/core/internal/catch"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -59,15 +59,14 @@ type Record interface {
|
|||
// a pointer type. Registration should be done in the init function of the package
|
||||
// where the Record type is defined:
|
||||
//
|
||||
// package hello_record
|
||||
// import record "github.com/libp2p/go-libp2p-core/record"
|
||||
// package hello_record
|
||||
// import record "github.com/libp2p/go-libp2p/core/record"
|
||||
//
|
||||
// func init() {
|
||||
// record.RegisterType(&HelloRecord{})
|
||||
// }
|
||||
//
|
||||
// type HelloRecord struct { } // etc..
|
||||
// func init() {
|
||||
// record.RegisterType(&HelloRecord{})
|
||||
// }
|
||||
//
|
||||
// type HelloRecord struct { } // etc..
|
||||
func RegisterType(prototype Record) {
|
||||
payloadTypeRegistry[string(prototype.Codec())] = getValueType(prototype)
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"context"
|
||||
"sync"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
)
|
||||
|
||||
// QueryEventType indicates the query event's type.
|
||||
|
|
|
@ -3,7 +3,7 @@ package routing
|
|||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
)
|
||||
|
||||
func (qe *QueryEvent) MarshalJSON() ([]byte, error) {
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
|
||||
ci "github.com/libp2p/go-libp2p-core/crypto"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
ci "github.com/libp2p/go-libp2p/core/crypto"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
|
||||
cid "github.com/ipfs/go-cid"
|
||||
)
|
||||
|
|
|
@ -9,12 +9,12 @@ import (
|
|||
"io"
|
||||
"net"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p-core/sec"
|
||||
"github.com/libp2p/go-msgio"
|
||||
ci "github.com/libp2p/go-libp2p/core/crypto"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
"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"
|
||||
pb "github.com/libp2p/go-libp2p-core/sec/insecure/pb"
|
||||
"github.com/libp2p/go-msgio"
|
||||
)
|
||||
|
||||
// ID is the multistream-select protocol ID that should be used when identifying
|
||||
|
|
|
@ -6,11 +6,11 @@ import (
|
|||
"net"
|
||||
"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/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p-core/sec"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// Run a set of sessions through the session setup and verification.
|
||||
|
|
|
@ -5,11 +5,12 @@ package plaintext_pb
|
|||
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
pb "github.com/libp2p/go-libp2p-core/crypto/pb"
|
||||
io "io"
|
||||
math "math"
|
||||
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.
|
||||
|
|
|
@ -2,7 +2,7 @@ syntax = "proto2";
|
|||
|
||||
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 {
|
||||
optional bytes id = 1;
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
"context"
|
||||
"net"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p/core/network"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
)
|
||||
|
||||
// SecureConn is an authenticated, encrypted connection.
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"math/rand"
|
||||
"sync/atomic"
|
||||
|
||||
ci "github.com/libp2p/go-libp2p-core/crypto"
|
||||
ci "github.com/libp2p/go-libp2p/core/crypto"
|
||||
)
|
||||
|
||||
var globalSeed int64
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"math/rand"
|
||||
"testing"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
|
||||
mh "github.com/multiformats/go-multihash"
|
||||
)
|
||||
|
|
|
@ -6,8 +6,8 @@ import (
|
|||
"context"
|
||||
"net"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p/core/network"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
manet "github.com/multiformats/go-multiaddr/net"
|
||||
|
|
|
@ -5,6 +5,7 @@ package libp2p
|
|||
import (
|
||||
"crypto/rand"
|
||||
|
||||
"github.com/libp2p/go-libp2p/core/crypto"
|
||||
"github.com/libp2p/go-libp2p/p2p/host/peerstore/pstoremem"
|
||||
rcmgr "github.com/libp2p/go-libp2p/p2p/host/resource-manager"
|
||||
"github.com/libp2p/go-libp2p/p2p/muxer/yamux"
|
||||
|
@ -15,8 +16,6 @@ import (
|
|||
"github.com/libp2p/go-libp2p/p2p/transport/tcp"
|
||||
ws "github.com/libp2p/go-libp2p/p2p/transport/websocket"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/crypto"
|
||||
|
||||
"github.com/multiformats/go-multiaddr"
|
||||
)
|
||||
|
||||
|
|
12
go.mod
12
go.mod
|
@ -4,6 +4,7 @@ go 1.18
|
|||
|
||||
require (
|
||||
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/flynn/noise v1.0.0
|
||||
github.com/gogo/protobuf v1.3.2
|
||||
|
@ -19,13 +20,14 @@ require (
|
|||
github.com/jbenet/go-temp-err-catcher v0.1.0
|
||||
github.com/klauspost/compress v1.15.1
|
||||
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-core v0.19.1
|
||||
github.com/libp2p/go-libp2p-testing v0.11.0
|
||||
github.com/libp2p/go-mplex v0.7.0
|
||||
github.com/libp2p/go-msgio v0.2.0
|
||||
github.com/libp2p/go-nat v0.1.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-yamux/v3 v3.1.2
|
||||
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/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b
|
||||
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-multiaddr v0.6.0
|
||||
github.com/multiformats/go-multiaddr-dns v0.3.1
|
||||
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-multistream v0.3.3
|
||||
github.com/multiformats/go-varint v0.0.6
|
||||
|
@ -54,7 +58,6 @@ require (
|
|||
require (
|
||||
github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 // 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/v2 v2.1.2 // 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/koron/go-ssdp v0.0.3 // indirect
|
||||
github.com/libp2p/go-cidranger v1.1.0 // indirect
|
||||
github.com/libp2p/go-flow-metrics v0.0.3 // indirect
|
||||
github.com/libp2p/go-openssl v0.0.7 // indirect
|
||||
github.com/libp2p/go-libp2p-core v0.19.1 // 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-18 v0.1.2 // indirect
|
||||
|
@ -90,10 +92,8 @@ require (
|
|||
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
|
||||
github.com/miekg/dns v1.1.50 // 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-multibase v0.1.1 // indirect
|
||||
github.com/multiformats/go-multicodec v0.5.0 // indirect
|
||||
github.com/nxadm/tail v1.4.8 // indirect
|
||||
github.com/onsi/ginkgo v1.16.5 // 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-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-flow-metrics v0.0.3 h1:8tAs/hSdNvUiLgtlSy3mxwxWP4I9y/jlkPFT7epKdeM=
|
||||
github.com/libp2p/go-flow-metrics v0.0.3/go.mod h1:HeoSNUrOJVK1jEpDqVEiUOIXqhbnS27omG0uWU5slZs=
|
||||
github.com/libp2p/go-flow-metrics v0.1.0 h1:0iPhMI8PskQwzh57jB9WxIuIOQ0r+15PChFGkx3Q3WM=
|
||||
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/go.mod h1:WoaWxbHKBymSN41hWSq/lGKJEca7TNm58+gGJi2WsLI=
|
||||
github.com/libp2p/go-libp2p-core v0.19.1 h1:zaZQQCeCrFMtxFa1wHy6AhsVynyNmZAvwgWqSSPT3WE=
|
||||
|
|
|
@ -2,8 +2,7 @@ package libp2p
|
|||
|
||||
import (
|
||||
"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.
|
||||
|
|
|
@ -7,14 +7,13 @@ import (
|
|||
"strings"
|
||||
"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-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"
|
||||
)
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package libp2p
|
||||
|
||||
import (
|
||||
"github.com/libp2p/go-libp2p-core/protocol"
|
||||
|
||||
"github.com/libp2p/go-libp2p/core/protocol"
|
||||
"github.com/libp2p/go-libp2p/p2p/host/autonat"
|
||||
rcmgr "github.com/libp2p/go-libp2p/p2p/host/resource-manager"
|
||||
relayv1 "github.com/libp2p/go-libp2p/p2p/protocol/circuitv1/relay"
|
||||
|
|
17
options.go
17
options.go
|
@ -8,15 +8,14 @@ import (
|
|||
"fmt"
|
||||
"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/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"
|
||||
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
|
||||
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
|
||||
// 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 {
|
||||
return func(cfg *Config) error {
|
||||
if cfg.ConnectionGater != nil {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package libp2p
|
||||
|
||||
import (
|
||||
"github.com/libp2p/go-libp2p-core/connmgr"
|
||||
"github.com/libp2p/go-libp2p-core/control"
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p/core/connmgr"
|
||||
"github.com/libp2p/go-libp2p/core/control"
|
||||
"github.com/libp2p/go-libp2p/core/network"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
)
|
||||
|
|
|
@ -6,8 +6,8 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/discovery"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p/core/discovery"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
)
|
||||
|
|
|
@ -10,8 +10,8 @@ import (
|
|||
bhost "github.com/libp2p/go-libp2p/p2p/host/blank"
|
||||
swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/discovery"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p/core/discovery"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
|
||||
mockClock "github.com/benbjohnson/clock"
|
||||
)
|
||||
|
|
|
@ -5,10 +5,10 @@ import (
|
|||
"sync"
|
||||
"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"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
lru "github.com/hashicorp/golang-lru"
|
||||
)
|
||||
|
||||
// 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"
|
||||
"time"
|
||||
|
||||
"github.com/libp2p/go-libp2p/core/host"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
bhost "github.com/libp2p/go-libp2p/p2p/host/blank"
|
||||
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"
|
||||
)
|
||||
|
||||
|
|
|
@ -8,11 +8,12 @@ import (
|
|||
"strings"
|
||||
"sync"
|
||||
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
"github.com/libp2p/go-libp2p-core/host"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p/core/host"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
|
||||
"github.com/libp2p/zeroconf/v2"
|
||||
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
manet "github.com/multiformats/go-multiaddr/net"
|
||||
)
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"time"
|
||||
|
||||
"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/require"
|
||||
|
|
|
@ -5,9 +5,9 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/discovery"
|
||||
"github.com/libp2p/go-libp2p-core/host"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p/core/discovery"
|
||||
"github.com/libp2p/go-libp2p/core/host"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
)
|
||||
|
||||
type clock interface {
|
||||
|
|
|
@ -4,9 +4,9 @@ import (
|
|||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/discovery"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p-core/routing"
|
||||
"github.com/libp2p/go-libp2p/core/discovery"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
"github.com/libp2p/go-libp2p/core/routing"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
mh "github.com/multiformats/go-multihash"
|
||||
|
|
|
@ -13,9 +13,9 @@ import (
|
|||
swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
"github.com/libp2p/go-libp2p-core/discovery"
|
||||
"github.com/libp2p/go-libp2p-core/host"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p/core/discovery"
|
||||
"github.com/libp2p/go-libp2p/core/host"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
)
|
||||
|
||||
type mockRoutingTable struct {
|
||||
|
|
|
@ -4,8 +4,8 @@ import (
|
|||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/discovery"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p/core/discovery"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
)
|
||||
|
|
|
@ -7,13 +7,12 @@ import (
|
|||
"sync/atomic"
|
||||
"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-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"
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
manet "github.com/multiformats/go-multiaddr/net"
|
||||
|
|
|
@ -5,15 +5,14 @@ import (
|
|||
"testing"
|
||||
"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"
|
||||
bhost "github.com/libp2p/go-libp2p/p2p/host/blank"
|
||||
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"
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
|
|
@ -5,13 +5,12 @@ import (
|
|||
"fmt"
|
||||
"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"
|
||||
|
||||
"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"
|
||||
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
)
|
||||
|
||||
|
|
|
@ -3,7 +3,8 @@ package autonat
|
|||
import (
|
||||
"net"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/host"
|
||||
"github.com/libp2p/go-libp2p/core/host"
|
||||
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
manet "github.com/multiformats/go-multiaddr/net"
|
||||
)
|
||||
|
|
|
@ -6,12 +6,11 @@ import (
|
|||
"net"
|
||||
"testing"
|
||||
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
"github.com/libp2p/go-libp2p/core/transport"
|
||||
blankhost "github.com/libp2p/go-libp2p/p2p/host/blank"
|
||||
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"
|
||||
)
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ import (
|
|||
"context"
|
||||
"io"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p/core/network"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package autonat
|
||||
|
||||
import (
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
"github.com/libp2p/go-libp2p/core/network"
|
||||
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
manet "github.com/multiformats/go-multiaddr/net"
|
||||
|
|
|
@ -4,8 +4,8 @@ import (
|
|||
"errors"
|
||||
"time"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/host"
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
"github.com/libp2p/go-libp2p/core/host"
|
||||
"github.com/libp2p/go-libp2p/core/network"
|
||||
)
|
||||
|
||||
// config holds configurable options for the autonat subsystem.
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
package autonat
|
||||
|
||||
import (
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
pb "github.com/libp2p/go-libp2p/p2p/host/autonat/pb"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
)
|
||||
|
||||
|
|
|
@ -7,12 +7,11 @@ import (
|
|||
"sync"
|
||||
"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"
|
||||
|
||||
"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"
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
)
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue