[go: nahoru, domu]

Skip to content

Commit

Permalink
Implement rate limiting reply snac
Browse files Browse the repository at this point in the history
  • Loading branch information
DrewML committed Dec 27, 2020
1 parent f0da6aa commit beff505
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/BossServer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export class BossServer extends OscarServer {
}

if (matchSnac(snac, 'GENERAL', 'RATE_INFO_REQUEST')) {
assert(false, 'snac 01,07 not implemented yet');
return oscarSocket.write({
type: FlapType.DATA,
data: rateLimitInfoSnac({ reqID: snac.requestID }),
Expand Down
22 changes: 20 additions & 2 deletions src/BossServer/serverSnacs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ export function supportedFamiliesSnac(opts: { reqID: number }) {
* @see http://iserverd.khstu.ru/oscar/snac_01_18.html
*/
export function familyVersionsSnac(opts: { reqID: number }) {
// Note: The official Oscar protocol docs claim something
// completely different for this snac. But the unofficial
// docs seem to be correct (weird)
// http://web.archive.org/web/20080308233204/http://dev.aol.com/aim/oscar/#OSERVICE__MIGRATE_GROUPS

// prettier-ignore
const versions = uint16BEBuffer([
// family, version
Expand All @@ -62,11 +67,24 @@ export function familyVersionsSnac(opts: { reqID: number }) {
}

/**
* @description Create a SNAC specifying the server-enforced
* rate limits. Note that this server currently
* doesn't enforce rate limits, this is just a
* necessary part of the signon process
* @see http://iserverd.khstu.ru/oscar/snac_01_07.html
* @see http://web.archive.org/web/20060113101258/http://joust.kano.net/wiki/oscar/moin.cgi/RateLimiting
* @see http://web.archive.org/web/20080308233204/http://dev.aol.com/aim/oscar/#RATELIMIT
*/
export function rateLimitInfoSnac(opts: { reqID: number }) {
// TODO: hardcode a giant buffer here
const data = Buffer.alloc(0);
// prettier-ignore
const data = Buffer.from([
0x0, 0x0, // uint16, number of rate classes
// Here is where all the rate classes would normally go.
// Luckily we can save a bunch of time because AIM clients
// (at least 5.2) will accept 0 total rate classes, as far
// as I can tell. Will likely implement proper rate classes
// when the server itself has rate limiting functionality
]);

return buildSnac({
family: SNACS.GENERAL.family,
Expand Down

0 comments on commit beff505

Please sign in to comment.