fix: receive error by switching to local croc build#217
Conversation
There was a problem hiding this comment.
Pull request overview
This PR resolves a runtime incompatibility between the upstream croc package and a locally customized croc implementation by switching the receive command to use local types and constructors instead of the upstream package.
Key Changes:
- Removed import of upstream
github.com/schollz/croc/v9/src/crocpackage - Updated
Optionsstruct initialization andNew()constructor to use local implementations - Added missing option fields (
DisableLocal,HashAlgorithm,RelayPorts) required by the local build
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| crocOptions := Options{ | ||
| Curve: "p256", | ||
| Debug: false, | ||
| DisableLocal: true, | ||
| HashAlgorithm: "xxhash", | ||
| IsSender: false, | ||
| NoPrompt: true, | ||
| Overwrite: true, | ||
| RelayAddress: relay.Address, | ||
| RelayPassword: relay.Password, | ||
| RelayPorts: strings.Split(relay.Ports, ","), | ||
| SharedSecret: sharedSecretCode, | ||
| } |
There was a problem hiding this comment.
The hardcoded values for Curve, Debug, DisableLocal, HashAlgorithm, NoPrompt, and Overwrite are magic values that should be defined as constants or configuration settings. This would improve maintainability and make it easier to adjust these values consistently across the codebase.
| } | ||
|
|
||
| cr, err := croc.New(crocOptions) | ||
| cr, err := New(crocOptions) |
There was a problem hiding this comment.
The New() function is called without a package qualifier, but no import statement shows where this function is defined. If New() is defined in the same package, this is correct. However, if it's intended to be from a local croc package that should be imported, this will cause a compilation error.
| relay := relays[relayIndex] | ||
|
|
||
| crocOptions := croc.Options{ | ||
| crocOptions := Options{ |
There was a problem hiding this comment.
The Options type is referenced without a package qualifier, but the upstream import github.com/schollz/croc/v9/src/croc has been removed. If Options is not defined in the current package or properly imported from a local package, this will result in a compilation error.
Fix receive error by switching to local croc build
This change fixes a receive-side error caused by a mismatch between our customized croc implementation and the upstream croc library. The official
crocpackage and our local build no longer share the same options and constructor signatures, which leads to runtime failures when callingcroc.New()and when initializing option fields. By switching to our localOptionstype and localNew()constructor, the receive command now uses the correct build and avoids the incompatibility that caused the error.How I tested it
Test it locally.