Compare commits
No commits in common. "86906576b3f811dbd52302db22a3ad982f90258d" and "64e8bc19111fda83bb8fbdf659b8ddd192768cd9" have entirely different histories.
86906576b3
...
64e8bc1911
|
@ -9,14 +9,10 @@ on:
|
||||||
schedule:
|
schedule:
|
||||||
# Build the staging image everyday at 00:00 UTC
|
# Build the staging image everyday at 00:00 UTC
|
||||||
- cron: "0 0 * * *"
|
- cron: "0 0 * * *"
|
||||||
push:
|
|
||||||
# Temporary workaround
|
|
||||||
branches:
|
|
||||||
- release
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
# This should allow creation of docker images even in forked repositories
|
# This should allow creation of docker images even in forked repositories
|
||||||
REPO: ${{ github.repository }}
|
IMAGE_NAME: ${{ github.repository }}
|
||||||
REGISTRY: ghcr.io
|
REGISTRY: ghcr.io
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
@ -24,34 +20,21 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
# Workaround for GitHub repo names containing uppercase characters
|
|
||||||
- name: Set lowercase repo name
|
|
||||||
run: |
|
|
||||||
echo "IMAGE_NAME=${REPO,,}" >> ${GITHUB_ENV}
|
|
||||||
|
|
||||||
# Using the following workaround because currently GitHub Actions
|
# Using the following workaround because currently GitHub Actions
|
||||||
# does not support logical AND/OR operations on triggers
|
# does not support logical AND/OR operations on triggers
|
||||||
# It's currently not possible to have `branches` under the `schedule` trigger
|
# It's currently not possible to have `branches` under the `schedule` trigger
|
||||||
- name: Checkout the release branch (on release)
|
- name: Checkout the release branch
|
||||||
if: ${{ github.event_name == 'release' || github.event_name == 'push' }}
|
if: ${{ github.event_name == 'release' }}
|
||||||
uses: actions/checkout@v4.1.2
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
ref: "release"
|
ref: "release"
|
||||||
|
|
||||||
- name: Checkout the staging branch
|
- name: Checkout the staging branch
|
||||||
if: ${{ github.event_name == 'schedule' }}
|
if: ${{ github.event_name == 'schedule' }}
|
||||||
uses: actions/checkout@v4.1.2
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
ref: "staging"
|
ref: "staging"
|
||||||
|
|
||||||
# Get current branch name
|
|
||||||
# This is also part of the workaround for Actions not allowing logical
|
|
||||||
# AND/OR operators on triggers
|
|
||||||
# Otherwise the action triggered by schedule always has ref_name = release
|
|
||||||
- name: Get the current branch name
|
|
||||||
run: |
|
|
||||||
echo "BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)" >> ${GITHUB_ENV}
|
|
||||||
|
|
||||||
# Setting up QEMU for multi-arch image build
|
# Setting up QEMU for multi-arch image build
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v3
|
||||||
|
@ -64,7 +47,7 @@ jobs:
|
||||||
id: metadata
|
id: metadata
|
||||||
with:
|
with:
|
||||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
tags: ${{ env.BRANCH_NAME }}
|
tags: ${{ github.ref_name }}
|
||||||
|
|
||||||
# Login into package repository as the person who created the release
|
# Login into package repository as the person who created the release
|
||||||
- name: Log in to the Container registry
|
- name: Log in to the Container registry
|
||||||
|
|
|
@ -3566,7 +3566,7 @@ async function onModelChange() {
|
||||||
|
|
||||||
if (oai_settings.chat_completion_source == chat_completion_sources.MAKERSUITE) {
|
if (oai_settings.chat_completion_source == chat_completion_sources.MAKERSUITE) {
|
||||||
if (oai_settings.max_context_unlocked) {
|
if (oai_settings.max_context_unlocked) {
|
||||||
$('#openai_max_context').attr('max', max_1mil);
|
$('#openai_max_context').attr('max', unlocked_max);
|
||||||
} else if (value === 'gemini-1.5-pro-latest') {
|
} else if (value === 'gemini-1.5-pro-latest') {
|
||||||
$('#openai_max_context').attr('max', max_1mil);
|
$('#openai_max_context').attr('max', max_1mil);
|
||||||
} else if (value === 'gemini-ultra' || value === 'gemini-1.0-pro-latest' || value === 'gemini-pro' || value === 'gemini-1.0-ultra-latest') {
|
} else if (value === 'gemini-ultra' || value === 'gemini-1.0-pro-latest' || value === 'gemini-pro' || value === 'gemini-1.0-ultra-latest') {
|
||||||
|
|
|
@ -71,7 +71,7 @@ export class Popup {
|
||||||
this.ok.textContent = okButton ?? 'OK';
|
this.ok.textContent = okButton ?? 'OK';
|
||||||
this.cancel.textContent = cancelButton ?? 'Cancel';
|
this.cancel.textContent = cancelButton ?? 'Cancel';
|
||||||
|
|
||||||
switch (type) {
|
switch(type) {
|
||||||
case POPUP_TYPE.TEXT: {
|
case POPUP_TYPE.TEXT: {
|
||||||
this.input.style.display = 'none';
|
this.input.style.display = 'none';
|
||||||
this.cancel.style.display = 'none';
|
this.cancel.style.display = 'none';
|
||||||
|
@ -107,16 +107,9 @@ export class Popup {
|
||||||
// illegal argument
|
// illegal argument
|
||||||
}
|
}
|
||||||
|
|
||||||
this.input.addEventListener('keydown', (evt) => {
|
this.ok.addEventListener('click', ()=>this.completeAffirmative());
|
||||||
if (evt.key != 'Enter' || evt.altKey || evt.ctrlKey || evt.shiftKey) return;
|
this.cancel.addEventListener('click', ()=>this.completeNegative());
|
||||||
evt.preventDefault();
|
const keyListener = (evt)=>{
|
||||||
evt.stopPropagation();
|
|
||||||
this.completeAffirmative();
|
|
||||||
});
|
|
||||||
|
|
||||||
this.ok.addEventListener('click', () => this.completeAffirmative());
|
|
||||||
this.cancel.addEventListener('click', () => this.completeNegative());
|
|
||||||
const keyListener = (evt) => {
|
|
||||||
switch (evt.key) {
|
switch (evt.key) {
|
||||||
case 'Escape': {
|
case 'Escape': {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
|
@ -134,7 +127,7 @@ export class Popup {
|
||||||
async show() {
|
async show() {
|
||||||
document.body.append(this.dom);
|
document.body.append(this.dom);
|
||||||
this.dom.style.display = 'block';
|
this.dom.style.display = 'block';
|
||||||
switch (this.type) {
|
switch(this.type) {
|
||||||
case POPUP_TYPE.INPUT: {
|
case POPUP_TYPE.INPUT: {
|
||||||
this.input.focus();
|
this.input.focus();
|
||||||
break;
|
break;
|
||||||
|
@ -203,7 +196,7 @@ export class Popup {
|
||||||
duration: animation_duration,
|
duration: animation_duration,
|
||||||
easing: animation_easing,
|
easing: animation_easing,
|
||||||
});
|
});
|
||||||
delay(animation_duration).then(() => {
|
delay(animation_duration).then(()=>{
|
||||||
this.dom.remove();
|
this.dom.remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -226,7 +219,7 @@ export function callGenericPopup(text, type, inputValue = '', { okButton, cancel
|
||||||
text,
|
text,
|
||||||
type,
|
type,
|
||||||
inputValue,
|
inputValue,
|
||||||
{ okButton, cancelButton, rows, wide, large, allowHorizontalScrolling, allowVerticalScrolling },
|
{ okButton, rows, wide, large, allowHorizontalScrolling, allowVerticalScrolling },
|
||||||
);
|
);
|
||||||
return popup.show();
|
return popup.show();
|
||||||
}
|
}
|
||||||
|
|
12
server.js
12
server.js
|
@ -499,14 +499,11 @@ const setupTasks = async function () {
|
||||||
|
|
||||||
const cleanupPlugins = await loadPlugins();
|
const cleanupPlugins = await loadPlugins();
|
||||||
|
|
||||||
const BackUpTitle = process.title;
|
|
||||||
|
|
||||||
const exitProcess = async () => {
|
const exitProcess = async () => {
|
||||||
statsEndpoint.onExit();
|
statsEndpoint.onExit();
|
||||||
if (typeof cleanupPlugins === 'function') {
|
if (typeof cleanupPlugins === 'function') {
|
||||||
await cleanupPlugins();
|
await cleanupPlugins();
|
||||||
}
|
}
|
||||||
setWindowTitle(BackUpTitle);
|
|
||||||
process.exit();
|
process.exit();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -523,7 +520,7 @@ const setupTasks = async function () {
|
||||||
|
|
||||||
if (autorun) open(autorunUrl.toString());
|
if (autorun) open(autorunUrl.toString());
|
||||||
|
|
||||||
setWindowTitle('SillyTavern WebServer');
|
console.log(String.fromCharCode(27) + "]0;SillyTavern WebServer" + String.fromCharCode(7)); // set window title
|
||||||
|
|
||||||
console.log(color.green('SillyTavern is listening on: ' + tavernUrl));
|
console.log(color.green('SillyTavern is listening on: ' + tavernUrl));
|
||||||
|
|
||||||
|
@ -592,10 +589,3 @@ function ensurePublicDirectoriesExist() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setWindowTitle(title) {
|
|
||||||
if (process.platform == 'win32')
|
|
||||||
process.title = title
|
|
||||||
else
|
|
||||||
process.stdout.write('\x1b]2;' + title + '\x1b\x5c')
|
|
||||||
}
|
|
||||||
|
|
|
@ -685,16 +685,14 @@ drawthings.post('/generate', jsonParser, async (request, response) => {
|
||||||
url.pathname = '/sdapi/v1/txt2img';
|
url.pathname = '/sdapi/v1/txt2img';
|
||||||
|
|
||||||
const body = { ...request.body };
|
const body = { ...request.body };
|
||||||
const auth = getBasicAuthHeader(request.body.auth);
|
|
||||||
delete body.url;
|
delete body.url;
|
||||||
delete body.auth;
|
|
||||||
|
|
||||||
const result = await fetch(url, {
|
const result = await fetch(url, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify(body),
|
body: JSON.stringify(body),
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Authorization': auth,
|
'Authorization': getBasicAuthHeader(request.body.auth),
|
||||||
},
|
},
|
||||||
timeout: 0,
|
timeout: 0,
|
||||||
});
|
});
|
||||||
|
|
|
@ -19,22 +19,6 @@ if (fs.existsSync(whitelistPath)) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getForwardedIp(req) {
|
|
||||||
// Check if X-Real-IP is available
|
|
||||||
if (req.headers['x-real-ip']) {
|
|
||||||
return req.headers['x-real-ip'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for X-Forwarded-For and parse if available
|
|
||||||
if (req.headers['x-forwarded-for']) {
|
|
||||||
const ipList = req.headers['x-forwarded-for'].split(',').map(ip => ip.trim());
|
|
||||||
return ipList[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
// If none of the headers are available, return undefined
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getIpFromRequest(req) {
|
function getIpFromRequest(req) {
|
||||||
let clientIp = req.connection.remoteAddress;
|
let clientIp = req.connection.remoteAddress;
|
||||||
let ip = ipaddr.parse(clientIp);
|
let ip = ipaddr.parse(clientIp);
|
||||||
|
@ -57,7 +41,6 @@ function getIpFromRequest(req) {
|
||||||
function whitelistMiddleware(listen) {
|
function whitelistMiddleware(listen) {
|
||||||
return function (req, res, next) {
|
return function (req, res, next) {
|
||||||
const clientIp = getIpFromRequest(req);
|
const clientIp = getIpFromRequest(req);
|
||||||
const forwardedIp = getForwardedIp(req);
|
|
||||||
|
|
||||||
if (listen && !knownIPs.has(clientIp)) {
|
if (listen && !knownIPs.has(clientIp)) {
|
||||||
const userAgent = req.headers['user-agent'];
|
const userAgent = req.headers['user-agent'];
|
||||||
|
@ -75,13 +58,9 @@ function whitelistMiddleware(listen) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//clientIp = req.connection.remoteAddress.split(':').pop();
|
//clientIp = req.connection.remoteAddress.split(':').pop();
|
||||||
if (whitelistMode === true && !whitelist.some(x => ipMatching.matches(clientIp, ipMatching.getMatch(x)))
|
if (whitelistMode === true && !whitelist.some(x => ipMatching.matches(clientIp, ipMatching.getMatch(x)))) {
|
||||||
|| forwardedIp && whitelistMode === true && !whitelist.some(x => ipMatching.matches(forwardedIp, ipMatching.getMatch(x)))
|
console.log(color.red('Forbidden: Connection attempt from ' + clientIp + '. If you are attempting to connect, please add your IP address in whitelist or disable whitelist mode in config.yaml in root of SillyTavern folder.\n'));
|
||||||
) {
|
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.yaml in root of SillyTavern folder.');
|
||||||
// Log the connection attempt with real IP address
|
|
||||||
const ipDetails = forwardedIp ? `${clientIp} (forwarded from ${forwardedIp})` : clientIp;
|
|
||||||
console.log(color.red('Forbidden: Connection attempt from ' + ipDetails + '. If you are attempting to connect, please add your IP address in whitelist or disable whitelist mode in config.yaml in root of SillyTavern folder.\n'));
|
|
||||||
return res.status(403).send('<b>Forbidden</b>: Connection attempt from <b>' + ipDetails + '</b>. If you are attempting to connect, please add your IP address in whitelist or disable whitelist mode in config.yaml in root of SillyTavern folder.');
|
|
||||||
}
|
}
|
||||||
next();
|
next();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue