summary refs log tree commit diff
path: root/src/webrtc/opcodes/Identify.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/webrtc/opcodes/Identify.ts')
-rw-r--r--src/webrtc/opcodes/Identify.ts35
1 files changed, 24 insertions, 11 deletions
diff --git a/src/webrtc/opcodes/Identify.ts b/src/webrtc/opcodes/Identify.ts

index 19a575ab..45ad6c0a 100644 --- a/src/webrtc/opcodes/Identify.ts +++ b/src/webrtc/opcodes/Identify.ts
@@ -1,33 +1,46 @@ import { CLOSECODES, Payload, Send, WebSocket } from "@fosscord/gateway"; -import { validateSchema, VoiceIdentifySchema, VoiceState } from "@fosscord/util"; +import { + validateSchema, + VoiceIdentifySchema, + VoiceState, +} from "@fosscord/util"; import { endpoint, getClients, VoiceOPCodes, PublicIP } from "@fosscord/webrtc"; import SemanticSDP from "semantic-sdp"; const defaultSDP = require("./sdp.json"); export async function onIdentify(this: WebSocket, data: Payload) { clearTimeout(this.readyTimeout); - const { server_id, user_id, session_id, token, streams, video } = validateSchema("VoiceIdentifySchema", data.d) as VoiceIdentifySchema; + const { server_id, user_id, session_id, token, streams, video } = + validateSchema("VoiceIdentifySchema", data.d) as VoiceIdentifySchema; - const voiceState = await VoiceState.findOne({ where: { guild_id: server_id, user_id, token, session_id } }); + const voiceState = await VoiceState.findOne({ + where: { guild_id: server_id, user_id, token, session_id }, + }); if (!voiceState) return this.close(CLOSECODES.Authentication_failed); this.user_id = user_id; this.session_id = session_id; const sdp = SemanticSDP.SDPInfo.expand(defaultSDP); - sdp.setDTLS(SemanticSDP.DTLSInfo.expand({ setup: "actpass", hash: "sha-256", fingerprint: endpoint.getDTLSFingerprint() })); + sdp.setDTLS( + SemanticSDP.DTLSInfo.expand({ + setup: "actpass", + hash: "sha-256", + fingerprint: endpoint.getDTLSFingerprint(), + }), + ); this.client = { websocket: this, out: { - tracks: new Map() + tracks: new Map(), }, in: { audio_ssrc: 0, video_ssrc: 0, - rtx_ssrc: 0 + rtx_ssrc: 0, }, sdp, - channel_id: voiceState.channel_id + channel_id: voiceState.channel_id, }; const clients = getClients(voiceState.channel_id)!; @@ -51,10 +64,10 @@ export async function onIdentify(this: WebSocket, data: Payload) { "xsalsa20_poly1305_lite_rtpsize", "xsalsa20_poly1305_lite", "xsalsa20_poly1305_suffix", - "xsalsa20_poly1305" + "xsalsa20_poly1305", ], ip: PublicIP, - experiments: [] - } + experiments: [], + }, }); -} \ No newline at end of file +}