@push.rocks/smartproxy 19.3.1 → 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 +10 -10
- package/dist_ts/proxies/smart-proxy/certificate-manager.js +19 -19
- 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 +29 -210
- 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 +19 -18
- 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 +162 -358
- 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
|
@@ -1,21 +1,15 @@
|
|
|
1
1
|
import * as plugins from '../../plugins.js';
|
|
2
|
-
import type {
|
|
3
|
-
IConnectionRecord,
|
|
4
|
-
ISmartProxyOptions
|
|
5
|
-
} from './models/interfaces.js';
|
|
2
|
+
import type { IConnectionRecord, ISmartProxyOptions } from './models/interfaces.js';
|
|
6
3
|
// Route checking functions have been removed
|
|
7
|
-
import type {
|
|
8
|
-
IRouteConfig,
|
|
9
|
-
IRouteAction,
|
|
10
|
-
IRouteContext
|
|
11
|
-
} from './models/route-types.js';
|
|
4
|
+
import type { IRouteConfig, IRouteAction, IRouteContext } from './models/route-types.js';
|
|
12
5
|
import { ConnectionManager } from './connection-manager.js';
|
|
13
6
|
import { SecurityManager } from './security-manager.js';
|
|
14
7
|
import { TlsManager } from './tls-manager.js';
|
|
15
|
-
import {
|
|
8
|
+
import { HttpProxyBridge } from './http-proxy-bridge.js';
|
|
16
9
|
import { TimeoutManager } from './timeout-manager.js';
|
|
17
10
|
import { RouteManager } from './route-manager.js';
|
|
18
11
|
import type { ForwardingHandler } from '../../forwarding/handlers/base-handler.js';
|
|
12
|
+
import { RedirectHandler, StaticHandler } from '../http-proxy/handlers/index.js';
|
|
19
13
|
|
|
20
14
|
/**
|
|
21
15
|
* Handles new connection processing and setup logic with support for route-based configuration
|
|
@@ -31,7 +25,7 @@ export class RouteConnectionHandler {
|
|
|
31
25
|
private connectionManager: ConnectionManager,
|
|
32
26
|
private securityManager: SecurityManager,
|
|
33
27
|
private tlsManager: TlsManager,
|
|
34
|
-
private
|
|
28
|
+
private httpProxyBridge: HttpProxyBridge,
|
|
35
29
|
private timeoutManager: TimeoutManager,
|
|
36
30
|
private routeManager: RouteManager
|
|
37
31
|
) {
|
|
@@ -75,7 +69,7 @@ export class RouteConnectionHandler {
|
|
|
75
69
|
|
|
76
70
|
// Additional properties
|
|
77
71
|
timestamp: Date.now(),
|
|
78
|
-
connectionId: options.connectionId
|
|
72
|
+
connectionId: options.connectionId,
|
|
79
73
|
};
|
|
80
74
|
}
|
|
81
75
|
|
|
@@ -232,16 +226,19 @@ export class RouteConnectionHandler {
|
|
|
232
226
|
console.log(`[${connectionId}] No SNI detected in TLS ClientHello; sending TLS alert.`);
|
|
233
227
|
if (record.incomingTerminationReason === null) {
|
|
234
228
|
record.incomingTerminationReason = 'session_ticket_blocked_no_sni';
|
|
235
|
-
this.connectionManager.incrementTerminationStat(
|
|
229
|
+
this.connectionManager.incrementTerminationStat(
|
|
230
|
+
'incoming',
|
|
231
|
+
'session_ticket_blocked_no_sni'
|
|
232
|
+
);
|
|
236
233
|
}
|
|
237
234
|
const alert = Buffer.from([0x15, 0x03, 0x03, 0x00, 0x02, 0x01, 0x70]);
|
|
238
|
-
try {
|
|
239
|
-
socket.cork();
|
|
240
|
-
socket.write(alert);
|
|
241
|
-
socket.uncork();
|
|
242
|
-
socket.end();
|
|
243
|
-
} catch {
|
|
244
|
-
socket.end();
|
|
235
|
+
try {
|
|
236
|
+
socket.cork();
|
|
237
|
+
socket.write(alert);
|
|
238
|
+
socket.uncork();
|
|
239
|
+
socket.end();
|
|
240
|
+
} catch {
|
|
241
|
+
socket.end();
|
|
245
242
|
}
|
|
246
243
|
this.connectionManager.cleanupConnection(record, 'session_ticket_blocked_no_sni');
|
|
247
244
|
return;
|
|
@@ -262,7 +259,7 @@ export class RouteConnectionHandler {
|
|
|
262
259
|
* Route the connection based on match criteria
|
|
263
260
|
*/
|
|
264
261
|
private routeConnection(
|
|
265
|
-
socket: plugins.net.Socket,
|
|
262
|
+
socket: plugins.net.Socket,
|
|
266
263
|
record: IConnectionRecord,
|
|
267
264
|
serverName: string,
|
|
268
265
|
initialChunk?: Buffer
|
|
@@ -277,11 +274,13 @@ export class RouteConnectionHandler {
|
|
|
277
274
|
domain: serverName,
|
|
278
275
|
clientIp: remoteIP,
|
|
279
276
|
path: undefined, // We don't have path info at this point
|
|
280
|
-
tlsVersion: undefined // We don't extract TLS version yet
|
|
277
|
+
tlsVersion: undefined, // We don't extract TLS version yet
|
|
281
278
|
});
|
|
282
279
|
|
|
283
280
|
if (!routeMatch) {
|
|
284
|
-
console.log(
|
|
281
|
+
console.log(
|
|
282
|
+
`[${connectionId}] No route found for ${serverName || 'connection'} on port ${localPort}`
|
|
283
|
+
);
|
|
285
284
|
|
|
286
285
|
// No matching route, use default/fallback handling
|
|
287
286
|
console.log(`[${connectionId}] Using default route handling for connection`);
|
|
@@ -304,7 +303,7 @@ export class RouteConnectionHandler {
|
|
|
304
303
|
}
|
|
305
304
|
}
|
|
306
305
|
}
|
|
307
|
-
|
|
306
|
+
|
|
308
307
|
// Setup direct connection with default settings
|
|
309
308
|
if (this.settings.defaults?.target) {
|
|
310
309
|
// Use defaults from configuration
|
|
@@ -328,54 +327,56 @@ export class RouteConnectionHandler {
|
|
|
328
327
|
return;
|
|
329
328
|
}
|
|
330
329
|
}
|
|
331
|
-
|
|
330
|
+
|
|
332
331
|
// A matching route was found
|
|
333
332
|
const route = routeMatch.route;
|
|
334
|
-
|
|
333
|
+
|
|
335
334
|
if (this.settings.enableDetailedLogging) {
|
|
336
335
|
console.log(
|
|
337
|
-
`[${connectionId}] Route matched: "${route.name || 'unnamed'}" for ${
|
|
336
|
+
`[${connectionId}] Route matched: "${route.name || 'unnamed'}" for ${
|
|
337
|
+
serverName || 'connection'
|
|
338
|
+
} on port ${localPort}`
|
|
338
339
|
);
|
|
339
340
|
}
|
|
340
|
-
|
|
341
|
+
|
|
341
342
|
// Check if this route uses NFTables for forwarding
|
|
342
343
|
if (route.action.forwardingEngine === 'nftables') {
|
|
343
344
|
// For NFTables routes, we don't need to do anything at the application level
|
|
344
345
|
// The packet is forwarded at the kernel level
|
|
345
|
-
|
|
346
|
+
|
|
346
347
|
// Log the connection
|
|
347
348
|
console.log(
|
|
348
349
|
`[${connectionId}] Connection forwarded by NFTables: ${record.remoteIP} -> port ${record.localPort}`
|
|
349
350
|
);
|
|
350
|
-
|
|
351
|
+
|
|
351
352
|
// Just close the socket in our application since it's handled at kernel level
|
|
352
353
|
socket.end();
|
|
353
354
|
this.connectionManager.cleanupConnection(record, 'nftables_handled');
|
|
354
355
|
return;
|
|
355
356
|
}
|
|
356
|
-
|
|
357
|
+
|
|
357
358
|
// Handle the route based on its action type
|
|
358
359
|
switch (route.action.type) {
|
|
359
360
|
case 'forward':
|
|
360
361
|
return this.handleForwardAction(socket, record, route, initialChunk);
|
|
361
|
-
|
|
362
|
+
|
|
362
363
|
case 'redirect':
|
|
363
364
|
return this.handleRedirectAction(socket, record, route);
|
|
364
|
-
|
|
365
|
+
|
|
365
366
|
case 'block':
|
|
366
367
|
return this.handleBlockAction(socket, record, route);
|
|
367
|
-
|
|
368
|
+
|
|
368
369
|
case 'static':
|
|
369
370
|
this.handleStaticAction(socket, record, route);
|
|
370
371
|
return;
|
|
371
|
-
|
|
372
|
+
|
|
372
373
|
default:
|
|
373
374
|
console.log(`[${connectionId}] Unknown action type: ${(route.action as any).type}`);
|
|
374
375
|
socket.end();
|
|
375
376
|
this.connectionManager.cleanupConnection(record, 'unknown_action');
|
|
376
377
|
}
|
|
377
378
|
}
|
|
378
|
-
|
|
379
|
+
|
|
379
380
|
/**
|
|
380
381
|
* Handle a forward action for a route
|
|
381
382
|
*/
|
|
@@ -394,33 +395,35 @@ export class RouteConnectionHandler {
|
|
|
394
395
|
if (this.settings.enableDetailedLogging) {
|
|
395
396
|
console.log(
|
|
396
397
|
`[${record.id}] Connection forwarded by NFTables (kernel-level): ` +
|
|
397
|
-
|
|
398
|
-
|
|
398
|
+
`${record.remoteIP}:${socket.remotePort} -> ${socket.localAddress}:${record.localPort}` +
|
|
399
|
+
` (Route: "${route.name || 'unnamed'}", Domain: ${record.lockedDomain || 'n/a'})`
|
|
399
400
|
);
|
|
400
401
|
} else {
|
|
401
402
|
console.log(
|
|
402
|
-
`[${record.id}] NFTables forwarding: ${record.remoteIP} -> port ${
|
|
403
|
+
`[${record.id}] NFTables forwarding: ${record.remoteIP} -> port ${
|
|
404
|
+
record.localPort
|
|
405
|
+
} (Route: "${route.name || 'unnamed'}")`
|
|
403
406
|
);
|
|
404
407
|
}
|
|
405
|
-
|
|
408
|
+
|
|
406
409
|
// Additional NFTables-specific logging if configured
|
|
407
410
|
if (action.nftables) {
|
|
408
411
|
const nftConfig = action.nftables;
|
|
409
412
|
if (this.settings.enableDetailedLogging) {
|
|
410
413
|
console.log(
|
|
411
414
|
`[${record.id}] NFTables config: ` +
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
415
|
+
`protocol=${nftConfig.protocol || 'tcp'}, ` +
|
|
416
|
+
`preserveSourceIP=${nftConfig.preserveSourceIP || false}, ` +
|
|
417
|
+
`priority=${nftConfig.priority || 'default'}, ` +
|
|
418
|
+
`maxRate=${nftConfig.maxRate || 'unlimited'}`
|
|
416
419
|
);
|
|
417
420
|
}
|
|
418
421
|
}
|
|
419
|
-
|
|
422
|
+
|
|
420
423
|
// This connection is handled at the kernel level, no need to process at application level
|
|
421
424
|
// Close the socket gracefully in our application layer
|
|
422
425
|
socket.end();
|
|
423
|
-
|
|
426
|
+
|
|
424
427
|
// Mark the connection as handled by NFTables for proper cleanup
|
|
425
428
|
record.nftablesHandled = true;
|
|
426
429
|
this.connectionManager.initiateCleanupOnce(record, 'nftables_handled');
|
|
@@ -445,7 +448,7 @@ export class RouteConnectionHandler {
|
|
|
445
448
|
isTls: record.isTLS || false,
|
|
446
449
|
tlsVersion: record.tlsVersion,
|
|
447
450
|
routeName: route.name,
|
|
448
|
-
routeId: route.id
|
|
451
|
+
routeId: route.id,
|
|
449
452
|
});
|
|
450
453
|
|
|
451
454
|
// Cache the context for potential reuse
|
|
@@ -457,7 +460,11 @@ export class RouteConnectionHandler {
|
|
|
457
460
|
try {
|
|
458
461
|
targetHost = action.target.host(routeContext);
|
|
459
462
|
if (this.settings.enableDetailedLogging) {
|
|
460
|
-
console.log(
|
|
463
|
+
console.log(
|
|
464
|
+
`[${connectionId}] Dynamic host resolved to: ${
|
|
465
|
+
Array.isArray(targetHost) ? targetHost.join(', ') : targetHost
|
|
466
|
+
}`
|
|
467
|
+
);
|
|
461
468
|
}
|
|
462
469
|
} catch (err) {
|
|
463
470
|
console.log(`[${connectionId}] Error in host mapping function: ${err}`);
|
|
@@ -480,7 +487,9 @@ export class RouteConnectionHandler {
|
|
|
480
487
|
try {
|
|
481
488
|
targetPort = action.target.port(routeContext);
|
|
482
489
|
if (this.settings.enableDetailedLogging) {
|
|
483
|
-
console.log(
|
|
490
|
+
console.log(
|
|
491
|
+
`[${connectionId}] Dynamic port mapping: ${record.localPort} -> ${targetPort}`
|
|
492
|
+
);
|
|
484
493
|
}
|
|
485
494
|
// Store the resolved target port in the context for potential future use
|
|
486
495
|
routeContext.targetPort = targetPort;
|
|
@@ -509,7 +518,7 @@ export class RouteConnectionHandler {
|
|
|
509
518
|
if (this.settings.enableDetailedLogging) {
|
|
510
519
|
console.log(`[${connectionId}] Using TLS passthrough to ${selectedHost}:${targetPort}`);
|
|
511
520
|
}
|
|
512
|
-
|
|
521
|
+
|
|
513
522
|
return this.setupDirectConnection(
|
|
514
523
|
socket,
|
|
515
524
|
record,
|
|
@@ -519,48 +528,50 @@ export class RouteConnectionHandler {
|
|
|
519
528
|
selectedHost,
|
|
520
529
|
targetPort
|
|
521
530
|
);
|
|
522
|
-
|
|
531
|
+
|
|
523
532
|
case 'terminate':
|
|
524
533
|
case 'terminate-and-reencrypt':
|
|
525
|
-
// For TLS termination, use
|
|
526
|
-
if (this.
|
|
534
|
+
// For TLS termination, use HttpProxy
|
|
535
|
+
if (this.httpProxyBridge.getHttpProxy()) {
|
|
527
536
|
if (this.settings.enableDetailedLogging) {
|
|
528
537
|
console.log(
|
|
529
|
-
`[${connectionId}] Using
|
|
538
|
+
`[${connectionId}] Using HttpProxy for TLS termination to ${action.target.host}`
|
|
530
539
|
);
|
|
531
540
|
}
|
|
532
|
-
|
|
541
|
+
|
|
533
542
|
// If we have an initial chunk with TLS data, start processing it
|
|
534
543
|
if (initialChunk && record.isTLS) {
|
|
535
|
-
this.
|
|
544
|
+
this.httpProxyBridge.forwardToHttpProxy(
|
|
536
545
|
connectionId,
|
|
537
546
|
socket,
|
|
538
547
|
record,
|
|
539
548
|
initialChunk,
|
|
540
|
-
this.settings.
|
|
549
|
+
this.settings.httpProxyPort || 8443,
|
|
541
550
|
(reason) => this.connectionManager.initiateCleanupOnce(record, reason)
|
|
542
551
|
);
|
|
543
552
|
return;
|
|
544
553
|
}
|
|
545
|
-
|
|
554
|
+
|
|
546
555
|
// This shouldn't normally happen - we should have TLS data at this point
|
|
547
556
|
console.log(`[${connectionId}] TLS termination route without TLS data`);
|
|
548
557
|
socket.end();
|
|
549
558
|
this.connectionManager.cleanupConnection(record, 'tls_error');
|
|
550
559
|
return;
|
|
551
560
|
} else {
|
|
552
|
-
console.log(`[${connectionId}]
|
|
561
|
+
console.log(`[${connectionId}] HttpProxy not available for TLS termination`);
|
|
553
562
|
socket.end();
|
|
554
|
-
this.connectionManager.cleanupConnection(record, '
|
|
563
|
+
this.connectionManager.cleanupConnection(record, 'no_http_proxy');
|
|
555
564
|
return;
|
|
556
565
|
}
|
|
557
566
|
}
|
|
558
567
|
} else {
|
|
559
568
|
// No TLS settings - basic forwarding
|
|
560
569
|
if (this.settings.enableDetailedLogging) {
|
|
561
|
-
console.log(
|
|
570
|
+
console.log(
|
|
571
|
+
`[${connectionId}] Using basic forwarding to ${action.target.host}:${action.target.port}`
|
|
572
|
+
);
|
|
562
573
|
}
|
|
563
|
-
|
|
574
|
+
|
|
564
575
|
// Get the appropriate host value
|
|
565
576
|
let targetHost: string;
|
|
566
577
|
|
|
@@ -602,7 +613,7 @@ export class RouteConnectionHandler {
|
|
|
602
613
|
);
|
|
603
614
|
}
|
|
604
615
|
}
|
|
605
|
-
|
|
616
|
+
|
|
606
617
|
/**
|
|
607
618
|
* Handle a redirect action for a route
|
|
608
619
|
*/
|
|
@@ -611,87 +622,22 @@ export class RouteConnectionHandler {
|
|
|
611
622
|
record: IConnectionRecord,
|
|
612
623
|
route: IRouteConfig
|
|
613
624
|
): void {
|
|
614
|
-
const connectionId = record.id;
|
|
615
|
-
const action = route.action;
|
|
616
|
-
|
|
617
|
-
// We should have a redirect configuration
|
|
618
|
-
if (!action.redirect) {
|
|
619
|
-
console.log(`[${connectionId}] Redirect action missing redirect configuration`);
|
|
620
|
-
socket.end();
|
|
621
|
-
this.connectionManager.cleanupConnection(record, 'missing_redirect');
|
|
622
|
-
return;
|
|
623
|
-
}
|
|
624
|
-
|
|
625
625
|
// For TLS connections, we can't do redirects at the TCP level
|
|
626
626
|
if (record.isTLS) {
|
|
627
|
-
console.log(`[${
|
|
627
|
+
console.log(`[${record.id}] Cannot redirect TLS connection at TCP level`);
|
|
628
628
|
socket.end();
|
|
629
629
|
this.connectionManager.cleanupConnection(record, 'tls_redirect_error');
|
|
630
630
|
return;
|
|
631
631
|
}
|
|
632
|
-
|
|
633
|
-
//
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
socket.removeListener('data', listener);
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
// Parse HTTP request to get path
|
|
643
|
-
try {
|
|
644
|
-
const headersEnd = chunk.indexOf('\r\n\r\n');
|
|
645
|
-
if (headersEnd === -1) {
|
|
646
|
-
// Not a complete HTTP request, need more data
|
|
647
|
-
socket.once('data', httpDataHandler);
|
|
648
|
-
dataListeners.push(httpDataHandler);
|
|
649
|
-
return;
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
const httpHeaders = chunk.slice(0, headersEnd).toString();
|
|
653
|
-
const requestLine = httpHeaders.split('\r\n')[0];
|
|
654
|
-
const [method, path] = requestLine.split(' ');
|
|
655
|
-
|
|
656
|
-
// Extract Host header
|
|
657
|
-
const hostMatch = httpHeaders.match(/Host: (.+?)(\r\n|\r|\n|$)/i);
|
|
658
|
-
const host = hostMatch ? hostMatch[1].trim() : record.lockedDomain || '';
|
|
659
|
-
|
|
660
|
-
// Process the redirect URL with template variables
|
|
661
|
-
let redirectUrl = action.redirect.to;
|
|
662
|
-
redirectUrl = redirectUrl.replace(/\{domain\}/g, host);
|
|
663
|
-
redirectUrl = redirectUrl.replace(/\{path\}/g, path || '');
|
|
664
|
-
redirectUrl = redirectUrl.replace(/\{port\}/g, record.localPort.toString());
|
|
665
|
-
|
|
666
|
-
// Prepare the HTTP redirect response
|
|
667
|
-
const redirectResponse = [
|
|
668
|
-
`HTTP/1.1 ${action.redirect.status} Moved`,
|
|
669
|
-
`Location: ${redirectUrl}`,
|
|
670
|
-
'Connection: close',
|
|
671
|
-
'Content-Length: 0',
|
|
672
|
-
'',
|
|
673
|
-
''
|
|
674
|
-
].join('\r\n');
|
|
675
|
-
|
|
676
|
-
if (this.settings.enableDetailedLogging) {
|
|
677
|
-
console.log(`[${connectionId}] Redirecting to ${redirectUrl} with status ${action.redirect.status}`);
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
// Send the redirect response
|
|
681
|
-
socket.end(redirectResponse);
|
|
682
|
-
this.connectionManager.initiateCleanupOnce(record, 'redirect_complete');
|
|
683
|
-
} catch (err) {
|
|
684
|
-
console.log(`[${connectionId}] Error processing HTTP redirect: ${err}`);
|
|
685
|
-
socket.end();
|
|
686
|
-
this.connectionManager.initiateCleanupOnce(record, 'redirect_error');
|
|
687
|
-
}
|
|
688
|
-
};
|
|
689
|
-
|
|
690
|
-
// Setup the HTTP data handler
|
|
691
|
-
socket.once('data', httpDataHandler);
|
|
692
|
-
dataListeners.push(httpDataHandler);
|
|
632
|
+
|
|
633
|
+
// Delegate to HttpProxy's RedirectHandler
|
|
634
|
+
RedirectHandler.handleRedirect(socket, route, {
|
|
635
|
+
connectionId: record.id,
|
|
636
|
+
connectionManager: this.connectionManager,
|
|
637
|
+
settings: this.settings
|
|
638
|
+
});
|
|
693
639
|
}
|
|
694
|
-
|
|
640
|
+
|
|
695
641
|
/**
|
|
696
642
|
* Handle a block action for a route
|
|
697
643
|
*/
|
|
@@ -701,16 +647,18 @@ export class RouteConnectionHandler {
|
|
|
701
647
|
route: IRouteConfig
|
|
702
648
|
): void {
|
|
703
649
|
const connectionId = record.id;
|
|
704
|
-
|
|
650
|
+
|
|
705
651
|
if (this.settings.enableDetailedLogging) {
|
|
706
|
-
console.log(
|
|
652
|
+
console.log(
|
|
653
|
+
`[${connectionId}] Blocking connection based on route "${route.name || 'unnamed'}"`
|
|
654
|
+
);
|
|
707
655
|
}
|
|
708
|
-
|
|
656
|
+
|
|
709
657
|
// Simply close the connection
|
|
710
658
|
socket.end();
|
|
711
659
|
this.connectionManager.initiateCleanupOnce(record, 'route_blocked');
|
|
712
660
|
}
|
|
713
|
-
|
|
661
|
+
|
|
714
662
|
/**
|
|
715
663
|
* Handle a static action for a route
|
|
716
664
|
*/
|
|
@@ -719,150 +667,14 @@ export class RouteConnectionHandler {
|
|
|
719
667
|
record: IConnectionRecord,
|
|
720
668
|
route: IRouteConfig
|
|
721
669
|
): Promise<void> {
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
return;
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
let buffer = Buffer.alloc(0);
|
|
732
|
-
|
|
733
|
-
const handleHttpData = async (chunk: Buffer) => {
|
|
734
|
-
buffer = Buffer.concat([buffer, chunk]);
|
|
735
|
-
|
|
736
|
-
// Look for end of HTTP headers
|
|
737
|
-
const headerEndIndex = buffer.indexOf('\r\n\r\n');
|
|
738
|
-
if (headerEndIndex === -1) {
|
|
739
|
-
// Need more data
|
|
740
|
-
if (buffer.length > 8192) { // Prevent excessive buffering
|
|
741
|
-
console.error(`[${connectionId}] HTTP headers too large`);
|
|
742
|
-
socket.end();
|
|
743
|
-
this.connectionManager.cleanupConnection(record, 'headers_too_large');
|
|
744
|
-
}
|
|
745
|
-
return;
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
// Parse the HTTP request
|
|
749
|
-
const headerBuffer = buffer.slice(0, headerEndIndex);
|
|
750
|
-
const headers = headerBuffer.toString();
|
|
751
|
-
const lines = headers.split('\r\n');
|
|
752
|
-
|
|
753
|
-
if (lines.length === 0) {
|
|
754
|
-
console.error(`[${connectionId}] Invalid HTTP request`);
|
|
755
|
-
socket.end();
|
|
756
|
-
this.connectionManager.cleanupConnection(record, 'invalid_request');
|
|
757
|
-
return;
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
// Parse request line
|
|
761
|
-
const requestLine = lines[0];
|
|
762
|
-
const requestParts = requestLine.split(' ');
|
|
763
|
-
if (requestParts.length < 3) {
|
|
764
|
-
console.error(`[${connectionId}] Invalid HTTP request line`);
|
|
765
|
-
socket.end();
|
|
766
|
-
this.connectionManager.cleanupConnection(record, 'invalid_request_line');
|
|
767
|
-
return;
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
const [method, path, httpVersion] = requestParts;
|
|
771
|
-
|
|
772
|
-
// Parse headers
|
|
773
|
-
const headersMap: Record<string, string> = {};
|
|
774
|
-
for (let i = 1; i < lines.length; i++) {
|
|
775
|
-
const colonIndex = lines[i].indexOf(':');
|
|
776
|
-
if (colonIndex > 0) {
|
|
777
|
-
const key = lines[i].slice(0, colonIndex).trim().toLowerCase();
|
|
778
|
-
const value = lines[i].slice(colonIndex + 1).trim();
|
|
779
|
-
headersMap[key] = value;
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
// Extract query string if present
|
|
784
|
-
let pathname = path;
|
|
785
|
-
let query: string | undefined;
|
|
786
|
-
const queryIndex = path.indexOf('?');
|
|
787
|
-
if (queryIndex !== -1) {
|
|
788
|
-
pathname = path.slice(0, queryIndex);
|
|
789
|
-
query = path.slice(queryIndex + 1);
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
try {
|
|
793
|
-
// Build route context with parsed HTTP information
|
|
794
|
-
const context: IRouteContext = {
|
|
795
|
-
port: record.localPort,
|
|
796
|
-
domain: record.lockedDomain || headersMap['host']?.split(':')[0],
|
|
797
|
-
clientIp: record.remoteIP,
|
|
798
|
-
serverIp: socket.localAddress!,
|
|
799
|
-
path: pathname,
|
|
800
|
-
query: query,
|
|
801
|
-
headers: headersMap,
|
|
802
|
-
method: method,
|
|
803
|
-
isTls: record.isTLS,
|
|
804
|
-
tlsVersion: record.tlsVersion,
|
|
805
|
-
routeName: route.name,
|
|
806
|
-
routeId: route.name,
|
|
807
|
-
timestamp: Date.now(),
|
|
808
|
-
connectionId
|
|
809
|
-
};
|
|
810
|
-
|
|
811
|
-
// Remove the data listener since we're handling the request
|
|
812
|
-
socket.removeListener('data', handleHttpData);
|
|
813
|
-
|
|
814
|
-
// Call the handler with the properly parsed context
|
|
815
|
-
const response = await route.action.handler(context);
|
|
816
|
-
|
|
817
|
-
// Prepare the HTTP response
|
|
818
|
-
const responseHeaders = response.headers || {};
|
|
819
|
-
const contentLength = Buffer.byteLength(response.body || '');
|
|
820
|
-
responseHeaders['Content-Length'] = contentLength.toString();
|
|
821
|
-
|
|
822
|
-
if (!responseHeaders['Content-Type']) {
|
|
823
|
-
responseHeaders['Content-Type'] = 'text/plain';
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
// Build the response
|
|
827
|
-
let httpResponse = `HTTP/1.1 ${response.status} ${getStatusText(response.status)}\r\n`;
|
|
828
|
-
for (const [key, value] of Object.entries(responseHeaders)) {
|
|
829
|
-
httpResponse += `${key}: ${value}\r\n`;
|
|
830
|
-
}
|
|
831
|
-
httpResponse += '\r\n';
|
|
832
|
-
|
|
833
|
-
// Send response
|
|
834
|
-
socket.write(httpResponse);
|
|
835
|
-
if (response.body) {
|
|
836
|
-
socket.write(response.body);
|
|
837
|
-
}
|
|
838
|
-
socket.end();
|
|
839
|
-
|
|
840
|
-
this.connectionManager.cleanupConnection(record, 'completed');
|
|
841
|
-
} catch (error) {
|
|
842
|
-
console.error(`[${connectionId}] Error in static handler: ${error}`);
|
|
843
|
-
|
|
844
|
-
// Send error response
|
|
845
|
-
const errorResponse = 'HTTP/1.1 500 Internal Server Error\r\n' +
|
|
846
|
-
'Content-Type: text/plain\r\n' +
|
|
847
|
-
'Content-Length: 21\r\n' +
|
|
848
|
-
'\r\n' +
|
|
849
|
-
'Internal Server Error';
|
|
850
|
-
socket.write(errorResponse);
|
|
851
|
-
socket.end();
|
|
852
|
-
|
|
853
|
-
this.connectionManager.cleanupConnection(record, 'handler_error');
|
|
854
|
-
}
|
|
855
|
-
};
|
|
856
|
-
|
|
857
|
-
// Listen for data
|
|
858
|
-
socket.on('data', handleHttpData);
|
|
859
|
-
|
|
860
|
-
// Ensure cleanup on socket close
|
|
861
|
-
socket.once('close', () => {
|
|
862
|
-
socket.removeListener('data', handleHttpData);
|
|
863
|
-
});
|
|
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);
|
|
864
676
|
}
|
|
865
|
-
|
|
677
|
+
|
|
866
678
|
/**
|
|
867
679
|
* Sets up a direct connection to the target
|
|
868
680
|
*/
|
|
@@ -878,22 +690,23 @@ export class RouteConnectionHandler {
|
|
|
878
690
|
const connectionId = record.id;
|
|
879
691
|
|
|
880
692
|
// Determine target host and port if not provided
|
|
881
|
-
const finalTargetHost =
|
|
882
|
-
record.targetHost ||
|
|
883
|
-
(this.settings.defaults?.target?.host || 'localhost');
|
|
693
|
+
const finalTargetHost =
|
|
694
|
+
targetHost || record.targetHost || this.settings.defaults?.target?.host || 'localhost';
|
|
884
695
|
|
|
885
696
|
// Determine target port
|
|
886
|
-
const finalTargetPort =
|
|
697
|
+
const finalTargetPort =
|
|
698
|
+
targetPort ||
|
|
887
699
|
record.targetPort ||
|
|
888
|
-
(overridePort !== undefined ? overridePort :
|
|
889
|
-
(this.settings.defaults?.target?.port || 443));
|
|
700
|
+
(overridePort !== undefined ? overridePort : this.settings.defaults?.target?.port || 443);
|
|
890
701
|
|
|
891
702
|
// Update record with final target information
|
|
892
703
|
record.targetHost = finalTargetHost;
|
|
893
704
|
record.targetPort = finalTargetPort;
|
|
894
705
|
|
|
895
706
|
if (this.settings.enableDetailedLogging) {
|
|
896
|
-
console.log(
|
|
707
|
+
console.log(
|
|
708
|
+
`[${connectionId}] Setting up direct connection to ${finalTargetHost}:${finalTargetPort}`
|
|
709
|
+
);
|
|
897
710
|
}
|
|
898
711
|
|
|
899
712
|
// Setup connection options
|
|
@@ -906,53 +719,53 @@ export class RouteConnectionHandler {
|
|
|
906
719
|
if (this.settings.defaults?.preserveSourceIP || this.settings.preserveSourceIP) {
|
|
907
720
|
connectionOptions.localAddress = record.remoteIP.replace('::ffff:', '');
|
|
908
721
|
}
|
|
909
|
-
|
|
722
|
+
|
|
910
723
|
// Create a safe queue for incoming data
|
|
911
724
|
const dataQueue: Buffer[] = [];
|
|
912
725
|
let queueSize = 0;
|
|
913
726
|
let processingQueue = false;
|
|
914
727
|
let drainPending = false;
|
|
915
728
|
let pipingEstablished = false;
|
|
916
|
-
|
|
729
|
+
|
|
917
730
|
// Pause the incoming socket to prevent buffer overflows
|
|
918
731
|
socket.pause();
|
|
919
|
-
|
|
732
|
+
|
|
920
733
|
// Function to safely process the data queue without losing events
|
|
921
734
|
const processDataQueue = () => {
|
|
922
735
|
if (processingQueue || dataQueue.length === 0 || pipingEstablished) return;
|
|
923
|
-
|
|
736
|
+
|
|
924
737
|
processingQueue = true;
|
|
925
|
-
|
|
738
|
+
|
|
926
739
|
try {
|
|
927
740
|
// Process all queued chunks with the current active handler
|
|
928
741
|
while (dataQueue.length > 0) {
|
|
929
742
|
const chunk = dataQueue.shift()!;
|
|
930
743
|
queueSize -= chunk.length;
|
|
931
|
-
|
|
744
|
+
|
|
932
745
|
// Once piping is established, we shouldn't get here,
|
|
933
746
|
// but just in case, pass to the outgoing socket directly
|
|
934
747
|
if (pipingEstablished && record.outgoing) {
|
|
935
748
|
record.outgoing.write(chunk);
|
|
936
749
|
continue;
|
|
937
750
|
}
|
|
938
|
-
|
|
751
|
+
|
|
939
752
|
// Track bytes received
|
|
940
753
|
record.bytesReceived += chunk.length;
|
|
941
|
-
|
|
754
|
+
|
|
942
755
|
// Check for TLS handshake
|
|
943
756
|
if (!record.isTLS && this.tlsManager.isTlsHandshake(chunk)) {
|
|
944
757
|
record.isTLS = true;
|
|
945
|
-
|
|
758
|
+
|
|
946
759
|
if (this.settings.enableTlsDebugLogging) {
|
|
947
760
|
console.log(
|
|
948
761
|
`[${connectionId}] TLS handshake detected in tempDataHandler, ${chunk.length} bytes`
|
|
949
762
|
);
|
|
950
763
|
}
|
|
951
764
|
}
|
|
952
|
-
|
|
765
|
+
|
|
953
766
|
// Check if adding this chunk would exceed the buffer limit
|
|
954
767
|
const newSize = record.pendingDataSize + chunk.length;
|
|
955
|
-
|
|
768
|
+
|
|
956
769
|
if (this.settings.maxPendingDataSize && newSize > this.settings.maxPendingDataSize) {
|
|
957
770
|
console.log(
|
|
958
771
|
`[${connectionId}] Buffer limit exceeded for connection from ${record.remoteIP}: ${newSize} bytes > ${this.settings.maxPendingDataSize} bytes`
|
|
@@ -961,7 +774,7 @@ export class RouteConnectionHandler {
|
|
|
961
774
|
this.connectionManager.initiateCleanupOnce(record, 'buffer_limit_exceeded');
|
|
962
775
|
return;
|
|
963
776
|
}
|
|
964
|
-
|
|
777
|
+
|
|
965
778
|
// Buffer the chunk and update the size counter
|
|
966
779
|
record.pendingData.push(Buffer.from(chunk));
|
|
967
780
|
record.pendingDataSize = newSize;
|
|
@@ -969,7 +782,7 @@ export class RouteConnectionHandler {
|
|
|
969
782
|
}
|
|
970
783
|
} finally {
|
|
971
784
|
processingQueue = false;
|
|
972
|
-
|
|
785
|
+
|
|
973
786
|
// If there's a pending drain and we've processed everything,
|
|
974
787
|
// signal we're ready for more data if we haven't established piping yet
|
|
975
788
|
if (drainPending && dataQueue.length === 0 && !pipingEstablished) {
|
|
@@ -978,48 +791,48 @@ export class RouteConnectionHandler {
|
|
|
978
791
|
}
|
|
979
792
|
}
|
|
980
793
|
};
|
|
981
|
-
|
|
794
|
+
|
|
982
795
|
// Unified data handler that safely queues incoming data
|
|
983
796
|
const safeDataHandler = (chunk: Buffer) => {
|
|
984
797
|
// If piping is already established, just let the pipe handle it
|
|
985
798
|
if (pipingEstablished) return;
|
|
986
|
-
|
|
799
|
+
|
|
987
800
|
// Add to our queue for orderly processing
|
|
988
801
|
dataQueue.push(Buffer.from(chunk)); // Make a copy to be safe
|
|
989
802
|
queueSize += chunk.length;
|
|
990
|
-
|
|
803
|
+
|
|
991
804
|
// If queue is getting large, pause socket until we catch up
|
|
992
805
|
if (this.settings.maxPendingDataSize && queueSize > this.settings.maxPendingDataSize * 0.8) {
|
|
993
806
|
socket.pause();
|
|
994
807
|
drainPending = true;
|
|
995
808
|
}
|
|
996
|
-
|
|
809
|
+
|
|
997
810
|
// Process the queue
|
|
998
811
|
processDataQueue();
|
|
999
812
|
};
|
|
1000
|
-
|
|
813
|
+
|
|
1001
814
|
// Add our safe data handler
|
|
1002
815
|
socket.on('data', safeDataHandler);
|
|
1003
|
-
|
|
816
|
+
|
|
1004
817
|
// Add initial chunk to pending data if present
|
|
1005
818
|
if (initialChunk) {
|
|
1006
819
|
record.bytesReceived += initialChunk.length;
|
|
1007
820
|
record.pendingData.push(Buffer.from(initialChunk));
|
|
1008
821
|
record.pendingDataSize = initialChunk.length;
|
|
1009
822
|
}
|
|
1010
|
-
|
|
823
|
+
|
|
1011
824
|
// Create the target socket but don't set up piping immediately
|
|
1012
825
|
const targetSocket = plugins.net.connect(connectionOptions);
|
|
1013
826
|
record.outgoing = targetSocket;
|
|
1014
827
|
record.outgoingStartTime = Date.now();
|
|
1015
|
-
|
|
828
|
+
|
|
1016
829
|
// Apply socket optimizations
|
|
1017
830
|
targetSocket.setNoDelay(this.settings.noDelay);
|
|
1018
|
-
|
|
831
|
+
|
|
1019
832
|
// Apply keep-alive settings to the outgoing connection as well
|
|
1020
833
|
if (this.settings.keepAlive) {
|
|
1021
834
|
targetSocket.setKeepAlive(true, this.settings.keepAliveInitialDelay);
|
|
1022
|
-
|
|
835
|
+
|
|
1023
836
|
// Apply enhanced TCP keep-alive options if enabled
|
|
1024
837
|
if (this.settings.enableKeepAliveProbes) {
|
|
1025
838
|
try {
|
|
@@ -1039,7 +852,7 @@ export class RouteConnectionHandler {
|
|
|
1039
852
|
}
|
|
1040
853
|
}
|
|
1041
854
|
}
|
|
1042
|
-
|
|
855
|
+
|
|
1043
856
|
// Setup specific error handler for connection phase
|
|
1044
857
|
targetSocket.once('error', (err) => {
|
|
1045
858
|
// This handler runs only once during the initial connection phase
|
|
@@ -1047,10 +860,10 @@ export class RouteConnectionHandler {
|
|
|
1047
860
|
console.log(
|
|
1048
861
|
`[${connectionId}] Connection setup error to ${finalTargetHost}:${connectionOptions.port}: ${err.message} (${code})`
|
|
1049
862
|
);
|
|
1050
|
-
|
|
863
|
+
|
|
1051
864
|
// Resume the incoming socket to prevent it from hanging
|
|
1052
865
|
socket.resume();
|
|
1053
|
-
|
|
866
|
+
|
|
1054
867
|
if (code === 'ECONNREFUSED') {
|
|
1055
868
|
console.log(
|
|
1056
869
|
`[${connectionId}] Target ${finalTargetHost}:${connectionOptions.port} refused connection`
|
|
@@ -1066,28 +879,28 @@ export class RouteConnectionHandler {
|
|
|
1066
879
|
} else if (code === 'EHOSTUNREACH') {
|
|
1067
880
|
console.log(`[${connectionId}] Host ${finalTargetHost} is unreachable`);
|
|
1068
881
|
}
|
|
1069
|
-
|
|
882
|
+
|
|
1070
883
|
// Clear any existing error handler after connection phase
|
|
1071
884
|
targetSocket.removeAllListeners('error');
|
|
1072
|
-
|
|
885
|
+
|
|
1073
886
|
// Re-add the normal error handler for established connections
|
|
1074
887
|
targetSocket.on('error', this.connectionManager.handleError('outgoing', record));
|
|
1075
|
-
|
|
888
|
+
|
|
1076
889
|
if (record.outgoingTerminationReason === null) {
|
|
1077
890
|
record.outgoingTerminationReason = 'connection_failed';
|
|
1078
891
|
this.connectionManager.incrementTerminationStat('outgoing', 'connection_failed');
|
|
1079
892
|
}
|
|
1080
|
-
|
|
893
|
+
|
|
1081
894
|
// Route-based configuration doesn't use domain handlers
|
|
1082
|
-
|
|
895
|
+
|
|
1083
896
|
// Clean up the connection
|
|
1084
897
|
this.connectionManager.initiateCleanupOnce(record, `connection_failed_${code}`);
|
|
1085
898
|
});
|
|
1086
|
-
|
|
899
|
+
|
|
1087
900
|
// Setup close handler
|
|
1088
901
|
targetSocket.on('close', this.connectionManager.handleClose('outgoing', record));
|
|
1089
902
|
socket.on('close', this.connectionManager.handleClose('incoming', record));
|
|
1090
|
-
|
|
903
|
+
|
|
1091
904
|
// Handle timeouts with keep-alive awareness
|
|
1092
905
|
socket.on('timeout', () => {
|
|
1093
906
|
// For keep-alive connections, just log a warning instead of closing
|
|
@@ -1101,7 +914,7 @@ export class RouteConnectionHandler {
|
|
|
1101
914
|
);
|
|
1102
915
|
return;
|
|
1103
916
|
}
|
|
1104
|
-
|
|
917
|
+
|
|
1105
918
|
// For non-keep-alive connections, proceed with normal cleanup
|
|
1106
919
|
console.log(
|
|
1107
920
|
`[${connectionId}] Timeout on incoming side from ${
|
|
@@ -1114,7 +927,7 @@ export class RouteConnectionHandler {
|
|
|
1114
927
|
}
|
|
1115
928
|
this.connectionManager.initiateCleanupOnce(record, 'timeout_incoming');
|
|
1116
929
|
});
|
|
1117
|
-
|
|
930
|
+
|
|
1118
931
|
targetSocket.on('timeout', () => {
|
|
1119
932
|
// For keep-alive connections, just log a warning instead of closing
|
|
1120
933
|
if (record.hasKeepAlive) {
|
|
@@ -1127,7 +940,7 @@ export class RouteConnectionHandler {
|
|
|
1127
940
|
);
|
|
1128
941
|
return;
|
|
1129
942
|
}
|
|
1130
|
-
|
|
943
|
+
|
|
1131
944
|
// For non-keep-alive connections, proceed with normal cleanup
|
|
1132
945
|
console.log(
|
|
1133
946
|
`[${connectionId}] Timeout on outgoing side from ${
|
|
@@ -1140,40 +953,40 @@ export class RouteConnectionHandler {
|
|
|
1140
953
|
}
|
|
1141
954
|
this.connectionManager.initiateCleanupOnce(record, 'timeout_outgoing');
|
|
1142
955
|
});
|
|
1143
|
-
|
|
956
|
+
|
|
1144
957
|
// Apply socket timeouts
|
|
1145
958
|
this.timeoutManager.applySocketTimeouts(record);
|
|
1146
|
-
|
|
959
|
+
|
|
1147
960
|
// Track outgoing data for bytes counting
|
|
1148
961
|
targetSocket.on('data', (chunk: Buffer) => {
|
|
1149
962
|
record.bytesSent += chunk.length;
|
|
1150
963
|
this.timeoutManager.updateActivity(record);
|
|
1151
964
|
});
|
|
1152
|
-
|
|
965
|
+
|
|
1153
966
|
// Wait for the outgoing connection to be ready before setting up piping
|
|
1154
967
|
targetSocket.once('connect', () => {
|
|
1155
968
|
// Clear the initial connection error handler
|
|
1156
969
|
targetSocket.removeAllListeners('error');
|
|
1157
|
-
|
|
970
|
+
|
|
1158
971
|
// Add the normal error handler for established connections
|
|
1159
972
|
targetSocket.on('error', this.connectionManager.handleError('outgoing', record));
|
|
1160
|
-
|
|
973
|
+
|
|
1161
974
|
// Process any remaining data in the queue before switching to piping
|
|
1162
975
|
processDataQueue();
|
|
1163
|
-
|
|
976
|
+
|
|
1164
977
|
// Set up piping immediately
|
|
1165
978
|
pipingEstablished = true;
|
|
1166
|
-
|
|
979
|
+
|
|
1167
980
|
// Flush all pending data to target
|
|
1168
981
|
if (record.pendingData.length > 0) {
|
|
1169
982
|
const combinedData = Buffer.concat(record.pendingData);
|
|
1170
|
-
|
|
983
|
+
|
|
1171
984
|
if (this.settings.enableDetailedLogging) {
|
|
1172
985
|
console.log(
|
|
1173
986
|
`[${connectionId}] Forwarding ${combinedData.length} bytes of initial data to target`
|
|
1174
987
|
);
|
|
1175
988
|
}
|
|
1176
|
-
|
|
989
|
+
|
|
1177
990
|
// Write pending data immediately
|
|
1178
991
|
targetSocket.write(combinedData, (err) => {
|
|
1179
992
|
if (err) {
|
|
@@ -1181,19 +994,19 @@ export class RouteConnectionHandler {
|
|
|
1181
994
|
return this.connectionManager.initiateCleanupOnce(record, 'write_error');
|
|
1182
995
|
}
|
|
1183
996
|
});
|
|
1184
|
-
|
|
997
|
+
|
|
1185
998
|
// Clear the buffer now that we've processed it
|
|
1186
999
|
record.pendingData = [];
|
|
1187
1000
|
record.pendingDataSize = 0;
|
|
1188
1001
|
}
|
|
1189
|
-
|
|
1002
|
+
|
|
1190
1003
|
// Setup piping in both directions without any delays
|
|
1191
1004
|
socket.pipe(targetSocket);
|
|
1192
1005
|
targetSocket.pipe(socket);
|
|
1193
|
-
|
|
1006
|
+
|
|
1194
1007
|
// Resume the socket to ensure data flows
|
|
1195
1008
|
socket.resume();
|
|
1196
|
-
|
|
1009
|
+
|
|
1197
1010
|
// Process any data that might be queued in the interim
|
|
1198
1011
|
if (dataQueue.length > 0) {
|
|
1199
1012
|
// Write any remaining queued data directly to the target socket
|
|
@@ -1204,7 +1017,7 @@ export class RouteConnectionHandler {
|
|
|
1204
1017
|
dataQueue.length = 0;
|
|
1205
1018
|
queueSize = 0;
|
|
1206
1019
|
}
|
|
1207
|
-
|
|
1020
|
+
|
|
1208
1021
|
if (this.settings.enableDetailedLogging) {
|
|
1209
1022
|
console.log(
|
|
1210
1023
|
`[${connectionId}] Connection established: ${record.remoteIP} -> ${finalTargetHost}:${connectionOptions.port}` +
|
|
@@ -1231,7 +1044,7 @@ export class RouteConnectionHandler {
|
|
|
1231
1044
|
}`
|
|
1232
1045
|
);
|
|
1233
1046
|
}
|
|
1234
|
-
|
|
1047
|
+
|
|
1235
1048
|
// Add the renegotiation handler for SNI validation
|
|
1236
1049
|
if (serverName) {
|
|
1237
1050
|
// Create connection info object for the existing connection
|
|
@@ -1241,7 +1054,7 @@ export class RouteConnectionHandler {
|
|
|
1241
1054
|
destIp: record.incoming.localAddress || '',
|
|
1242
1055
|
destPort: record.incoming.localPort || 0,
|
|
1243
1056
|
};
|
|
1244
|
-
|
|
1057
|
+
|
|
1245
1058
|
// Create a renegotiation handler function
|
|
1246
1059
|
const renegotiationHandler = this.tlsManager.createRenegotiationHandler(
|
|
1247
1060
|
connectionId,
|
|
@@ -1249,13 +1062,13 @@ export class RouteConnectionHandler {
|
|
|
1249
1062
|
connInfo,
|
|
1250
1063
|
(connectionId, reason) => this.connectionManager.initiateCleanupOnce(record, reason)
|
|
1251
1064
|
);
|
|
1252
|
-
|
|
1065
|
+
|
|
1253
1066
|
// Store the handler in the connection record so we can remove it during cleanup
|
|
1254
1067
|
record.renegotiationHandler = renegotiationHandler;
|
|
1255
|
-
|
|
1068
|
+
|
|
1256
1069
|
// Add the handler to the socket
|
|
1257
1070
|
socket.on('data', renegotiationHandler);
|
|
1258
|
-
|
|
1071
|
+
|
|
1259
1072
|
if (this.settings.enableDetailedLogging) {
|
|
1260
1073
|
console.log(
|
|
1261
1074
|
`[${connectionId}] TLS renegotiation handler installed for SNI domain: ${serverName}`
|
|
@@ -1267,7 +1080,7 @@ export class RouteConnectionHandler {
|
|
|
1267
1080
|
}
|
|
1268
1081
|
}
|
|
1269
1082
|
}
|
|
1270
|
-
|
|
1083
|
+
|
|
1271
1084
|
// Set connection timeout
|
|
1272
1085
|
record.cleanupTimer = this.timeoutManager.setupConnectionTimeout(record, (record, reason) => {
|
|
1273
1086
|
console.log(
|
|
@@ -1275,11 +1088,11 @@ export class RouteConnectionHandler {
|
|
|
1275
1088
|
);
|
|
1276
1089
|
this.connectionManager.initiateCleanupOnce(record, reason);
|
|
1277
1090
|
});
|
|
1278
|
-
|
|
1091
|
+
|
|
1279
1092
|
// Mark TLS handshake as complete for TLS connections
|
|
1280
1093
|
if (record.isTLS) {
|
|
1281
1094
|
record.tlsHandshakeComplete = true;
|
|
1282
|
-
|
|
1095
|
+
|
|
1283
1096
|
if (this.settings.enableTlsDebugLogging) {
|
|
1284
1097
|
console.log(
|
|
1285
1098
|
`[${connectionId}] TLS handshake complete for connection from ${record.remoteIP}`
|
|
@@ -1290,12 +1103,3 @@ export class RouteConnectionHandler {
|
|
|
1290
1103
|
}
|
|
1291
1104
|
}
|
|
1292
1105
|
|
|
1293
|
-
// Helper function for status text
|
|
1294
|
-
function getStatusText(status: number): string {
|
|
1295
|
-
const statusTexts: Record<number, string> = {
|
|
1296
|
-
200: 'OK',
|
|
1297
|
-
404: 'Not Found',
|
|
1298
|
-
500: 'Internal Server Error'
|
|
1299
|
-
};
|
|
1300
|
-
return statusTexts[status] || 'Unknown';
|
|
1301
|
-
}
|