node-firebird 2.16.2 → 2.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/lib/types.d.ts +2 -0
- package/lib/utils.d.ts +5 -0
- package/lib/utils.js +9 -0
- package/lib/wire/database.js +1 -3
- package/package.json +1 -1
- package/src/types.ts +2 -0
- package/src/utils.ts +7 -0
- package/src/wire/database.ts +2 -4
package/README.md
CHANGED
|
@@ -181,6 +181,7 @@ same way `PGUSER`/`PGPASSWORD` work with pg.
|
|
|
181
181
|
var options = {};
|
|
182
182
|
|
|
183
183
|
options.host = '127.0.0.1';
|
|
184
|
+
options.eventHost = undefined; // optional; override the server-advertised host for the auxiliary event connection
|
|
184
185
|
options.port = 3050;
|
|
185
186
|
options.database = 'database.fdb';
|
|
186
187
|
options.user = 'SYSDBA';
|
|
@@ -1455,6 +1456,11 @@ If the server reports `0.0.0.0` or `::` as the aux address — usual when it lis
|
|
|
1455
1456
|
interfaces — the driver dials the host from your connection options instead, so that host must
|
|
1456
1457
|
be the one reaching the aux port.
|
|
1457
1458
|
|
|
1459
|
+
Behind NAT, a tunnel, container networking, or a load balancer, the advertised
|
|
1460
|
+
address may not be reachable from the client. Set `options.eventHost` to override
|
|
1461
|
+
only the host used for the auxiliary event connection. The auxiliary port is
|
|
1462
|
+
still selected by Firebird; use `RemoteAuxPort` when it also needs to be fixed.
|
|
1463
|
+
|
|
1458
1464
|
Since **2.16.2** a failed dial is reported to the attachment callback as an `Error`, exactly
|
|
1459
1465
|
once, carrying Node's socket `code`. Earlier versions recorded it internally and never called
|
|
1460
1466
|
back, so `attachEvent()` and `attachEventAsync()` hung indefinitely:
|
package/lib/types.d.ts
CHANGED
|
@@ -352,6 +352,8 @@ export interface Statement {
|
|
|
352
352
|
export type SupportedCharacterSet = 'NONE' | 'CP943C' | 'DOS737' | 'DOS775' | 'DOS858' | 'DOS862' | 'DOS864' | 'DOS866' | 'DOS869' | 'GB18030' | 'GBK' | 'ISO8859_1' | 'ISO8859_2' | 'ISO8859_3' | 'ISO8859_4' | 'ISO8859_5' | 'ISO8859_6' | 'ISO8859_7' | 'ISO8859_8' | 'ISO8859_9' | 'ISO8859_13' | 'KOI8R' | 'KOI8U' | 'TIS620' | 'UTF8' | 'WIN1251' | 'WIN1252' | 'WIN1253' | 'WIN1254' | 'WIN1255' | 'WIN1256' | 'WIN1257' | 'WIN1258' | 'WIN_1258';
|
|
353
353
|
export interface Options {
|
|
354
354
|
host?: string;
|
|
355
|
+
/** Override the server-advertised auxiliary event host (for NAT, tunnels and load balancers). */
|
|
356
|
+
eventHost?: string;
|
|
355
357
|
port?: number;
|
|
356
358
|
database?: string;
|
|
357
359
|
user?: string;
|
package/lib/utils.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { FbStatusItem } from './callback';
|
|
2
|
+
/** Resolve the address used for Firebird's auxiliary event connection. */
|
|
3
|
+
export declare function resolveEventHost(options: {
|
|
4
|
+
host?: string;
|
|
5
|
+
eventHost?: string;
|
|
6
|
+
}, advertisedHost: string): string;
|
|
2
7
|
/**
|
|
3
8
|
* Parse date from string
|
|
4
9
|
*/
|
package/lib/utils.js
CHANGED
|
@@ -4,10 +4,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.escape = exports.lookupMessages = exports.batchResultToError = exports.parseDate = void 0;
|
|
7
|
+
exports.resolveEventHost = resolveEventHost;
|
|
7
8
|
exports.noop = noop;
|
|
8
9
|
const firebird_msg_json_1 = __importDefault(require("./firebird.msg.json"));
|
|
9
10
|
const const_1 = __importDefault(require("./wire/const"));
|
|
10
11
|
const MessagesError = firebird_msg_json_1.default;
|
|
12
|
+
/** Resolve the address used for Firebird's auxiliary event connection. */
|
|
13
|
+
function resolveEventHost(options, advertisedHost) {
|
|
14
|
+
if (options.eventHost)
|
|
15
|
+
return options.eventHost;
|
|
16
|
+
if (advertisedHost === '0.0.0.0' || advertisedHost === '::')
|
|
17
|
+
return options.host || const_1.default.DEFAULT_HOST;
|
|
18
|
+
return advertisedHost;
|
|
19
|
+
}
|
|
11
20
|
/**
|
|
12
21
|
* Parse date from string
|
|
13
22
|
*/
|
package/lib/wire/database.js
CHANGED
|
@@ -404,9 +404,7 @@ class Database extends events_1.default.EventEmitter {
|
|
|
404
404
|
if (process.env.FIREBIRD_DEBUG) {
|
|
405
405
|
console.log('[fb-debug] Database.attachEvent: auxConnection ok, connecting to aux port %s:%d', socket_info.host, socket_info.port);
|
|
406
406
|
}
|
|
407
|
-
const host = (
|
|
408
|
-
? self.connection.options.host
|
|
409
|
-
: socket_info.host;
|
|
407
|
+
const host = (0, utils_1.resolveEventHost)(self.connection.options, socket_info.host);
|
|
410
408
|
const eventConnection = new eventConnection_1.default(host, socket_info.port, function (err) {
|
|
411
409
|
if (err) {
|
|
412
410
|
if (process.env.FIREBIRD_DEBUG) {
|
package/package.json
CHANGED
package/src/types.ts
CHANGED
|
@@ -413,6 +413,8 @@ export type SupportedCharacterSet = |
|
|
|
413
413
|
|
|
414
414
|
export interface Options {
|
|
415
415
|
host?: string;
|
|
416
|
+
/** Override the server-advertised auxiliary event host (for NAT, tunnels and load balancers). */
|
|
417
|
+
eventHost?: string;
|
|
416
418
|
port?: number;
|
|
417
419
|
database?: string;
|
|
418
420
|
user?: string;
|
package/src/utils.ts
CHANGED
|
@@ -4,6 +4,13 @@ import type { FbStatusItem } from './callback';
|
|
|
4
4
|
|
|
5
5
|
const MessagesError = messagesJson as Record<string, string>;
|
|
6
6
|
|
|
7
|
+
/** Resolve the address used for Firebird's auxiliary event connection. */
|
|
8
|
+
export function resolveEventHost(options: { host?: string; eventHost?: string }, advertisedHost: string): string {
|
|
9
|
+
if (options.eventHost) return options.eventHost;
|
|
10
|
+
if (advertisedHost === '0.0.0.0' || advertisedHost === '::') return options.host || Const.DEFAULT_HOST;
|
|
11
|
+
return advertisedHost;
|
|
12
|
+
}
|
|
13
|
+
|
|
7
14
|
/**
|
|
8
15
|
* Parse date from string
|
|
9
16
|
*/
|
package/src/wire/database.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Events from 'events';
|
|
2
2
|
import { doError, fromCallback, type Callback, type SimpleCallback } from '../callback';
|
|
3
|
-
import { batchResultToError, escape } from '../utils';
|
|
3
|
+
import { batchResultToError, escape, resolveEventHost } from '../utils';
|
|
4
4
|
import Const from './const';
|
|
5
5
|
import { makeSqlTag, type SqlTag } from '../sql-template';
|
|
6
6
|
import { computeColumnKeys, nestCell, resolveKeyTransform, resolveNestTables } from './xsqlvar';
|
|
@@ -481,9 +481,7 @@ class Database extends Events.EventEmitter {
|
|
|
481
481
|
console.log('[fb-debug] Database.attachEvent: auxConnection ok, connecting to aux port %s:%d', socket_info.host, socket_info.port);
|
|
482
482
|
}
|
|
483
483
|
|
|
484
|
-
const host = (
|
|
485
|
-
? self.connection.options.host
|
|
486
|
-
: socket_info.host;
|
|
484
|
+
const host = resolveEventHost(self.connection.options, socket_info.host);
|
|
487
485
|
|
|
488
486
|
const eventConnection = new EventConnection(
|
|
489
487
|
host, socket_info.port, function(err?: any) {
|