mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge pull request #113 from sanskar-mk2/whitelist-txt-feature
optional whitelist.txt
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -13,3 +13,4 @@ config.conf
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
public/settings.json
|
public/settings.json
|
||||||
/thumbnails
|
/thumbnails
|
||||||
|
whitelist.txt
|
||||||
|
11
readme.md
11
readme.md
@@ -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
|
||||||
|
12
server.js
12
server.js
@@ -31,7 +31,17 @@ 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;
|
|
||||||
|
const whitelistPath = path.join(process.cwd(), "./whitelist.txt");
|
||||||
|
let whitelist = config.whitelist;
|
||||||
|
|
||||||
|
if (fs.existsSync(whitelistPath)) {
|
||||||
|
try {
|
||||||
|
let whitelistTxt = fs.readFileSync(whitelistPath, 'utf-8');
|
||||||
|
whitelist = whitelistTxt.split("\n").filter(ip => ip).map(ip => ip.trim());
|
||||||
|
} catch (e) { }
|
||||||
|
}
|
||||||
|
|
||||||
const whitelistMode = config.whitelistMode;
|
const whitelistMode = config.whitelistMode;
|
||||||
const autorun = config.autorun;
|
const autorun = config.autorun;
|
||||||
const enableExtensions = config.enableExtensions;
|
const enableExtensions = config.enableExtensions;
|
||||||
|
Reference in New Issue
Block a user