@push.rocks/smartproxy 19.3.2 → 19.3.3
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_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/forwarding/factory/forwarding-factory.js +29 -1
- package/dist_ts/http/index.d.ts +1 -3
- package/dist_ts/http/index.js +4 -10
- package/dist_ts/http/models/http-types.d.ts +4 -91
- package/dist_ts/http/models/http-types.js +5 -60
- package/dist_ts/http/router/proxy-router.d.ts +1 -1
- package/dist_ts/http/router/route-router.d.ts +1 -1
- package/dist_ts/index.d.ts +9 -7
- package/dist_ts/index.js +10 -7
- package/dist_ts/proxies/{network-proxy → http-proxy}/certificate-manager.d.ts +2 -2
- package/dist_ts/proxies/{network-proxy → http-proxy}/certificate-manager.js +1 -1
- package/dist_ts/proxies/{network-proxy → http-proxy}/connection-pool.d.ts +2 -2
- package/dist_ts/proxies/http-proxy/connection-pool.js +210 -0
- package/dist_ts/proxies/http-proxy/context-creator.js +108 -0
- package/dist_ts/proxies/{network-proxy → http-proxy}/function-cache.js +1 -1
- package/dist_ts/proxies/http-proxy/handlers/index.d.ts +5 -0
- package/dist_ts/proxies/http-proxy/handlers/index.js +6 -0
- package/dist_ts/proxies/http-proxy/handlers/redirect-handler.d.ts +18 -0
- package/dist_ts/proxies/http-proxy/handlers/redirect-handler.js +78 -0
- package/dist_ts/proxies/http-proxy/handlers/static-handler.d.ts +19 -0
- package/dist_ts/proxies/http-proxy/handlers/static-handler.js +203 -0
- package/dist_ts/proxies/{network-proxy/network-proxy.d.ts → http-proxy/http-proxy.d.ts} +10 -9
- package/dist_ts/proxies/{network-proxy/network-proxy.js → http-proxy/http-proxy.js} +13 -12
- package/dist_ts/proxies/{network-proxy → http-proxy}/http-request-handler.js +1 -1
- package/dist_ts/proxies/http-proxy/http2-request-handler.js +201 -0
- package/dist_ts/proxies/{network-proxy → http-proxy}/index.d.ts +2 -2
- package/dist_ts/proxies/http-proxy/index.js +12 -0
- package/dist_ts/proxies/http-proxy/models/http-types.d.ts +119 -0
- package/dist_ts/proxies/http-proxy/models/http-types.js +112 -0
- package/dist_ts/proxies/http-proxy/models/index.d.ts +5 -0
- package/dist_ts/proxies/http-proxy/models/index.js +6 -0
- package/dist_ts/proxies/{network-proxy → http-proxy}/models/types.d.ts +2 -2
- package/dist_ts/proxies/http-proxy/models/types.js +276 -0
- package/dist_ts/proxies/{network-proxy → http-proxy}/request-handler.d.ts +3 -3
- package/dist_ts/proxies/{network-proxy → http-proxy}/request-handler.js +2 -2
- package/dist_ts/proxies/http-proxy/security-manager.js +255 -0
- package/dist_ts/proxies/{network-proxy → http-proxy}/websocket-handler.d.ts +3 -3
- package/dist_ts/proxies/{network-proxy → http-proxy}/websocket-handler.js +2 -2
- package/dist_ts/proxies/index.d.ts +5 -5
- package/dist_ts/proxies/index.js +5 -5
- package/dist_ts/proxies/smart-proxy/certificate-manager.d.ts +4 -4
- package/dist_ts/proxies/smart-proxy/certificate-manager.js +11 -11
- package/dist_ts/proxies/smart-proxy/http-proxy-bridge.d.ts +41 -0
- package/dist_ts/proxies/smart-proxy/http-proxy-bridge.js +121 -0
- package/dist_ts/proxies/smart-proxy/index.d.ts +2 -1
- package/dist_ts/proxies/smart-proxy/index.js +4 -2
- package/dist_ts/proxies/smart-proxy/models/interfaces.d.ts +2 -2
- package/dist_ts/proxies/smart-proxy/port-manager.js +3 -3
- package/dist_ts/proxies/smart-proxy/route-connection-handler.d.ts +3 -3
- package/dist_ts/proxies/smart-proxy/route-connection-handler.js +24 -265
- package/dist_ts/proxies/smart-proxy/smart-proxy.d.ts +1 -1
- package/dist_ts/proxies/smart-proxy/smart-proxy.js +25 -25
- package/dist_ts/routing/index.d.ts +5 -0
- package/dist_ts/routing/index.js +8 -0
- package/dist_ts/routing/models/http-types.d.ts +6 -0
- package/dist_ts/routing/models/http-types.js +7 -0
- package/dist_ts/routing/router/index.d.ts +8 -0
- package/dist_ts/routing/router/index.js +7 -0
- package/dist_ts/{classes.router.d.ts → routing/router/proxy-router.d.ts} +14 -11
- package/dist_ts/{classes.router.js → routing/router/proxy-router.js} +2 -2
- package/dist_ts/routing/router/route-router.d.ts +108 -0
- package/dist_ts/routing/router/route-router.js +393 -0
- package/package.json +1 -1
- package/readme.md +12 -12
- package/readme.plan.md +152 -257
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/forwarding/factory/forwarding-factory.ts +28 -0
- package/ts/index.ts +13 -9
- package/ts/proxies/{network-proxy → http-proxy}/certificate-manager.ts +2 -2
- package/ts/proxies/{network-proxy → http-proxy}/connection-pool.ts +2 -2
- package/ts/proxies/http-proxy/handlers/index.ts +6 -0
- package/ts/proxies/http-proxy/handlers/redirect-handler.ts +105 -0
- package/ts/proxies/http-proxy/handlers/static-handler.ts +251 -0
- package/ts/proxies/{network-proxy/network-proxy.ts → http-proxy/http-proxy.ts} +15 -14
- package/ts/proxies/{network-proxy → http-proxy}/index.ts +3 -3
- package/ts/proxies/http-proxy/models/http-types.ts +165 -0
- package/ts/proxies/http-proxy/models/index.ts +5 -0
- package/ts/proxies/{network-proxy → http-proxy}/models/types.ts +2 -2
- package/ts/proxies/{network-proxy → http-proxy}/request-handler.ts +3 -3
- package/ts/proxies/{network-proxy → http-proxy}/websocket-handler.ts +3 -3
- package/ts/proxies/index.ts +7 -7
- package/ts/proxies/smart-proxy/certificate-manager.ts +10 -10
- package/ts/proxies/smart-proxy/{network-proxy-bridge.ts → http-proxy-bridge.ts} +44 -44
- package/ts/proxies/smart-proxy/index.ts +4 -1
- package/ts/proxies/smart-proxy/models/interfaces.ts +3 -3
- package/ts/proxies/smart-proxy/port-manager.ts +2 -2
- package/ts/proxies/smart-proxy/route-connection-handler.ts +23 -307
- package/ts/proxies/smart-proxy/smart-proxy.ts +25 -25
- package/ts/routing/index.ts +9 -0
- package/ts/routing/models/http-types.ts +6 -0
- package/ts/{http → routing}/router/proxy-router.ts +1 -1
- package/ts/{http → routing}/router/route-router.ts +1 -1
- package/dist_ts/certificate/acme/acme-factory.d.ts +0 -17
- package/dist_ts/certificate/acme/acme-factory.js +0 -40
- package/dist_ts/certificate/acme/challenge-handler.d.ts +0 -44
- package/dist_ts/certificate/acme/challenge-handler.js +0 -92
- package/dist_ts/certificate/acme/index.d.ts +0 -4
- package/dist_ts/certificate/acme/index.js +0 -5
- package/dist_ts/certificate/certificate-manager.d.ts +0 -150
- package/dist_ts/certificate/certificate-manager.js +0 -505
- package/dist_ts/certificate/events/certificate-events.d.ts +0 -33
- package/dist_ts/certificate/events/certificate-events.js +0 -38
- package/dist_ts/certificate/events/simplified-events.d.ts +0 -56
- package/dist_ts/certificate/events/simplified-events.js +0 -13
- package/dist_ts/certificate/index.d.ts +0 -30
- package/dist_ts/certificate/index.js +0 -37
- package/dist_ts/certificate/models/certificate-errors.d.ts +0 -69
- package/dist_ts/certificate/models/certificate-errors.js +0 -141
- package/dist_ts/certificate/models/certificate-strategy.d.ts +0 -60
- package/dist_ts/certificate/models/certificate-strategy.js +0 -73
- package/dist_ts/certificate/models/certificate-types.d.ts +0 -97
- package/dist_ts/certificate/models/certificate-types.js +0 -2
- package/dist_ts/certificate/providers/cert-provisioner.d.ts +0 -119
- package/dist_ts/certificate/providers/cert-provisioner.js +0 -422
- package/dist_ts/certificate/providers/index.d.ts +0 -4
- package/dist_ts/certificate/providers/index.js +0 -5
- package/dist_ts/certificate/simplified-certificate-manager.d.ts +0 -150
- package/dist_ts/certificate/simplified-certificate-manager.js +0 -501
- package/dist_ts/certificate/storage/file-storage.d.ts +0 -66
- package/dist_ts/certificate/storage/file-storage.js +0 -194
- package/dist_ts/certificate/storage/index.d.ts +0 -4
- package/dist_ts/certificate/storage/index.js +0 -5
- package/dist_ts/certificate/utils/certificate-helpers.d.ts +0 -17
- package/dist_ts/certificate/utils/certificate-helpers.js +0 -45
- package/dist_ts/classes.iptablesproxy.d.ts +0 -112
- package/dist_ts/classes.iptablesproxy.js +0 -765
- package/dist_ts/classes.networkproxy.d.ts +0 -243
- package/dist_ts/classes.networkproxy.js +0 -1424
- package/dist_ts/classes.nftablesproxy.d.ts +0 -219
- package/dist_ts/classes.nftablesproxy.js +0 -1542
- package/dist_ts/classes.port80handler.d.ts +0 -215
- package/dist_ts/classes.port80handler.js +0 -736
- package/dist_ts/classes.portproxy.d.ts +0 -171
- package/dist_ts/classes.portproxy.js +0 -1802
- package/dist_ts/classes.pp.acmemanager.d.ts +0 -34
- package/dist_ts/classes.pp.acmemanager.js +0 -123
- package/dist_ts/classes.pp.connectionhandler.d.ts +0 -39
- package/dist_ts/classes.pp.connectionhandler.js +0 -754
- package/dist_ts/classes.pp.connectionmanager.d.ts +0 -78
- package/dist_ts/classes.pp.connectionmanager.js +0 -378
- package/dist_ts/classes.pp.domainconfigmanager.d.ts +0 -55
- package/dist_ts/classes.pp.domainconfigmanager.js +0 -103
- package/dist_ts/classes.pp.interfaces.d.ts +0 -133
- package/dist_ts/classes.pp.interfaces.js +0 -2
- package/dist_ts/classes.pp.networkproxybridge.d.ts +0 -57
- package/dist_ts/classes.pp.networkproxybridge.js +0 -306
- package/dist_ts/classes.pp.portproxy.d.ts +0 -64
- package/dist_ts/classes.pp.portproxy.js +0 -567
- package/dist_ts/classes.pp.portrangemanager.d.ts +0 -56
- package/dist_ts/classes.pp.portrangemanager.js +0 -179
- package/dist_ts/classes.pp.securitymanager.d.ts +0 -47
- package/dist_ts/classes.pp.securitymanager.js +0 -126
- package/dist_ts/classes.pp.snihandler.d.ts +0 -153
- package/dist_ts/classes.pp.snihandler.js +0 -1053
- package/dist_ts/classes.pp.timeoutmanager.d.ts +0 -47
- package/dist_ts/classes.pp.timeoutmanager.js +0 -154
- package/dist_ts/classes.pp.tlsalert.d.ts +0 -149
- package/dist_ts/classes.pp.tlsalert.js +0 -225
- package/dist_ts/classes.pp.tlsmanager.d.ts +0 -57
- package/dist_ts/classes.pp.tlsmanager.js +0 -132
- package/dist_ts/classes.snihandler.d.ts +0 -198
- package/dist_ts/classes.snihandler.js +0 -1210
- package/dist_ts/classes.sslredirect.d.ts +0 -8
- package/dist_ts/classes.sslredirect.js +0 -28
- package/dist_ts/common/acmeFactory.d.ts +0 -9
- package/dist_ts/common/acmeFactory.js +0 -20
- package/dist_ts/common/port80-adapter.d.ts +0 -11
- package/dist_ts/common/port80-adapter.js +0 -87
- package/dist_ts/examples/forwarding-example.d.ts +0 -1
- package/dist_ts/examples/forwarding-example.js +0 -96
- package/dist_ts/forwarding/config/domain-config.d.ts +0 -12
- package/dist_ts/forwarding/config/domain-config.js +0 -12
- package/dist_ts/forwarding/config/domain-manager.d.ts +0 -86
- package/dist_ts/forwarding/config/domain-manager.js +0 -242
- package/dist_ts/helpers.certificates.d.ts +0 -5
- package/dist_ts/helpers.certificates.js +0 -23
- package/dist_ts/http/port80/acme-interfaces.d.ts +0 -108
- package/dist_ts/http/port80/acme-interfaces.js +0 -51
- package/dist_ts/http/port80/challenge-responder.d.ts +0 -53
- package/dist_ts/http/port80/challenge-responder.js +0 -203
- package/dist_ts/http/port80/index.d.ts +0 -6
- package/dist_ts/http/port80/index.js +0 -9
- package/dist_ts/http/port80/port80-handler.d.ts +0 -136
- package/dist_ts/http/port80/port80-handler.js +0 -592
- package/dist_ts/http/redirects/index.d.ts +0 -4
- package/dist_ts/http/redirects/index.js +0 -5
- package/dist_ts/networkproxy/classes.np.certificatemanager.d.ts +0 -77
- package/dist_ts/networkproxy/classes.np.certificatemanager.js +0 -372
- package/dist_ts/networkproxy/classes.np.connectionpool.d.ts +0 -47
- package/dist_ts/networkproxy/classes.np.connectionpool.js +0 -210
- package/dist_ts/networkproxy/classes.np.networkproxy.d.ts +0 -118
- package/dist_ts/networkproxy/classes.np.networkproxy.js +0 -387
- package/dist_ts/networkproxy/classes.np.requesthandler.d.ts +0 -56
- package/dist_ts/networkproxy/classes.np.requesthandler.js +0 -393
- package/dist_ts/networkproxy/classes.np.types.d.ts +0 -83
- package/dist_ts/networkproxy/classes.np.types.js +0 -35
- package/dist_ts/networkproxy/classes.np.websockethandler.d.ts +0 -38
- package/dist_ts/networkproxy/classes.np.websockethandler.js +0 -188
- package/dist_ts/networkproxy/index.d.ts +0 -1
- package/dist_ts/networkproxy/index.js +0 -4
- package/dist_ts/nfttablesproxy/classes.nftablesproxy.d.ts +0 -219
- package/dist_ts/nfttablesproxy/classes.nftablesproxy.js +0 -1542
- package/dist_ts/port80handler/classes.port80handler.d.ts +0 -10
- package/dist_ts/port80handler/classes.port80handler.js +0 -16
- package/dist_ts/proxies/network-proxy/connection-pool.js +0 -210
- package/dist_ts/proxies/network-proxy/context-creator.js +0 -108
- package/dist_ts/proxies/network-proxy/http2-request-handler.js +0 -201
- package/dist_ts/proxies/network-proxy/index.js +0 -12
- package/dist_ts/proxies/network-proxy/models/index.d.ts +0 -4
- package/dist_ts/proxies/network-proxy/models/index.js +0 -5
- package/dist_ts/proxies/network-proxy/models/types.js +0 -276
- package/dist_ts/proxies/network-proxy/security-manager.js +0 -255
- package/dist_ts/proxies/network-proxy/simplified-certificate-bridge.d.ts +0 -48
- package/dist_ts/proxies/network-proxy/simplified-certificate-bridge.js +0 -76
- package/dist_ts/proxies/smart-proxy/connection-handler.d.ts +0 -39
- package/dist_ts/proxies/smart-proxy/connection-handler.js +0 -894
- package/dist_ts/proxies/smart-proxy/domain-config-manager.d.ts +0 -110
- package/dist_ts/proxies/smart-proxy/domain-config-manager.js +0 -386
- package/dist_ts/proxies/smart-proxy/legacy-smart-proxy.d.ts +0 -168
- package/dist_ts/proxies/smart-proxy/legacy-smart-proxy.js +0 -642
- package/dist_ts/proxies/smart-proxy/models/simplified-smartproxy-config.d.ts +0 -65
- package/dist_ts/proxies/smart-proxy/models/simplified-smartproxy-config.js +0 -31
- package/dist_ts/proxies/smart-proxy/models/smartproxy-options.d.ts +0 -102
- package/dist_ts/proxies/smart-proxy/models/smartproxy-options.js +0 -73
- package/dist_ts/proxies/smart-proxy/network-proxy-bridge.d.ts +0 -41
- package/dist_ts/proxies/smart-proxy/network-proxy-bridge.js +0 -121
- package/dist_ts/proxies/smart-proxy/port-range-manager.d.ts +0 -56
- package/dist_ts/proxies/smart-proxy/port-range-manager.js +0 -176
- package/dist_ts/proxies/smart-proxy/route-helpers/index.d.ts +0 -9
- package/dist_ts/proxies/smart-proxy/route-helpers/index.js +0 -11
- package/dist_ts/proxies/smart-proxy/route-helpers.d.ts +0 -7
- package/dist_ts/proxies/smart-proxy/route-helpers.js +0 -9
- package/dist_ts/proxies/smart-proxy/simplified-smart-proxy.d.ts +0 -41
- package/dist_ts/proxies/smart-proxy/simplified-smart-proxy.js +0 -132
- package/dist_ts/proxies/smart-proxy/utils/route-migration-utils.d.ts +0 -51
- package/dist_ts/proxies/smart-proxy/utils/route-migration-utils.js +0 -124
- package/dist_ts/redirect/classes.redirect.d.ts +0 -96
- package/dist_ts/redirect/classes.redirect.js +0 -194
- package/dist_ts/smartproxy/classes.pp.certprovisioner.d.ts +0 -54
- package/dist_ts/smartproxy/classes.pp.certprovisioner.js +0 -179
- package/dist_ts/smartproxy/classes.pp.connectionhandler.d.ts +0 -39
- package/dist_ts/smartproxy/classes.pp.connectionhandler.js +0 -894
- package/dist_ts/smartproxy/classes.pp.connectionmanager.d.ts +0 -78
- package/dist_ts/smartproxy/classes.pp.connectionmanager.js +0 -378
- package/dist_ts/smartproxy/classes.pp.domainconfigmanager.d.ts +0 -94
- package/dist_ts/smartproxy/classes.pp.domainconfigmanager.js +0 -255
- package/dist_ts/smartproxy/classes.pp.interfaces.d.ts +0 -103
- package/dist_ts/smartproxy/classes.pp.interfaces.js +0 -2
- package/dist_ts/smartproxy/classes.pp.networkproxybridge.d.ts +0 -62
- package/dist_ts/smartproxy/classes.pp.networkproxybridge.js +0 -316
- package/dist_ts/smartproxy/classes.pp.portrangemanager.d.ts +0 -56
- package/dist_ts/smartproxy/classes.pp.portrangemanager.js +0 -176
- package/dist_ts/smartproxy/classes.pp.securitymanager.d.ts +0 -64
- package/dist_ts/smartproxy/classes.pp.securitymanager.js +0 -149
- package/dist_ts/smartproxy/classes.pp.snihandler.d.ts +0 -153
- package/dist_ts/smartproxy/classes.pp.snihandler.js +0 -1053
- package/dist_ts/smartproxy/classes.pp.timeoutmanager.d.ts +0 -47
- package/dist_ts/smartproxy/classes.pp.timeoutmanager.js +0 -154
- package/dist_ts/smartproxy/classes.pp.tlsalert.d.ts +0 -149
- package/dist_ts/smartproxy/classes.pp.tlsalert.js +0 -225
- package/dist_ts/smartproxy/classes.pp.tlsmanager.d.ts +0 -57
- package/dist_ts/smartproxy/classes.pp.tlsmanager.js +0 -132
- package/dist_ts/smartproxy/classes.smartproxy.d.ts +0 -63
- package/dist_ts/smartproxy/classes.smartproxy.js +0 -521
- package/dist_ts/smartproxy/forwarding/domain-config.d.ts +0 -12
- package/dist_ts/smartproxy/forwarding/domain-config.js +0 -12
- package/dist_ts/smartproxy/forwarding/domain-manager.d.ts +0 -86
- package/dist_ts/smartproxy/forwarding/domain-manager.js +0 -241
- package/dist_ts/smartproxy/forwarding/forwarding.factory.d.ts +0 -24
- package/dist_ts/smartproxy/forwarding/forwarding.factory.js +0 -137
- package/dist_ts/smartproxy/forwarding/forwarding.handler.d.ts +0 -55
- package/dist_ts/smartproxy/forwarding/forwarding.handler.js +0 -94
- package/dist_ts/smartproxy/forwarding/http.handler.d.ts +0 -25
- package/dist_ts/smartproxy/forwarding/http.handler.js +0 -123
- package/dist_ts/smartproxy/forwarding/https-passthrough.handler.d.ts +0 -24
- package/dist_ts/smartproxy/forwarding/https-passthrough.handler.js +0 -154
- package/dist_ts/smartproxy/forwarding/https-terminate-to-http.handler.d.ts +0 -36
- package/dist_ts/smartproxy/forwarding/https-terminate-to-http.handler.js +0 -229
- package/dist_ts/smartproxy/forwarding/https-terminate-to-https.handler.d.ts +0 -35
- package/dist_ts/smartproxy/forwarding/https-terminate-to-https.handler.js +0 -254
- package/dist_ts/smartproxy/forwarding/index.d.ts +0 -16
- package/dist_ts/smartproxy/forwarding/index.js +0 -23
- package/dist_ts/smartproxy/types/forwarding.types.d.ts +0 -104
- package/dist_ts/smartproxy/types/forwarding.types.js +0 -50
- package/dist_ts/smartproxy.classes.networkproxy.d.ts +0 -31
- package/dist_ts/smartproxy.classes.networkproxy.js +0 -305
- package/dist_ts/smartproxy.classes.router.d.ts +0 -13
- package/dist_ts/smartproxy.classes.router.js +0 -33
- package/dist_ts/smartproxy.classes.sslredirect.d.ts +0 -8
- package/dist_ts/smartproxy.classes.sslredirect.js +0 -28
- package/dist_ts/smartproxy.helpers.certificates.d.ts +0 -5
- package/dist_ts/smartproxy.helpers.certificates.js +0 -23
- package/dist_ts/smartproxy.plugins.d.ts +0 -18
- package/dist_ts/smartproxy.plugins.js +0 -23
- package/dist_ts/smartproxy.portproxy.d.ts +0 -26
- package/dist_ts/smartproxy.portproxy.js +0 -295
- package/ts/http/index.ts +0 -16
- package/ts/http/models/http-types.ts +0 -108
- package/ts/http/redirects/index.ts +0 -3
- package/ts/proxies/network-proxy/models/index.ts +0 -4
- package/ts/redirect/classes.redirect.ts +0 -295
- /package/dist_ts/proxies/{network-proxy → http-proxy}/context-creator.d.ts +0 -0
- /package/dist_ts/proxies/{network-proxy → http-proxy}/function-cache.d.ts +0 -0
- /package/dist_ts/proxies/{network-proxy → http-proxy}/http-request-handler.d.ts +0 -0
- /package/dist_ts/proxies/{network-proxy → http-proxy}/http2-request-handler.d.ts +0 -0
- /package/dist_ts/proxies/{network-proxy → http-proxy}/security-manager.d.ts +0 -0
- /package/ts/proxies/{network-proxy → http-proxy}/context-creator.ts +0 -0
- /package/ts/proxies/{network-proxy → http-proxy}/function-cache.ts +0 -0
- /package/ts/proxies/{network-proxy → http-proxy}/http-request-handler.ts +0 -0
- /package/ts/proxies/{network-proxy → http-proxy}/http2-request-handler.ts +0 -0
- /package/ts/proxies/{network-proxy → http-proxy}/security-manager.ts +0 -0
- /package/ts/{http → routing}/router/index.ts +0 -0
|
@@ -5,10 +5,11 @@ import type { IRouteConfig, IRouteAction, IRouteContext } from './models/route-t
|
|
|
5
5
|
import { ConnectionManager } from './connection-manager.js';
|
|
6
6
|
import { SecurityManager } from './security-manager.js';
|
|
7
7
|
import { TlsManager } from './tls-manager.js';
|
|
8
|
-
import {
|
|
8
|
+
import { HttpProxyBridge } from './http-proxy-bridge.js';
|
|
9
9
|
import { TimeoutManager } from './timeout-manager.js';
|
|
10
10
|
import { RouteManager } from './route-manager.js';
|
|
11
11
|
import type { ForwardingHandler } from '../../forwarding/handlers/base-handler.js';
|
|
12
|
+
import { RedirectHandler, StaticHandler } from '../http-proxy/handlers/index.js';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Handles new connection processing and setup logic with support for route-based configuration
|
|
@@ -24,7 +25,7 @@ export class RouteConnectionHandler {
|
|
|
24
25
|
private connectionManager: ConnectionManager,
|
|
25
26
|
private securityManager: SecurityManager,
|
|
26
27
|
private tlsManager: TlsManager,
|
|
27
|
-
private
|
|
28
|
+
private httpProxyBridge: HttpProxyBridge,
|
|
28
29
|
private timeoutManager: TimeoutManager,
|
|
29
30
|
private routeManager: RouteManager
|
|
30
31
|
) {
|
|
@@ -530,22 +531,22 @@ export class RouteConnectionHandler {
|
|
|
530
531
|
|
|
531
532
|
case 'terminate':
|
|
532
533
|
case 'terminate-and-reencrypt':
|
|
533
|
-
// For TLS termination, use
|
|
534
|
-
if (this.
|
|
534
|
+
// For TLS termination, use HttpProxy
|
|
535
|
+
if (this.httpProxyBridge.getHttpProxy()) {
|
|
535
536
|
if (this.settings.enableDetailedLogging) {
|
|
536
537
|
console.log(
|
|
537
|
-
`[${connectionId}] Using
|
|
538
|
+
`[${connectionId}] Using HttpProxy for TLS termination to ${action.target.host}`
|
|
538
539
|
);
|
|
539
540
|
}
|
|
540
541
|
|
|
541
542
|
// If we have an initial chunk with TLS data, start processing it
|
|
542
543
|
if (initialChunk && record.isTLS) {
|
|
543
|
-
this.
|
|
544
|
+
this.httpProxyBridge.forwardToHttpProxy(
|
|
544
545
|
connectionId,
|
|
545
546
|
socket,
|
|
546
547
|
record,
|
|
547
548
|
initialChunk,
|
|
548
|
-
this.settings.
|
|
549
|
+
this.settings.httpProxyPort || 8443,
|
|
549
550
|
(reason) => this.connectionManager.initiateCleanupOnce(record, reason)
|
|
550
551
|
);
|
|
551
552
|
return;
|
|
@@ -557,9 +558,9 @@ export class RouteConnectionHandler {
|
|
|
557
558
|
this.connectionManager.cleanupConnection(record, 'tls_error');
|
|
558
559
|
return;
|
|
559
560
|
} else {
|
|
560
|
-
console.log(`[${connectionId}]
|
|
561
|
+
console.log(`[${connectionId}] HttpProxy not available for TLS termination`);
|
|
561
562
|
socket.end();
|
|
562
|
-
this.connectionManager.cleanupConnection(record, '
|
|
563
|
+
this.connectionManager.cleanupConnection(record, 'no_http_proxy');
|
|
563
564
|
return;
|
|
564
565
|
}
|
|
565
566
|
}
|
|
@@ -621,87 +622,20 @@ export class RouteConnectionHandler {
|
|
|
621
622
|
record: IConnectionRecord,
|
|
622
623
|
route: IRouteConfig
|
|
623
624
|
): void {
|
|
624
|
-
const connectionId = record.id;
|
|
625
|
-
const action = route.action;
|
|
626
|
-
|
|
627
|
-
// We should have a redirect configuration
|
|
628
|
-
if (!action.redirect) {
|
|
629
|
-
console.log(`[${connectionId}] Redirect action missing redirect configuration`);
|
|
630
|
-
socket.end();
|
|
631
|
-
this.connectionManager.cleanupConnection(record, 'missing_redirect');
|
|
632
|
-
return;
|
|
633
|
-
}
|
|
634
|
-
|
|
635
625
|
// For TLS connections, we can't do redirects at the TCP level
|
|
636
626
|
if (record.isTLS) {
|
|
637
|
-
console.log(`[${
|
|
627
|
+
console.log(`[${record.id}] Cannot redirect TLS connection at TCP level`);
|
|
638
628
|
socket.end();
|
|
639
629
|
this.connectionManager.cleanupConnection(record, 'tls_redirect_error');
|
|
640
630
|
return;
|
|
641
631
|
}
|
|
642
632
|
|
|
643
|
-
//
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
socket.removeListener('data', listener);
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
// Parse HTTP request to get path
|
|
653
|
-
try {
|
|
654
|
-
const headersEnd = chunk.indexOf('\r\n\r\n');
|
|
655
|
-
if (headersEnd === -1) {
|
|
656
|
-
// Not a complete HTTP request, need more data
|
|
657
|
-
socket.once('data', httpDataHandler);
|
|
658
|
-
dataListeners.push(httpDataHandler);
|
|
659
|
-
return;
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
const httpHeaders = chunk.slice(0, headersEnd).toString();
|
|
663
|
-
const requestLine = httpHeaders.split('\r\n')[0];
|
|
664
|
-
const [method, path] = requestLine.split(' ');
|
|
665
|
-
|
|
666
|
-
// Extract Host header
|
|
667
|
-
const hostMatch = httpHeaders.match(/Host: (.+?)(\r\n|\r|\n|$)/i);
|
|
668
|
-
const host = hostMatch ? hostMatch[1].trim() : record.lockedDomain || '';
|
|
669
|
-
|
|
670
|
-
// Process the redirect URL with template variables
|
|
671
|
-
let redirectUrl = action.redirect.to;
|
|
672
|
-
redirectUrl = redirectUrl.replace(/\{domain\}/g, host);
|
|
673
|
-
redirectUrl = redirectUrl.replace(/\{path\}/g, path || '');
|
|
674
|
-
redirectUrl = redirectUrl.replace(/\{port\}/g, record.localPort.toString());
|
|
675
|
-
|
|
676
|
-
// Prepare the HTTP redirect response
|
|
677
|
-
const redirectResponse = [
|
|
678
|
-
`HTTP/1.1 ${action.redirect.status} Moved`,
|
|
679
|
-
`Location: ${redirectUrl}`,
|
|
680
|
-
'Connection: close',
|
|
681
|
-
'Content-Length: 0',
|
|
682
|
-
'',
|
|
683
|
-
'',
|
|
684
|
-
].join('\r\n');
|
|
685
|
-
|
|
686
|
-
if (this.settings.enableDetailedLogging) {
|
|
687
|
-
console.log(
|
|
688
|
-
`[${connectionId}] Redirecting to ${redirectUrl} with status ${action.redirect.status}`
|
|
689
|
-
);
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
// Send the redirect response
|
|
693
|
-
socket.end(redirectResponse);
|
|
694
|
-
this.connectionManager.initiateCleanupOnce(record, 'redirect_complete');
|
|
695
|
-
} catch (err) {
|
|
696
|
-
console.log(`[${connectionId}] Error processing HTTP redirect: ${err}`);
|
|
697
|
-
socket.end();
|
|
698
|
-
this.connectionManager.initiateCleanupOnce(record, 'redirect_error');
|
|
699
|
-
}
|
|
700
|
-
};
|
|
701
|
-
|
|
702
|
-
// Setup the HTTP data handler
|
|
703
|
-
socket.once('data', httpDataHandler);
|
|
704
|
-
dataListeners.push(httpDataHandler);
|
|
633
|
+
// Delegate to HttpProxy's RedirectHandler
|
|
634
|
+
RedirectHandler.handleRedirect(socket, route, {
|
|
635
|
+
connectionId: record.id,
|
|
636
|
+
connectionManager: this.connectionManager,
|
|
637
|
+
settings: this.settings
|
|
638
|
+
});
|
|
705
639
|
}
|
|
706
640
|
|
|
707
641
|
/**
|
|
@@ -733,221 +667,12 @@ export class RouteConnectionHandler {
|
|
|
733
667
|
record: IConnectionRecord,
|
|
734
668
|
route: IRouteConfig
|
|
735
669
|
): Promise<void> {
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
return;
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
let buffer = Buffer.alloc(0);
|
|
746
|
-
let processingData = false;
|
|
747
|
-
|
|
748
|
-
const handleHttpData = async (chunk: Buffer) => {
|
|
749
|
-
// Accumulate the data
|
|
750
|
-
buffer = Buffer.concat([buffer, chunk]);
|
|
751
|
-
|
|
752
|
-
// Prevent concurrent processing of the same buffer
|
|
753
|
-
if (processingData) return;
|
|
754
|
-
processingData = true;
|
|
755
|
-
|
|
756
|
-
try {
|
|
757
|
-
// Process data until we have a complete request or need more data
|
|
758
|
-
await processBuffer();
|
|
759
|
-
} finally {
|
|
760
|
-
processingData = false;
|
|
761
|
-
}
|
|
762
|
-
};
|
|
763
|
-
|
|
764
|
-
const processBuffer = async () => {
|
|
765
|
-
// Look for end of HTTP headers
|
|
766
|
-
const headerEndIndex = buffer.indexOf('\r\n\r\n');
|
|
767
|
-
if (headerEndIndex === -1) {
|
|
768
|
-
// Need more data
|
|
769
|
-
if (buffer.length > 8192) {
|
|
770
|
-
// Prevent excessive buffering
|
|
771
|
-
console.error(`[${connectionId}] HTTP headers too large`);
|
|
772
|
-
socket.end();
|
|
773
|
-
this.connectionManager.cleanupConnection(record, 'headers_too_large');
|
|
774
|
-
}
|
|
775
|
-
return; // Wait for more data to arrive
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
// Parse the HTTP request
|
|
779
|
-
const headerBuffer = buffer.slice(0, headerEndIndex);
|
|
780
|
-
const headers = headerBuffer.toString();
|
|
781
|
-
const lines = headers.split('\r\n');
|
|
782
|
-
|
|
783
|
-
if (lines.length === 0) {
|
|
784
|
-
console.error(`[${connectionId}] Invalid HTTP request`);
|
|
785
|
-
socket.end();
|
|
786
|
-
this.connectionManager.cleanupConnection(record, 'invalid_request');
|
|
787
|
-
return;
|
|
788
|
-
}
|
|
789
|
-
|
|
790
|
-
// Parse request line
|
|
791
|
-
const requestLine = lines[0];
|
|
792
|
-
const requestParts = requestLine.split(' ');
|
|
793
|
-
if (requestParts.length < 3) {
|
|
794
|
-
console.error(`[${connectionId}] Invalid HTTP request line`);
|
|
795
|
-
socket.end();
|
|
796
|
-
this.connectionManager.cleanupConnection(record, 'invalid_request_line');
|
|
797
|
-
return;
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
const [method, path, httpVersion] = requestParts;
|
|
801
|
-
|
|
802
|
-
// Parse headers
|
|
803
|
-
const headersMap: Record<string, string> = {};
|
|
804
|
-
for (let i = 1; i < lines.length; i++) {
|
|
805
|
-
const colonIndex = lines[i].indexOf(':');
|
|
806
|
-
if (colonIndex > 0) {
|
|
807
|
-
const key = lines[i].slice(0, colonIndex).trim().toLowerCase();
|
|
808
|
-
const value = lines[i].slice(colonIndex + 1).trim();
|
|
809
|
-
headersMap[key] = value;
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
// Check for Content-Length to handle request body
|
|
814
|
-
const requestBodyLength = parseInt(headersMap['content-length'] || '0', 10);
|
|
815
|
-
const bodyStartIndex = headerEndIndex + 4; // Skip the \r\n\r\n
|
|
816
|
-
|
|
817
|
-
// If there's a body, ensure we have the full body
|
|
818
|
-
if (requestBodyLength > 0) {
|
|
819
|
-
const totalExpectedLength = bodyStartIndex + requestBodyLength;
|
|
820
|
-
|
|
821
|
-
// If we don't have the complete body yet, wait for more data
|
|
822
|
-
if (buffer.length < totalExpectedLength) {
|
|
823
|
-
// Implement a reasonable body size limit to prevent memory issues
|
|
824
|
-
if (requestBodyLength > 1024 * 1024) {
|
|
825
|
-
// 1MB limit
|
|
826
|
-
console.error(`[${connectionId}] Request body too large`);
|
|
827
|
-
socket.end();
|
|
828
|
-
this.connectionManager.cleanupConnection(record, 'body_too_large');
|
|
829
|
-
return;
|
|
830
|
-
}
|
|
831
|
-
return; // Wait for more data
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
|
|
835
|
-
// Extract query string if present
|
|
836
|
-
let pathname = path;
|
|
837
|
-
let query: string | undefined;
|
|
838
|
-
const queryIndex = path.indexOf('?');
|
|
839
|
-
if (queryIndex !== -1) {
|
|
840
|
-
pathname = path.slice(0, queryIndex);
|
|
841
|
-
query = path.slice(queryIndex + 1);
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
try {
|
|
845
|
-
// Get request body if present
|
|
846
|
-
let requestBody: Buffer | undefined;
|
|
847
|
-
if (requestBodyLength > 0) {
|
|
848
|
-
requestBody = buffer.slice(bodyStartIndex, bodyStartIndex + requestBodyLength);
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
// Pause socket to prevent data loss during async processing
|
|
852
|
-
socket.pause();
|
|
853
|
-
|
|
854
|
-
// Remove the data listener since we're handling the request
|
|
855
|
-
socket.removeListener('data', handleHttpData);
|
|
856
|
-
|
|
857
|
-
// Build route context with parsed HTTP information
|
|
858
|
-
const context: IRouteContext = {
|
|
859
|
-
port: record.localPort,
|
|
860
|
-
domain: record.lockedDomain || headersMap['host']?.split(':')[0],
|
|
861
|
-
clientIp: record.remoteIP,
|
|
862
|
-
serverIp: socket.localAddress!,
|
|
863
|
-
path: pathname,
|
|
864
|
-
query: query,
|
|
865
|
-
headers: headersMap,
|
|
866
|
-
method: method,
|
|
867
|
-
isTls: record.isTLS,
|
|
868
|
-
tlsVersion: record.tlsVersion,
|
|
869
|
-
routeName: route.name,
|
|
870
|
-
routeId: route.id,
|
|
871
|
-
timestamp: Date.now(),
|
|
872
|
-
connectionId,
|
|
873
|
-
};
|
|
874
|
-
|
|
875
|
-
// Since IRouteContext doesn't have a body property,
|
|
876
|
-
// we need an alternative approach to handle the body
|
|
877
|
-
let response;
|
|
878
|
-
|
|
879
|
-
if (requestBody) {
|
|
880
|
-
if (this.settings.enableDetailedLogging) {
|
|
881
|
-
console.log(
|
|
882
|
-
`[${connectionId}] Processing request with body (${requestBody.length} bytes)`
|
|
883
|
-
);
|
|
884
|
-
}
|
|
885
|
-
|
|
886
|
-
// Pass the body as an additional parameter by extending the context object
|
|
887
|
-
// This is not type-safe, but it allows handlers that expect a body to work
|
|
888
|
-
const extendedContext = {
|
|
889
|
-
...context,
|
|
890
|
-
// Provide both raw buffer and string representation
|
|
891
|
-
requestBody: requestBody,
|
|
892
|
-
requestBodyText: requestBody.toString(),
|
|
893
|
-
};
|
|
894
|
-
|
|
895
|
-
// Call the handler with the extended context
|
|
896
|
-
// The handler needs to know to look for the non-standard properties
|
|
897
|
-
response = await route.action.handler(extendedContext as any);
|
|
898
|
-
} else {
|
|
899
|
-
// Call the handler with the standard context
|
|
900
|
-
response = await route.action.handler(context);
|
|
901
|
-
}
|
|
902
|
-
|
|
903
|
-
// Prepare the HTTP response
|
|
904
|
-
const responseHeaders = response.headers || {};
|
|
905
|
-
const contentLength = Buffer.byteLength(response.body || '');
|
|
906
|
-
responseHeaders['Content-Length'] = contentLength.toString();
|
|
907
|
-
|
|
908
|
-
if (!responseHeaders['Content-Type']) {
|
|
909
|
-
responseHeaders['Content-Type'] = 'text/plain';
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
// Build the response
|
|
913
|
-
let httpResponse = `HTTP/1.1 ${response.status} ${getStatusText(response.status)}\r\n`;
|
|
914
|
-
for (const [key, value] of Object.entries(responseHeaders)) {
|
|
915
|
-
httpResponse += `${key}: ${value}\r\n`;
|
|
916
|
-
}
|
|
917
|
-
httpResponse += '\r\n';
|
|
918
|
-
|
|
919
|
-
// Send response
|
|
920
|
-
socket.write(httpResponse);
|
|
921
|
-
if (response.body) {
|
|
922
|
-
socket.write(response.body);
|
|
923
|
-
}
|
|
924
|
-
socket.end();
|
|
925
|
-
|
|
926
|
-
this.connectionManager.cleanupConnection(record, 'completed');
|
|
927
|
-
} catch (error) {
|
|
928
|
-
console.error(`[${connectionId}] Error in static handler: ${error}`);
|
|
929
|
-
|
|
930
|
-
// Send error response
|
|
931
|
-
const errorResponse =
|
|
932
|
-
'HTTP/1.1 500 Internal Server Error\r\n' +
|
|
933
|
-
'Content-Type: text/plain\r\n' +
|
|
934
|
-
'Content-Length: 21\r\n' +
|
|
935
|
-
'\r\n' +
|
|
936
|
-
'Internal Server Error';
|
|
937
|
-
socket.write(errorResponse);
|
|
938
|
-
socket.end();
|
|
939
|
-
|
|
940
|
-
this.connectionManager.cleanupConnection(record, 'handler_error');
|
|
941
|
-
}
|
|
942
|
-
};
|
|
943
|
-
|
|
944
|
-
// Listen for data
|
|
945
|
-
socket.on('data', handleHttpData);
|
|
946
|
-
|
|
947
|
-
// Ensure cleanup on socket close
|
|
948
|
-
socket.once('close', () => {
|
|
949
|
-
socket.removeListener('data', handleHttpData);
|
|
950
|
-
});
|
|
670
|
+
// Delegate to HttpProxy's StaticHandler
|
|
671
|
+
await StaticHandler.handleStatic(socket, route, {
|
|
672
|
+
connectionId: record.id,
|
|
673
|
+
connectionManager: this.connectionManager,
|
|
674
|
+
settings: this.settings
|
|
675
|
+
}, record);
|
|
951
676
|
}
|
|
952
677
|
|
|
953
678
|
/**
|
|
@@ -1378,12 +1103,3 @@ export class RouteConnectionHandler {
|
|
|
1378
1103
|
}
|
|
1379
1104
|
}
|
|
1380
1105
|
|
|
1381
|
-
// Helper function for status text
|
|
1382
|
-
function getStatusText(status: number): string {
|
|
1383
|
-
const statusTexts: Record<number, string> = {
|
|
1384
|
-
200: 'OK',
|
|
1385
|
-
404: 'Not Found',
|
|
1386
|
-
500: 'Internal Server Error',
|
|
1387
|
-
};
|
|
1388
|
-
return statusTexts[status] || 'Unknown';
|
|
1389
|
-
}
|
|
@@ -4,7 +4,7 @@ import * as plugins from '../../plugins.js';
|
|
|
4
4
|
import { ConnectionManager } from './connection-manager.js';
|
|
5
5
|
import { SecurityManager } from './security-manager.js';
|
|
6
6
|
import { TlsManager } from './tls-manager.js';
|
|
7
|
-
import {
|
|
7
|
+
import { HttpProxyBridge } from './http-proxy-bridge.js';
|
|
8
8
|
import { TimeoutManager } from './timeout-manager.js';
|
|
9
9
|
import { PortManager } from './port-manager.js';
|
|
10
10
|
import { RouteManager } from './route-manager.js';
|
|
@@ -49,7 +49,7 @@ export class SmartProxy extends plugins.EventEmitter {
|
|
|
49
49
|
private connectionManager: ConnectionManager;
|
|
50
50
|
private securityManager: SecurityManager;
|
|
51
51
|
private tlsManager: TlsManager;
|
|
52
|
-
private
|
|
52
|
+
private httpProxyBridge: HttpProxyBridge;
|
|
53
53
|
private timeoutManager: TimeoutManager;
|
|
54
54
|
public routeManager: RouteManager; // Made public for route management
|
|
55
55
|
private routeConnectionHandler: RouteConnectionHandler;
|
|
@@ -123,7 +123,7 @@ export class SmartProxy extends plugins.EventEmitter {
|
|
|
123
123
|
keepAliveTreatment: settingsArg.keepAliveTreatment || 'extended',
|
|
124
124
|
keepAliveInactivityMultiplier: settingsArg.keepAliveInactivityMultiplier || 6,
|
|
125
125
|
extendedKeepAliveLifetime: settingsArg.extendedKeepAliveLifetime || 7 * 24 * 60 * 60 * 1000,
|
|
126
|
-
|
|
126
|
+
httpProxyPort: settingsArg.httpProxyPort || 8443,
|
|
127
127
|
};
|
|
128
128
|
|
|
129
129
|
// Normalize ACME options if provided (support both email and accountEmail)
|
|
@@ -164,7 +164,7 @@ export class SmartProxy extends plugins.EventEmitter {
|
|
|
164
164
|
|
|
165
165
|
// Create other required components
|
|
166
166
|
this.tlsManager = new TlsManager(this.settings);
|
|
167
|
-
this.
|
|
167
|
+
this.httpProxyBridge = new HttpProxyBridge(this.settings);
|
|
168
168
|
|
|
169
169
|
// Initialize connection handler with route support
|
|
170
170
|
this.routeConnectionHandler = new RouteConnectionHandler(
|
|
@@ -172,7 +172,7 @@ export class SmartProxy extends plugins.EventEmitter {
|
|
|
172
172
|
this.connectionManager,
|
|
173
173
|
this.securityManager,
|
|
174
174
|
this.tlsManager,
|
|
175
|
-
this.
|
|
175
|
+
this.httpProxyBridge,
|
|
176
176
|
this.timeoutManager,
|
|
177
177
|
this.routeManager
|
|
178
178
|
);
|
|
@@ -212,9 +212,9 @@ export class SmartProxy extends plugins.EventEmitter {
|
|
|
212
212
|
await this.updateRoutes(routes);
|
|
213
213
|
});
|
|
214
214
|
|
|
215
|
-
// Connect with
|
|
216
|
-
if (this.
|
|
217
|
-
certManager.
|
|
215
|
+
// Connect with HttpProxy if available
|
|
216
|
+
if (this.httpProxyBridge.getHttpProxy()) {
|
|
217
|
+
certManager.setHttpProxy(this.httpProxyBridge.getHttpProxy());
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
// Set the ACME state manager
|
|
@@ -312,16 +312,16 @@ export class SmartProxy extends plugins.EventEmitter {
|
|
|
312
312
|
// Initialize certificate manager before starting servers
|
|
313
313
|
await this.initializeCertificateManager();
|
|
314
314
|
|
|
315
|
-
// Initialize and start
|
|
316
|
-
if (this.settings.
|
|
317
|
-
await this.
|
|
315
|
+
// Initialize and start HttpProxy if needed
|
|
316
|
+
if (this.settings.useHttpProxy && this.settings.useHttpProxy.length > 0) {
|
|
317
|
+
await this.httpProxyBridge.initialize();
|
|
318
318
|
|
|
319
|
-
// Connect
|
|
319
|
+
// Connect HttpProxy with certificate manager
|
|
320
320
|
if (this.certManager) {
|
|
321
|
-
this.certManager.
|
|
321
|
+
this.certManager.setHttpProxy(this.httpProxyBridge.getHttpProxy());
|
|
322
322
|
}
|
|
323
323
|
|
|
324
|
-
await this.
|
|
324
|
+
await this.httpProxyBridge.start();
|
|
325
325
|
}
|
|
326
326
|
|
|
327
327
|
// Validate the route configuration
|
|
@@ -368,7 +368,7 @@ export class SmartProxy extends plugins.EventEmitter {
|
|
|
368
368
|
let completedTlsHandshakes = 0;
|
|
369
369
|
let pendingTlsHandshakes = 0;
|
|
370
370
|
let keepAliveConnections = 0;
|
|
371
|
-
let
|
|
371
|
+
let httpProxyConnections = 0;
|
|
372
372
|
|
|
373
373
|
// Get connection records for analysis
|
|
374
374
|
const connectionRecords = this.connectionManager.getConnections();
|
|
@@ -392,7 +392,7 @@ export class SmartProxy extends plugins.EventEmitter {
|
|
|
392
392
|
}
|
|
393
393
|
|
|
394
394
|
if (record.usingNetworkProxy) {
|
|
395
|
-
|
|
395
|
+
httpProxyConnections++;
|
|
396
396
|
}
|
|
397
397
|
|
|
398
398
|
maxIncoming = Math.max(maxIncoming, now - record.incomingStartTime);
|
|
@@ -408,7 +408,7 @@ export class SmartProxy extends plugins.EventEmitter {
|
|
|
408
408
|
console.log(
|
|
409
409
|
`Active connections: ${connectionRecords.size}. ` +
|
|
410
410
|
`Types: TLS=${tlsConnections} (Completed=${completedTlsHandshakes}, Pending=${pendingTlsHandshakes}), ` +
|
|
411
|
-
`Non-TLS=${nonTlsConnections}, KeepAlive=${keepAliveConnections},
|
|
411
|
+
`Non-TLS=${nonTlsConnections}, KeepAlive=${keepAliveConnections}, HttpProxy=${httpProxyConnections}. ` +
|
|
412
412
|
`Longest running: IN=${plugins.prettyMs(maxIncoming)}, OUT=${plugins.prettyMs(maxOutgoing)}. ` +
|
|
413
413
|
`Termination stats: ${JSON.stringify({
|
|
414
414
|
IN: terminationStats.incoming,
|
|
@@ -460,8 +460,8 @@ export class SmartProxy extends plugins.EventEmitter {
|
|
|
460
460
|
// Clean up all active connections
|
|
461
461
|
this.connectionManager.clearConnections();
|
|
462
462
|
|
|
463
|
-
// Stop
|
|
464
|
-
await this.
|
|
463
|
+
// Stop HttpProxy
|
|
464
|
+
await this.httpProxyBridge.stop();
|
|
465
465
|
|
|
466
466
|
// Clear ACME state manager
|
|
467
467
|
this.acmeStateManager.clear();
|
|
@@ -574,9 +574,9 @@ export class SmartProxy extends plugins.EventEmitter {
|
|
|
574
574
|
// Update settings with the new routes
|
|
575
575
|
this.settings.routes = newRoutes;
|
|
576
576
|
|
|
577
|
-
// If
|
|
578
|
-
if (this.
|
|
579
|
-
await this.
|
|
577
|
+
// If HttpProxy is initialized, resync the configurations
|
|
578
|
+
if (this.httpProxyBridge.getHttpProxy()) {
|
|
579
|
+
await this.httpProxyBridge.syncRoutesToHttpProxy(newRoutes);
|
|
580
580
|
}
|
|
581
581
|
|
|
582
582
|
// Update certificate manager with new routes
|
|
@@ -711,14 +711,14 @@ export class SmartProxy extends plugins.EventEmitter {
|
|
|
711
711
|
let tlsConnections = 0;
|
|
712
712
|
let nonTlsConnections = 0;
|
|
713
713
|
let keepAliveConnections = 0;
|
|
714
|
-
let
|
|
714
|
+
let httpProxyConnections = 0;
|
|
715
715
|
|
|
716
716
|
// Analyze active connections
|
|
717
717
|
for (const record of connectionRecords.values()) {
|
|
718
718
|
if (record.isTLS) tlsConnections++;
|
|
719
719
|
else nonTlsConnections++;
|
|
720
720
|
if (record.hasKeepAlive) keepAliveConnections++;
|
|
721
|
-
if (record.usingNetworkProxy)
|
|
721
|
+
if (record.usingNetworkProxy) httpProxyConnections++;
|
|
722
722
|
}
|
|
723
723
|
|
|
724
724
|
return {
|
|
@@ -726,7 +726,7 @@ export class SmartProxy extends plugins.EventEmitter {
|
|
|
726
726
|
tlsConnections,
|
|
727
727
|
nonTlsConnections,
|
|
728
728
|
keepAliveConnections,
|
|
729
|
-
|
|
729
|
+
httpProxyConnections,
|
|
730
730
|
terminationStats,
|
|
731
731
|
acmeEnabled: !!this.certManager,
|
|
732
732
|
port80HandlerPort: this.certManager ? 80 : null,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as plugins from '../../plugins.js';
|
|
2
|
-
import type { IReverseProxyConfig } from '../../proxies/
|
|
2
|
+
import type { IReverseProxyConfig } from '../../proxies/http-proxy/models/types.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Optional path pattern configuration that can be added to proxy configs
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as plugins from '../../plugins.js';
|
|
2
2
|
import type { IRouteConfig } from '../../proxies/smart-proxy/models/route-types.js';
|
|
3
|
-
import type { ILogger } from '../../proxies/
|
|
3
|
+
import type { ILogger } from '../../proxies/http-proxy/models/types.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Optional path pattern configuration that can be added to proxy configs
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { IAcmeOptions } from '../models/certificate-types.js';
|
|
2
|
-
import { Port80Handler } from '../../http/port80/port80-handler.js';
|
|
3
|
-
/**
|
|
4
|
-
* Factory to create a Port80Handler with common setup.
|
|
5
|
-
* Ensures the certificate store directory exists and instantiates the handler.
|
|
6
|
-
* @param options Port80Handler configuration options
|
|
7
|
-
* @returns A new Port80Handler instance
|
|
8
|
-
*/
|
|
9
|
-
export declare function buildPort80Handler(options: IAcmeOptions): Port80Handler;
|
|
10
|
-
/**
|
|
11
|
-
* Creates default ACME options with sensible defaults
|
|
12
|
-
* @param email Account email for ACME provider
|
|
13
|
-
* @param certificateStore Path to store certificates
|
|
14
|
-
* @param useProduction Whether to use production ACME servers
|
|
15
|
-
* @returns Configured ACME options
|
|
16
|
-
*/
|
|
17
|
-
export declare function createDefaultAcmeOptions(email: string, certificateStore: string, useProduction?: boolean): IAcmeOptions;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import * as fs from 'fs';
|
|
2
|
-
import * as path from 'path';
|
|
3
|
-
import { ensureCertificateDirectory } from '../utils/certificate-helpers.js';
|
|
4
|
-
// We'll need to update this import when we move the Port80Handler
|
|
5
|
-
import { Port80Handler } from '../../http/port80/port80-handler.js';
|
|
6
|
-
/**
|
|
7
|
-
* Factory to create a Port80Handler with common setup.
|
|
8
|
-
* Ensures the certificate store directory exists and instantiates the handler.
|
|
9
|
-
* @param options Port80Handler configuration options
|
|
10
|
-
* @returns A new Port80Handler instance
|
|
11
|
-
*/
|
|
12
|
-
export function buildPort80Handler(options) {
|
|
13
|
-
if (options.certificateStore) {
|
|
14
|
-
ensureCertificateDirectory(options.certificateStore);
|
|
15
|
-
console.log(`Ensured certificate store directory: ${options.certificateStore}`);
|
|
16
|
-
}
|
|
17
|
-
return new Port80Handler(options);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Creates default ACME options with sensible defaults
|
|
21
|
-
* @param email Account email for ACME provider
|
|
22
|
-
* @param certificateStore Path to store certificates
|
|
23
|
-
* @param useProduction Whether to use production ACME servers
|
|
24
|
-
* @returns Configured ACME options
|
|
25
|
-
*/
|
|
26
|
-
export function createDefaultAcmeOptions(email, certificateStore, useProduction = false) {
|
|
27
|
-
return {
|
|
28
|
-
accountEmail: email,
|
|
29
|
-
enabled: true,
|
|
30
|
-
port: 80,
|
|
31
|
-
useProduction,
|
|
32
|
-
httpsRedirectPort: 443,
|
|
33
|
-
renewThresholdDays: 30,
|
|
34
|
-
renewCheckIntervalHours: 24,
|
|
35
|
-
autoRenew: true,
|
|
36
|
-
certificateStore,
|
|
37
|
-
skipConfiguredCerts: false
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWNtZS1mYWN0b3J5LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vdHMvY2VydGlmaWNhdGUvYWNtZS9hY21lLWZhY3RvcnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsTUFBTSxJQUFJLENBQUM7QUFDekIsT0FBTyxLQUFLLElBQUksTUFBTSxNQUFNLENBQUM7QUFFN0IsT0FBTyxFQUFFLDBCQUEwQixFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDN0Usa0VBQWtFO0FBQ2xFLE9BQU8sRUFBRSxhQUFhLEVBQUUsTUFBTSxxQ0FBcUMsQ0FBQztBQUVwRTs7Ozs7R0FLRztBQUNILE1BQU0sVUFBVSxrQkFBa0IsQ0FDaEMsT0FBcUI7SUFFckIsSUFBSSxPQUFPLENBQUMsZ0JBQWdCLEVBQUUsQ0FBQztRQUM3QiwwQkFBMEIsQ0FBQyxPQUFPLENBQUMsZ0JBQWdCLENBQUMsQ0FBQztRQUNyRCxPQUFPLENBQUMsR0FBRyxDQUFDLHdDQUF3QyxPQUFPLENBQUMsZ0JBQWdCLEVBQUUsQ0FBQyxDQUFDO0lBQ2xGLENBQUM7SUFDRCxPQUFPLElBQUksYUFBYSxDQUFDLE9BQU8sQ0FBQyxDQUFDO0FBQ3BDLENBQUM7QUFFRDs7Ozs7O0dBTUc7QUFDSCxNQUFNLFVBQVUsd0JBQXdCLENBQ3RDLEtBQWEsRUFDYixnQkFBd0IsRUFDeEIsZ0JBQXlCLEtBQUs7SUFFOUIsT0FBTztRQUNMLFlBQVksRUFBRSxLQUFLO1FBQ25CLE9BQU8sRUFBRSxJQUFJO1FBQ2IsSUFBSSxFQUFFLEVBQUU7UUFDUixhQUFhO1FBQ2IsaUJBQWlCLEVBQUUsR0FBRztRQUN0QixrQkFBa0IsRUFBRSxFQUFFO1FBQ3RCLHVCQUF1QixFQUFFLEVBQUU7UUFDM0IsU0FBUyxFQUFFLElBQUk7UUFDZixnQkFBZ0I7UUFDaEIsbUJBQW1CLEVBQUUsS0FBSztLQUMzQixDQUFDO0FBQ0osQ0FBQyJ9
|