From 7b315bcc25969ec52bd2b9007967e6978f3944ad Mon Sep 17 00:00:00 2001 From: Ground0 Date: Wed, 13 Mar 2024 09:23:28 +0100 Subject: [PATCH] Bugfixes --- inc/lweb_helper.pbi | 1 + inc/lweb_helper_header.pbi | 1 + inc/lweb_server_cfg.pbi | 66 ---------------- lhttpd.pb | 2 +- lweb.pbi | 17 ++-- lweb.pbp | 156 ++++++++++++++++++------------------- lweb_auth.pb | 39 +++++++++- server_example.pb | 10 ++- 8 files changed, 134 insertions(+), 158 deletions(-) diff --git a/inc/lweb_helper.pbi b/inc/lweb_helper.pbi index 2bc8d29..5f78df1 100644 --- a/inc/lweb_helper.pbi +++ b/inc/lweb_helper.pbi @@ -4,6 +4,7 @@ ;* Procedure.s mimetype(file.s) + ; TODO:Mimetype dynamic configurable via XML Select LCase(file) Case "pdf" ProcedureReturn "application/pdf" diff --git a/inc/lweb_helper_header.pbi b/inc/lweb_helper_header.pbi index 02bdadf..e317a93 100644 --- a/inc/lweb_helper_header.pbi +++ b/inc/lweb_helper_header.pbi @@ -3,6 +3,7 @@ ;* lweb_helper_header.pbi ;* +; TODO:Mimetype dynamic configurable via XML Declare.s mimetype(file.s) Declare.s MapToJSONString(Map ConvertMap.s()) \ No newline at end of file diff --git a/inc/lweb_server_cfg.pbi b/inc/lweb_server_cfg.pbi index 9c3f472..d9e3a75 100644 --- a/inc/lweb_server_cfg.pbi +++ b/inc/lweb_server_cfg.pbi @@ -209,58 +209,6 @@ EndIf Case #conf_runfile -; Case #conf_HTTP_port -; configuration\http\port = Val(setting) -; Case #conf_HTTPS_Port -; configuration\https\port = Val(setting) -; Case #conf_HTTP_binding -; If IsIPStringValid(setting) -; configuration\http\binding = setting -; Else -; configuration\http\binding = "127.0.0.1" -; ProcedureReturn #False -; EndIf -; Case #conf_HTTPS_Binding -; If IsIPStringValid(setting) -; configuration\https\binding = setting -; Else -; configuration\https\binding = "127.0.0.1" -; ProcedureReturn #False -; EndIf -; Case #conf_HTTPS_CA -; configuration\https\CA = setting -; Case #conf_HTTPS_Cert -; configuration\https\Certs = setting -; Case #conf_HTTPS_Key -; configuration\https\Key = setting -; Case #conf_HTTPS_Key_Pass -; configuration\https\key_pass = setting -; Case #conf_HTTPS_Enable -; configuration\https\enabled = Val(setting) -; Case #conf_defaultfile -; configuration\defaultfile = setting -; Case #conf_basedir -; configuration\basedir = setting -; Case #conf_error400 -; configuration\error400 = setting ; Kann "integrated" sein wass die integrierte Standard Fehlermeldung hervorruft. -; Case #conf_max_HTTP_clients -; If MemoryStatus(#PB_System_FreePhysical) > (Val(setting)*(1024*384)) -; configuration\http\max_clients = Val(setting) -; Else -; configuration\http\max_clients = 10 -; ProcedureReturn #False -; EndIf -; Case #conf_max_HTTPS_clients -; If MemoryStatus(#PB_System_FreePhysical) > (Val(setting)*(1024*384)) -; configuration\https\max_clients = Val(setting) -; Else -; configuration\https\max_clients = 10 -; ProcedureReturn #False -; EndIf -; Case #conf_server_type -; configuration\type = Val(setting) -; Case #conf_cache_enable -; configuration\cache\enable = Val(Setting) Default ProcedureReturn #False EndSelect @@ -285,20 +233,6 @@ Else ProcedureReturn "false" EndIf -; Case #conf_defaultfile -; ProcedureReturn configuration\defaultfile -; Case #conf_basedir -; ProcedureReturn configuration\basedir -; Case #conf_error400 -; ProcedureReturn configuration\error400 -; Case #conf_max_HTTP_clients -; ProcedureReturn Str(configuration\http\max_clients) -; Case #conf_server_type -; ProcedureReturn Str(configuration\type) -; Case #conf_HTTP_port -; ProcedureReturn Str(configuration\http\port) -; Case #conf_HTTPS_Port -; ProcedureReturn Str(configuration\https\port) Default ProcedureReturn "" EndSelect diff --git a/lhttpd.pb b/lhttpd.pb index 6abfac4..c5424a1 100644 --- a/lhttpd.pb +++ b/lhttpd.pb @@ -2,7 +2,7 @@ ;* ;* Lihaso Web Server (lhttpd) ;* -;* (c)2020 by Linder Hard- und Software +;* (c)2024 by Linder Hard- und Software ;* ;* V0.5 ;* - Simple webserver for HTTP & HTTPS diff --git a/lweb.pbi b/lweb.pbi index e44cdad..39dd5a1 100644 --- a/lweb.pbi +++ b/lweb.pbi @@ -266,6 +266,7 @@ Module lhs_web EndProcedure Procedure main_server(id.i) + ldl::Logging("main Server Loading") status_defaults() EndProcedure @@ -1057,14 +1058,14 @@ Module lhs_web ElseIf response_status <> "" Header(#http_head_status) = response_status Else - Header(#http_head_status) = status_get_message("200") + Header(#http_head_status) = status_get_header("200") EndIf If Response(#http_head_set_cookie) <> "" Header(#http_head_set_cookie) = Response(#http_head_set_cookie) EndIf If thread_redirect = #True Header(#http_head_redirect) = file_check(thread_requested, m_clients(Str(thread_cli_id))\host_id) - Header(#http_head_status) = status_get_message("303") + Header(#http_head_status) = status_get_header("303") Else Header(#http_head_content_length) = Str(thread_data_size) Header(#http_head_content_type) = thread_type @@ -1072,7 +1073,9 @@ Module lhs_web Header(#http_head_connection) = "Keep-Alive" Header(#http_head_keep_alive) = "timeout=15, max=1000" + thread_header = http_header_generate(Header()) + ldl::Logging("Header:"+thread_header) ;large File Handling If thread_redirect = #True thread_buffer = AllocateMemory(StringByteLength(thread_header)+12) @@ -1094,7 +1097,7 @@ Module lhs_web thread_temp_cache_memory = 0 ElseIf thread_temp_cache_memory <> 0 And thread_buffer_offset <> 0 And thread_data_size <> 0 And thread_temp_file_readed <> 0 And thread_oversized_file = #True And thread_redirect = #False CopyMemory(thread_temp_cache_memory, thread_buffer_offset, thread_temp_file_readed) - ldl::Logging("Cache Address Memory:"+Str(thread_temp_cache_memory)) + ldl::Logging("Oversized Cache Address Memory:"+Str(thread_temp_cache_memory)) FreeMemory(thread_temp_cache_memory) thread_temp_cache_memory = 0 ElseIf thread_redirect = #True @@ -1125,7 +1128,7 @@ Module lhs_web Else sent_total = thread_temp_file_readed+(thread_buffer_offset-thread_buffer) EndIf - + ldl::Logging("Memory send_total:"+Str(sent_total)) ;TODO: Stoped download kill server... If m_clients(Str(thread_cli_id))\client_type = #client_HTTPS sent_length = sent_total @@ -1134,7 +1137,7 @@ Module lhs_web Repeat sent = tls::WriteTLSSocket(thread_cli_id, sent_buffer_address , sent_length) If sent <> -1 - ;ldl::Logging("ClientID:" + Str(thread_cli_id) + " HTTPS Sent:"+Str(sent)+" bytes") + ldl::Logging("ClientID:" + Str(thread_cli_id) + " HTTPS Sent:"+Str(sent)+" bytes") sent_length - sent If thread_oversized_file = #False sent_buffer_address + sent @@ -1142,14 +1145,14 @@ Module lhs_web ;Read next Block to Memory If sent_length <= 0 And IsFile(thread_file_handle) sent_readed = ReadData(thread_file_handle, thread_buffer, thread_temp_file_readed) - ;ldl::Logging("ClientID:" + Str(thread_cli_id) + " HTTPS Large File -> Read Next:"+Str(sent_readed)+" bytes") + ldl::Logging("ClientID:" + Str(thread_cli_id) + " HTTPS Large File -> Read Next:"+Str(sent_readed)+" bytes") If sent_readed < thread_temp_file_readed CloseFile(thread_file_handle) EndIf sent_buffer_address = thread_buffer sent_length = sent_readed Else - ;ldl::Logging("ClientID:" + Str(thread_cli_id) + " HTTPS Large File -> to Send:"+Str(sent_length)+" bytes") + ldl::Logging("ClientID:" + Str(thread_cli_id) + " HTTPS Large File -> to Send:"+Str(sent_length)+" bytes") sent_buffer_address + sent EndIf EndIf diff --git a/lweb.pbp b/lweb.pbp index 90c672d..6fb0840 100644 --- a/lweb.pbp +++ b/lweb.pbp @@ -1,6 +1,6 @@ - +
Projekt ist inklusive Beispiel Code @@ -8,121 +8,121 @@
- +
- - - + + + - - - + + + - - - + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - + - + - - + + - + - + - + - + - - - + + + - - - + + + + + + + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - @@ -131,22 +131,18 @@ - - - -
- + - + - + @@ -160,7 +156,7 @@ - + @@ -168,7 +164,7 @@ - + @@ -176,7 +172,7 @@ - + diff --git a/lweb_auth.pb b/lweb_auth.pb index bd8f34b..aa2b9f1 100644 --- a/lweb_auth.pb +++ b/lweb_auth.pb @@ -1,11 +1,12 @@ ;************************ ;* lweb_auth.pb ;* -;* Authentication Library. +;* Simple Authentication Library. ;* ;* Created and develobed by Linder Hard- und Software ;* -;* +;* First Release Only "demo" Database + XIncludeFile "lhs_lib/NET/lhs_web_helper.pbi" @@ -43,6 +44,12 @@ ProcedureCDLL Database_User(DB_Cfg.s) ;mar:host=localhost port=3306 dbname=test user=|USERNAME| password=|PASSWORD| Case "psq" ;psq:host=localhost port=5432 dbname=test user=|USERNAME| password=|PASSWORD| + Case "demo" + ;Demo Accounts + ; Grp. Usr. Pw. ID Mod + ;|demo|admin|admin1234|0 |777| + ;|demo|user |user1234 |1 |744| + ;|demo|guest|guest1234|2 |004| Default State = "Failed" ProcedureReturn @State @@ -83,6 +90,34 @@ Procedure.s GetPassworfFromDBCFG(DB_Cfg.s) ProcedureReturn User_Password EndProcedure +Procedure.s CreateSession(ID.s) + +EndProcedure + +Procedure.s IsSession(SessionID.s) + +EndProcedure + +Procedure.s User_Verify(User.s) + +EndProcedure + +Procedure.s User_Login(User.s, Password.s) + +EndProcedure + +Procedure.s Get_MOD(SessionID.s) + +EndProcedure + +Procedure.s Get_Group(SessionID.s) + +EndProcedure + +Procedure.s Get_UseID(SessionID.s) + +EndProcedure + ProcedureCDLL post_test(handler_Map_JSON.s, ContentData.s) Define *Text Define.s Encoded, TBD, Text, JSONStringToMap diff --git a/server_example.pb b/server_example.pb index 6b3aab8..f79566f 100644 --- a/server_example.pb +++ b/server_example.pb @@ -4,7 +4,7 @@ ;* ;* HTTP/HTTPS example extended Server ;* -;* (c)2015 - 2023 by Linder Hard- und Software +;* (c)2015 - 2024 by Linder Hard- und Software ;* ;* @@ -36,7 +36,9 @@ lhs_log_ext::Init(DebugLog) ldl::Register(lhs_log_ext::@Out(), DebugLog, 1, DebugLog, ldl::#AdvancedLog) ldl::SetDefault(DebugLog) ldl::Logging("Start Debug Log registered with ldl at UUID:"+DebugLog) - +ldl::Logging("-------------------------------------------------------------------------------------------------------------------------------") +ldl::Logging("Server initializing.") +ldl::Logging("-------------------------------------------------------------------------------------------------------------------------------") Debuggings = lhs_web::get_config(lhs_web::#conf_Debug_logUUID) Debug Debuggings ;* @@ -64,6 +66,7 @@ PrintN("Configuration read done.") ;* PrintN("Start the Server") +lhs_web::main_server(0) If lhs_web::server_start() ldl::Logging("Server started") Else @@ -75,6 +78,9 @@ counter = 0 PrintN("Server_Sample started.") PrintN("Press Enter to Exit") Input() +ldl::Logging("-------------------------------------------------------------------------------------------------------------------------------") +ldl::Logging("Server Stopped.") +ldl::Logging("-------------------------------------------------------------------------------------------------------------------------------") lhs_log_ext::StopAllLogger() lhs_web::server_stop() PrintN("Finished")