optional whitelist.txt

This commit is contained in:
Sanskar Tiwari
2023-04-20 18:11:20 +05:30
parent b2366993a8
commit 50792fdef5
3 changed files with 19 additions and 1 deletions

1
.gitignore vendored
View File

@@ -13,3 +13,4 @@ config.conf
.DS_Store .DS_Store
public/settings.json public/settings.json
/thumbnails /thumbnails
whitelist.txt

View File

@@ -134,6 +134,17 @@ Restart your TAI server.
You will now be able to connect from other devices. You will now be able to connect from other devices.
### Managing whitelisted IPs
You can add or remove whitelisted IPs by editing the `whitelist` array in `config.conf`. You can also provide a `whitelist.txt` file in the same directory as `config.conf` with one IP address per line like:
```txt
192.168.0.1
192.168.0.2
```
The `whitelist` array in `config.conf` will be ignored if `whitelist.txt` exists.
***Disclaimer: Anyone else who knows your IP address and TAI port number will be able to connect as well*** ***Disclaimer: Anyone else who knows your IP address and TAI port number will be able to connect as well***
To connect over wifi you'll need your PC's local wifi IP address To connect over wifi you'll need your PC's local wifi IP address

View File

@@ -31,7 +31,13 @@ const webp = require('webp-converter');
const config = require(path.join(process.cwd(), './config.conf')); const config = require(path.join(process.cwd(), './config.conf'));
const server_port = process.env.SILLY_TAVERN_PORT || config.port; const server_port = process.env.SILLY_TAVERN_PORT || config.port;
const whitelist = config.whitelist;
let whitelistTxt = null;
try {
whitelistTxt = fs.readFileSync(path.join(process.cwd(), "./whitelist.txt"));
} catch (e) {}
const whitelist = whitelistTxt.toString().split("\n").filter(ip => ip) || config.whitelist;
const whitelistMode = config.whitelistMode; const whitelistMode = config.whitelistMode;
const autorun = config.autorun; const autorun = config.autorun;
const enableExtensions = config.enableExtensions; const enableExtensions = config.enableExtensions;