fix: Fixes connection closures.

This commit is contained in:
greysoh 2024-05-04 16:38:52 -04:00
parent 86bf85ccf0
commit 364e268b11
No known key found for this signature in database
GPG key ID: FE0F173B8FC01571
3 changed files with 9 additions and 5 deletions

View file

@ -1,5 +1,5 @@
if [ ! -d ".tmp" ]; then
echo "Hello and welcome to the NextNet (backend) project! Please wait while I initialize things for you..."
echo "Please wait while I initialize the backend source for you..."
cp dev.env .env
mkdir .tmp
fi

View file

@ -121,8 +121,7 @@ export class SSHBackendProvider implements BackendBaseClass {
(async() => {
await this.sshInstance.forwardIn("0.0.0.0", destPort, (info, accept, reject) => {
const foundProxyEntry = this.proxies.find((i) => i.sourceIP == sourceIP && i.sourcePort == sourcePort && i.destPort == destPort);
if (!foundProxyEntry) return reject();
if (!foundProxyEntry.enabled) return reject();
if (!foundProxyEntry || !foundProxyEntry.enabled) return reject();
const client: ConnectedClient = {
ip: info.srcIP,
@ -143,11 +142,11 @@ export class SSHBackendProvider implements BackendBaseClass {
// Why is this so confusing
const destConn = accept();
destConn.on("data", (chunk: Uint8Array) => {
destConn.addListener("data", (chunk: Uint8Array) => {
srcConn.write(chunk);
});
destConn.on("exit", () => {
destConn.addListener("close", () => {
this.clients.splice(this.clients.indexOf(client), 1);
srcConn.end();
});

View file

@ -27,6 +27,11 @@
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${pkgs.xorg.libXi}/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${pkgs.libGL}/lib
if [ ! -d ".tmp" ]; then
echo "Hello and welcome to the NextNet project!"
mkdir .tmp
fi
source init.sh
'';
}