@push.rocks/smartproxy 4.2.3 → 4.2.6

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.
@@ -1,6 +1,7 @@
1
1
  export * from './classes.iptablesproxy.js';
2
2
  export * from './classes.networkproxy.js';
3
- export * from './classes.pp.portproxy.js';
4
3
  export * from './classes.port80handler.js';
5
4
  export * from './classes.sslredirect.js';
5
+ export * from './classes.pp.portproxy.js';
6
6
  export * from './classes.pp.snihandler.js';
7
+ export * from './classes.pp.interfaces.js';
package/dist_ts/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  export * from './classes.iptablesproxy.js';
2
2
  export * from './classes.networkproxy.js';
3
- export * from './classes.pp.portproxy.js';
4
3
  export * from './classes.port80handler.js';
5
4
  export * from './classes.sslredirect.js';
5
+ export * from './classes.pp.portproxy.js';
6
6
  export * from './classes.pp.snihandler.js';
7
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLDRCQUE0QixDQUFDO0FBQzNDLGNBQWMsMkJBQTJCLENBQUM7QUFDMUMsY0FBYywyQkFBMkIsQ0FBQztBQUMxQyxjQUFjLDRCQUE0QixDQUFDO0FBQzNDLGNBQWMsMEJBQTBCLENBQUM7QUFDekMsY0FBYyw0QkFBNEIsQ0FBQyJ9
7
+ export * from './classes.pp.interfaces.js';
8
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLDRCQUE0QixDQUFDO0FBQzNDLGNBQWMsMkJBQTJCLENBQUM7QUFDMUMsY0FBYyw0QkFBNEIsQ0FBQztBQUMzQyxjQUFjLDBCQUEwQixDQUFDO0FBQ3pDLGNBQWMsMkJBQTJCLENBQUM7QUFDMUMsY0FBYyw0QkFBNEIsQ0FBQztBQUMzQyxjQUFjLDRCQUE0QixDQUFDIn0=
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@push.rocks/smartproxy",
3
- "version": "4.2.3",
3
+ "version": "4.2.6",
4
4
  "private": false,
5
5
  "description": "A powerful proxy package that effectively handles high traffic, with features such as SSL/TLS support, port proxying, WebSocket handling, dynamic routing with authentication options, and automatic ACME certificate management.",
6
6
  "main": "dist_ts/index.js",
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@push.rocks/smartproxy',
6
- version: '4.2.3',
6
+ version: '4.2.6',
7
7
  description: 'A powerful proxy package that effectively handles high traffic, with features such as SSL/TLS support, port proxying, WebSocket handling, dynamic routing with authentication options, and automatic ACME certificate management.'
8
8
  }
@@ -1,6 +1,6 @@
1
1
  import * as plugins from './plugins.js';
2
2
  import { ProxyRouter } from './classes.router.js';
3
- import { AcmeCertManager, CertManagerEvents } from './classes.port80handler.js';
3
+ import { Port80Handler, Port80HandlerEvents, type IDomainOptions } from './classes.port80handler.js';
4
4
  import * as fs from 'fs';
5
5
  import * as path from 'path';
6
6
  import { fileURLToPath } from 'url';
