gon2n
gon2n copied to clipboard
How to static compile edged & supernoded? any doc?
I compile edgectl & supernodectl successful, but when I compile edged & supernoded, prompt failed and miss n2n related files. then I search for n2n source code, and no idea about that, hope get sone help.
Hi! Thanks for your issue. To compile gon2n
, the headers for n2n
need to be present. I implemented a go:generate
line for it (see https://github.com/pojntfx/gon2n/blob/master/pkg/workers/supernode.go#L3); by running go generate ./...
and subsequently using go build
etc. the build should continue normally. Concerning the docs, a note to self, I'll add them - sorry for the inconvenience ;)
follow your lead and try again, but I failed, emm, very confused, Not very good at golang. output below: kali@kali:~/go/src/github.com/pojntfx/gon2n/cmd/edged$ env CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags "-s -w" -o edged_x86.exe package github.com/pojntfx/gon2n/cmd/edged imports github.com/pojntfx/gon2n/pkg/workers: build constraints exclude all Go files in /home/kali/go/src/github.com/pojntfx/gon2n/pkg/workers
kali@kali:~/go/src/github.com/pojntfx/gon2n/cmd/supernoded$ env CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags "-s -w" -o supernoded_x86.exe package github.com/pojntfx/gon2n/cmd/supernoded imports github.com/pojntfx/gon2n/pkg/workers: build constraints exclude all Go files in /home/kali/go/src/github.com/pojntfx/gon2n/pkg/workers
The build constraints error happens due to CGo; it is not possible to cross-compile CGo (n2n is written is C, so CGo is required). I do not test on Windows, but if you need to use that platform, I’d recommend either building on it directly using MinGW64 or using https://github.com/karalabe/xgo. If you want to I could also set up a Windows build workflow here in GitHub actions so you could just download the Windows binaries; right now, only macOS and Linux are supported.
thanks. and I just release a asciinema cast about gon2n running on android: https://asciinema.org/a/365251 but it works lol
I packaged gon2n into a standard debian package https://github.com/Droid-MAX/gon2n/releases
That's awesome! I just noticed right now.
Can We write a full manual document about static compiling GON2N?
The key is that the Go Generate part component also needs static compilation.
I try to compile gon2n on my zeropi board with armbian system but I got this error.
@pojntfx Can you tell me the specific details of statically compiling gon2n?
@Droid-MAX Sorry for not responding earlier, I've been busy with uni and work. I'll take a look at it later. Note that gon2n has to use CGo, so cross-compilation is harder.
Note that static cross-compilation will probably not be possible. I'll be providing a workaround based on staticx
though which will allow you to make the binaries "static" (by including & extracting the LD
s). A preview: https://github.com/pojntfx/gon2n/tree/modernize-build-system (this should also make packaging for you much easier, as its a much more "standard" build system)
Good news! Working on a custom gccgo
cross-compiler, which now has reached a usable state and can compile gon2n
:
Note that all of this is Linux-only and will stay Linux-only though; I've checked n2n
upstream too and as I've expected cross-compilation to Windows is also broken there. The clients and "esoteric" Linux platforms should work just fine though.
I'll be adding CI/CD to the cross-compiler etc. tomorrow.
@Droid-MAX While I'm still working on a new release, you can already grab some static binaries for testing here: https://github.com/pojntfx/gon2n/releases/tag/unstable
@Droid-MAX The release (v0.2.0) is out :) You can now just download the static binaries as described in the README or compile them from source; for instructions, check out https://github.com/pojntfx/gon2n#contributing, https://github.com/pojntfx/gon2n/blob/main/.github/workflows/hydrun.yaml and https://github.com/pojntfx/gon2n/blob/main/Hydrunfile.
@pojntfx Can you use the strip command to reduce the file size?
When using a 0.1.0 version I found that the specified encryption method will have an error when it is no encryption.
The SuperNode parameter cannot use the domain name, and can only use the IP address, otherwise it will be wrong.