Update main.py

This commit is contained in:
Saifeddine ALOUI 2024-01-30 16:52:39 +01:00 committed by GitHub
parent f470b345ea
commit 302473b469
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 1 deletions

View File

@ -47,9 +47,11 @@ def main():
parser.add_argument('--log_path', default="access_log.txt", help='Path to the access log file') parser.add_argument('--log_path', default="access_log.txt", help='Path to the access log file')
parser.add_argument('--users_list', default="authorized_users.txt", help='Path to the config file') parser.add_argument('--users_list', default="authorized_users.txt", help='Path to the config file')
parser.add_argument('--port', type=int, default=8000, help='Port number for the server') parser.add_argument('--port', type=int, default=8000, help='Port number for the server')
parser.add_argument('-d', '--deactivate_security', action='store_true', const=True, default=False, help='Deactivates security')
args = parser.parse_args() args = parser.parse_args()
servers = get_config(args.config) servers = get_config(args.config)
authorized_users = get_authorized_users(args.users_list) authorized_users = get_authorized_users(args.users_list)
deactivate_security = args.deactivate_security
print("Ollama Proxy server") print("Ollama Proxy server")
print("Author: ParisNeo") print("Author: ParisNeo")
@ -102,7 +104,7 @@ def main():
except: except:
return False return False
def proxy(self): def proxy(self):
if not self._validate_user_and_key(): if not deactivate_security and not self._validate_user_and_key():
ASCIIColors.red(f'User is not authorized') ASCIIColors.red(f'User is not authorized')
client_ip, client_port = self.client_address client_ip, client_port = self.client_address
# Extract the bearer token from the headers # Extract the bearer token from the headers