앱 v1.2.1: 겜녹이 봇 토큰을 앱에 보내지 않고 사이트 서버가 봇을 대신 연결
- 사이트 서버: discord.js 로 디스코드 게이트웨이에 한 번 붙고(discord-source.ts), 로그인한 앱에 WS /app/bot/ws 로 중계(bot-broker.ts) · 앱이 보낸 op 4 는 지켜보는 서버의 음성채널 참여 · 나가기만 허용하고 필드를 다시 만들어 보낸다 · 디스코드가 준 일회용 음성 접속 정보(VOICE_STATE/SERVER_UPDATE)는 음성을 가진 앱에만 넘긴다. 음성은 앱 ↔ 디스코드로 바로 · 한 서버의 봇 음성은 마지막으로 요청한 앱이 가져가고 이전 앱은 taken. 이전 앱의 늦은 나가기 무시, 음성 가진 앱이 끊기면 봇을 뺀다 · 슬래시 명령은 서버가 받아 defer 후 그 서버를 지켜보는 앱으로 보낸다 · 등록 해제 · 로그아웃하면 그 유저의 중계 연결을 바로 끊는다 (4401), 30초마다 다시 확인 - /app/me 에서 botToken 제거. 앱은 v1.2.0 이 저장해 둔 봇 토큰을 시작할 때 지운다 - 앱: BotGateway 로 디스코드 연결을 분리 (RemoteGateway = 겜녹이 봇 서버 중계, LocalGateway = 다른 봇 토큰 직접 연결) Bot 은 discord.js 객체 대신 이 인터페이스만 쓴다. 중계가 로그인 만료를 알리면 바로 다시 확인해서 잠근다 - 로그인 확인: 잠그라는 응답(401 · 403)은 겹친 확인 때문에 늦게 와도 같은 토큰이면 따른다 (겹친 두 번째 확인이 401 을 받아 "등록되지 않은 아이디" 대신 "로그인 만료"로 잠기던 문제). 미등록 화면은 다시 확인해도 유지 - 테스트: 봇 중계 4건(토큰 미노출 · 음성 정보 전달 · 다른 PC 인계 · 명령 라우팅 · 해제 시 끊김), 겹친 확인 1건 실제 디스코드: voice-e2e GVR_E2E_RELAY=1 (서버 중계로 따라 들어가 녹음 · STT · 녹음 제외), login-e2e 19/19 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -250,11 +250,10 @@ export type AppLoginPoll =
|
||||
| { state: 'not_registered'; user: AppUserInfo }
|
||||
| { state: 'error'; error: string };
|
||||
|
||||
/** GET /app/me 응답 (등록된 유저만). botToken = 겜녹이 기본 봇 토큰 (서버에서만 내려준다) */
|
||||
/** GET /app/me 응답 (등록된 유저만). 겜녹이 봇 토큰은 내려주지 않는다 (봇은 서버가 대신 연결, 아래 BotGw*) */
|
||||
export interface AppMe {
|
||||
user: AppUserInfo;
|
||||
role: AppRole;
|
||||
botToken: string | null;
|
||||
serverTime: number;
|
||||
}
|
||||
|
||||
@@ -271,3 +270,44 @@ export interface AppUserRow {
|
||||
lastSeenAt: number | null;
|
||||
lastVersion: string | null;
|
||||
}
|
||||
|
||||
// 겜녹이 봇 중계 (사이트 서버 WebSocket /app/bot/ws, Authorization: Bearer <앱 토큰>)
|
||||
// 봇 토큰은 서버에만 있다. 서버가 디스코드 게이트웨이에 붙어 있고, 앱은 필요한 정보만 받는다.
|
||||
// 음성채널에 들어갈 때는 앱의 @discordjs/voice 가 보낸 op 4 를 서버가 대신 보내고,
|
||||
// 디스코드가 준 일회용 음성 접속 정보(VOICE_STATE/SERVER_UPDATE)를 앱에 넘긴다. 음성은 앱 ↔ 디스코드로 바로 간다.
|
||||
export interface BotGwMember {
|
||||
id: string;
|
||||
name: string;
|
||||
avatar: string | null;
|
||||
bot: boolean;
|
||||
}
|
||||
export interface BotGwGuild {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string | null;
|
||||
}
|
||||
export interface BotGwChannel {
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export type BotGwToApp =
|
||||
| { t: 'ready'; me: BotGwMember; guilds: BotGwGuild[] }
|
||||
| { t: 'guilds'; guilds: BotGwGuild[] }
|
||||
/** watch 응답: 그 서버의 음성채널 · 음성채널에 있는 사람 */
|
||||
| { t: 'guild'; guild: BotGwGuild; channels: BotGwChannel[]; voice: { member: BotGwMember; channelId: string }[] }
|
||||
| { t: 'voiceState'; guildId: string; member: BotGwMember; oldChannelId: string | null; newChannelId: string | null; channel: BotGwChannel | null }
|
||||
| { t: 'cmd'; id: string; name: string; guildId: string; user: BotGwMember; voiceChannel: BotGwChannel | null }
|
||||
/** 음성 접속 정보 (디스코드 VOICE_SERVER_UPDATE / 봇 자신의 VOICE_STATE_UPDATE 원문) */
|
||||
| { t: 'vserver'; guildId: string; data: any }
|
||||
| { t: 'vstate'; guildId: string; data: any }
|
||||
/** 다른 PC 가 이 서버에서 봇을 데려갔다 → 녹음을 멈춘다 */
|
||||
| { t: 'taken'; guildId: string }
|
||||
| { t: 'res'; id: string; ok: boolean; data?: any; error?: string };
|
||||
|
||||
export type BotGwFromApp =
|
||||
| { t: 'watch'; guildId: string; commands: boolean }
|
||||
/** @discordjs/voice 어댑터가 보낸 게이트웨이 op 4 (음성채널 참여 · 나가기) */
|
||||
| { t: 'voice'; guildId: string; payload: any }
|
||||
| { t: 'cmd_res'; id: string; content: string }
|
||||
| { t: 'req'; id: string; op: 'members'; guildId: string };
|
||||
|
||||
Reference in New Issue
Block a user