Discord.js gateway connection when connecting to voice will close 4002 decode error due to not sending self_video field. temp solution: remove it from server.
this commit will probably be reverted later; I'm just trying to see if a proper ( not self signed ) SSL cert on slowcord.maddy.k.vu will fix this SSL error I'm receiving.
This commit is contained in:
parent
204fe2aed1
commit
d491bcd8be
1172
bundle/package-lock.json
generated
1172
bundle/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -64,6 +64,7 @@
|
|||||||
"@fosscord/gateway": "file:../gateway",
|
"@fosscord/gateway": "file:../gateway",
|
||||||
"@sentry/node": "^6.16.1",
|
"@sentry/node": "^6.16.1",
|
||||||
"@sentry/tracing": "^6.16.1",
|
"@sentry/tracing": "^6.16.1",
|
||||||
|
"@yukikaze-bot/erlpack": "^1.0.1",
|
||||||
"ajv": "8.6.2",
|
"ajv": "8.6.2",
|
||||||
"ajv-formats": "^2.1.1",
|
"ajv-formats": "^2.1.1",
|
||||||
"amqplib": "^0.8.0",
|
"amqplib": "^0.8.0",
|
||||||
|
@ -3,7 +3,7 @@ export const VoiceStateUpdateSchema = {
|
|||||||
$channel_id: String,
|
$channel_id: String,
|
||||||
self_mute: Boolean,
|
self_mute: Boolean,
|
||||||
self_deaf: Boolean,
|
self_deaf: Boolean,
|
||||||
self_video: Boolean,
|
$self_video: Boolean, //required in docs but bots don't always send it
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface VoiceStateUpdateSchema {
|
export interface VoiceStateUpdateSchema {
|
||||||
@ -11,5 +11,5 @@ export interface VoiceStateUpdateSchema {
|
|||||||
channel_id?: string;
|
channel_id?: string;
|
||||||
self_mute: boolean;
|
self_mute: boolean;
|
||||||
self_deaf: boolean;
|
self_deaf: boolean;
|
||||||
self_video: boolean;
|
self_video?: boolean;
|
||||||
}
|
}
|
4
webrtc/.vscode/launch.json
vendored
4
webrtc/.vscode/launch.json
vendored
@ -17,7 +17,9 @@
|
|||||||
],
|
],
|
||||||
"cwd": "${workspaceRoot}",
|
"cwd": "${workspaceRoot}",
|
||||||
"protocol": "inspector",
|
"protocol": "inspector",
|
||||||
"internalConsoleOptions": "openOnSessionStart"
|
"internalConsoleOptions": "openOnSessionStart",
|
||||||
|
"sourceMaps": true,
|
||||||
|
"resolveSourceMapLocations": null,
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
import { Server as WebSocketServer } from "ws";
|
import { Server as WebSocketServer } from "ws";
|
||||||
import { WebSocket, Payload, CLOSECODES } from "@fosscord/gateway";
|
import { WebSocket, CLOSECODES } from "@fosscord/gateway";
|
||||||
import { Config, initDatabase } from "@fosscord/util";
|
import { Config, initDatabase } from "@fosscord/util";
|
||||||
import OPCodeHandlers from "./opcodes";
|
import OPCodeHandlers, { Payload } from "./opcodes";
|
||||||
import { setHeartbeat } from "./util";
|
import { setHeartbeat } from "./util";
|
||||||
import * as mediasoup from "mediasoup";
|
import * as mediasoup from "mediasoup";
|
||||||
import { types as MediasoupTypes } from "mediasoup";
|
import { types as MediasoupTypes } from "mediasoup";
|
||||||
@ -26,8 +26,16 @@ export class Server {
|
|||||||
socket.on("message", async (message: string) => {
|
socket.on("message", async (message: string) => {
|
||||||
const payload: Payload = JSON.parse(message);
|
const payload: Payload = JSON.parse(message);
|
||||||
|
|
||||||
|
console.log(payload);
|
||||||
|
|
||||||
if (OPCodeHandlers[payload.op])
|
if (OPCodeHandlers[payload.op])
|
||||||
await OPCodeHandlers[payload.op].call(this, socket, payload);
|
try {
|
||||||
|
await OPCodeHandlers[payload.op].call(this, socket, payload);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
socket.close(CLOSECODES.Unknown_error);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
console.error(`Unimplemented`, payload);
|
console.error(`Unimplemented`, payload);
|
||||||
socket.close(CLOSECODES.Unknown_opcode);
|
socket.close(CLOSECODES.Unknown_opcode);
|
||||||
|
@ -1,9 +1,38 @@
|
|||||||
import { WebSocket } from "@fosscord/gateway";
|
import { WebSocket, CLOSECODES } from "@fosscord/gateway";
|
||||||
import { Payload } from "./index";
|
import { Payload } from "./index";
|
||||||
import { VoiceOPCodes } from "@fosscord/util";
|
import { VoiceOPCodes, Session, User, Guild } from "@fosscord/util";
|
||||||
import { Server } from "../Server";
|
import { Server } from "../Server";
|
||||||
|
|
||||||
export async function onIdentify(this: Server, socket: WebSocket, data: Payload) {
|
export interface IdentifyPayload extends Payload {
|
||||||
|
d: {
|
||||||
|
server_id: string, //guild id
|
||||||
|
session_id: string, //gateway session
|
||||||
|
streams: Array<{
|
||||||
|
type: string,
|
||||||
|
rid: string, //number
|
||||||
|
quality: number,
|
||||||
|
}>,
|
||||||
|
token: string, //voice_states token
|
||||||
|
user_id: string,
|
||||||
|
video: boolean,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function onIdentify(this: Server, socket: WebSocket, data: IdentifyPayload) {
|
||||||
|
|
||||||
|
const session = await Session.findOneOrFail(
|
||||||
|
{ session_id: data.d.session_id, },
|
||||||
|
{
|
||||||
|
where: { user_id: data.d.user_id },
|
||||||
|
relations: ["user"]
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const user = session.user;
|
||||||
|
const guild = await Guild.findOneOrFail({ id: data.d.server_id });
|
||||||
|
|
||||||
|
if (!guild.members.find(x => x.id === user.id))
|
||||||
|
return socket.close(CLOSECODES.Invalid_intent);
|
||||||
|
|
||||||
var transport = await this.mediasoupRouters[0].createWebRtcTransport({
|
var transport = await this.mediasoupRouters[0].createWebRtcTransport({
|
||||||
listenIps: [{ ip: "0.0.0.0", announcedIp: "127.0.0.1" }],
|
listenIps: [{ ip: "0.0.0.0", announcedIp: "127.0.0.1" }],
|
||||||
enableUdp: true,
|
enableUdp: true,
|
||||||
@ -40,15 +69,17 @@ export async function onIdentify(this: Server, socket: WebSocket, data: Payload)
|
|||||||
socket.send(JSON.stringify({
|
socket.send(JSON.stringify({
|
||||||
op: VoiceOPCodes.READY,
|
op: VoiceOPCodes.READY,
|
||||||
d: {
|
d: {
|
||||||
streams: [],
|
streams: [...data.d.streams.map(x => ({ ...x, rtx_ssrc: 1311886, ssrc: 1311885, active: false, }))],
|
||||||
ssrc: 1,
|
ssrc: 1,
|
||||||
ip: transport.iceCandidates[0].ip,
|
ip: transport.iceCandidates[0].ip,
|
||||||
port: transport.iceCandidates[0].port,
|
port: transport.iceCandidates[0].port,
|
||||||
modes: [
|
modes: [
|
||||||
"aead_aes256_gcm_rtpsize",
|
"aead_aes256_gcm_rtpsize",
|
||||||
// "xsalsa20_poly1305",
|
"aead_aes256_gcm",
|
||||||
// "xsalsa20_poly1305_suffix",
|
"xsalsa20_poly1305_lite_rtpsize",
|
||||||
// "xsalsa20_poly1305_lite",
|
"xsalsa20_poly1305_lite",
|
||||||
|
"xsalsa20_poly1305_suffix",
|
||||||
|
"xsalsa20_poly1305"
|
||||||
],
|
],
|
||||||
heartbeat_interval: 1,
|
heartbeat_interval: 1,
|
||||||
experiments: [],
|
experiments: [],
|
||||||
|
@ -3,9 +3,9 @@ import { VoiceOPCodes } from "@fosscord/util";
|
|||||||
|
|
||||||
export interface Payload {
|
export interface Payload {
|
||||||
op: number;
|
op: number;
|
||||||
d?: any;
|
d: any;
|
||||||
s?: number;
|
s: number;
|
||||||
t?: string;
|
t: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
import { onIdentify } from "./Identify";
|
import { onIdentify } from "./Identify";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user