2026-02-01 23:33:35 +00:00
|
|
|
import * as plugins from '../../plugins.js';
|
2026-01-31 11:33:11 +00:00
|
|
|
import type { ICommandHandler, IHandlerContext } from '../CommandRouter.js';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* HelloHandler - Handles hello/isMaster handshake commands
|
|
|
|
|
*
|
|
|
|
|
* This is the first command sent by MongoDB drivers to establish a connection.
|
|
|
|
|
* It returns server capabilities and configuration.
|
|
|
|
|
*/
|
|
|
|
|
export class HelloHandler implements ICommandHandler {
|
|
|
|
|
async handle(context: IHandlerContext): Promise<plugins.bson.Document> {
|
|
|
|
|
const { command, server } = context;
|
|
|
|
|
|
|
|
|
|
// Build response with server capabilities
|
|
|
|
|
const response: plugins.bson.Document = {
|
|
|
|
|
ismaster: true,
|
|
|
|
|
ok: 1,
|
|
|
|
|
|
|
|
|
|
// Maximum sizes
|
|
|
|
|
maxBsonObjectSize: 16777216, // 16 MB
|
|
|
|
|
maxMessageSizeBytes: 48000000, // 48 MB
|
|
|
|
|
maxWriteBatchSize: 100000, // 100k documents per batch
|
|
|
|
|
|
|
|
|
|
// Timestamps
|
|
|
|
|
localTime: new Date(),
|
|
|
|
|
|
|
|
|
|
// Session support
|
|
|
|
|
logicalSessionTimeoutMinutes: 30,
|
|
|
|
|
|
|
|
|
|
// Connection info
|
|
|
|
|
connectionId: 1,
|
|
|
|
|
|
|
|
|
|
// Wire protocol versions (support MongoDB 3.6 through 7.0)
|
|
|
|
|
minWireVersion: 0,
|
|
|
|
|
maxWireVersion: 21,
|
|
|
|
|
|
|
|
|
|
// Server mode
|
|
|
|
|
readOnly: false,
|
|
|
|
|
|
|
|
|
|
// Topology info (standalone mode)
|
|
|
|
|
isWritablePrimary: true,
|
|
|
|
|
|
|
|
|
|
// Additional info
|
|
|
|
|
topologyVersion: {
|
|
|
|
|
processId: new plugins.bson.ObjectId(),
|
|
|
|
|
counter: plugins.bson.Long.fromNumber(0),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Handle hello-specific fields
|
|
|
|
|
if (command.hello || command.hello === 1) {
|
|
|
|
|
response.helloOk = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Handle client metadata
|
|
|
|
|
if (command.client) {
|
|
|
|
|
// Client is providing metadata about itself
|
|
|
|
|
// We just acknowledge it - no need to do anything special
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Handle SASL mechanisms query
|
|
|
|
|
if (command.saslSupportedMechs) {
|
|
|
|
|
response.saslSupportedMechs = [
|
|
|
|
|
// We don't actually support auth, but the driver needs to see this
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Compression support (none for now)
|
|
|
|
|
if (command.compression) {
|
|
|
|
|
response.compression = [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Server version info
|
|
|
|
|
response.version = '7.0.0';
|
|
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
}
|