mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 19:28:17 +00:00
bug fixes for proxy ws
This commit is contained in:
+13
-9
@@ -10,7 +10,7 @@ import { baseEndpoints, GATEWAY_VERSION } from "./util/constants.ts";
|
|||||||
import { spawnShards } from "./ws/shard_manager.ts";
|
import { spawnShards } from "./ws/shard_manager.ts";
|
||||||
|
|
||||||
export let authorization = "";
|
export let authorization = "";
|
||||||
export let restAuthorization = "";
|
export let secretKey = "";
|
||||||
export let botID = "";
|
export let botID = "";
|
||||||
export let applicationID = "";
|
export let applicationID = "";
|
||||||
|
|
||||||
@@ -95,10 +95,9 @@ export async function startBigBrainBot(data: BigBrainBotConfig) {
|
|||||||
authorization = `Bot ${data.token}`;
|
authorization = `Bot ${data.token}`;
|
||||||
identifyPayload.token = `Bot ${data.token}`;
|
identifyPayload.token = `Bot ${data.token}`;
|
||||||
|
|
||||||
if (data.restAuthorization) restAuthorization = data.restAuthorization;
|
if (data.secretKey) secretKey = data.secretKey;
|
||||||
if (data.restURL) baseEndpoints.BASE_URL = data.restURL;
|
if (data.restURL) baseEndpoints.BASE_URL = data.restURL;
|
||||||
if (data.cdnURL) baseEndpoints.CDN_URL = data.cdnURL;
|
if (data.cdnURL) baseEndpoints.CDN_URL = data.cdnURL;
|
||||||
if (data.wsURL) proxyWSURL = data.wsURL;
|
|
||||||
if (data.eventHandlers) eventHandlers = data.eventHandlers;
|
if (data.eventHandlers) eventHandlers = data.eventHandlers;
|
||||||
if (data.compress) {
|
if (data.compress) {
|
||||||
identifyPayload.compress = data.compress;
|
identifyPayload.compress = data.compress;
|
||||||
@@ -109,10 +108,14 @@ export async function startBigBrainBot(data: BigBrainBotConfig) {
|
|||||||
0,
|
0,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// PROXY DOESNT NEED US SPAWNING SHARDS
|
||||||
|
if (data.wsPort) {
|
||||||
|
// Need HTTP Server to listen to proxy
|
||||||
|
console.log("TODO: make http");
|
||||||
|
} else {
|
||||||
// Initial API connection to get info about bots connection
|
// Initial API connection to get info about bots connection
|
||||||
botGatewayData = await getGatewayBot();
|
botGatewayData = await getGatewayBot();
|
||||||
|
proxyWSURL = botGatewayData.url;
|
||||||
if (!data.wsURL) proxyWSURL = botGatewayData.url;
|
|
||||||
await spawnShards(
|
await spawnShards(
|
||||||
botGatewayData,
|
botGatewayData,
|
||||||
identifyPayload,
|
identifyPayload,
|
||||||
@@ -122,6 +125,7 @@ export async function startBigBrainBot(data: BigBrainBotConfig) {
|
|||||||
? (data.firstShardID + 25)
|
? (data.firstShardID + 25)
|
||||||
: botGatewayData.shards),
|
: botGatewayData.shards),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BigBrainBotConfig extends BotConfig {
|
export interface BigBrainBotConfig extends BotConfig {
|
||||||
@@ -129,12 +133,12 @@ export interface BigBrainBotConfig extends BotConfig {
|
|||||||
firstShardID: number;
|
firstShardID: number;
|
||||||
/** The last shard to start for this worker. By default it will be 25 + the firstShardID. */
|
/** The last shard to start for this worker. By default it will be 25 + the firstShardID. */
|
||||||
lastShardID?: number;
|
lastShardID?: number;
|
||||||
/** This can be used to forward the ws handling to a proxy. */
|
/** This can be used to forward the ws handling to a proxy. It will disable the sharding done by the bot side. */
|
||||||
wsURL?: string;
|
wsPort?: number;
|
||||||
/** This can be used to forward the REST handling to a proxy. */
|
/** This can be used to forward the REST handling to a proxy. */
|
||||||
restURL?: string;
|
restURL?: string;
|
||||||
/** This can be used to forward the CDN handling to a proxy. */
|
/** This can be used to forward the CDN handling to a proxy. */
|
||||||
cdnURL?: string;
|
cdnURL?: string;
|
||||||
/** This is the authorization header that your rest proxy will validate */
|
/** This is the authorization header that your servers will send. Helpful to prevent DDOS attacks and such. */
|
||||||
restAuthorization?: string;
|
secretKey?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user