From 98a080257b368168035247b3cea32264949856c3 Mon Sep 17 00:00:00 2001 From: dank074 Date: Fri, 26 Nov 2021 19:45:53 -0600 Subject: [PATCH] organize handshake packets --- src/nitro/communication/NitroMessages.ts | 30 +++++++++++-------- .../demo/NitroCommunicationDemo.ts | 16 +++++----- .../messages/outgoing/OutgoingHeader.ts | 1 + .../messages/outgoing/client/index.ts | 2 -- .../ClientHelloMessageComposer.ts} | 4 +-- .../handshake/DisconnectMessageComposer.ts | 21 +++++++++++++ ...oser.ts => InfoRetrieveMessageComposer.ts} | 6 ++-- .../PongMessageComposer.ts} | 6 ++-- ...omposer.ts => SSOTicketMessageComposer.ts} | 6 ++-- .../handshake/UniqueIDMessageComposer.ts | 21 +++++++++++++ .../handshake/VersionCheckMessageComposer.ts | 21 +++++++++++++ .../messages/outgoing/handshake/index.ts | 9 ++++-- 12 files changed, 107 insertions(+), 36 deletions(-) delete mode 100644 src/nitro/communication/messages/outgoing/client/index.ts rename src/nitro/communication/messages/outgoing/{client/ClientReleaseVersionComposer.ts => handshake/ClientHelloMessageComposer.ts} (77%) create mode 100644 src/nitro/communication/messages/outgoing/handshake/DisconnectMessageComposer.ts rename src/nitro/communication/messages/outgoing/handshake/{InfoRetrieveBaseMessageComposer.ts => InfoRetrieveMessageComposer.ts} (56%) rename src/nitro/communication/messages/outgoing/{client/ClientPongComposer.ts => handshake/PongMessageComposer.ts} (60%) rename src/nitro/communication/messages/outgoing/handshake/{SecurityTicketComposer.ts => SSOTicketMessageComposer.ts} (61%) create mode 100644 src/nitro/communication/messages/outgoing/handshake/UniqueIDMessageComposer.ts create mode 100644 src/nitro/communication/messages/outgoing/handshake/VersionCheckMessageComposer.ts diff --git a/src/nitro/communication/NitroMessages.ts b/src/nitro/communication/NitroMessages.ts index d1be3b09..d4683dca 100644 --- a/src/nitro/communication/NitroMessages.ts +++ b/src/nitro/communication/NitroMessages.ts @@ -248,8 +248,6 @@ import { PurchaseFromCatalogComposer } from './messages/outgoing/catalog/Purchas import { RedeemVoucherMessageComposer } from './messages/outgoing/catalog/RedeemVoucherMessageComposer'; import { RoomAdPurchaseInitiatedComposer } from './messages/outgoing/catalog/RoomAdPurchaseInitiatedComposer'; import { SelectClubGiftComposer } from './messages/outgoing/catalog/SelectClubGiftComposer'; -import { ClientPongComposer } from './messages/outgoing/client/ClientPongComposer'; -import { ClientReleaseVersionComposer } from './messages/outgoing/client/ClientReleaseVersionComposer'; import { ForwardToACompetitionRoomMessageComposer } from './messages/outgoing/competition/ForwardToACompetitionRoomMessageComposer'; import { GetIsUserPartOfCompetitionMessageComposer } from './messages/outgoing/competition/GetIsUserPartOfCompetitionMessageComposer'; import { CraftComposer } from './messages/outgoing/crafting/CraftComposer'; @@ -293,8 +291,13 @@ import { GroupSaveInformationComposer } from './messages/outgoing/group/GroupSav import { GroupSavePreferencesComposer } from './messages/outgoing/group/GroupSavePreferencesComposer'; import { GroupSettingsComposer } from './messages/outgoing/group/GroupSettingsComposer'; import { AuthenticationMessageComposer } from './messages/outgoing/handshake/AuthenticationMessageComposer'; -import { InfoRetrieveBaseMessageComposer } from './messages/outgoing/handshake/InfoRetrieveBaseMessageComposer'; -import { SecurityTicketComposer } from './messages/outgoing/handshake/SecurityTicketComposer'; +import { ClientHelloMessageComposer } from './messages/outgoing/handshake/ClientHelloMessageComposer'; +import { DisconnectMessageComposer } from './messages/outgoing/handshake/DisconnectMessageComposer'; +import { InfoRetrieveMessageComposer } from './messages/outgoing/handshake/InfoRetrieveMessageComposer'; +import { PongMessageComposer } from './messages/outgoing/handshake/PongMessageComposer'; +import { SSOTicketMessageComposer } from './messages/outgoing/handshake/SSOTicketMessageComposer'; +import { UniqueIDMessageComposer } from './messages/outgoing/handshake/UniqueIDMessageComposer'; +import { VersionCheckMessageComposer } from './messages/outgoing/handshake/VersionCheckMessageComposer'; import { RequestBadgesComposer } from './messages/outgoing/inventory/badges/RequestBadgesComposer'; import { SetActivatedBadgesComposer } from './messages/outgoing/inventory/badges/SetActivatedBadgesComposer'; import { GetBotInventoryComposer } from './messages/outgoing/inventory/bots/GetBotInventoryComposer'; @@ -997,6 +1000,15 @@ export class NitroMessages implements IMessageConfiguration this._composers.set(OutgoingHeader.UPDATE_FORUM_SETTINGS, UpdateForumSettingsMessageComposer); this._composers.set(OutgoingHeader.FORUM_UPDATE_THREAD, UpdateThreadMessageComposer); + // HANDSHAKE + this._composers.set(OutgoingHeader.CLIENT_PONG, PongMessageComposer); + this._composers.set(OutgoingHeader.RELEASE_VERSION, ClientHelloMessageComposer); + this._composers.set(OutgoingHeader.SECURITY_TICKET, SSOTicketMessageComposer); + this._composers.set(OutgoingHeader.USER_INFO, InfoRetrieveMessageComposer); + this._composers.set(OutgoingHeader.DISCONNECT, DisconnectMessageComposer); + this._composers.set(OutgoingHeader.SECURITY_MACHINE, UniqueIDMessageComposer); + this._composers.set(OutgoingHeader.CLIENT_VARIABLES, VersionCheckMessageComposer); + // HELP this._composers.set(OutgoingHeader.CALL_FOR_HELP_FROM_FORUM_MESSAGE, CallForHelpFromForumMessageMessageComposer); this._composers.set(OutgoingHeader.CALL_FOR_HELP_FROM_FORUM_THREAD, CallForHelpFromForumThreadMessageComposer); @@ -1029,10 +1041,6 @@ export class NitroMessages implements IMessageConfiguration this._composers.set(OutgoingHeader.POST_QUIZ_ANSWERS, PostQuizAnswersComposer); this._composers.set(OutgoingHeader.SEARCH_FAQS, SearchFaqsMessageComposer); - // CLIENT - this._composers.set(OutgoingHeader.CLIENT_PONG, ClientPongComposer); - this._composers.set(OutgoingHeader.RELEASE_VERSION, ClientReleaseVersionComposer); - // DESKTOP this._composers.set(OutgoingHeader.DESKTOP_VIEW, DesktopViewComposer); @@ -1058,10 +1066,6 @@ export class NitroMessages implements IMessageConfiguration this._composers.set(OutgoingHeader.GROUP_FAVORITE, GroupFavoriteComposer); this._composers.set(OutgoingHeader.GROUP_BADGES, GroupBadgesComposer); - // SECURITY - this._composers.set(OutgoingHeader.SECURITY_TICKET, SecurityTicketComposer); - this._composers.set(OutgoingHeader.USER_INFO, InfoRetrieveBaseMessageComposer); - // NAVIGATOR this._composers.set(OutgoingHeader.NAVIGATOR_CATEGORIES, NavigatorCategoriesComposer); this._composers.set(OutgoingHeader.NAVIGATOR_INIT, NavigatorInitComposer); @@ -1288,7 +1292,7 @@ export class NitroMessages implements IMessageConfiguration // SUBSCRIPTION this._composers.set(OutgoingHeader.USER_SUBSCRIPTION, UserSubscriptionComposer); - // MODTOOL + // MODERATION this._composers.set(OutgoingHeader.MODTOOL_REQUEST_ROOM_INFO, GetModeratorRoomInfoMessageComposer); this._composers.set(OutgoingHeader.MODTOOL_CHANGE_ROOM_SETTINGS, ModerateRoomMessageComposer); this._composers.set(OutgoingHeader.MODTOOL_REQUEST_USER_CHATLOG, GetUserChatlogMessageComposer); diff --git a/src/nitro/communication/demo/NitroCommunicationDemo.ts b/src/nitro/communication/demo/NitroCommunicationDemo.ts index e61307f2..a67dae46 100644 --- a/src/nitro/communication/demo/NitroCommunicationDemo.ts +++ b/src/nitro/communication/demo/NitroCommunicationDemo.ts @@ -6,10 +6,10 @@ import { Nitro } from '../../Nitro'; import { INitroCommunicationManager } from '../INitroCommunicationManager'; import { ClientPingEvent } from '../messages/incoming/client/ClientPingEvent'; import { AuthenticatedEvent } from '../messages/incoming/security/AuthenticatedEvent'; -import { ClientPongComposer } from '../messages/outgoing/client/ClientPongComposer'; -import { ClientReleaseVersionComposer } from '../messages/outgoing/client/ClientReleaseVersionComposer'; -import { InfoRetrieveBaseMessageComposer } from '../messages/outgoing/handshake/InfoRetrieveBaseMessageComposer'; -import { SecurityTicketComposer } from '../messages/outgoing/handshake/SecurityTicketComposer'; +import { ClientHelloMessageComposer } from '../messages/outgoing/handshake/ClientHelloMessageComposer'; +import { InfoRetrieveMessageComposer } from '../messages/outgoing/handshake/InfoRetrieveMessageComposer'; +import { PongMessageComposer } from '../messages/outgoing/handshake/PongMessageComposer'; +import { SSOTicketMessageComposer } from '../messages/outgoing/handshake/SSOTicketMessageComposer'; import { NitroCommunicationDemoEvent } from './NitroCommunicationDemoEvent'; export class NitroCommunicationDemo extends NitroManager @@ -88,7 +88,7 @@ export class NitroCommunicationDemo extends NitroManager this.startHandshake(connection); - connection.send(new ClientReleaseVersionComposer(null, null, null, null)); + connection.send(new ClientHelloMessageComposer(null, null, null, null)); this.tryAuthentication(connection); } @@ -129,7 +129,7 @@ export class NitroCommunicationDemo extends NitroManager return; } - connection.send(new SecurityTicketComposer(this._sso, Nitro.instance.time)); + connection.send(new SSOTicketMessageComposer(this._sso, Nitro.instance.time)); } private onClientPingEvent(event: ClientPingEvent): void @@ -149,7 +149,7 @@ export class NitroCommunicationDemo extends NitroManager //event.connection.send(new UserHomeRoomComposer(555)); - event.connection.send(new InfoRetrieveBaseMessageComposer()); + event.connection.send(new InfoRetrieveMessageComposer()); } public setSSO(sso: string): void @@ -195,7 +195,7 @@ export class NitroCommunicationDemo extends NitroManager if(!connection) return; - connection.send(new ClientPongComposer()); + connection.send(new PongMessageComposer()); } private dispatchCommunicationDemoEvent(type: string, connection: IConnection): void diff --git a/src/nitro/communication/messages/outgoing/OutgoingHeader.ts b/src/nitro/communication/messages/outgoing/OutgoingHeader.ts index 88781222..583bad0e 100644 --- a/src/nitro/communication/messages/outgoing/OutgoingHeader.ts +++ b/src/nitro/communication/messages/outgoing/OutgoingHeader.ts @@ -376,4 +376,5 @@ export class OutgoingHeader public static POLL_ANSWER = 3505; public static POLL_REJECT = 1773; public static POLL_START = 109; + public static DISCONNECT = 2445; } diff --git a/src/nitro/communication/messages/outgoing/client/index.ts b/src/nitro/communication/messages/outgoing/client/index.ts deleted file mode 100644 index 87f344d5..00000000 --- a/src/nitro/communication/messages/outgoing/client/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './ClientPongComposer'; -export * from './ClientReleaseVersionComposer'; diff --git a/src/nitro/communication/messages/outgoing/client/ClientReleaseVersionComposer.ts b/src/nitro/communication/messages/outgoing/handshake/ClientHelloMessageComposer.ts similarity index 77% rename from src/nitro/communication/messages/outgoing/client/ClientReleaseVersionComposer.ts rename to src/nitro/communication/messages/outgoing/handshake/ClientHelloMessageComposer.ts index af2d8a33..775075bc 100644 --- a/src/nitro/communication/messages/outgoing/client/ClientReleaseVersionComposer.ts +++ b/src/nitro/communication/messages/outgoing/handshake/ClientHelloMessageComposer.ts @@ -3,9 +3,9 @@ import { ClientDeviceCategoryEnum } from '../../../../../core/communication/conn import { ClientPlatformEnum } from '../../../../../core/communication/connections/enums/ClientPlatformEnum'; import { IMessageComposer } from '../../../../../core/communication/messages/IMessageComposer'; -export class ClientReleaseVersionComposer implements IMessageComposer> +export class ClientHelloMessageComposer implements IMessageComposer> { - private _data: ConstructorParameters; + private _data: ConstructorParameters; constructor(releaseVersion: string, type: string, platform: number, category: number) { diff --git a/src/nitro/communication/messages/outgoing/handshake/DisconnectMessageComposer.ts b/src/nitro/communication/messages/outgoing/handshake/DisconnectMessageComposer.ts new file mode 100644 index 00000000..d7e43d36 --- /dev/null +++ b/src/nitro/communication/messages/outgoing/handshake/DisconnectMessageComposer.ts @@ -0,0 +1,21 @@ +import { IMessageComposer } from '../../../../..'; + +export class DisconnectMessageComposer implements IMessageComposer> +{ + private _data: ConstructorParameters; + + constructor() + { + this._data = []; + } + + public getMessageArray() + { + return this._data; + } + + public dispose(): void + { + return; + } +} diff --git a/src/nitro/communication/messages/outgoing/handshake/InfoRetrieveBaseMessageComposer.ts b/src/nitro/communication/messages/outgoing/handshake/InfoRetrieveMessageComposer.ts similarity index 56% rename from src/nitro/communication/messages/outgoing/handshake/InfoRetrieveBaseMessageComposer.ts rename to src/nitro/communication/messages/outgoing/handshake/InfoRetrieveMessageComposer.ts index 1a133511..36f72e1c 100644 --- a/src/nitro/communication/messages/outgoing/handshake/InfoRetrieveBaseMessageComposer.ts +++ b/src/nitro/communication/messages/outgoing/handshake/InfoRetrieveMessageComposer.ts @@ -1,8 +1,8 @@ import { IMessageComposer } from '../../../../../core/communication/messages/IMessageComposer'; -export class InfoRetrieveBaseMessageComposer implements IMessageComposer> +export class InfoRetrieveMessageComposer implements IMessageComposer> { - private _data: ConstructorParameters; + private _data: ConstructorParameters; constructor() { @@ -18,4 +18,4 @@ export class InfoRetrieveBaseMessageComposer implements IMessageComposer> +export class PongMessageComposer implements IMessageComposer> { - private _data: ConstructorParameters; + private _data: ConstructorParameters; constructor() { @@ -18,4 +18,4 @@ export class ClientPongComposer implements IMessageComposer> +export class SSOTicketMessageComposer implements IMessageComposer> { - private _data: ConstructorParameters; + private _data: ConstructorParameters; constructor(ticket: string, time: number) { @@ -18,4 +18,4 @@ export class SecurityTicketComposer implements IMessageComposer> +{ + private _data: ConstructorParameters; + + constructor(machineId:string, fingerprint:string, flashVersion:string) + { + this._data = [ machineId, fingerprint, flashVersion ]; + } + + public getMessageArray() + { + return this._data; + } + + public dispose(): void + { + return; + } +} diff --git a/src/nitro/communication/messages/outgoing/handshake/VersionCheckMessageComposer.ts b/src/nitro/communication/messages/outgoing/handshake/VersionCheckMessageComposer.ts new file mode 100644 index 00000000..12076b26 --- /dev/null +++ b/src/nitro/communication/messages/outgoing/handshake/VersionCheckMessageComposer.ts @@ -0,0 +1,21 @@ +import { IMessageComposer } from '../../../../..'; + +export class VersionCheckMessageComposer implements IMessageComposer> +{ + private _data: ConstructorParameters; + + constructor(clientID:number, clientURL:string, externalVariablesURL:string) + { + this._data = [clientID, clientURL, externalVariablesURL]; + } + + public getMessageArray() + { + return this._data; + } + + public dispose(): void + { + return; + } +} diff --git a/src/nitro/communication/messages/outgoing/handshake/index.ts b/src/nitro/communication/messages/outgoing/handshake/index.ts index d4f561a0..f8b54484 100644 --- a/src/nitro/communication/messages/outgoing/handshake/index.ts +++ b/src/nitro/communication/messages/outgoing/handshake/index.ts @@ -1,3 +1,8 @@ export * from './AuthenticationMessageComposer'; -export * from './InfoRetrieveBaseMessageComposer'; -export * from './SecurityTicketComposer'; +export * from './ClientHelloMessageComposer'; +export * from './DisconnectMessageComposer'; +export * from './InfoRetrieveMessageComposer'; +export * from './PongMessageComposer'; +export * from './SSOTicketMessageComposer'; +export * from './UniqueIDMessageComposer'; +export * from './VersionCheckMessageComposer';