Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added password transmit block when on --host mode #459

Merged
merged 3 commits into from
Sep 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion aiserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ def UI_2_log_history(message):

#logger.add("log_file_1.log", rotation="500 MB") # Automatically rotate too big file
koboldai_vars = koboldai_settings.koboldai_vars(socketio)
koboldai_settings.koboldai_vars_main = koboldai_vars
utils.koboldai_vars = koboldai_vars
utils.socketio = socketio

Expand Down Expand Up @@ -7992,7 +7993,7 @@ def model_info():
@require_allowed_ip
@logger.catch
def show_vars():
if args.no_ui:
if args.no_ui or koboldai_vars.host:
return redirect('/api/latest')
json_data = {}
json_data['story_settings'] = json.loads(koboldai_vars.to_json("story_settings"))
Expand Down
14 changes: 11 additions & 3 deletions koboldai_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
if importlib.util.find_spec("tortoise") is not None:
from tortoise import api
from tortoise.utils.audio import load_voices

password_vars = ["horde_api_key", "privacy_password", "img_gen_api_password"]

def clean_var_for_emit(value):
if isinstance(value, KoboldStoryRegister) or isinstance(value, KoboldWorldInfo):
Expand All @@ -37,7 +39,7 @@ def clean_var_for_emit(value):
return value

def process_variable_changes(socketio, classname, name, value, old_value, debug_message=None):
global multi_story
global multi_story, koboldai_vars_main
if serverstarted and name != "serverstarted":
transmit_time = str(datetime.datetime.now())
if debug_message is not None:
Expand Down Expand Up @@ -83,14 +85,20 @@ def process_variable_changes(socketio, classname, name, value, old_value, debug_
else:
#If we got a variable change from a thread other than what the app is run it, eventlet seems to block and no further messages are sent. Instead, we'll rely the message to the app and have the main thread send it
if not has_request_context():
data = ["var_changed", {"classname": classname, "name": name, "old_value": clean_var_for_emit(old_value), "value": clean_var_for_emit(value), "transmit_time": transmit_time}, {"include_self":True, "broadcast":True, "room":room}]
if not koboldai_vars_main.host or name not in password_vars:
data = ["var_changed", {"classname": classname, "name": name, "old_value": clean_var_for_emit(old_value), "value": clean_var_for_emit(value), "transmit_time": transmit_time}, {"include_self":True, "broadcast":True, "room":room}]
else:
data = ["var_changed", {"classname": classname, "name": name, "old_value": "*" * len(old_value) if old_value is not None else "", "value": "*" * len(value) if value is not None else "", "transmit_time": transmit_time}, {"include_self":True, "broadcast":True, "room":room}]
if queue is not None:
#logger.debug("Had to use queue")
queue.put(data)

else:
if socketio is not None:
socketio.emit("var_changed", {"classname": classname, "name": name, "old_value": clean_var_for_emit(old_value), "value": clean_var_for_emit(value), "transmit_time": transmit_time}, include_self=True, broadcast=True, room=room)
if not koboldai_vars_main.host or name not in password_vars:
socketio.emit("var_changed", {"classname": classname, "name": name, "old_value": clean_var_for_emit(old_value), "value": clean_var_for_emit(value), "transmit_time": transmit_time}, include_self=True, broadcast=True, room=room)
else:
socketio.emit("var_changed", {"classname": classname, "name": name, "old_value": "*" * len(old_value) if old_value is not None else "", "value": "*" * len(value) if value is not None else "", "transmit_time": transmit_time}, include_self=True, broadcast=True, room=room)

class koboldai_vars(object):
def __init__(self, socketio):
Expand Down
8 changes: 8 additions & 0 deletions static/koboldai.css
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,10 @@ border-top-right-radius: var(--tabs_rounding);
grid-area: lefticon;
}

.high_z.right_menu_icon {
z-index: 51;
}

@media only screen and (max-aspect-ratio: 5/6) {
/* mobile */
.right_menu_icon.hidden {
Expand All @@ -932,6 +936,10 @@ border-top-right-radius: var(--tabs_rounding);
will-change: transform;
}

.high_z.rightSideMenu {
z-index: 50;
}

.rightSideMenu.open {
left: calc(100% - var(--flyout_menu_width));
}
Expand Down
6 changes: 6 additions & 0 deletions static/koboldai.js
Original file line number Diff line number Diff line change
Expand Up @@ -4963,11 +4963,17 @@ function toggle_flyout_right(x) {
x.classList.remove("change");
document.getElementById("rightSideMenu").classList.remove("open");
document.getElementById("main-grid").classList.remove("story_menu-open");
//need to set the layer priority back down
document.getElementById("rightSideMenu").classList.remove("high_z");
document.getElementById("story_menu_icon").classList.remove("high_z");
} else {
x.classList.add("change");
document.getElementById("rightSideMenu").classList.add("open");
document.getElementById("main-grid").classList.add("story_menu-open");
document.getElementById("story_menu_pin").classList.remove("hidden");
//need to set the layer priority up (due to mobile overlap
document.getElementById("rightSideMenu").classList.add("high_z");
document.getElementById("story_menu_icon").classList.add("high_z");
}
}

Expand Down