Coder Social home page Coder Social logo

discord_bouncer's Introduction

Discord Bouncer

An example of how to use this can be found in test/index.js

Interface select

The first message the bouncer sends is a SELECT, which looks something like

{
  "cmd": "SELECT",
  "evt": null,
  "args": {},
  "nonce": null
}

You should send a SELECT back, looking something like

{
  "cmd": "SELECT",
  "evt": null,
  "args": {
    "interface": "mock"
  },
  "nonce": "61487326491873246"
}

In response you will get the READY DISPATCH from the mock or rpc interface

{
  "cmd": "DISPATCH",
  "data": {
    "v": 1,
    "config": {
      "cdn_host": "cdn.discordapp.com",
      "api_endpoint": "https://discordapp.com",
      "environment": "production"
    }
  },
  "evt": "READY",
  "nonce": null,
  "interface": "mock"
}

At this point, the stdin/stdout behaves exactly like a regular RPC connection. However, if you are using mock, you can send your own DISPATCH packets to do things like ban users:

{
  "cmd": "DISPATCH",
  "evt": "MEMBER_BAN_ADD",
  "nonce": "641872364918273",
  "args": {
    "guild_id": "188767514824671233",
    "member_id": "157982098022596609",
    "reason": "testing more"
  }
}

Unix Domain Sockets (UDS)

UDS will be used in two situations:

  1. Sending voice/video data
  2. Sending messages that are larger than the system IPC buffer

Case 2:

If the server attempts to respond with a payload that is larger than the system IPC buffer, it will issue a UNIX_DOMAIN_SOCKET_UPGRADE, which looks a bit like:

{
  "cmd": "UNIX_DOMAIN_SOCKET_UPGRADE",
  "evt": "CREATE",
  "data": {
    "file": "/Users/Gus/Desktop/projects/discord_bouncer/331970512651681792.sock"
  },
  "nonce":"331967930134822915"
}

As soon as you connect to the UDS, it will send the raw payload, and then immediately close, and then the main process will issue another UNIX_DOMAIN_SOCKET_UPGRADE, looking like this:

{
  "cmd": "UNIX_DOMAIN_SOCKET_UPGRADE",
  "evt": "DELETE",
  "data": {
    "success": true
  },
  "nonce": "331967930134822915"
}

data.success represents if the server thinks the data was successfully sent. the UDS will stay open for exactly 10 seconds, or until it delivers the payload, and then the data it has will be lost forever.

discord_bouncer's People

Contributors

devsnek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

sleepyynet nomsi

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.