Compare commits

...

24 Commits

Author SHA1 Message Date
steve02081504 86906576b3 Merge remote-tracking branch 'upstream/staging' into staging 2024-04-14 01:39:49 +08:00
steve02081504 f48d90a9c9 some fixes 2024-04-14 01:39:28 +08:00
Cohee ba397dd2a8 #2062 Extend unlock for MakerSuite models 2024-04-13 20:09:51 +03:00
Cohee ba312d316c Merge branch 'release' into staging 2024-04-13 20:04:52 +03:00
Cohee 8ae9212cc5 #2075 Fix Draw Things auth 2024-04-13 20:02:54 +03:00
Cohee 3a4405016c #2075 Fix Draw Things auth 2024-04-13 20:01:17 +03:00
Cohee de8339f77b Fix ESLint 2024-04-13 15:24:49 +03:00
Cohee f79f335491
Merge pull request #2078 from LenAnderson/fix-popup
Fix popup
2024-04-13 15:23:39 +03:00
Cohee 6c8b29a39a
Merge pull request #2079 from Zhongyi-Lu/dev-forward-ip
Check forwarded IP in WhiteList
2024-04-13 15:22:53 +03:00
Zhongyi Lu 792be63c5c fix: whitelist in real-ip 2024-04-12 22:03:36 -07:00
LenAnderson 278ec029f5 add missing cancelButton setting to callGenericPopup 2024-04-12 20:50:14 -04:00
LenAnderson 91558ad9ea add enter to submit on input type 2024-04-12 20:49:55 -04:00
Cohee 4f83782430 Fix double count of chat injects for message fitting logic 2024-04-09 19:06:39 +03:00
Cohee 2411a7480e Add deprecated endpoint redirection 2024-04-09 16:21:13 +03:00
Cohee f3f29cfe0b
Merge pull request #2035 from caesarw/feat/build-nightly-staging-image
Fix the wrong tags for the scheduled nightly build
2024-04-07 17:49:36 +03:00
caesarw 299ee3ae90 Fix the wrong tags for the scheduled nightly build
* simplified the checkout process
* fixed the wrong tags for the scheduled builds (used to be `release`,
  now it should be `staging`)
* upgraded the `checkout` action to v4.1.2 (no warnings anymore)
2024-04-07 14:37:54 +00:00
Cohee b8ea75f79f Merge branch 'staging' into release 2024-04-06 20:38:58 +03:00
Cohee 24ae6eb49c Merge branch 'staging' into release 2024-04-06 20:18:11 +03:00
Cohee b18921de7f Merge branch 'staging' into release 2024-04-06 20:15:20 +03:00
Cohee 48295bc378
Update docker-publish.yml 2024-04-06 16:04:05 +03:00
Cohee b4fcfcd6d6
Update docker-publish.yml 2024-04-06 16:01:58 +03:00
Cohee 679a249674
Update docker-publish.yml 2024-04-06 16:00:42 +03:00
Cohee 368df65337
Update docker-publish.yml 2024-04-06 15:55:06 +03:00
Cohee 13762470b0
Merge pull request #2018 from SillyTavern/staging
Staging
2024-04-06 15:30:02 +03:00
6 changed files with 76 additions and 19 deletions

View File

@ -9,10 +9,14 @@ on:
schedule:
# Build the staging image everyday at 00:00 UTC
- cron: "0 0 * * *"
push:
# Temporary workaround
branches:
- release
env:
# This should allow creation of docker images even in forked repositories
IMAGE_NAME: ${{ github.repository }}
REPO: ${{ github.repository }}
REGISTRY: ghcr.io
jobs:
@ -20,21 +24,34 @@ jobs:
runs-on: ubuntu-latest
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
# does not support logical AND/OR operations on triggers
# It's currently not possible to have `branches` under the `schedule` trigger
- name: Checkout the release branch
if: ${{ github.event_name == 'release' }}
uses: actions/checkout@v3
- name: Checkout the release branch (on release)
if: ${{ github.event_name == 'release' || github.event_name == 'push' }}
uses: actions/checkout@v4.1.2
with:
ref: "release"
- name: Checkout the staging branch
if: ${{ github.event_name == 'schedule' }}
uses: actions/checkout@v3
uses: actions/checkout@v4.1.2
with:
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
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
@ -47,7 +64,7 @@ jobs:
id: metadata
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: ${{ github.ref_name }}
tags: ${{ env.BRANCH_NAME }}
# Login into package repository as the person who created the release
- name: Log in to the Container registry

View File

