UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

2 lines • 2.01 kB
//!src/infra/net/proxy/active-proxy-state.ts let activeProxyUrl;let activeProxyLoopbackMode;let activeProxyTlsOptions;function parseActiveManagedProxyLoopbackMode(e){if(e===`gateway-only`||e===`proxy`||e===`block`)return e}function readInheritedActiveManagedProxyLoopbackMode(){if(process.env[`OPENCLAW_PROXY_ACTIVE`]!==`1`)return;return parseActiveManagedProxyLoopbackMode(process.env[`OPENCLAW_PROXY_LOOPBACK_MODE`])??`gateway-only`}function registerActiveManagedProxyUrl(e,{loopbackMode:t=`gateway-only`,proxyTls:n}={}){const r=new URL(e.href);if(activeProxyUrl!==void 0){if(activeProxyUrl.href!==r.href)throw new Error(`proxy: cannot activate a managed proxy while another proxy is active; stop the current proxy before changing proxy.proxyUrl.`);if(activeProxyLoopbackMode!==t)throw new Error(`proxy: cannot activate a managed proxy with a different proxy.loopbackMode while another proxy is active; stop the current proxy before changing proxy.loopbackMode.`);if(activeProxyTlsOptions?.ca!==n?.ca)throw new Error(`proxy: cannot activate a managed proxy with different proxy TLS options while another proxy is active; stop the current proxy before changing proxy.tls.`);throw new Error(`proxy: cannot activate a managed proxy while another proxy is active; stop the current proxy before changing proxy.proxyUrl.`)}activeProxyUrl=r;activeProxyLoopbackMode=t;activeProxyTlsOptions=n;return{stopped:false}}function stopActiveManagedProxyRegistration(e){if(e.stopped)return;e.stopped=true;activeProxyUrl=void 0;activeProxyLoopbackMode=void 0;activeProxyTlsOptions=void 0}function getActiveManagedProxyLoopbackMode(){return activeProxyLoopbackMode??readInheritedActiveManagedProxyLoopbackMode()}function getActiveManagedProxyUrl(){return activeProxyUrl}function getActiveManagedProxyTlsOptions(){return activeProxyTlsOptions}export{stopActiveManagedProxyRegistration as a,registerActiveManagedProxyUrl as i,getActiveManagedProxyTlsOptions as n,getActiveManagedProxyUrl as r,getActiveManagedProxyLoopbackMode as t};