Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

chore: removal of RelayV1 support #51

Merged
merged 3 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
> [!WARNING]
> # No longer maintained. No longer relevant.
>
> This project is no longer maintained, was used in transitional period when ecosystem was switching from V1 to [V2](https://github.com/libp2p/specs/blob/master/relay/circuit-v2.md).
> `go-libp2p` >= `v0.26.0` [no longer supports Relay V1](https://github.com/libp2p/go-libp2p/issues/2075), making this project outdated.
>
> Modern deployments should implement their own relay setups based on [Relay V2 protocol](https://github.com/libp2p/specs/blob/master/relay/circuit-v2.md), which is supported via [go-libp2p](https://github.com/libp2p/go-libp2p) and `libp2p.EnableRelayService`

# libp2p-relay-daemon

> A standalone daemon that provides libp2p circuit relay services,
Expand Down Expand Up @@ -66,8 +74,12 @@ Below JSON config ensures only the circuit relay v2 is provided on custom ports:
},
"Network": {
"ListenAddrs": [
"/ip4/0.0.0.0/udp/4002/quic",
"/ip6/::/udp/4002/quic",
"/ip4/0.0.0.0/udp/4002/quic-v1",
"/ip6/::/udp/4002/quic-v1",
"/ip4/0.0.0.0/udp/4002/webrtc-direct",
"/ip6/::/udp/4002/webrtc-direct",
"/ip4/0.0.0.0/udp/4002/quic-v1/webtransport",
"/ip6/::/udp/4002/quic-v1/webtransport",
"/ip4/0.0.0.0/tcp/4002",
"/ip6/::/tcp/4002",
"/ip4/0.0.0.0/tcp/4003/ws",
Expand Down Expand Up @@ -104,10 +116,14 @@ type NetworkConfig struct {
// Addresses to listen on, as multiaddrs.
// Default:
// [
// "/ip4/0.0.0.0/udp/4001/quic",
// "/ip6/::/udp/4001/quic",
// "/ip4/0.0.0.0/tcp/4001",
// "/ip6/::/tcp/4001",
// "/ip4/0.0.0.0/udp/4001/quic-v1",
// "/ip6/::/udp/4001/quic-v1",
// "/ip4/0.0.0.0/udp/4001/webrtc-direct",
// "/ip6/::/udp/4001/webrtc-direct",
// "/ip4/0.0.0.0/udp/4001/quic-v1/webtransport",
// "/ip6/::/udp/4001/quic-v1/webtransport",
// "/ip4/0.0.0.0/tcp/4001",
// "/ip6/::/tcp/4001",
// ]
ListenAddrs []string

Expand Down Expand Up @@ -217,8 +233,8 @@ type RelayLimit struct {
## Release Process

1. Bump version in `version.json` and wait for CI to create a tag in this repo
2. Follow [ipfs/distributions#adding-a-version](https://github.com/ipfs/distributions#adding-a-version), wait for `master` branch there to finish and add new version to `/ipns/dist.ipfs.io/libp2p-relay-daemon/`
3. Back to this repo, create Github Release, and attach artifacts from `/ipns/dist.ipfs.io/libp2p-relay-daemon/{version}`
2. Follow [ipfs/distributions#adding-a-version](https://github.com/ipfs/distributions#adding-a-version), wait for `master` branch there to finish and add new version to `/ipns/dist.ipfs.tech/libp2p-relay-daemon/`
3. Back to this repo, create Github Release, and attach artifacts from `/ipns/dist.ipfs.tech/libp2p-relay-daemon/{version}`

## License

Expand Down
49 changes: 22 additions & 27 deletions cmd/libp2p-relay-daemon/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"errors"
"flag"
"fmt"
"net/http"
Expand All @@ -12,7 +13,6 @@
"github.com/libp2p/go-libp2p/p2p/net/connmgr"
relayv2 "github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/relay"
ma "github.com/multiformats/go-multiaddr"
manet "github.com/multiformats/go-multiaddr/net"
)

// Define the names of arguments here.
Expand Down Expand Up @@ -43,7 +43,10 @@
libp2p.UserAgent("relayd/1.0"),
libp2p.Identity(privk),
libp2p.DisableRelay(),
libp2p.ListenAddrStrings(cfg.Network.ListenAddrs...),
libp2p.NATPortMap(),
libp2p.EnableHolePunching(),
libp2p.DefaultTransports,
libp2p.DefaultMuxers,

Check warning on line 49 in cmd/libp2p-relay-daemon/main.go

View check run for this annotation

Codecov / codecov/patch

cmd/libp2p-relay-daemon/main.go#L46-L49

Added lines #L46 - L49 were not covered by tests
)

// load PSK if applicable
Expand All @@ -58,6 +61,12 @@
}
}

if len(cfg.Network.ListenAddrs) == 0 {
opts = append(opts, libp2p.DefaultListenAddrs)
} else {
opts = append(opts, libp2p.ListenAddrStrings(cfg.Network.ListenAddrs...))

Check warning on line 67 in cmd/libp2p-relay-daemon/main.go

View check run for this annotation

Codecov / codecov/patch

cmd/libp2p-relay-daemon/main.go#L64-L67

Added lines #L64 - L67 were not covered by tests
}

if len(cfg.Network.AnnounceAddrs) > 0 {
var announce []ma.Multiaddr
for _, s := range cfg.Network.AnnounceAddrs {
Expand All @@ -69,18 +78,6 @@
return announce
}),
)
} else {
opts = append(opts,
libp2p.AddrsFactory(func(addrs []ma.Multiaddr) []ma.Multiaddr {
announce := make([]ma.Multiaddr, 0, len(addrs))
for _, a := range addrs {
if manet.IsPublicAddr(a) {
announce = append(announce, a)
}
}
return announce
}),
)
}

cm, err := connmgr.NewConnManager(
Expand All @@ -102,10 +99,7 @@
}

fmt.Printf("I am %s\n", host.ID())
fmt.Printf("Public Addresses:\n")
for _, addr := range host.Addrs() {
fmt.Printf("\t%s/p2p/%s\n", addr, host.ID())
}
fmt.Printf("Libp2p listening on %v\n", host.Addrs())

Check warning on line 102 in cmd/libp2p-relay-daemon/main.go

View check run for this annotation

Codecov / codecov/patch

cmd/libp2p-relay-daemon/main.go#L102

Added line #L102 was not covered by tests

go listenPprof(cfg.Daemon.PprofPort)
time.Sleep(10 * time.Millisecond)
Expand All @@ -115,16 +109,17 @@
panic(err)
}

if cfg.RelayV2.Enabled {
fmt.Printf("Starting RelayV2...\n")
_, err = relayv2.New(host,
relayv2.WithResources(cfg.RelayV2.Resources),
relayv2.WithACL(acl))
if err != nil {
panic(err)
}
fmt.Printf("RelayV2 is running!\n")
if !cfg.RelayV2.Enabled {
panic(errors.New("RelayV2.Enabled=false is no longer supported. V2 is the only supported version now (https://github.com/libp2p/go-libp2p/issues/2075)"))

Check warning on line 113 in cmd/libp2p-relay-daemon/main.go

View check run for this annotation

Codecov / codecov/patch

cmd/libp2p-relay-daemon/main.go#L112-L113

Added lines #L112 - L113 were not covered by tests
}
_, err = relayv2.New(host,
relayv2.WithResources(cfg.RelayV2.Resources),
relayv2.WithACL(acl))
if err != nil {
panic(err)

Check warning on line 119 in cmd/libp2p-relay-daemon/main.go

View check run for this annotation

Codecov / codecov/patch

cmd/libp2p-relay-daemon/main.go#L115-L119

Added lines #L115 - L119 were not covered by tests
}
fmt.Printf("RelayV2 is running!\n")
fmt.Println("WARNING: this project is no longer maintained, see https://github.com/libp2p/go-libp2p-relay-daemon#readme")

Check warning on line 122 in cmd/libp2p-relay-daemon/main.go

View check run for this annotation

Codecov / codecov/patch

cmd/libp2p-relay-daemon/main.go#L121-L122

Added lines #L121 - L122 were not covered by tests

select {}
}
Expand Down
8 changes: 6 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@
return Config{
Network: NetworkConfig{
ListenAddrs: []string{
"/ip4/0.0.0.0/udp/4001/quic",
"/ip6/::/udp/4001/quic",
"/ip4/0.0.0.0/udp/4001/quic-v1",
"/ip6/::/udp/4001/quic-v1",
"/ip4/0.0.0.0/udp/4001/webrtc-direct",
"/ip6/::/udp/4001/webrtc-direct",
"/ip4/0.0.0.0/udp/4001/quic-v1/webtransport",
"/ip6/::/udp/4001/quic-v1/webtransport",

Check warning on line 66 in config.go

View check run for this annotation

Codecov / codecov/patch

config.go#L61-L66

Added lines #L61 - L66 were not covered by tests
"/ip4/0.0.0.0/tcp/4001",
"/ip6/::/tcp/4001",
},
Expand Down
103 changes: 61 additions & 42 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,50 @@ module github.com/libp2p/go-libp2p-relay-daemon
go 1.22

require (
github.com/libp2p/go-libp2p v0.30.0
github.com/multiformats/go-multiaddr v0.11.0
golang.org/x/crypto v0.12.0
github.com/libp2p/go-libp2p v0.36.3
github.com/multiformats/go-multiaddr v0.13.0
golang.org/x/crypto v0.26.0
)

require (
github.com/benbjohnson/clock v1.3.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/containerd/cgroups v1.1.0 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/elastic/gosigar v0.14.2 // indirect
github.com/flynn/noise v1.0.0 // indirect
github.com/elastic/gosigar v0.14.3 // indirect
github.com/flynn/noise v1.1.0 // indirect
github.com/francoispqt/gojay v1.2.13 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gopacket v1.1.19 // indirect
github.com/google/pprof v0.0.0-20230821062121-407c9e7a662f // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/huin/goupnp v1.2.0 // indirect
github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/huin/goupnp v1.3.0 // indirect
github.com/ipfs/go-cid v0.4.1 // indirect
github.com/ipfs/go-log/v2 v2.5.1 // indirect
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect
github.com/klauspost/compress v1.16.7 // indirect
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
github.com/koron/go-ssdp v0.0.4 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/libp2p/go-cidranger v1.1.0 // indirect
github.com/libp2p/go-flow-metrics v0.1.0 // indirect
github.com/libp2p/go-libp2p-asn-util v0.3.0 // indirect
github.com/libp2p/go-libp2p-asn-util v0.4.1 // indirect
github.com/libp2p/go-msgio v0.3.0 // indirect
github.com/libp2p/go-nat v0.2.0 // indirect
github.com/libp2p/go-netroute v0.2.1 // indirect
github.com/libp2p/go-reuseport v0.4.0 // indirect
github.com/libp2p/go-yamux/v4 v4.0.1 // indirect
github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/miekg/dns v1.1.55 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/miekg/dns v1.1.61 // indirect
github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b // indirect
github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc // indirect
github.com/minio/sha256-simd v1.0.1 // indirect
Expand All @@ -60,33 +58,54 @@ require (
github.com/multiformats/go-multibase v0.2.0 // indirect
github.com/multiformats/go-multicodec v0.9.0 // indirect
github.com/multiformats/go-multihash v0.2.3 // indirect
github.com/multiformats/go-multistream v0.4.1 // indirect
github.com/multiformats/go-multistream v0.5.0 // indirect
github.com/multiformats/go-varint v0.0.7 // indirect
github.com/onsi/ginkgo/v2 v2.11.0 // indirect
github.com/opencontainers/runtime-spec v1.1.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/onsi/ginkgo/v2 v2.19.1 // indirect
github.com/opencontainers/runtime-spec v1.2.0 // indirect
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
github.com/pion/datachannel v1.5.8 // indirect
github.com/pion/dtls/v2 v2.2.12 // indirect
github.com/pion/ice/v2 v2.3.34 // indirect
github.com/pion/interceptor v0.1.29 // indirect
github.com/pion/logging v0.2.2 // indirect
github.com/pion/mdns v0.0.12 // indirect
github.com/pion/randutil v0.1.0 // indirect
github.com/pion/rtcp v1.2.14 // indirect
github.com/pion/rtp v1.8.8 // indirect
github.com/pion/sctp v1.8.20 // indirect
github.com/pion/sdp/v3 v3.0.9 // indirect
github.com/pion/srtp/v2 v2.0.20 // indirect
github.com/pion/stun v0.6.1 // indirect
github.com/pion/transport/v2 v2.2.10 // indirect
github.com/pion/turn/v2 v2.1.6 // indirect
github.com/pion/webrtc/v3 v3.3.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.16.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.11.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.19.1 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.55.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/quic-go/qpack v0.4.0 // indirect
github.com/quic-go/qtls-go1-20 v0.3.2 // indirect
github.com/quic-go/quic-go v0.38.0 // indirect
github.com/quic-go/webtransport-go v0.5.3 // indirect
github.com/quic-go/quic-go v0.45.2 // indirect
github.com/quic-go/webtransport-go v0.8.0 // indirect
github.com/raulk/go-watchdog v1.3.0 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
go.uber.org/dig v1.17.0 // indirect
go.uber.org/fx v1.20.0 // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/wlynxg/anet v0.0.3 // indirect
go.uber.org/dig v1.17.1 // indirect
go.uber.org/fx v1.22.1 // indirect
go.uber.org/mock v0.4.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.25.0 // indirect
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 // indirect
google.golang.org/protobuf v1.31.0 // indirect
lukechampine.com/blake3 v1.2.1 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
golang.org/x/mod v0.19.0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.23.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/tools v0.23.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
lukechampine.com/blake3 v1.3.0 // indirect
)
Loading
Loading