@ -3566,7 +3566,7 @@ async function onModelChange() {
if (oai_settings.chat_completion_source == chat_completion_sources.MAKERSUITE) {
if (oai_settings.max_context_unlocked) {
$('#openai_max_context').attr('max', unlocked_max);
$('#openai_max_context').attr('max', max_1mil);
} else if (value === 'gemini-1.5-pro-latest') {
$('#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') {

View File

@ -71,7 +71,7 @@ export class Popup {
this.ok.textContent = okButton ?? 'OK';
this.cancel.textContent = cancelButton ?? 'Cancel';
switch(type) {
switch (type) {
case POPUP_TYPE.TEXT: {
this.input.style.display = 'none';
this.cancel.style.display = 'none';
@ -107,9 +107,16 @@ export class Popup {
// illegal argument
}
this.ok.addEventListener('click', ()=>this.completeAffirmative());
this.cancel.addEventListener('click', ()=>this.completeNegative());
const keyListener = (evt)=>{
this.input.addEventListener('keydown', (evt) => {
if (evt.key != 'Enter' || evt.altKey || evt.ctrlKey || evt.shiftKey) return;
evt.preventDefault();
evt.stopPropagation();
this.completeAffirmative();
});
this.ok.addEventListener('click', () => this.completeAffirmative());
this.cancel.addEventListener('click', () => this.completeNegative());
const keyListener = (evt) => {
switch (evt.key) {
case 'Escape': {
evt.preventDefault();
@ -127,7 +134,7 @@ export class Popup {
async show() {
document.body.append(this.dom);
this.dom.style.display = 'block';
switch(this.type) {
switch (this.type) {
case POPUP_TYPE.INPUT: {
this.input.focus();
break;
@ -196,7 +203,7 @@ export class Popup {
duration: animation_duration,
easing: animation_easing,
});
delay(animation_duration).then(()=>{
delay(animation_duration).then(() => {
this.dom.remove();
});
@ -219,7 +226,7 @@ export function callGenericPopup(text, type, inputValue = '', { okButton, cancel
text,
type,
inputValue,
{ okButton, rows, wide, large, allowHorizontalScrolling, allowVerticalScrolling },
{ okButton, cancelButton, rows, wide, large, allowHorizontalScrolling, allowVerticalScrolling },
);
return popup.show();
}

View File

@ -499,11 +499,14 @@ const setupTasks = async function () {
const cleanupPlugins = await loadPlugins();
const BackUpTitle = process.title;
const exitProcess = async () => {
statsEndpoint.onExit();
if (typeof cleanupPlugins === 'function') {
await cleanupPlugins();
}
setWindowTitle(BackUpTitle);
process.exit();
};
@ -520,7 +523,7 @@ const setupTasks = async function () {
if (autorun) open(autorunUrl.toString());
console.log(String.fromCharCode(27) + "]0;SillyTavern WebServer" + String.fromCharCode(7)); // set window title
setWindowTitle('SillyTavern WebServer');
console.log(color.green('SillyTavern is listening on: ' + tavernUrl));
@ -589,3 +592,10 @@ function ensurePublicDirectoriesExist() {
}
}
}
function setWindowTitle(title) {
if (process.platform == 'win32')
process.title = title
else
process.stdout.write('\x1b]2;' + title + '\x1b\x5c')
}

View File

@ -685,14 +685,16 @@ drawthings.post('/generate', jsonParser, async (request, response) => {
url.pathname = '/sdapi/v1/txt2img';
const body = { ...request.body };
const auth = getBasicAuthHeader(request.body.auth);
delete body.url;
delete body.auth;
const result = await fetch(url, {
method: 'POST',
body: JSON.stringify(body),
headers: {
'Content-Type': 'application/json',
'Authorization': getBasicAuthHeader(request.body.auth),
'Authorization': auth,
},
timeout: 0,
});

View File

@ -19,6 +19,22 @@ 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) {
let clientIp = req.connection.remoteAddress;
let ip = ipaddr.parse(clientIp);
@ -41,6 +57,7 @@ function getIpFromRequest(req) {
function whitelistMiddleware(listen) {
return function (req, res, next) {
const clientIp = getIpFromRequest(req);
const forwardedIp = getForwardedIp(req);
if (listen && !knownIPs.has(clientIp)) {
const userAgent = req.headers['user-agent'];
@ -58,9 +75,13 @@ function whitelistMiddleware(listen) {
}
//clientIp = req.connection.remoteAddress.split(':').pop();
if (whitelistMode === true && !whitelist.some(x => ipMatching.matches(clientIp, 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.');
if (whitelistMode === true && !whitelist.some(x => ipMatching.matches(clientIp, ipMatching.getMatch(x)))
|| forwardedIp && whitelistMode === true && !whitelist.some(x => ipMatching.matches(forwardedIp, ipMatching.getMatch(x)))
) {
// 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();
};