Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation problems with Go v1.20 and 1.21 #3

Closed
aabbtree77 opened this issue Aug 10, 2023 · 8 comments
Closed

Compilation problems with Go v1.20 and 1.21 #3

aabbtree77 opened this issue Aug 10, 2023 · 8 comments

Comments

@aabbtree77
Copy link
Contributor

  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 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.

  1. One can find examples where go-libp2p works with go-quic and Go v1.20. 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.

  2. The code compiles with Go v19.12.

@balena
Copy link
Owner

balena commented Aug 10, 2023

@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
Copy link
Contributor Author

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
Copy link
Owner

balena commented Aug 11, 2023

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
Copy link

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

@balena
Copy link
Owner

balena commented Aug 12, 2023

Which error you're referring to @mooijtech?

@mooijtech
Copy link

@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
Copy link
Owner

balena commented Aug 12, 2023

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

@mooijtech
Copy link

Correct this issue is from go-libp2p.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants