wrapper-lite

repository·lite·Indexed 43 days ago

https://github.com/worldobservationlog/wrapper

A lightweight HTTP wrapper for Apple Music decryption providing a single-port API for M3U8, keys, lyrics, licenses, and web playback. It supports native execution, Docker containerization, and a recommended QEMU guest environment via the wrapper-lite-qemu launcher.

Tokens
2.7K
Snippets
9
Records
14
Agent score
56%

What's inside wrapper-lite

  1. How device-info works

    lite

    The lite binary identifies itself to Apple's servers using a device-info string formatted as:

    ClientIdentifier/VersionIdentifier/PlatformIdentifier/ProductVersion/DeviceModel/BuildVersion/LocaleIdentifier/LanguageIdentifier/AndroidID

    AndroidID Generation

    The AndroidID is handled automatically:

    • During --login: It is the FNV-1a 64-bit hash of the account username and is saved to <base-dir>/ANDROID_ID. This ensures a stable identity for the account.
    • In service mode: The persisted ANDROID_ID is reused. If no ID exists, a default is used.

    You can override the entire string using the --device-info <string> argument.

  2. Run wrapper-lite natively

    lite

    You can run the host launchers directly. This typically requires a two-step process: first logging in to cache tokens, then starting the HTTP service.

    1. Login and cache tokens

    Use --login with credentials. If using --code-from-file, the 2FA code should be placed in data/2fa.txt (or the path specified by --base-dir).

    ./wrapper-lite-rootless --login user:pass --code-from-file --base-dir /data

    2. Start the HTTP service

    Once logged in, start the service by specifying the host and port.

    ./wrapper-lite-rootless --base-dir /data --host 0.0.0.0 --port 12340
    # Login, cache tokens, then exit
    ./wrapper-lite-rootless --login user:pass --code-from-file --base-dir /data
    
    # Start the HTTP service
    ./wrapper-lite-rootless --base-dir /data --host 0.0.0.0 --port 12340
  3. Build QEMU assets and launcher

    lite

    To use wrapper-lite-qemu, you must first build the QEMU assets (vmlinuz, initramfs, etc.) and then compile the launcher binary.

    1. Build assets: Requires busybox-static to be downloaded via apt-get.
    2. Build launcher: Compile the wrapper-lite-qemu.cpp source using a C++11 compatible compiler.
    # Build QEMU assets
    apt-get download busybox-static
    ./qemu/build.sh
    
    # Build launcher
    c++ -std=c++11 -O2 -o wrapper-lite-qemu wrapper-lite-qemu.cpp
  4. Run wrapper-lite with QEMU (Recommended)

    lite

    The wrapper-lite-qemu launcher is the recommended method. It boots a self-contained QEMU guest and forwards the HTTP API to the host, eliminating the need for a rooted device or native chroot.

    1. Build the launcher

    c++ -std=c++11 -O2 -o wrapper-lite-qemu wrapper-lite-qemu.cpp

    2. Login and Serve

    First, run the login command to forward the --login flag to the guest. Then, run the launcher without arguments to start the service.

    ./wrapper-lite-qemu --login user:pass --code-from-file
    ./wrapper-lite-qemu

    QEMU Binary Discovery

    The launcher looks for the QEMU binary in this order:

    1. The path provided via --qemu-bin <path> or the QEMU_BIN environment variable.
    2. The system PATH.
    3. The bundled qemu/bin/ directory.
    # one-time: build the launcher
    c++ -std=c++11 -O2 -o wrapper-lite-qemu wrapper-lite-qemu.cpp
    
    # login first
    ./wrapper-lite-qemu --login user:pass --code-from-file
    
    # then serve
    ./wrapper-lite-qemu
  5. Run wrapper-lite-qemu

    lite

    Execute the wrapper-lite-qemu binary to start the guest environment.

    Argument Forwarding: All arguments passed to the launcher are forwarded line-by-line to the wrapper-lite instance running inside the QEMU guest, with the exception of the --accel flag.

    # View help
    ./wrapper-lite-qemu --help
    
    # Login with credentials and specify a base directory
    ./wrapper-lite-qemu --login user:pass --base-dir /data
    
    # Run with default settings
    ./wrapper-lite-qemu
  6. Build wrapper-lite

    lite

    To build the project from source, use CMake. The build produces three main binaries: rootfs/system/bin/lite (the Android-layer binary), wrapper-lite (privileged host launcher), and wrapper-lite-rootless (rootless host launcher using user namespaces).

    Release Build

    Builds with SSL verification enabled by default.

    mkdir -p build && cd build
    cmake .. -DCMAKE_BUILD_TYPE=Release
    make -j$(nproc)

    Debug Build

    Builds with SSL verification disabled by default.

    cmake .. -DCMAKE_BUILD_TYPE=Debug
  7. Configure QEMU acceleration

    lite

    The launcher automatically attempts to use the best available acceleration based on your host OS:

    • Linux: Auto-detects KVM.
    • macOS: Tries HVF, falls back to TCG.
    • Windows: Tries WHPX, falls back to TCG.

    You can force a specific acceleration mode using the --accel flag.

    Note for Windows WHPX users: When using WHPX, the system uses -accel whpx,kernel-irqchip=off and -cpu qemu64-v1 internally.

    ./wrapper-lite-qemu --accel kvm ...
    ./wrapper-lite-qemu --accel hvf ...
    ./wrapper-lite-qemu --accel whpx ...
    ./wrapper-lite-qemu --accel tcg ...
  8. Configure the app service via compose.yaml

    lite

    The app service is defined in compose.yaml and can be configured using the following settings:

    Build Arguments

    • NDK_VERSION: Specifies the Android NDK version used during the build process. Defaults to 23 in the provided configuration.

    Environment Variables

    • USERNAME: The username for the application (passed from the host environment).
    • PASSWORD: The password for the application (passed from the host environment).

    Volumes

    • ./rootfs/data is mounted to /app/rootfs/data inside the container to persist data.

    Ports

    • The service exposes port 12340 on both the host and the container (12340:12340).

    Security

    • The service runs with seccomp:unconfined to allow broader system call access, which may be required for the underlying emulation or native execution.
    services:
      app:
        build:
          context: .
          dockerfile: Dockerfile
          args:
            NDK_VERSION: 23
        volumes:
          - ./rootfs/data:/app/rootfs/data
        ports:
          - "12340:12340"
        environment:
          USERNAME: ${USERNAME}
          PASSWORD: ${PASSWORD}
        security_opt:
          - seccomp:unconfined
  9. Configure wrapper-lite-qemu via environment variables

    lite

    Use the following environment variables to customize the guest environment and host connectivity.

    | Variable | Default | Description |
    |----------|---------|-------------|
    | `HOST_PORT` | `12340` | host port |
    | `GUEST_PORT` | `12340` | guest port |
    | `MEMORY` | `512` | guest memory in MB |
    | `SMP` | `2` | guest CPU count |
    | `LITE_QEMU_ACCEL` | auto | force acceleration |
    | `QEMU_BIN` | auto | QEMU binary path |
  10. Configure QEMU launcher arguments

    lite

    The wrapper-lite-qemu launcher accepts the following arguments to control the guest and host networking. Environment variables can be used as fallbacks.

    ArgumentDefaultDescription
    --host <addr>127.0.0.1host address the forwarded port binds to (0.0.0.0 to expose)
    --host-port <port>12340host port
    --guest-port <port>12340guest port
    --guest-host <addr>0.0.0.0address the guest lite listens on
    --memory <MB>512guest memory in MB
    --smp <N>2guest CPU count
    --accel <accel>autoforce acceleration (kvm, hvf, whpx, tcg)
    --qemu-bin <path>autoQEMU binary path

    Environment Variables:

    • LITE_QEMU_HOST / HOST_PORT / GUEST_PORT / LITE_GUEST_HOST / MEMORY / SMP / LITE_QEMU_ACCEL / QEMU_BIN