node-firebird 2.0.1 → 2.0.2
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/lib/wire/connection.js +8 -8
- package/package.json +1 -1
- package/0001-fix-attachEvent-host-resolution.patch +0 -72
- package/diff +0 -62
package/lib/wire/connection.js
CHANGED
|
@@ -1208,7 +1208,10 @@ class Connection {
|
|
|
1208
1208
|
|
|
1209
1209
|
fetchAll(statement, transaction, callback) {
|
|
1210
1210
|
const self = this;
|
|
1211
|
-
const
|
|
1211
|
+
const custom = statement.custom || {};
|
|
1212
|
+
const asStream = custom.asStream && custom.on;
|
|
1213
|
+
const data = asStream ? null : [];
|
|
1214
|
+
let streamIndex = 0;
|
|
1212
1215
|
const loop = (err, ret) => {
|
|
1213
1216
|
if (err) {
|
|
1214
1217
|
callback(err);
|
|
@@ -1224,11 +1227,8 @@ class Connection {
|
|
|
1224
1227
|
ret.data[blob.row][blob.column] = blob.value;
|
|
1225
1228
|
}
|
|
1226
1229
|
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
doSynchronousLoop(ret.data, (row, i, next) => {
|
|
1231
|
-
const pos = data.push(row) - 1;
|
|
1230
|
+
doSynchronousLoop(ret.data, (row, _i, next) => {
|
|
1231
|
+
const pos = asStream ? streamIndex++ : (data.push(row) - 1);
|
|
1232
1232
|
if (asStream) {
|
|
1233
1233
|
executeStreamRow(custom, row, pos, statement.output, next);
|
|
1234
1234
|
} else {
|
|
@@ -1241,7 +1241,7 @@ class Connection {
|
|
|
1241
1241
|
}
|
|
1242
1242
|
|
|
1243
1243
|
if (ret.fetched) {
|
|
1244
|
-
callback(undefined, data);
|
|
1244
|
+
callback(undefined, data || []);
|
|
1245
1245
|
} else {
|
|
1246
1246
|
self.fetch(statement, transaction, Const.DEFAULT_FETCHSIZE, loop);
|
|
1247
1247
|
}
|
|
@@ -1251,7 +1251,7 @@ class Connection {
|
|
|
1251
1251
|
}
|
|
1252
1252
|
|
|
1253
1253
|
if (ret && ret.fetched) {
|
|
1254
|
-
callback(undefined, data);
|
|
1254
|
+
callback(undefined, data || []);
|
|
1255
1255
|
} else {
|
|
1256
1256
|
self.fetch(statement, transaction, Const.DEFAULT_FETCHSIZE, loop);
|
|
1257
1257
|
}
|
package/package.json
CHANGED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
2
|
-
From: Gobbo89 <gobbo89@users.noreply.github.com>
|
|
3
|
-
Date: Thu, 19 Feb 2026 00:00:00 +0000
|
|
4
|
-
Subject: [PATCH] fix(events): resolve event channel host from connection options
|
|
5
|
-
|
|
6
|
-
When Firebird is configured with RemoteBindAddress unset (default),
|
|
7
|
-
auxConnection() returns socket_info.host = "0.0.0.0", which is a
|
|
8
|
-
bind-any address and not a routable destination for remote clients.
|
|
9
|
-
|
|
10
|
-
This commit changes the host selection logic in attachEvent to prefer
|
|
11
|
-
connection.options.host (the address that the user explicitly provided
|
|
12
|
-
and that is proven reachable, since the initial DB attach succeeded).
|
|
13
|
-
|
|
14
|
-
Only if options.host is absent does it fall back to socket_info.host,
|
|
15
|
-
and even then only when that host is a concrete routable address (i.e.
|
|
16
|
-
not "0.0.0.0" and not "::"). As a last resort it uses the socket's
|
|
17
|
-
remoteAddress, normalizing IPv6-mapped IPv4 (::ffff:x.x.x.x → x.x.x.x).
|
|
18
|
-
|
|
19
|
-
Fixes #386.
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
lib/wire/database.js | 25 +++++++++++++++++++++++--
|
|
23
|
-
1 file changed, 23 insertions(+), 2 deletions(-)
|
|
24
|
-
|
|
25
|
-
diff --git a/lib/wire/database.js b/lib/wire/database.js
|
|
26
|
-
index xxxxxxx..yyyyyyy 100644
|
|
27
|
-
--- a/lib/wire/database.js
|
|
28
|
-
+++ b/lib/wire/database.js
|
|
29
|
-
@@ -1,3 +1,18 @@
|
|
30
|
-
+/**
|
|
31
|
-
+ * Resolves the host to use for the auxiliary event channel.
|
|
32
|
-
+ *
|
|
33
|
-
+ * Priority:
|
|
34
|
-
+ * 1. connection.options.host – explicitly provided by the caller; known reachable.
|
|
35
|
-
+ * 2. socket_info.host – only when it is a concrete routable address
|
|
36
|
-
+ * (i.e. not "0.0.0.0" and not "::").
|
|
37
|
-
+ * 3. socket.remoteAddress – the OS-level address of the main connection socket,
|
|
38
|
-
+ * with IPv6-mapped IPv4 prefixes stripped.
|
|
39
|
-
+ *
|
|
40
|
-
+ * @param {object} connection The active database connection object.
|
|
41
|
-
+ * @param {string} auxHost The host returned by the auxConnection() call.
|
|
42
|
-
+ * @returns {string} A connectable host string.
|
|
43
|
-
+ */
|
|
44
|
-
+function resolveEventHost(connection, auxHost) {
|
|
45
|
-
+ // 1. Prefer the host the caller explicitly supplied.
|
|
46
|
-
+ if (connection.options && connection.options.host) {
|
|
47
|
-
+ return connection.options.host;
|
|
48
|
-
+ }
|
|
49
|
-
+
|
|
50
|
-
+ // 2. Use auxConnection host only when it is a real address.
|
|
51
|
-
+ var BIND_ANY = ['0.0.0.0', '::'];
|
|
52
|
-
+ if (auxHost && BIND_ANY.indexOf(auxHost) === -1) {
|
|
53
|
-
+ return auxHost;
|
|
54
|
-
+ }
|
|
55
|
-
+
|
|
56
|
-
+ // 3. Fall back to the OS-reported remote address of the main socket,
|
|
57
|
-
+ // normalising IPv6-mapped IPv4 (e.g. "::ffff:10.0.0.1" → "10.0.0.1").
|
|
58
|
-
+ var remoteAddress = connection._socket && connection._socket.remoteAddress;
|
|
59
|
-
+ if (remoteAddress) {
|
|
60
|
-
+ return remoteAddress.replace(/^::ffff:/, '');
|
|
61
|
-
+ }
|
|
62
|
-
+
|
|
63
|
-
+ // Last resort: return whatever auxConnection gave us and let the caller fail
|
|
64
|
-
+ // with a meaningful socket error rather than a silent undefined.
|
|
65
|
-
+ return auxHost;
|
|
66
|
-
+}
|
|
67
|
-
+
|
|
68
|
-
// ... (existing code) ...
|
|
69
|
-
|
|
70
|
-
- var eventConnection = new EventConnection(socket_info.host, socket_info.port, self.connection.options, eventCallback);
|
|
71
|
-
+ var eventHost = resolveEventHost(self.connection, socket_info.host);
|
|
72
|
-
+ var eventConnection = new EventConnection(eventHost, socket_info.port, self.connection.options, eventCallback);
|
package/diff
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
diff --git a/lib/wire/database.js b/lib/wire/database.js
|
|
2
|
-
index d91b9db..a9f3128 100644
|
|
3
|
-
--- a/lib/wire/database.js
|
|
4
|
-
+++ b/lib/wire/database.js
|
|
5
|
-
@@ -5,6 +5,46 @@ const Const = require('./const');
|
|
6
|
-
const EventConnection = require('./eventConnection');
|
|
7
|
-
const FbEventManager = require('./fbEventManager');
|
|
8
|
-
|
|
9
|
-
+/**
|
|
10
|
-
+ * Resolves the host to use for the auxiliary event channel.
|
|
11
|
-
+ *
|
|
12
|
-
+ * Priority:
|
|
13
|
-
+ * 1. connection.options.host – explicitly provided by the caller; known reachable.
|
|
14
|
-
+ * 2. socket_info.host – only when it is a concrete routable address
|
|
15
|
-
+ * (i.e. not "0.0.0.0" and not "::").
|
|
16
|
-
+ * 3. socket.remoteAddress – the OS-level address of the main connection socket,
|
|
17
|
-
+ * with IPv6-mapped IPv4 prefixes stripped.
|
|
18
|
-
+ *
|
|
19
|
-
+ * @param {object} connection The active database connection object.
|
|
20
|
-
+ * @param {string} auxHost The host returned by the auxConnection() call.
|
|
21
|
-
+ * @returns {string} A connectable host string.
|
|
22
|
-
+ */
|
|
23
|
-
+function resolveEventHost(connection, auxHost) {
|
|
24
|
-
+ // 1. Prefer the host the caller explicitly supplied.
|
|
25
|
-
+ if (connection.options && connection.options.host) {
|
|
26
|
-
+ return connection.options.host;
|
|
27
|
-
+ }
|
|
28
|
-
+
|
|
29
|
-
+ // 2. Use auxConnection host only when it is a real address.
|
|
30
|
-
+ var BIND_ANY = ['0.0.0.0', '::'];
|
|
31
|
-
+ if (auxHost && BIND_ANY.indexOf(auxHost) === -1) {
|
|
32
|
-
+ return auxHost;
|
|
33
|
-
+ }
|
|
34
|
-
+
|
|
35
|
-
+ // 3. Fall back to the OS-reported remote address of the main socket,
|
|
36
|
-
+ // normalising IPv6-mapped IPv4 (e.g. "::ffff:10.0.0.1" → "10.0.0.1").
|
|
37
|
-
+ var remoteAddress = connection._socket && connection._socket.remoteAddress;
|
|
38
|
-
+ if (remoteAddress) {
|
|
39
|
-
+ return remoteAddress.replace(/^::ffff:/, '');
|
|
40
|
-
+ }
|
|
41
|
-
+
|
|
42
|
-
+ // Last resort: return whatever auxConnection gave us and let the caller fail
|
|
43
|
-
+ // with a meaningful socket error rather than a silent undefined.
|
|
44
|
-
+ return auxHost;
|
|
45
|
-
+}
|
|
46
|
-
+
|
|
47
|
-
+
|
|
48
|
-
+
|
|
49
|
-
/***************************************
|
|
50
|
-
*
|
|
51
|
-
* Database
|
|
52
|
-
@@ -279,8 +319,9 @@ class Database extends Events.EventEmitter {
|
|
53
|
-
doError(err, callback);
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
+ var eventHost = resolveEventHost(self.connection, socket_info.host);
|
|
57
|
-
|
|
58
|
-
- const eventConnection = new EventConnection(socket_info.host, socket_info.port, function (err) {
|
|
59
|
-
+ const eventConnection = new EventConnection(eventHost, socket_info.port, function (err) {
|
|
60
|
-
if (err) {
|
|
61
|
-
doError(err, callback);
|
|
62
|
-
return;
|