Skip to content

feat: added TCP healthcheck with nc, better clipboard support, fixed docker deployments and minor changes#971

Merged
schollz merged 1 commit intomainfrom
unknown repository
Sep 29, 2025
Merged

feat: added TCP healthcheck with nc, better clipboard support, fixed docker deployments and minor changes#971
schollz merged 1 commit intomainfrom
unknown repository

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Sep 28, 2025

Hey, I love croc and I've been reading through the codebase today!

This PR should solve #967, provides a possible solution to #968 and allows wider and better clipboard support without additional dependencies. @schollz

The previous implementation worked fine but only covered Windows, macOS, and Linux (running Xorg with xclip or Wayland with wl-copy). Now the clipboard will work as expected on less popular systems such as the BSDs and Solaris, also falling back to xsel if xclip is unavailable!

I manually ran golangci-lint on the codebase and improved things here and there.
Please review my other changes, these are minor and include some formatting improvements.

Using gsa(go size analyzer) on this I get an 11MB executable from:

CGO_ENABLED=0 go build -ldflags '-s -w -extldflags "-static"' -o croc

which might be a bit bloated. The whole codebase is pretty big.

┌─────────────────────────────────────────────────────────────────────────────┐
│ croc                                                                        │
├─────────┬──────────────────────────────────────────────┬────────┬───────────┤
│ PERCENT │ NAME                                         │ SIZE   │ TYPE      │
├─────────┼──────────────────────────────────────────────┼────────┼───────────┤
│ 18.27%  │ .rodata                                      │ 2.0 MB │ section   │
│ 15.33%  │ crypto                                       │ 1.6 MB │ std       │
│ 13.40%  │ net                                          │ 1.4 MB │ std       │
│ 8.27%   │ runtime                                      │ 886 kB │ std       │
│ 4.07%   │ .noptrdata                                   │ 436 kB │ section   │
│ 2.74%   │ reflect                                      │ 293 kB │ std       │
│ 2.30%   │ text/template                                │ 247 kB │ std       │
│ 2.25%   │ golang.org/x/net                             │ 241 kB │ vendor    │
│ 2.19%   │ github.com/schollz/croc/v10                  │ 235 kB │ main      │
│ 1.79%   │ math                                         │ 191 kB │ std       │
│ 1.69%   │ github.com/chzyer/readline                   │ 182 kB │ vendor    │
│ 1.64%   │ regexp                                       │ 176 kB │ std       │
│ 1.47%   │ slices                                       │ 158 kB │ std       │
│ 1.42%   │ time                                         │ 152 kB │ std       │
│ 1.38%   │ encoding/json                                │ 148 kB │ std       │
│ 1.34%   │ github.com/schollz/cli/v2                    │ 143 kB │ vendor    │
| ....... | ............................................ | ...... | ......... |
│ 0.00%   │ .text                                        │ 16 B   │ section   │
├─────────┼──────────────────────────────────────────────┼────────┴───────────┤
│ 100.00% │ Known                                        │ 11 MB              │
│ 100%    │ Total                                        │ 11 MB              │
└─────────┴──────────────────────────────────────────────┴────────────────────┘

Here are some additional notes and observations.

The README is telling Alpine Linux users to install both bash and GNU coreutils to run this natively which is a big ask IMO. Maybe rewrite the installer in POSIX sh so Busybox ash can run it.
That said, using the Docker image works great both as a client and relay!

The installer checks $EUID and then tries to use sudo if that's not 0. This won't work for anyone using doas over sudo or something else. Might be worth to tell doas users to install doas-sudo-shim!

There are other tools with similar to croc, such as wormhole-william that's also made in Go.

Why -git over the expected standard --git and use a personal fork of urfave/cli instead of the upstream v3?

While there aren't many environment variables used, you could use godotenv and a -e/--environment flag to point to a specific .env type file.

A flag to specify the number of processors to use could be beneficial for performance tuning.

There's more!
#943 (on goroutines) may be worth investigating.
#946 is a significant bug that should be addressed.

The codebase generally lacks comments and has a deeply nested structure(e.g., making changes requires updates in multiple places).

This was my attempt at contributing to croc.
I have a long way ahead in programming and hope I've been useful.
Thank you for the work you all put in!

@ghost
Copy link
Copy Markdown
Author

ghost commented Sep 28, 2025

(I am gonna lose it)

@ghost
Copy link
Copy Markdown
Author

ghost commented Sep 28, 2025

(fixed it)

@schollz
Copy link
Copy Markdown
Owner

schollz commented Sep 29, 2025

AWESOME looks good!!!

@schollz schollz merged commit 4be7618 into schollz:main Sep 29, 2025
1 check passed
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

Successfully merging this pull request may close these issues.

1 participant