Skip to content

ruilisi/lingti-sdk-electron-example

Repository files navigation

Lingti SDK - Electron Example App

This is an example Electron application demonstrating how to use the Lingti SDK Node.js native addon.

Features

  • ✅ Simple, modern UI
  • ✅ Start/Stop Lingti SDK tunnel
  • ✅ Real-time traffic statistics
  • ✅ Ping monitoring
  • ✅ Token persistence (localStorage)
  • ✅ Status indicator
  • ✅ Error handling

Prerequisites

  • Windows OS (required for the native addon)
  • Node.js 16+ and npm/yarn
  • Built Lingti SDK native addon - IMPORTANT: Run yarn in the parent directory first:
    cd ..
    yarn
    cd example

Installation

# Install dependencies
npm install
# or
yarn

Usage

Start the app

npm start
# or
yarn start

Development mode (with DevTools)

npm run dev
# or
yarn dev

How to Use

  1. Enter Encrypted Token: Input your encrypted token in the text field
  2. Start SDK: Click the "Start SDK" button to initialize the tunnel
  3. Monitor Status: Watch the status indicator and statistics
  4. Stop SDK: Click the "Stop SDK" button to terminate the tunnel

Configuration

The app uses the following default configuration when starting the SDK:

{
  Mode: "tun_switch",
  Server: "server.lingti.com:443",
  Token: "<your-encrypted-token>",
  LogLevel: "info",
  GameExes: [],
  GameID: "EXAMPLE_GAME"
}

You can modify these settings in main.js (search for the sdk:start handler).

API Reference

The app exposes the following APIs to the renderer process via contextBridge:

  • window.lingtiApi.startSdk(encryptedToken) - Start the SDK with encrypted token
  • window.lingtiApi.stopSdk() - Stop the SDK
  • window.lingtiApi.isRunning() - Check if SDK is running
  • window.lingtiApi.getVersion() - Get SDK version
  • window.lingtiApi.getStats() - Get traffic and ping statistics
  • window.lingtiApi.checkAddon() - Check if native addon is available

Statistics

When the SDK is running, the app displays:

  • TX/RX Bytes: Total transmitted and received bytes
  • Router Ping: Latency to router (ms)
  • Landing Ping: Latency to landing server (ms)

Statistics are updated every 2 seconds.

Error Handling

The app handles various error scenarios:

  • Missing or invalid token
  • SDK already running
  • SDK not running when trying to stop
  • Platform incompatibility (non-Windows)
  • Native addon not available

Errors are displayed in a user-friendly message box.

Security Notes

  • The app uses Electron's contextIsolation and preload script for security
  • Direct Node.js integration is disabled in the renderer process
  • Only specific SDK APIs are exposed to the renderer via IPC

Troubleshooting

Native addon not found

If you see "Native addon not available":

  1. Make sure you're running on Windows
  2. Build the native addon first:
    cd ..
    yarn

SDK fails to start

  • Verify your encrypted token is correct
  • Check that no other instance is running
  • Look at error messages for specific error codes

Project Structure

example/
├── package.json        # Project metadata and dependencies
├── main.js            # Electron main process (SDK integration)
├── preload.js         # Preload script (IPC bridge)
├── index.html         # Application UI
├── renderer.js        # Renderer process logic
└── README.md          # This file

License

UNLICENSED

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published