le-injectore
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

Local Escape Injector

A webserver handler for porting your local servers.

Completely free, client-to-client request handler.

How does that work you ask? Like this.

// CONTROL-SIDE. THIS IS THE PART THAT SENDS THE REQUESTS TO THE SERVER.

import injectore from "le-injectore";

const controller_id = 123456789; // Can be any number. Choose wisely, make it unique.
const client_id = 987654321; // client id. Must be the same as the client connecting to the server for the client to be redirected to the correct stream.

injectore.Control.CreateStream({
    auth_at: controller_id, // The controller. This ID allows the controller to manage the stream.
    remote_at: client_id, // The client. This ID is the ID of the client that is searching for a strema, as defined above.
    remote: {
        PORT: 5555, // Port of the server in the client. This value is parsed when a request is recieved, allowing the client to check this port in its computer.
        INTENTS: ["*"] // intents are parsed to the client when a request is recieved. This does not determine if a command goes through, but the client can access these values and can reject if it wishes to.
    },
    authkey: 'helloworld' // key of the stream.
}).then(response => {
    // The stream was successfully created.
    console.log(response.id); // ID of the stream. 
    injectore.Control.SendCommand(response.id, 'helloworld', 'anything here. can be a json object, number, null, undefined, you name it.').then(response => {
        // Response recieved. A response must be sent by the client within 20 seconds. Otherwise the Control will be errored and the stream will be deleted after 60 seconds due to inactivity.
        console.log(response); // response will be the object that was sent by the client. 
    });
}).catch((error) => {
    // An error occured. 
    console.error(error);
});
// CLIENT-SIDE. THIS IS THE PART WHERE  HAS THE WEBSERVER IS SET UP.

import injectore from 'le-injectore';

injectore.Client.SearchStream(987654321).then(async streamdata => {
    console.log(streamdata.id); // stream id. Successful find.
    const connection = await injectore.Client.EstablishConnection(987654321, streamdata.id); // connect to the stream.
    console.log(connection.stream); // stream info. remote, remote id, authkey, auth id and all other info is in this object.
    
    // LISTENERS
    connection.onCommand(async function handlecommand(cmd) {
        let stream = cmd.stream;
        let command = cmd.command; // this object is the object that is sent by the Control. Has type "any", but can be changed in TypeScript with: let command = injectore.ParseCommand<TYPE_HERE>(cmd);
    
    });
}).catch(error => {
    // error occured.
    console.error(error);
}); // set up for searching. THIS MUST BE EXECUTED BEFORE THE CONTROL CREATES THE SERVER!
do not question the last 'e' character in the name 'le-injectore', you will live to regret it.

Readme

Keywords

none

Package Sidebar

Install

npm i le-injectore

Weekly Downloads

2

Version

1.1.1

License

ISC

Unpacked Size

19.6 kB

Total Files

12

Last publish

Collaborators

  • cyberdevs