Skip to content

Commit

Permalink
Merge branch 'main' into binary-support-2024
Browse files Browse the repository at this point in the history
  • Loading branch information
Danny-Dasilva authored Aug 10, 2024
2 parents 5872ab4 + 3b2eba0 commit 0387e10
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 54 deletions.
4 changes: 2 additions & 2 deletions cycletls/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ func processRequest(request cycleTLSRequest) (result fullRequest) {
}

}
headeOrder := parseUserAgent(request.Options.UserAgent).HeaderOrder
headerOrder := parseUserAgent(request.Options.UserAgent).HeaderOrder

//ordering the pseudo headers and our normal headers
req.Header = http.Header{
http.HeaderOrderKey: headerorderkey,
http.PHeaderOrderKey: headeOrder,
http.PHeaderOrderKey: headerOrder,
}
//set our Host header
u, err := url.Parse(request.Options.URL)
Expand Down
65 changes: 13 additions & 52 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,37 +71,17 @@ const cleanExit = async (message?: string | Error, exit?: boolean) => {
if (message) console.log(message);
exit = exit ?? true;

if (process.platform == "win32") {
if (child) {
await new Promise((resolve, reject) => {
exec(
"taskkill /pid " + child.pid + " /T /F",
(error: any, stdout: any, stderr: any) => {
if (error) {
console.warn(error);
}
resolve(stdout);
}
);
});
}
} else {
if (child) {
// For Linux/Darwin OS
process.kill(-child.pid);
if (exit)
process.exit();
}
}
child?.kill();
if (exit) process.exit();
};
process.on("SIGINT", () => cleanExit());
process.on("SIGTERM", () => cleanExit());

const handleSpawn = (debug: boolean, fileName: string, port: number, filePath?: string) => {
const execPath = filePath ?? path.join(__dirname, fileName);
const execPath = filePath ? `"${filePath}"` : `"${path.join(__dirname, fileName)}"`;
child = spawn(execPath, {
env: { WS_PORT: port.toString() },
shell: true,
shell: false,
windowsHide: true,
detached: process.platform !== "win32"
});
Expand Down Expand Up @@ -397,34 +377,15 @@ class Golang extends EventEmitter {
}

exit(): Promise<undefined> {
if (process.platform == "win32") {
return new Promise((resolve, reject) => {
this.server.close();
if (this.host) {
exec(
"taskkill /pid " + child.pid + " /T /F",
(error: any, stdout: any, stderr: any) => {
if (error) {
console.warn(error);
}
resolve(stdout ? stdout : stderr);
}
);
} else {
resolve(null);
}
});
} else {
return new Promise((resolve, reject) => {
this.server.close();
if (this.host) {
process.kill(-child.pid);
resolve(null);
} else {
resolve(null);
}
});
}
return new Promise((resolve, reject) => {
this.server.close();
if (this.host) {
child?.kill();
resolve(null);
} else {
resolve(null);
}
});
}
}
export interface CycleTLSClient {
Expand Down

0 comments on commit 0387e10

Please sign in to comment.