balena / go-libp2p-vpn

A VPN Built on top of libp2p
MIT License
8 stars 4 forks source link

Compilation problems with Go v1.20 and 1.21 #3

Closed aabbtree77 closed 1 year ago

aabbtree77 commented 1 year ago
  1. The following error occurs when running "go build" in the libp2p-vpn folder (Ubuntu 22.04):
go version
go version go1.21.0 linux/amd64

go build
# github.com/lucas-clemente/quic-go/internal/qtls
../../go/pkg/mod/github.com/lucas-clemente/quic-go@v0.31.1/internal/qtls/go120.go:5:13: cannot use "The version of quic-go you're using can't be built on Go 1.20 yet. For more details, please see https://github.com/lucas-clemente/quic-go/wiki/quic-go-and-Go-versions." (untyped string constant "The version of quic-go you're using can't be built on Go 1.20 yet. F...) as int value in variable declaration

Turning the line "go 1.19" to "go 1.21" inside go.mod, followed by "go mod tidy" does not change anything.

  1. Running "go mod tidy" on a newly cloned original repo without anything else indicates the indirect packages:

go 1.19

require ( github.com/ipfs/go-log/v2 v2.5.1 github.com/libp2p/go-buffer-pool v0.1.0 github.com/libp2p/go-libp2p v0.24.2 github.com/multiformats/go-multiaddr v0.8.0 github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8 github.com/vishvananda/netlink v1.1.0 )

require ( github.com/benbjohnson/clock v1.3.0 // indirect .... google.golang.org/protobuf v1.28.1 // indirect lukechampine.com/blake3 v1.1.7 // indirect )


Afterwards, I bump up the Go version, enforce "latest" and remove the indirects:

module github.com/balena/go-libp2p-vpn

go 1.21

require ( github.com/ipfs/go-log/v2 latest github.com/libp2p/go-buffer-pool latest github.com/libp2p/go-libp2p latest github.com/multiformats/go-multiaddr latest github.com/songgao/water latest github.com/vishvananda/netlink latest )


  Running "go mod tidy" now brings all the latest versions:

module github.com/balena/go-libp2p-vpn

go 1.21

require ( github.com/ipfs/go-log/v2 v2.5.1 github.com/libp2p/go-buffer-pool v0.1.0 github.com/libp2p/go-libp2p v0.29.2 github.com/multiformats/go-multiaddr v0.11.0 github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8 github.com/vishvananda/netlink v1.1.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/containerd/cgroups v1.1.0 // indirect github.com/coreos/go-systemd/v22 v22.5.0 // 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/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/francoispqt/gojay v1.2.13 // indirect github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // 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-20230705174524-200ffdc848b8 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/huin/goupnp v1.2.0 // indirect github.com/ipfs/go-cid v0.4.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/koron/go-ssdp v0.0.4 // 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-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.3.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/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 github.com/mr-tron/base58 v1.2.0 // indirect github.com/multiformats/go-base32 v0.1.0 // indirect github.com/multiformats/go-base36 v0.2.0 // indirect github.com/multiformats/go-multiaddr-dns v0.3.1 // indirect github.com/multiformats/go-multiaddr-fmt v0.1.0 // indirect 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-varint v0.0.7 // indirect github.com/onsi/ginkgo/v2 v2.11.0 // indirect github.com/opencontainers/runtime-spec v1.0.2 // indirect github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/prometheus/client_golang v1.14.0 // indirect github.com/prometheus/client_model v0.4.0 // indirect github.com/prometheus/common v0.37.0 // indirect github.com/prometheus/procfs v0.8.0 // indirect github.com/quic-go/qpack v0.4.0 // indirect github.com/quic-go/qtls-go1-19 v0.3.3 // indirect github.com/quic-go/qtls-go1-20 v0.2.3 // indirect github.com/quic-go/quic-go v0.36.4 // indirect github.com/quic-go/webtransport-go v0.5.3 // indirect github.com/raulk/go-watchdog v1.3.0 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df // indirect go.uber.org/atomic v1.11.0 // indirect go.uber.org/dig v1.17.0 // indirect go.uber.org/fx v1.20.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.24.0 // indirect golang.org/x/crypto v0.11.0 // indirect golang.org/x/exp v0.0.0-20230725012225-302865e7556b // indirect golang.org/x/mod v0.12.0 // indirect golang.org/x/net v0.12.0 // indirect golang.org/x/sync v0.3.0 // indirect golang.org/x/sys v0.10.0 // indirect golang.org/x/text v0.11.0 // indirect golang.org/x/tools v0.11.0 // indirect google.golang.org/protobuf v1.30.0 // indirect lukechampine.com/blake3 v1.2.1 // indirect )


  Oddly, I get nearly the same quic-go issue:

go build

github.com/quic-go/quic-go/internal/qtls

../../go/pkg/mod/github.com/quic-go/quic-go@v0.36.4/internal/qtls/go121.go:5:13: cannot use "The version of quic-go you're using can't be built on Go 1.21 yet. For more details, please see https://github.com/quic-go/quic-go/wiki/quic-go-and-Go-versions." (untyped string constant "The version of quic-go you're using can't be built on Go 1.21 yet. F...) as int value in variable declaration

github.com/libp2p/go-libp2p/p2p/protocol/identify

../../go/pkg/mod/github.com/libp2p/go-libp2p@v0.29.2/p2p/protocol/identify/id.go:559:25: type func(a multiaddr.Multiaddr, b multiaddr.Multiaddr) bool of func(a, b ma.Multiaddr) bool {…} does not match inferred type func(a multiaddr.Multiaddr, b multiaddr.Multiaddr) int for func(a E, b E) int ../../go/pkg/mod/github.com/libp2p/go-libp2p@v0.29.2/p2p/protocol/identify/obsaddr.go:217:22: type func(first observedAddr, second observedAddr) bool of func(first, second observedAddr) bool {…} does not match inferred type func(a observedAddr, b *observedAddr) int for func(a E, b E) int



  I could also note that in the past I have been able to solve this [quic-go issue](https://github.com/hyprspace/hyprspace/issues/94) when going from Go v1.16 to v1.19, but not this time.

It is possible to get through this go-quic error by experimenting with different versions of Go (1.20 or 1.21), go-libp2p, and go-quic, but I do not remember precise numbers anymore and there were still some go-libp2p errors about generic type conversions thrown in the end of the compilation of this code with go build.

3. One can find [examples where go-libp2p works with go-quic and Go v1.20](https://github.com/anywherelan/awl/blob/master/go.mod). No doubt it is possible to hunt for correct versions there, but I would like to avoid that and move on to Go v1.21.

4. The code compiles with Go v19.12.
balena commented 1 year ago

@aabbtree77 if you agree, the reported problem should move to github.com/lucas-clemente/quic-go, as it is used as a dependency of github.com/libp2p/go-libp2p.

Also, go-libp2p currently requires Go 1.19 as you can see here: https://github.com/libp2p/go-libp2p/blob/master/go.mod. There is this too to play with.

aabbtree77 commented 1 year ago

I agree with you, go-libp2p doesn't support v1.21 yet, as indicated in #2468.

Let's wait for the August 22-24 2023 release then, that should solve the problem #2428.

After skimming through some issues I see that go-libp2p is quite actively developed with some breaking changes, I am afraid to touch any 3-5 year old libp2p codes now.

I mostly need this to ssh into computers without proper IPs, and awl solves this fairly well for me, one can even get access to remote Linux terminal from Android, but it is slow and not so reliable, so I keep looking around. Eyeballing goose now.

Ideally, also something free, open and simple/reliable to send a message from PC to PC directly in Go.

This version stuff is such a mess everywhere. I spent an evening compiling Android code for awl, and I should probably report a similar issue there, but it takes time and I do not remember all the fixes anymore.

balena commented 1 year ago

I've had some experience actually adding the networking level required for connectivity so you could use ssh or any other regular network protocol.

You can take a look at wireguard-go-vsock. It essentially implements a "Bind" that aims opening WireGuard over hosts with VSOCK. Of course in this case, as the objective is just to establish a TCP/IP stack host to guest, other more lightweight alternatives exist and may be more suitable, such as SOCAT. Anyways, once you establish this network link, you can use iptables to promote NAT (masquerade) to your guest.

I leave it as another option to you case you feel it suits your needs.

go-libp2p-vpn has only one advantage compared to all other projects you mentioned: it's very simple to hack. In fact it has been created as a proof of concept project, feel free to fork and modify as you want.

mooijtech commented 1 year ago

The last error is due to a signature change in slices where an int is currently returned instead of bool, references: https://github.com/golang/go/issues/61374

balena commented 1 year ago

Which error you're referring to @mooijtech?

mooijtech commented 1 year ago

@balena This one:

# github.com/libp2p/go-libp2p/p2p/protocol/identify
../../go/pkg/mod/github.com/libp2p/go-libp2p@v0.29.2/p2p/protocol/identify/id.go:559:25: type func(a multiaddr.Multiaddr, b multiaddr.Multiaddr) bool of func(a, b ma.Multiaddr) bool {…} does not match inferred type func(a multiaddr.Multiaddr, b multiaddr.Multiaddr) int for func(a E, b E) int
../../go/pkg/mod/github.com/libp2p/go-libp2p@v0.29.2/p2p/protocol/identify/obsaddr.go:217:22: type func(first *observedAddr, second *observedAddr) bool of func(first, second *observedAddr) bool {…} does not match inferred type func(a *observedAddr, b *observedAddr) int for func(a E, b E) int

There is a pull request to fix this but it hasn't been merged.

balena commented 1 year ago

Interesting @mooijtech but from the error message I can't infer the problem comes from this project but from go-libp2p

mooijtech commented 1 year ago

Correct this issue is from go-libp2p.