From 0114e686b8a8ef3de984d1e003c66aa375e2dc48 Mon Sep 17 00:00:00 2001 From: dumbmoron Date: Sun, 12 May 2024 14:06:04 +0000 Subject: [PATCH] api: add FREEBIND_CIDR env variable --- docs/run-an-instance.md | 11 +++++++++-- src/modules/config.js | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/run-an-instance.md b/docs/run-an-instance.md index d89d506c..75b6ef7e 100644 --- a/docs/run-an-instance.md +++ b/docs/run-an-instance.md @@ -60,7 +60,8 @@ sudo service nscd start | `CORS_URL` | not used | `https://cobalt.tools/` | cross-origin resource sharing url. api will be available only from this url if `CORS_WILDCARD` is set to `0`. | | `COOKIE_PATH` | not used | `/cookies.json` | path for cookie file relative to main folder. | | `PROCESSING_PRIORITY` | not used | `10` | changes `nice` value* for ffmpeg subprocess. available only on unix systems. | -| `TIKTOK_DEVICE_INFO` | ➖ | *see below* | device info (including `iid` and `device_id`) for tiktok functionality. required for tiktok to work. | +| `TIKTOK_DEVICE_INFO` | ➖ | *see below* | device info (including `iid` and `device_id`) for tiktok functionality. required for tiktok to work. | +| `FREEBIND_CIDR` | ➖ | `2001:db8::/32` | IPv6 prefix used for randomly assigning addresses to cobalt requests. Only supported on Linux systems. For more info, see below. | \* the higher the nice value, the lower the priority. [read more here](https://en.wikipedia.org/wiki/Nice_(Unix)). @@ -86,6 +87,12 @@ you can compress the json to save space. if you're using a `.env` file then the TIKTOK_DEVICE_INFO='{"iid":"","device_id":"","channel":"googleplay","app_name":"musical_ly","version_code":"310503","device_platform":"android","device_type":"Redmi+7","os_version":"13"}' ``` +#### FREEBIND_CIDR +setting a `FREEBIND_CIDR` allows cobalt to pick a random IP for every download and use it for all +requests it makes for that particular download. to use freebind in cobalt, you need to follow its [setup instructions](https://github.com/imputnet/freebind.js?tab=readme-ov-file#setup) first. if you configure this option while running cobalt +in a docker container, you also need to set the `API_LISTEN_ADDRESS` env to `127.0.0.1`, and set +`network_mode` for the container to `host`. + ### variables for web | variable name | default | example | description | |:---------------------|:---------------------|:------------------------|:--------------------------------------------------------------------------------------| @@ -96,4 +103,4 @@ TIKTOK_DEVICE_INFO='{"iid":"","device_id":"","c | `IS_BETA` | `0` | `1` | toggles beta tag next to cobalt logo.
`0`: disabled. `1`: enabled. | | `PLAUSIBLE_HOSTNAME` | ➖ | `plausible.io`* | enables plausible analytics with provided hostname as receiver backend. | -\* don't use plausible.io as receiver backend unless you paid for their cloud service. use your own domain when hosting community edition of plausible. refer to their [docs](https://plausible.io/docs) when needed. +\* don't use plausible.io as receiver backend unless you paid for their cloud service. use your own domain when hosting community edition of plausible. refer to their [docs](https://plausible.io/docs) when needed. \ No newline at end of file diff --git a/src/modules/config.js b/src/modules/config.js index 89ac1b33..1722b795 100644 --- a/src/modules/config.js +++ b/src/modules/config.js @@ -1,5 +1,6 @@ import UrlPattern from "url-pattern"; import { loadJSON } from "./sub/loadFromFs.js"; + const config = loadJSON("./src/config.json"); const packageJson = loadJSON("./package.json"); const servicesConfigJson = loadJSON("./src/modules/processing/servicesConfig.json"); @@ -37,6 +38,7 @@ const && process.env.PROCESSING_PRIORITY && parseInt(process.env.PROCESSING_PRIORITY), tiktokDeviceInfo: process.env.TIKTOK_DEVICE_INFO && JSON.parse(process.env.TIKTOK_DEVICE_INFO), + freebindCIDR: process.platform === 'linux' && process.env.FREEBIND_CIDR, apiURL }