@@ -72,8 +72,8 @@ export class NetworkProxy {
72
72
  private defaultCertificates: { key: string; cert: string };
73
73
  private certificateCache: Map<string, { key: string; cert: string; expires?: Date }> = new Map();
74
74
 
75
- // ACME certificate manager
76
- private certManager: AcmeCertManager | null = null;
75
+ // Port80Handler for certificate management
76
+ private port80Handler: Port80Handler | null = null;
77
77
  private certificateStoreDir: string;
78
78
 
79
79
  // New connection pool for backend connections
@@ -375,16 +375,16 @@ export class NetworkProxy {
375
375
  }
376
376
 
377
377
  /**
378
- * Initializes the ACME certificate manager for automatic certificate issuance
378
+ * Initializes the Port80Handler for ACME certificate management
379
379
  * @private
380
380
  */
381
- private async initializeAcmeManager(): Promise<void> {
381
+ private async initializePort80Handler(): Promise<void> {
382
382
  if (!this.options.acme.enabled) {
383
383
  return;
384
384
  }
385
385
 
386
386
  // Create certificate manager
387
- this.certManager = new AcmeCertManager({
387
+ this.port80Handler = new Port80Handler({
388
388
  port: this.options.acme.port,
389
389
  contactEmail: this.options.acme.contactEmail,
390
390
  useProduction: this.options.acme.useProduction,
@@ -394,32 +394,32 @@ export class NetworkProxy {
394
394
  });
395
395
 
396
396
  // Register event handlers
397
- this.certManager.on(CertManagerEvents.CERTIFICATE_ISSUED, this.handleCertificateIssued.bind(this));
398
- this.certManager.on(CertManagerEvents.CERTIFICATE_RENEWED, this.handleCertificateIssued.bind(this));
399
- this.certManager.on(CertManagerEvents.CERTIFICATE_FAILED, this.handleCertificateFailed.bind(this));
400
- this.certManager.on(CertManagerEvents.CERTIFICATE_EXPIRING, (data) => {
397
+ this.port80Handler.on(Port80HandlerEvents.CERTIFICATE_ISSUED, this.handleCertificateIssued.bind(this));
398
+ this.port80Handler.on(Port80HandlerEvents.CERTIFICATE_RENEWED, this.handleCertificateIssued.bind(this));
399
+ this.port80Handler.on(Port80HandlerEvents.CERTIFICATE_FAILED, this.handleCertificateFailed.bind(this));
400
+ this.port80Handler.on(Port80HandlerEvents.CERTIFICATE_EXPIRING, (data) => {
401
401
  this.log('info', `Certificate for ${data.domain} expires in ${data.daysRemaining} days`);
402
402
  });
403
403
 
404
- // Start the manager
404
+ // Start the handler
405
405
  try {
406
- await this.certManager.start();
407
- this.log('info', `ACME Certificate Manager started on port ${this.options.acme.port}`);
406
+ await this.port80Handler.start();
407
+ this.log('info', `Port80Handler started on port ${this.options.acme.port}`);
408
408
 
409
409
  // Add domains from proxy configs
410
- this.registerDomainsWithAcmeManager();
410
+ this.registerDomainsWithPort80Handler();
411
411
  } catch (error) {
412
- this.log('error', `Failed to start ACME Certificate Manager: ${error}`);
413
- this.certManager = null;
412
+ this.log('error', `Failed to start Port80Handler: ${error}`);
413
+ this.port80Handler = null;
414
414
  }
415
415
  }
416
416
 
417
417
  /**
418
- * Registers domains from proxy configs with the ACME manager
418
+ * Registers domains from proxy configs with the Port80Handler
419
419
  * @private
420
420
  */
421
- private registerDomainsWithAcmeManager(): void {
422
- if (!this.certManager) return;
421
+ private registerDomainsWithPort80Handler(): void {
422
+ if (!this.port80Handler) return;
423
423
 
424
424
  // Get all hostnames from proxy configs
425
425
  this.proxyConfigs.forEach(config => {
@@ -461,26 +461,32 @@ export class NetworkProxy {
461
461
  this.log('warn', `Failed to extract expiry date from certificate for ${hostname}`);
462
462
  }
463
463
 
464
- // Update the certificate in the manager
465
- this.certManager.setCertificate(hostname, cert, key, expiryDate);
464
+ // Update the certificate in the handler
465
+ this.port80Handler.setCertificate(hostname, cert, key, expiryDate);
466
466
 
467
467
  // Also update our own certificate cache
468
468
  this.updateCertificateCache(hostname, cert, key, expiryDate);
469
469
 
470
470
  this.log('info', `Loaded existing certificate for ${hostname}`);
471
471
  } else {
472
- // Register the domain for certificate issuance
473
- this.certManager.addDomain(hostname);
472
+ // Register the domain for certificate issuance with new domain options format
473
+ const domainOptions: IDomainOptions = {
474
+ domainName: hostname,
475
+ sslRedirect: true,
476
+ acmeMaintenance: true
477
+ };
478
+
479
+ this.port80Handler.addDomain(domainOptions);
474
480
  this.log('info', `Registered domain for ACME certificate issuance: ${hostname}`);
475
481
  }
476
482
  } catch (error) {
477
- this.log('error', `Error registering domain ${hostname} with ACME manager: ${error}`);
483
+ this.log('error', `Error registering domain ${hostname} with Port80Handler: ${error}`);
478
484
  }
479
485
  });
480
486
  }
481
487
 
482
488
  /**
483
- * Handles newly issued or renewed certificates from ACME manager
489
+ * Handles newly issued or renewed certificates from Port80Handler
484
490
  * @private
485
491
  */
486
492
  private handleCertificateIssued(data: { domain: string; certificate: string; privateKey: string; expiryDate: Date }): void {
@@ -556,13 +562,21 @@ export class NetworkProxy {
556
562
  }
557
563
 
558
564
  // Check if we should trigger certificate issuance
559
- if (this.options.acme?.enabled && this.certManager && !domain.includes('*')) {
565
+ if (this.options.acme?.enabled && this.port80Handler && !domain.includes('*')) {
560
566
  // Check if this domain is already registered
561
- const certData = this.certManager.getCertificate(domain);
567
+ const certData = this.port80Handler.getCertificate(domain);
562
568
 
563
569
  if (!certData) {
564
570
  this.log('info', `No certificate found for ${domain}, registering for issuance`);
565
- this.certManager.addDomain(domain);
571
+
572
+ // Register with new domain options format
573
+ const domainOptions: IDomainOptions = {
574
+ domainName: domain,
575
+ sslRedirect: true,
576
+ acmeMaintenance: true
577
+ };
578
+
579
+ this.port80Handler.addDomain(domainOptions);
566
580
  }
567
581
  }
568
582
 
@@ -587,9 +601,9 @@ export class NetworkProxy {
587
601
  public async start(): Promise<void> {
588
602
  this.startTime = Date.now();
589
603
 
590
- // Initialize ACME certificate manager if enabled
604
+ // Initialize Port80Handler if enabled
591
605
  if (this.options.acme.enabled) {
592
- await this.initializeAcmeManager();
606
+ await this.initializePort80Handler();
593
607
  }
594
608
 
595
609
  // Create the HTTPS server
@@ -1588,13 +1602,13 @@ export class NetworkProxy {
1588
1602
  }
1589
1603
  this.connectionPool.clear();
1590
1604
 
1591
- // Stop ACME certificate manager if it's running
1592
- if (this.certManager) {
1605
+ // Stop Port80Handler if it's running
1606
+ if (this.port80Handler) {
1593
1607
  try {
1594
- await this.certManager.stop();
1595
- this.log('info', 'ACME Certificate Manager stopped');
1608
+ await this.port80Handler.stop();
1609
+ this.log('info', 'Port80Handler stopped');
1596
1610
  } catch (error) {
1597
- this.log('error', 'Error stopping ACME Certificate Manager', error);
1611
+ this.log('error', 'Error stopping Port80Handler', error);
1598
1612
  }
1599
1613
  }
1600
1614
 
@@ -1619,8 +1633,8 @@ export class NetworkProxy {
1619
1633
  return false;
1620
1634
  }
1621
1635
 
1622
- if (!this.certManager) {
1623
- this.log('error', 'ACME certificate manager is not initialized');
1636
+ if (!this.port80Handler) {
1637
+ this.log('error', 'Port80Handler is not initialized');
1624
1638
  return false;
1625
1639
  }
1626
1640
 
@@ -1631,7 +1645,14 @@ export class NetworkProxy {
1631
1645
  }
1632
1646
 
1633
1647
  try {
1634
- this.certManager.addDomain(domain);
1648
+ // Use the new domain options format
1649
+ const domainOptions: IDomainOptions = {
1650
+ domainName: domain,
1651
+ sslRedirect: true,
1652
+ acmeMaintenance: true
1653
+ };
1654
+
1655
+ this.port80Handler.addDomain(domainOptions);
1635
1656
  this.log('info', `Certificate request submitted for domain: ${domain}`);
1636
1657
  return true;
1637
1658
  } catch (error) {