@apocaliss92/nodelink-js 0.6.7 → 0.6.8

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/dist/index.d.cts CHANGED
@@ -2712,6 +2712,8 @@ declare class BaichuanClient extends EventEmitter<{
2712
2712
  subscribed: boolean;
2713
2713
  private keepAliveTimer;
2714
2714
  private keepAlivePingInFlight;
2715
+ private consecutiveKeepalivePingFailures;
2716
+ private static readonly KEEPALIVE_MAX_PING_FAILURES;
2715
2717
  private udpReconnectCooldownUntilMs;
2716
2718
  private udpReconnectBackoffMs;
2717
2719
  private udpReconnectLastD2cDiscAtMs;
@@ -4592,6 +4594,18 @@ declare class BaichuanRtspServer extends EventEmitter<{
4592
4594
  private readonly nativeStreamNoFrameDeadlineMs;
4593
4595
  private readonly PREBUFFER_MAX_MS;
4594
4596
  private prebuffer;
4597
+ /**
4598
+ * Hard cap on the userspace TCP send buffer for a single RTSP client. A
4599
+ * healthy consumer drains near-instantly; if this much data backs up the
4600
+ * client is dead or far too slow to keep up with the live stream.
4601
+ */
4602
+ static readonly MAX_CLIENT_BUFFERED_BYTES: number;
4603
+ /**
4604
+ * Pure backpressure decision: should the client socket be disconnected
4605
+ * because its send buffer has grown past the hard cap? Extracted so the
4606
+ * decision can be unit-tested without a live socket.
4607
+ */
4608
+ static shouldDisconnectForBackpressure(bufferedBytes: number): boolean;
4595
4609
  private static isAdtsAacFrame;
4596
4610
  private static parseAdtsSamplingInfo;
4597
4611
  /** Returns true if the raw (packed/Annex B) frame is an IDR (H.264) or IRAP (H.265). */
@@ -4971,6 +4985,7 @@ declare class BaichuanVideoStream extends EventEmitter<{
4971
4985
  private logger;
4972
4986
  private active;
4973
4987
  private videoFrameHandler;
4988
+ private clientCloseHandler;
4974
4989
  private readonly expectedStreamTypes;
4975
4990
  private activeMsgNum;
4976
4991
  private readonly cmdId;
package/dist/index.d.ts CHANGED
@@ -726,6 +726,8 @@ export declare class BaichuanClient extends EventEmitter<{
726
726
  subscribed: boolean;
727
727
  private keepAliveTimer;
728
728
  private keepAlivePingInFlight;
729
+ private consecutiveKeepalivePingFailures;
730
+ private static readonly KEEPALIVE_MAX_PING_FAILURES;
729
731
  private udpReconnectCooldownUntilMs;
730
732
  private udpReconnectBackoffMs;
731
733
  private udpReconnectLastD2cDiscAtMs;
@@ -1786,6 +1788,18 @@ export declare class BaichuanRtspServer extends EventEmitter<{
1786
1788
  private readonly nativeStreamNoFrameDeadlineMs;
1787
1789
  private readonly PREBUFFER_MAX_MS;
1788
1790
  private prebuffer;
1791
+ /**
1792
+ * Hard cap on the userspace TCP send buffer for a single RTSP client. A
1793
+ * healthy consumer drains near-instantly; if this much data backs up the
1794
+ * client is dead or far too slow to keep up with the live stream.
1795
+ */
1796
+ static readonly MAX_CLIENT_BUFFERED_BYTES: number;
1797
+ /**
1798
+ * Pure backpressure decision: should the client socket be disconnected
1799
+ * because its send buffer has grown past the hard cap? Extracted so the
1800
+ * decision can be unit-tested without a live socket.
1801
+ */
1802
+ static shouldDisconnectForBackpressure(bufferedBytes: number): boolean;
1789
1803
  private static isAdtsAacFrame;
1790
1804
  private static parseAdtsSamplingInfo;
1791
1805
  /** Returns true if the raw (packed/Annex B) frame is an IDR (H.264) or IRAP (H.265). */
@@ -2239,6 +2253,7 @@ export declare class BaichuanVideoStream extends EventEmitter<{
2239
2253
  private logger;
2240
2254
  private active;
2241
2255
  private videoFrameHandler;
2256
+ private clientCloseHandler;
2242
2257
  private readonly expectedStreamTypes;
2243
2258
  private activeMsgNum;
2244
2259
  private readonly cmdId;
package/dist/index.js CHANGED
@@ -76,7 +76,7 @@ import {
76
76
  setGlobalLogger,
77
77
  tcpReachabilityProbe,
78
78
  xmlIndicatesFloodlight
79
- } from "./chunk-T22QCNBR.js";
79
+ } from "./chunk-OJ4YR45R.js";
80
80
  import {
81
81
  ReolinkCgiApi,
82
82
  ReolinkHttpClient,
@@ -123,7 +123,7 @@ import {
123
123
  upsertXmlTag,
124
124
  xmlEscape,
125
125
  zipDirectory
126
- } from "./chunk-IQVVVSXO.js";
126
+ } from "./chunk-27ZKJZFH.js";
127
127
  import {
128
128
  AesStreamDecryptor,
129
129
  BC_AES_IV,
@@ -297,7 +297,7 @@ import {
297
297
  parseBcMedia,
298
298
  splitAnnexBToNalPayloads,
299
299
  splitAnnexBToNalPayloads2
300
- } from "./chunk-MZUSWKF3.js";
300
+ } from "./chunk-4LZABN6I.js";
301
301
 
302
302
  // src/reolink/baichuan/HlsSessionManager.ts
303
303
  var withTimeout = async (p, ms, label) => {
@@ -8898,6 +8898,17 @@ function createEmailPushServer(params) {
8898
8898
  disabledCommands: config.requireAuth ? [] : ["AUTH"],
8899
8899
  allowInsecureAuth: !config.tls,
8900
8900
  size: config.maxMessageBytes,
8901
+ // Bound concurrent SMTP sessions. Cameras deliver one message and hang
8902
+ // up, so real fan-in is tiny; this caps file-descriptor growth if a
8903
+ // batch of half-open sessions ever piles up (default is UNLIMITED) and
8904
+ // keeps the intake from contributing to a process-wide EMFILE.
8905
+ maxClients: 50,
8906
+ // Pin the reap timers explicitly (these match the smtp-server defaults,
8907
+ // but making them visible guards against a future default change): a
8908
+ // battery camera that powers off mid-delivery leaves a half-open socket
8909
+ // that is reclaimed after socketTimeout instead of lingering for days.
8910
+ socketTimeout: 6e4,
8911
+ closeTimeout: 3e4,
8901
8912
  // smtp-server invokes its internal logger as
8902
8913
  // logger.info(metadata, formatString, ...args)
8903
8914
  // where `metadata` is an opaque session/connection object and
@@ -9024,7 +9035,24 @@ function createEmailPushServer(params) {
9024
9035
  });
9025
9036
  next.on("error", (err) => {
9026
9037
  status.lastErrorMessage = err.message;
9027
- log.error(`Email push server error: ${err.message}`);
9038
+ log.error(`Email push server error: ${err.code ?? ""} ${err.message}`);
9039
+ const netServer = next.server;
9040
+ if (server === next && netServer && netServer.listening === false) {
9041
+ status.running = false;
9042
+ setTimeout(() => {
9043
+ if (server !== next) return;
9044
+ try {
9045
+ next.listen(config.port, config.bindHost, () => {
9046
+ status.running = true;
9047
+ log.warn(
9048
+ `Email push SMTP re-listened on ${config.bindHost}:${config.port} after error`
9049
+ );
9050
+ });
9051
+ } catch (e) {
9052
+ log.error(`Email push re-listen failed: ${e.message}`);
9053
+ }
9054
+ }, 5e3).unref?.();
9055
+ }
9028
9056
  });
9029
9057
  await new Promise((resolve, reject) => {
9030
9058
  next.listen(config.port, config.bindHost, () => {