Skip to content

Add macOS support (Steam auth + OpenSSL/TLS)#2

Open
ChronoFinale wants to merge 1 commit into
Balatro-Multiplayer:mainfrom
ChronoFinale:macos-support
Open

Add macOS support (Steam auth + OpenSSL/TLS)#2
ChronoFinale wants to merge 1 commit into
Balatro-Multiplayer:mainfrom
ChronoFinale:macos-support

Conversation

@ChronoFinale

Copy link
Copy Markdown

Adds macOS support for the two FFI-based features. Windows/Linux behavior is unchanged.

Steam auth tickets

steam.lua resolved Steam's flat API only via Win32 GetModuleHandleA/GetProcAddress. This adds a dlopen/dlsym path for macOS/Linux (the Win32 path is kept under ffi.os == 'Windows'). It resolves symbols from the game's already-loaded Steam library (libsteam_api.dylib), which is universal, so this is arch-agnostic.

OpenSSL / TLS

openssl_ffi.lua is now platform-aware. On macOS a bare-name load (libssl.dylib) resolves to Apple's deprecated /usr/lib LibreSSL and aborts the process ("loading libcrypto in an unsafe way", Abort trap: 6). So on macOS we load bundled OpenSSL 3 dylibs by absolute path.

Because OpenSSL is loaded inside the MQTT worker thread — a separate Lua state with no MPAPI and a different CWD — the mod's networking/ directory is recovered from package.path (which core.lua already populates and which is forwarded to the worker), rather than from a global. The two load loops were also deduplicated into a single helper.

Native libraries (not committed)

libssl.3.dylib + libcrypto.3.dylib are not in this PR. They should ship as a release asset (or via Git LFS) placed in networking/:

  • universal (x86_64 + arm64) — Intel + Apple Silicon
  • OpenSSL 3.6.2, built from Homebrew bottles with minos 14.0 (loads on macOS 14 / 15 / 26)
  • relinked with @loader_path (no Homebrew dependency) and ad-hoc signed (matching liblovely.dylib / luasteam.so, which are also ad-hoc)

Testing

Verified on an M2 (arm64) MacBook, macOS 26: joined a lobby, played a full match, and Steam login worked. The x86_64 slice is built from the official Homebrew Intel bottle but has not been runtime-tested (no Intel hardware available).

- steam.lua: resolve the Steam flat API via dlopen/dlsym on macOS/Linux
  (Win32 GetModuleHandleA/GetProcAddress kept under ffi.os == 'Windows')
- openssl_ffi.lua: platform-aware library loading; on macOS load the
  bundled OpenSSL 3 .dylib by absolute path (a bare name would hit Apple's
  /usr/lib LibreSSL and abort the process). The mod's networking/ dir is
  read from package.path, so it works in the MQTT worker thread too.
@ChronoFinale

Copy link
Copy Markdown
Author

macOS native libraries (kept out of the tree to avoid committing ~12 MB of binaries):

Unzip the attached archive and drop libssl.3.dylib + libcrypto.3.dylib into networking/ (next to openssl_ffi.lua). The loader derives that directory from package.path, so that's where it looks.

Details:

  • Universal (x86_64 + arm64) — Intel + Apple Silicon
  • OpenSSL 3.6.2, minos 14.0 → loads on macOS 14 / 15 / 26
  • @loader_path-linked (no Homebrew dependency) and ad-hoc signed (same posture as liblovely.dylib / luasteam.so)

(zip attached below)

@ChronoFinale

Copy link
Copy Markdown
Author

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