1+ import { ipcRenderer } from "electron" ;
12import { staticConfig } from "../config" ;
23
3- var http = require ( "http" ) ;
4- const pem_path = staticConfig . ROOT_CERT_PATH ;
4+ const http = require ( "http" ) ;
5+
6+ const pemPath = staticConfig . ROOT_CERT_PATH ;
7+
8+ function trackHelperServerHit ( ) {
9+ ipcRenderer . invoke ( "helper-server-hit" ) ;
10+ }
511
612const getShellScript = ( port ) => `
713 export http_proxy="http://127.0.0.1:${ port } "
@@ -13,13 +19,13 @@ const getShellScript = (port) => `
1319 export npm_config_proxy="http://127.0.0.1:${ port } "
1420 export npm_config_https_proxy="http://127.0.0.1:${ port } "
1521 export GOPROXY="http://127.0.0.1:${ port } "
16- export SSL_CERT_FILE="${ pem_path } "
17- export NODE_EXTRA_CA_CERTS="${ pem_path } "
18- export REQUESTS_CA_BUNDLE="${ pem_path } "
19- export PERL_LWP_SSL_CA_FILE="${ pem_path } "
20- export GIT_SSL_CAINFO="${ pem_path } "
21- export CARGO_HTTP_CAINFO="${ pem_path } "
22- export CURL_CA_BUNDLE="${ pem_path } "
22+ export SSL_CERT_FILE="${ pemPath } "
23+ export NODE_EXTRA_CA_CERTS="${ pemPath } "
24+ export REQUESTS_CA_BUNDLE="${ pemPath } "
25+ export PERL_LWP_SSL_CA_FILE="${ pemPath } "
26+ export GIT_SSL_CAINFO="${ pemPath } "
27+ export CARGO_HTTP_CAINFO="${ pemPath } "
28+ export CURL_CA_BUNDLE="${ pemPath } "
2329 if command -v winpty >/dev/null 2>&1; then
2430 # Work around for winpty's hijacking of certain commands
2531 alias php=php
@@ -35,12 +41,13 @@ const getShellScript = (port) => `
3541
3642const startHelperServer = async ( helperServerPort ) => {
3743 return new Promise ( ( resolve ) => {
38- var server = http . createServer ( function ( req , res ) {
39- //create web server
44+ const server = http . createServer ( ( req , res ) => {
45+ // create web server
4046 console . log ( window . proxy . httpPort ) ;
41- if ( req . url == "/tpsetup" ) {
47+ if ( req . url === "/tpsetup" ) {
4248 const shellScript = getShellScript ( window . proxy . httpPort ) ;
4349 // const shellScript = `export http_proxy="http://127.0.0.1:${window.proxy.httpPort}"`
50+ trackHelperServerHit ( ) ;
4451 res . writeHead ( 200 , { "Content-Type" : "text/x-shellscript" } ) ;
4552 res . write ( shellScript ) ;
4653 res . end ( ) ;
0 commit comments