From 7b0867a6cf9337ba0a52e76fb0cefc664661e3a2 Mon Sep 17 00:00:00 2001 From: Burer Date: Fri, 17 Oct 2025 11:04:08 +0200 Subject: [PATCH] [apps/cmm] add new proxy for https sources (#277) Deployed new https proxy for WebView and Downloader. Made it configurable through /sys/settings/app.ini. Reviewed-on: https://git.kolibrios.org/KolibriOS/kolibrios/pulls/277 Reviewed-by: Mikhail Frolov Co-authored-by: Burer Co-committed-by: Burer --- data/common/settings/app.ini | 2 ++ programs/cmm/browser/WebView.c | 24 +++++++++++++++++------- programs/cmm/browser/const.h | 2 +- programs/cmm/browser/settings.h | 9 +++++++++ programs/cmm/downloader/dl.c | 22 +++++++++++++++++----- programs/cmm/downloader/settings.h | 9 +++++++++ programs/cmm/lib/obj/http.h | 3 +-- 7 files changed, 56 insertions(+), 15 deletions(-) create mode 100644 programs/cmm/browser/settings.h create mode 100644 programs/cmm/downloader/settings.h diff --git a/data/common/settings/app.ini b/data/common/settings/app.ini index 115e8f054..4901c82e9 100644 --- a/data/common/settings/app.ini +++ b/data/common/settings/app.ini @@ -22,3 +22,5 @@ ToggleBar=Tab path=/usbhd0/1/kolibri.img autoclose=0 +[WebView] +proxy=http://proxy.kolibrios.org:82/?site= \ No newline at end of file diff --git a/programs/cmm/browser/WebView.c b/programs/cmm/browser/WebView.c index 71e37a393..fdfc03de9 100644 --- a/programs/cmm/browser/WebView.c +++ b/programs/cmm/browser/WebView.c @@ -1,10 +1,9 @@ //Copyright 2007-2025 by Veliant & Leency -//Asper, lev, Lrz, Barsuk, Nable, hidnplayr... +//Asper, lev, Lrz, Barsuk, Nable, hidnplayr, Burer... //BUGS //if maximize a window on image load => crash //issues with a long line -//add proxy settings //===================================================// // // @@ -13,6 +12,7 @@ //===================================================// #define MEMSIZE 1024 * 160 + #include "..\lib\gui.h" #include "..\lib\draw_buf.h" #include "..\lib\list_box.h" @@ -21,6 +21,7 @@ #include "..\lib\random.h" #include "..\lib\clipboard.h" +#include "..\lib\obj\libini.h" #include "..\lib\obj\box_lib.h" #include "..\lib\obj\libimg.h" #include "..\lib\obj\http.h" @@ -67,6 +68,10 @@ _http http = 0; progress_bar prbar; proc_info Form; +char settings_file[256]; +char proxy_address[768]; + +#include "settings.h" #include "tabs.h" dword cur_img_url; @@ -90,6 +95,7 @@ edit_box omnibox_edit = {250, 0, 0, 0xffffff, void LoadLibraries() { + load_dll(libini, #lib_init,1); load_dll(boxlib, #box_lib_init,0); load_dll(libimg, #libimg_init,1); load_dll(libHTTP, #http_lib_init,1); @@ -130,6 +136,7 @@ void main() TOOLBAR_H = PADDING+TSZE+PADDING+2; LoadLibraries(); + LoadIniConfig(); HandleParam(); omnibox_edit.left = PADDING+TSZE*2+PADDING+6; @@ -517,14 +524,17 @@ bool GetLocalFileData(dword _path) bool GetUrl(dword _http_url) { char new_url_full[URL_SIZE+1]; - if (!strncmp(_http_url,"http:",5)) { + if (!strncmp(_http_url,"http://",7)) { http.get(_http_url); return true; } else if (!strncmp(_http_url,"https://",8)) { - strcpy(#new_url_full, "http://gate.aspero.pro/?site="); - strncat(#new_url_full, _http_url, URL_SIZE); - http.get(#new_url_full); - return true; + if (#proxy_address) { + strcpy(#new_url_full, #proxy_address); + strncat(#new_url_full, _http_url, URL_SIZE); + http.get(#new_url_full); + return true; + } + return false; } return false; } diff --git a/programs/cmm/browser/const.h b/programs/cmm/browser/const.h index 823ec1822..80da4de1d 100644 --- a/programs/cmm/browser/const.h +++ b/programs/cmm/browser/const.h @@ -112,4 +112,4 @@ char editbox_icons[] = FROM "res/editbox_icons.raw"; #define DEFAULT_URL URL_SERVICE_HOMEPAGE -char version[]="WebView 3.91"; \ No newline at end of file +char version[]="WebView 3.92"; \ No newline at end of file diff --git a/programs/cmm/browser/settings.h b/programs/cmm/browser/settings.h new file mode 100644 index 000000000..cddde5cc7 --- /dev/null +++ b/programs/cmm/browser/settings.h @@ -0,0 +1,9 @@ +_ini ini; + +void LoadIniConfig() +{ + ini.path = GetIni(#settings_file, "app.ini"); + ini.section = "WebView"; + + ini.GetString("proxy", #proxy_address, sizeof(proxy_address), NULL); +} \ No newline at end of file diff --git a/programs/cmm/downloader/dl.c b/programs/cmm/downloader/dl.c index bd62c5757..a94b22134 100644 --- a/programs/cmm/downloader/dl.c +++ b/programs/cmm/downloader/dl.c @@ -1,7 +1,12 @@ +//Copyright 2020 - 2025 by Leency +//Burer... + #define MEMSIZE 1024 * 40 -//Copyright 2020 - 2021 by Leency + #include "../lib/gui.h" #include "../lib/random.h" + +#include "../lib/obj/libini.h" #include "../lib/obj/box_lib.h" #include "../lib/obj/http.h" @@ -21,6 +26,11 @@ char uEdit[URL_SIZE]; char filepath[4096]; char save_dir[4096]; +char settings_file[256]; +char proxy_address[768]; + +#include "settings.h" + char* active_status; edit_box ed = {WIN_W-GAPX-GAPX,GAPX,20,0xffffff,0x94AECE,0xffffff,0xffffff, @@ -32,9 +42,13 @@ progress_bar pb = {0, GAPX, 52, WIN_W - GAPX - GAPX, 17, 0, NULL, NULL, void main() { dword shared_url; + + load_dll(libini, #lib_init,1); load_dll(boxlib, #box_lib_init,0); load_dll(libHTTP, #http_lib_init,1); + LoadIniConfig(); + strcpy(#save_dir, DEFAULT_SAVE_DIR); if (!dir_exists(#save_dir)) CreateDir(#save_dir); SetCurDir(#save_dir); @@ -167,10 +181,8 @@ void StartDownloading() if (http.transfer > 0) return; ResetDownloadSpeed(); pb.back_color = 0xFFFfff; - if (!strncmp(#uEdit,"https:",6)) { - //miniprintf(#get_url, "http://gate.aspero.pro/?site=%s", #uEdit); - notify("'HTTPS for download temporary is not supported,\ntrying to download the file via HTTP' -W"); - miniprintf(#uEdit, "http://%s", #uEdit+8); + if (!strncmp(#uEdit,"https://",8)) { + miniprintf(#get_url, "%s%s", #proxy_address, #uEdit); } strcpy(#get_url, #uEdit); diff --git a/programs/cmm/downloader/settings.h b/programs/cmm/downloader/settings.h new file mode 100644 index 000000000..cddde5cc7 --- /dev/null +++ b/programs/cmm/downloader/settings.h @@ -0,0 +1,9 @@ +_ini ini; + +void LoadIniConfig() +{ + ini.path = GetIni(#settings_file, "app.ini"); + ini.section = "WebView"; + + ini.GetString("proxy", #proxy_address, sizeof(proxy_address), NULL); +} \ No newline at end of file diff --git a/programs/cmm/lib/obj/http.h b/programs/cmm/lib/obj/http.h index 14aff6902..d9cbf9987 100644 --- a/programs/cmm/lib/obj/http.h +++ b/programs/cmm/lib/obj/http.h @@ -112,7 +112,6 @@ struct _http dword _http::get(dword _url) { cur_url = _url; - if (streqrp(cur_url, "http://gate.aspero.pro/?site=")) cur_url += 29; http_get stdcall (_url, 0, 0, #accept_language); transfer = EAX; return EAX; @@ -138,7 +137,7 @@ bool _http::stop() transfer=0; */ hfree(); - return true; + return true; } return false; }