Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: include instance name in Login7 message #1668

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,7 @@ export interface ConnectionOptions {
interface RoutingData {
server: string;
port: number;
login7server: string;
}

/**
Expand Down Expand Up @@ -2484,7 +2485,7 @@ class Connection extends EventEmitter {
}

payload.hostname = this.config.options.workstationId || os.hostname();
payload.serverName = this.routingData ? this.routingData.server : this.config.server;
payload.serverName = this.routingData ? this.routingData.login7server : this.config.server;
payload.appName = this.config.options.appName || 'Tedious';
payload.libraryName = libraryName;
payload.language = this.config.options.language;
Expand Down
16 changes: 10 additions & 6 deletions src/login7-payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,12 @@ class Login7Payload {
}

// (ibUnused / ibExtension): 2-byte
offset = fixedData.writeUInt16LE(dataOffset, offset);
const extensionOffsetHeaderOffset = offset;
offset = fixedData.writeUInt16LE(0, offset);


// (cchUnused / cbExtension): 2-byte
const extensions = this.buildFeatureExt();
offset = fixedData.writeUInt16LE(4, offset);
const extensionOffset = Buffer.alloc(4);
extensionOffset.writeUInt32LE(dataOffset += 4, 0);
dataOffset += extensions.length;
buffers.push(extensionOffset, extensions);

// ibCltIntName: 2-byte
offset = fixedData.writeUInt16LE(dataOffset, offset);
Expand Down Expand Up @@ -365,6 +362,13 @@ class Login7Payload {
fixedData.writeUInt32LE(0, offset);
}

fixedData.writeUInt16LE(dataOffset, extensionOffsetHeaderOffset);

const extensions = this.buildFeatureExt();
const extensionOffset = Buffer.alloc(4);
extensionOffset.writeUInt32LE(dataOffset + 4, 0);
buffers.push(extensionOffset, extensions);

const data = Buffer.concat(buffers);
data.writeUInt32LE(data.length, 0);
return data;
Expand Down
4 changes: 2 additions & 2 deletions src/token/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export class Login7TokenHandler extends TokenHandler {
declare connection: Connection;

declare fedAuthInfoToken: FedAuthInfoToken | undefined;
declare routingData: { server: string, port: number } | undefined;
declare routingData: { server: string, port: number, login7server: string } | undefined;
TPVallancourt marked this conversation as resolved.
Show resolved Hide resolved

declare loginAckReceived: boolean;

Expand Down Expand Up @@ -340,7 +340,7 @@ export class Login7TokenHandler extends TokenHandler {
const [ server ] = token.newValue.server.split('\\');

this.routingData = {
server, port: token.newValue.port
server, port: token.newValue.port, login7server: token.newValue.server
};
}

Expand Down
Loading