diff --git a/src/shadowbox/docker/Dockerfile b/src/shadowbox/docker/Dockerfile index e62ec115..0ad8cb1e 100644 --- a/src/shadowbox/docker/Dockerfile +++ b/src/shadowbox/docker/Dockerfile @@ -25,8 +25,8 @@ LABEL shadowbox.outline-ss-server_version="${SS_VERSION}" ARG GITHUB_RELEASE LABEL shadowbox.github.release="${GITHUB_RELEASE}" -# lsof for Shadowbox, curl for detecting our public IP. -RUN apk add --no-cache lsof curl +# We use curl to detect the server's public IP. +RUN apk add --no-cache curl COPY src/shadowbox/scripts scripts/ COPY src/shadowbox/scripts/update_mmdb.sh /etc/periodic/weekly/update_mmdb diff --git a/src/shadowbox/infrastructure/get_port.spec.ts b/src/shadowbox/infrastructure/get_port.spec.ts index eb9d35f2..1539f7d7 100644 --- a/src/shadowbox/infrastructure/get_port.spec.ts +++ b/src/shadowbox/infrastructure/get_port.spec.ts @@ -60,19 +60,3 @@ function listen(): Promise { }); }); } - -describe('getUsedPorts', () => { - it('returns used port', async () => { - const server = await listen(); - const serverPort = server.address().port; - const usedPorts = await get_port.getUsedPorts(); - expect(usedPorts).toContain(serverPort); - - const onceClosed = new Promise((resolve, reject) => { - server.on('close', () => resolve()); - }); - server.close(); - await onceClosed; - expect(await get_port.getUsedPorts()).not.toContain(serverPort); - }); -}); \ No newline at end of file diff --git a/src/shadowbox/infrastructure/get_port.ts b/src/shadowbox/infrastructure/get_port.ts index bd25fa8c..cf39d840 100644 --- a/src/shadowbox/infrastructure/get_port.ts +++ b/src/shadowbox/infrastructure/get_port.ts @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -import * as child_process from 'child_process'; import * as net from 'net'; const MAX_PORT = 65535; @@ -66,36 +65,6 @@ function getRandomPortOver1023() { return Math.floor(Math.random() * (MAX_PORT + 1 - MIN_PORT) + MIN_PORT); } -// Returns the list of ports used by either TCP or UDP. -export function getUsedPorts(): Promise> { - return new Promise((resolve, reject) => { - child_process.exec('lsof -P -i -F n', (error, stdout, stderr) => { - const tcpPorts = new Set(); - if (error) { - if (error.code === 1) { - // Empty list case - return resolve(tcpPorts); - } - return reject(error); - } - for (const line of stdout.split(/\r?\n/)) { - if (line.length === 0 || line[0] !== 'n') { - continue; - } - const parts = line.split(':'); - if (parts.length !== 2) { - continue; - } - const port = parseInt(parts[1], 10); - if (port) { - tcpPorts.add(port); - } - } - resolve(tcpPorts); - }); - }); -} - interface ServerError extends Error { code: string; }