mirror of
https://github.com/status-im/libp2p-test-plans.git
synced 2025-01-13 00:04:17 +00:00
d872355bc0
* .github/workflows/run-composition.yml: retry the build command * .github/workflows/run-composition.yml: reduce run timeout for now * .github/workflows/*: run on push and PR * .github/actions: check testground health * ping/_composition/*: reorder lib versions * ping/: update with go-libp2p v0.22 * chore: gofmt * .github/workflows: allow check test-plans during PR and push * .github/workflows/*: introduce ping-interop-latest * .github/workflow: tweak retry + timeout * .github/actions/setup-testground: retry install * ping/rust: update with v0.47.0 release
38 lines
850 B
Go
38 lines
850 B
Go
//go:build v0.22
|
|
// +build v0.22
|
|
|
|
package compat
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/libp2p/go-libp2p"
|
|
"github.com/libp2p/go-libp2p/config"
|
|
"github.com/libp2p/go-libp2p/core/host"
|
|
"github.com/libp2p/go-libp2p/core/peer"
|
|
|
|
noise "github.com/libp2p/go-libp2p/p2p/security/noise"
|
|
tls "github.com/libp2p/go-libp2p/p2p/security/tls"
|
|
)
|
|
|
|
type PeerAddrInfo = peer.AddrInfo
|
|
|
|
func NewLibp2(ctx context.Context, secureChannel string, opts ...config.Option) (host.Host, error) {
|
|
security := getSecurityByName(secureChannel)
|
|
|
|
return libp2p.New(
|
|
append(opts, security)...,
|
|
)
|
|
}
|
|
|
|
func getSecurityByName(secureChannel string) libp2p.Option {
|
|
switch secureChannel {
|
|
case "noise":
|
|
return libp2p.Security(noise.ID, noise.New)
|
|
case "tls":
|
|
return libp2p.Security(tls.ID, tls.New)
|
|
}
|
|
panic(fmt.Sprintf("unknown secure channel: %s", secureChannel))
|
|
}
|