Skip to content

Commit

Permalink
Close loopback proxies on SWEX proxy stop
Browse files Browse the repository at this point in the history
  • Loading branch information
Xzandro committed Feb 11, 2024
1 parent 28bb432 commit 3d3b669
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/proxy/SWProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class SWProxy extends EventEmitter {
'summonerswar-kr-lb.qpyou.cn': '127.11.12.17',
'summonerswar-cn-lb.qpyou.cn': '127.11.12.18',
};
this.loopbackProxies = [];
}
async start(port, steamMode) {
const self = this;
Expand All @@ -62,6 +63,7 @@ class SWProxy extends EventEmitter {
const loopbackProxy = new this.steamproxy.TransparentProxy(hostname, 443, proxyHost, proxyPort);
const bindAddr = this.proxiedHostnames[hostname];
loopbackProxy.run(bindAddr, 443);
this.loopbackProxies.push(loopbackProxy);
}
}

Expand Down Expand Up @@ -233,6 +235,13 @@ class SWProxy extends EventEmitter {
this.proxy.close();
this.proxy = null;

if (this.loopbackProxies.length > 0) {
for (const loopbackProxy of this.loopbackProxies) {
loopbackProxy.server.close();
}
this.loopbackProxies = [];
}

await removeHostsEntries(
Object.entries(this.proxiedHostnames).map(([host, ip]) => {
return { ip, host, wrapper: 'SWEX' };
Expand Down

0 comments on commit 3d3b669

Please sign in to comment.