Giter Club home page Giter Club logo

lan-play's Introduction

switch-lan-play

Build status Chat on discord

English | δΈ­ζ–‡

Make you and your friends play games like in a LAN.

                     Internet
                        |
                  [SOCKS5 Proxy] (optional)
                        |
        ARP,IPv4        |          LAN Packets
Switch <-------->  PC(lan-play)  <-------------> Server
                                       UDP

NOTE:

  • This project is in an early stage. The protocol may change frequently.

Usage

To play with your friends, you and your friends should run lan-play client connecting to the same Server on your PC, and set static IP on your Switch.

Your PC and Switch must be connected to the same router.

Visit https://www.lan-play.com/ for steps on how to set this up. See below for build instructions.

SOCKS5 Proxy

lan-play --socks5-server-addr example.com:1080

Data sent to the relay server does not pass through the proxy.

Build

Debug or Release

cmake -DCMAKE_BUILD_TYPE=Debug .. cmake -DCMAKE_BUILD_TYPE=Release ..

Ubuntu / Debian

This project depends on libpcap, you can install libpcap0.8-dev on Ubuntu or Debian:

sudo apt install libpcap0.8-dev git gcc g++ cmake

Prepare a cmake, gcc, and run like this:

mkdir build
cd build
cmake ..
make

Windows

Use MSYS2 to compile.

pacman -Sy
pacman -S make \
    mingw-w64-x86_64-cmake \
    mingw-w64-x86_64-gcc

To compile 32bit program:

pacman -S mingw-w64-i686-cmake \
    mingw-w64-i686-gcc

Open MSYS2 MinGW 64-bit or MSYS2 MinGW 32-bit.

mkdir build
cd build
cmake -G "MSYS Makefiles" ..
make

Mac OS

brew install cmake
mkdir build
cd build
cmake ..
make

Server

Docker

docker run -d -p 11451:11451/udp -p 11451:11451/tcp spacemeowx2/switch-lan-play

Node

git clone https://github.com/spacemeowx2/switch-lan-play
cd switch-lan-play/server
npm install
npm run build # build ts to js. run it again when code changed.
npm start

Use --port pass the port parameter, or else it will use 11451/udp as default.

Use --simpleAuth pass the auth via username and password, or else there's no authentication.

Use --httpAuth pass the auth via http url, or else there's no authentication.

Use --jsonAuth pass the auth via json file, or else there's no authentication.

Example:

npm run build
npm start -- --port 10086 --simpleAuth username:password

Meanwhile the monitor service will be started on port 11451/tcp by default, you can get online client count via HTTP request:

Request: GET http://{YOUR_SERVER_IP}:11451/info

Response: { "online": 42 }

Protocol

The protocol is very simple now, but I'm going to add some fileds to calculate network quality(packet loss, ping), like timestamp, seq_id, etc.

struct packet {
    uint8_t type;
    uint8_t payload[packet_len - 1];
};
enum type {
    KEEPALIVE = 0,
    IPV4 = 1,
    PING = 2,
    IPV4_FRAG = 3
};

The server can read IP addresses from payload and save source IP -> LAN IP to a cache table. If target ip address shown in payload doesn't hit the cache, broadcast this packet to the entire room(now a server is a room).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.