metalbear-co / mirrord

Connect your local process and your cloud environment, and run local code in cloud conditions.
https://mirrord.dev
MIT License
3.81k stars 104 forks source link

Translate dns errors between macOS and Linux #1481

Open aviramha opened 1 year ago

aviramha commented 1 year ago

The definition of EAI_* errors is different between Linux and macOS, leading to the following error happening when resolving fails:

Assertion failed: (!"unknown EAI_* error code"), function uv__getaddrinfo_translate_error, file ../deps/uv/src/unix/getaddrinfo.c, line 90.

This is Linux:

pub const EAI_BADFLAGS: ::c_int = -1;
pub const EAI_NONAME: ::c_int = -2;
pub const EAI_AGAIN: ::c_int = -3;
pub const EAI_FAIL: ::c_int = -4;
pub const EAI_NODATA: ::c_int = -5;
pub const EAI_FAMILY: ::c_int = -6;
pub const EAI_SOCKTYPE: ::c_int = -7;
pub const EAI_SERVICE: ::c_int = -8;
pub const EAI_MEMORY: ::c_int = -10;
pub const EAI_SYSTEM: ::c_int = -11;
pub const EAI_OVERFLOW: ::c_int = -12;

macOS:

pub const EAI_AGAIN: ::c_int = 2;
pub const EAI_BADFLAGS: ::c_int = 3;
pub const EAI_FAIL: ::c_int = 4;
pub const EAI_FAMILY: ::c_int = 5;
pub const EAI_MEMORY: ::c_int = 6;
pub const EAI_NODATA: ::c_int = 7;
pub const EAI_NONAME: ::c_int = 8;
pub const EAI_SERVICE: ::c_int = 9;
pub const EAI_SOCKTYPE: ::c_int = 10;
pub const EAI_SYSTEM: ::c_int = 11;
pub const EAI_OVERFLOW: ::c_int = 14;

I suggest to have an enum that maps the errors to our internal type, which can be converted from/to Linux and to macOS (so agent converts the Linux error, sends it over the wire, then layer converts it to Linux/macOS based on need)

infiniteregrets commented 1 year ago

1489 has a temporary fix, which will be extended when the protocol is improvised

aviramha commented 1 year ago

1489 has a temporary fix, which will be extended when the protocol is improvised

we should add an integration test already.

infiniteregrets commented 1 year ago

we should add an integration test already.

will do