mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge branch 'TavernAI:main' into worldinfo
This commit is contained in:
5
config.json
Normal file
5
config.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"port": 8000,
|
||||
"whitelist": ["127.0.0.1"],
|
||||
"whitelistMode": true
|
||||
}
|
@@ -37,7 +37,7 @@
|
||||
create_date: 0,
|
||||
mes: '\n*You went inside. The air smelled of fried meat, tobacco and a hint of wine. A dim light was cast by candles, and a fire crackled in the fireplace. It seems to be a very pleasant place. Behind the wooden bar is an elf waitress, she is smiling. Her ears are very pointy, and there is a twinkle in her eye. She wears glasses and a white apron. As soon as she noticed you, she immediately came right up close to you.*\n\n' +
|
||||
' Hello there! How is your evening going?\n' +
|
||||
'<img src="img/star_dust_city.png" width=80% style="opacity:0.3; disolay:block;border-radius:5px;margin-top:25px;margin-bottom:23px; margin-left: 45px;margin-right: auto;">\n<a id="verson" style="color:rgb(229, 224, 216,0.8);" href="https://github.com/TavernAI/TavernAI" target="_blank">@@@TavernAI v'+VERSION+'@@@</a><div id="characloud_url" style="margin-right:10px;margin-top:0px;float:right; height:25px;cursor: pointer;opacity: 0.99;display:inline-block;"><img src="img/cloud_logo.png" style="width: 25px;height: auto;display:inline-block; opacity:0.7;"><div style="vertical-align: top;display:inline-block;">Cloud</div></div><br><br><br><br>'
|
||||
'<img src="img/star_dust_city.png" width=80% style="opacity:0.3; display:block;border-radius:5px;margin-top:25px;margin-bottom:23px; margin-left: 45px;margin-right: auto;">\n<a id="verson" style="color:rgb(229, 224, 216,0.8);" href="https://github.com/TavernAI/TavernAI" target="_blank">@@@TavernAI v'+VERSION+'@@@</a><div id="characloud_url" style="margin-right:10px;margin-top:0px;float:right; height:25px;cursor: pointer;opacity: 0.99;display:inline-block;"><img src="img/cloud_logo.png" style="width: 25px;height: auto;display:inline-block; opacity:0.7;"><div style="vertical-align: top;display:inline-block;">Cloud</div></div><br><br><br><br>'
|
||||
}];
|
||||
|
||||
var chat_create_date = 0;
|
||||
|
73
server.js
73
server.js
@@ -16,11 +16,16 @@ const sharp = require('sharp');
|
||||
sharp.cache(false);
|
||||
const path = require('path');
|
||||
|
||||
const config = require('./config.json');
|
||||
const server_port = config.port;
|
||||
const whitelist = config.whitelist;
|
||||
const whitelistMode = config.whitelistMode;
|
||||
|
||||
var Client = require('node-rest-client').Client;
|
||||
var client = new Client();
|
||||
|
||||
var api_server = "";//"http://127.0.0.1:5000";
|
||||
var server_port = 8000;
|
||||
//var server_port = 8000;
|
||||
|
||||
var api_novelai = "https://api.novelai.net";
|
||||
|
||||
@@ -45,38 +50,17 @@ const jsonParser = express.json({limit: '100mb'});
|
||||
const urlencodedParser = express.urlencoded({extended: true, limit: '100mb'});
|
||||
|
||||
|
||||
|
||||
|
||||
app.post("/getlastversion", jsonParser, function(request, response_getlastversion = response){
|
||||
if(!request.body) return response_getlastversion.sendStatus(400);
|
||||
|
||||
const repo = 'TavernAI/TavernAI';
|
||||
|
||||
const req = https.request({
|
||||
hostname: 'github.com',
|
||||
path: `/${repo}/releases/latest`,
|
||||
method: 'HEAD'
|
||||
}, (res) => {
|
||||
if(res.statusCode === 302) {
|
||||
const glocation = res.headers.location;
|
||||
const versionStartIndex = glocation.lastIndexOf('@')+1;
|
||||
const version = glocation.substring(versionStartIndex);
|
||||
//console.log(version);
|
||||
response_getlastversion.send({version: version});
|
||||
}else{
|
||||
response_getlastversion.send({version: 'error'});
|
||||
app.use(function (req, res, next) { //Security
|
||||
const clientIp = req.connection.remoteAddress.split(':').pop();
|
||||
if (whitelistMode === true && !whitelist.includes(clientIp)) {
|
||||
console.log('Forbidden: Connection attempt from '+ clientIp+'. If you are attempting to connect, please add your IP address in whitelist or disable whitelist mode in config.json in root of TavernAI folder.\nExample for add several IP in whitelist: "whitelist": ["127.0.0.1", "'+ clientIp+'"]\nExample for disable whitelist mode: "whitelistMode": false');
|
||||
return res.status(403).send('<b>Forbidden</b>: Connection attempt from <b>'+ clientIp+'</b>. If you are attempting to connect, please add your IP address in whitelist or disable whitelist mode in config.json in root of TavernAI folder.<br>Example for add several IP in whitelist: "whitelist": ["127.0.0.1", "'+ clientIp+'"]<br>Example for disable whitelist mode: "whitelistMode": false');
|
||||
}
|
||||
});
|
||||
|
||||
req.on('error', (error) => {
|
||||
console.error(error);
|
||||
response_getlastversion.send({version: 'error'});
|
||||
});
|
||||
|
||||
req.end();
|
||||
|
||||
next();
|
||||
});
|
||||
|
||||
|
||||
|
||||
app.use(express.static(__dirname + "/public", { refresh: true }));
|
||||
app.use('/backgrounds', (req, res) => {
|
||||
const filePath = path.join(process.cwd(), 'public/backgrounds', req.url);
|
||||
@@ -108,6 +92,35 @@ app.get("/", function(request, response){
|
||||
app.get("/notes/*", function(request, response){
|
||||
response.sendFile(__dirname + "/public"+request.url+".html");
|
||||
//response.send("<h1>Главная страница</h1>");
|
||||
});
|
||||
app.post("/getlastversion", jsonParser, function(request, response_getlastversion = response){
|
||||
if(!request.body) return response_getlastversion.sendStatus(400);
|
||||
|
||||
const repo = 'TavernAI/TavernAI';
|
||||
let req;
|
||||
req = https.request({
|
||||
hostname: 'github.com',
|
||||
path: `/${repo}/releases/latest`,
|
||||
method: 'HEAD'
|
||||
}, (res) => {
|
||||
if(res.statusCode === 302) {
|
||||
const glocation = res.headers.location;
|
||||
const versionStartIndex = glocation.lastIndexOf('@')+1;
|
||||
const version = glocation.substring(versionStartIndex);
|
||||
//console.log(version);
|
||||
response_getlastversion.send({version: version});
|
||||
}else{
|
||||
response_getlastversion.send({version: 'error'});
|
||||
}
|
||||
});
|
||||
|
||||
req.on('error', (error) => {
|
||||
console.error(error);
|
||||
response_getlastversion.send({version: 'error'});
|
||||
});
|
||||
|
||||
req.end();
|
||||
|
||||
});
|
||||
//**************Kobold api
|
||||
app.post("/generate", jsonParser, function(request, response_generate = response){
|
||||
|
Reference in New Issue
Block a user