forked from KolibriOS/kolibrios
apps/cmm: update HTTPS proxy (#439)
- new proxy address - fix proxy usage for `dl` - fix buffers overflow - optimize memory usage - explicit notify error for `dl` when URL is HTTPS and proxy is not found - cleanup some dead code to fit app in the same sectors size Reviewed-on: KolibriOS/kolibrios#439 Reviewed-by: Ivan B <1+dunkaist@noreply.localhost>
This commit is contained in:
1 parent
fac0425ac0
commit
ca99b669f2
4 files changed
+31
-19
No files matched your search
@@ -23,7 +23,7 @@ path=/usbhd0/1/kolibri.img
|
|||||||
autoclose=0
|
autoclose=0
|
||||||
|
|
||||||
[WebView]
|
[WebView]
|
||||||
proxy_address=http://proxy.kolibrios.org:82/?site=
|
proxy_address=http://proxy.kolibrios.org/?site=
|
||||||
search_engine=http://wiby.me/?q=
|
search_engine=http://wiby.me/?q=
|
||||||
;search_engine=http://bing.com/search?q=
|
;search_engine=http://bing.com/search?q=
|
||||||
;search_engine=https://html.duckduckgo.com/html/?q=
|
;search_engine=https://html.duckduckgo.com/html/?q=
|
||||||
@@ -72,8 +72,8 @@ progress_bar prbar;
|
|||||||
proc_info Form;
|
proc_info Form;
|
||||||
|
|
||||||
char settings_file[256];
|
char settings_file[256];
|
||||||
char proxy_address[768];
|
char proxy_address[256];
|
||||||
char search_engine[768];
|
char search_engine[256];
|
||||||
|
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "tabs.h"
|
#include "tabs.h"
|
||||||
@@ -533,12 +533,12 @@ bool GetLocalFileData(dword _path)
|
|||||||
|
|
||||||
bool GetUrl(dword _http_url)
|
bool GetUrl(dword _http_url)
|
||||||
{
|
{
|
||||||
char new_url_full[URL_SIZE+1];
|
char new_url_full[URL_SIZE + sizeof(proxy_address) + 1];
|
||||||
if (!strncmp(_http_url,"http://",7)) {
|
if (!strncmp(_http_url,"http://",7)) {
|
||||||
http.get(_http_url);
|
http.get(_http_url);
|
||||||
return true;
|
return true;
|
||||||
} else if (!strncmp(_http_url,"https://",8)) {
|
} else if (!strncmp(_http_url,"https://",8)) {
|
||||||
if (#proxy_address) {
|
if (proxy_address[0]) {
|
||||||
strcpy(#new_url_full, #proxy_address);
|
strcpy(#new_url_full, #proxy_address);
|
||||||
strncat(#new_url_full, _http_url, URL_SIZE);
|
strncat(#new_url_full, _http_url, URL_SIZE);
|
||||||
http.get(#new_url_full);
|
http.get(#new_url_full);
|
||||||
@@ -840,7 +840,7 @@ void ProcessMenuClick()
|
|||||||
|
|
||||||
void EventSearchWeb()
|
void EventSearchWeb()
|
||||||
{
|
{
|
||||||
char new_url[URL_SIZE+1];
|
char new_url[URL_SIZE + sizeof(search_engine) + 1];
|
||||||
// replace the spaces with '+' for the search query
|
// replace the spaces with '+' for the search query
|
||||||
replace_char(#editURL, ' ', '+', URL_SIZE);
|
replace_char(#editURL, ' ', '+', URL_SIZE);
|
||||||
strcpy(#new_url, #search_engine);
|
strcpy(#new_url, #search_engine);
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ char filepath[4096];
|
|||||||
char save_dir[4096];
|
char save_dir[4096];
|
||||||
|
|
||||||
char settings_file[256];
|
char settings_file[256];
|
||||||
char proxy_address[768];
|
char proxy_address[256];
|
||||||
|
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ progress_bar pb = {0, GAPX, 52, WIN_W - GAPX - GAPX, 17, 0, NULL, NULL,
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
dword shared_url;
|
// dword shared_url; // only used by the disabled -mem branch (long URL via SHM)
|
||||||
|
|
||||||
load_dll(libini, #lib_init,1);
|
load_dll(libini, #lib_init,1);
|
||||||
load_dll(boxlib, #box_lib_init,0);
|
load_dll(boxlib, #box_lib_init,0);
|
||||||
@@ -66,12 +66,15 @@ void main()
|
|||||||
param += 4;
|
param += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strncmp(#param, "-mem", 5)) {
|
// Disabled long-URL-via-SHM ("DL") channel. memopen was never
|
||||||
//shared_url = memopen(#dl_shared, URL_SIZE+1, SHM_OPEN + SHM_WRITE);
|
// finished (read from uninitialised ptr). Reimplement properly
|
||||||
strcpy(#uEdit, shared_url);
|
// if passing long URLs from WebView is ever needed.
|
||||||
} else {
|
// if (!strncmp(#param, "-mem", 5)) {
|
||||||
|
// shared_url = memopen(#dl_shared, URL_SIZE+1, SHM_OPEN + SHM_WRITE);
|
||||||
|
// strcpy(#uEdit, shared_url);
|
||||||
|
// } else {
|
||||||
strcpy(#uEdit, #param);
|
strcpy(#uEdit, #param);
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (streq(#param, "-test")) {
|
if (streq(#param, "-test")) {
|
||||||
strcpy(#uEdit, URL_SPEED_TEST);
|
strcpy(#uEdit, URL_SPEED_TEST);
|
||||||
@@ -157,7 +160,7 @@ void DrawWindow()
|
|||||||
} else if (http.transfer) {
|
} else if (http.transfer) {
|
||||||
DrawDlButton(WIN_W-BUT_W/2, BTN_STOP, T_CANCEL);
|
DrawDlButton(WIN_W-BUT_W/2, BTN_STOP, T_CANCEL);
|
||||||
DrawDownloadingProgress();
|
DrawDownloadingProgress();
|
||||||
} else if (!http.transfer) && (filepath) {
|
} else {
|
||||||
autoclose.disabled = true;
|
autoclose.disabled = true;
|
||||||
DrawDlButton(GAPX, BTN_RUN, T_RUN);
|
DrawDlButton(GAPX, BTN_RUN, T_RUN);
|
||||||
DrawDlButton(WIN_W-BUT_W/2, BTN_DIR, T_OPEN_DIR);
|
DrawDlButton(WIN_W-BUT_W/2, BTN_DIR, T_OPEN_DIR);
|
||||||
@@ -177,14 +180,24 @@ void DrawWindow()
|
|||||||
|
|
||||||
void StartDownloading()
|
void StartDownloading()
|
||||||
{
|
{
|
||||||
char get_url[URL_SIZE+33];
|
char get_url[URL_SIZE + sizeof(proxy_address) + 1];
|
||||||
if (http.transfer > 0) return;
|
if (http.transfer > 0) return;
|
||||||
ResetDownloadSpeed();
|
ResetDownloadSpeed();
|
||||||
pb.back_color = 0xFFFfff;
|
pb.back_color = 0xFFFfff;
|
||||||
if (!strncmp(#uEdit,"https://",8)) {
|
if (!strncmp(#uEdit,"https://",8)) {
|
||||||
miniprintf(#get_url, "%s%s", #proxy_address, #uEdit);
|
if (!proxy_address[0]) {
|
||||||
|
pb.progress_color = PB_COL_ERROR;
|
||||||
|
notify("'HTTPS URLs require proxy_address in app.ini' -E");
|
||||||
|
StopDownloading();
|
||||||
|
EditBox_UpdateText(#ed, ed_focus + ed_always_focus);
|
||||||
|
DrawWindow();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
strcpy(#get_url, #proxy_address);
|
||||||
|
strncat(#get_url, #uEdit, URL_SIZE);
|
||||||
|
} else {
|
||||||
strcpy(#get_url, #uEdit);
|
strcpy(#get_url, #uEdit);
|
||||||
|
}
|
||||||
|
|
||||||
if (http.get(#get_url)) {
|
if (http.get(#get_url)) {
|
||||||
pb.value = 0;
|
pb.value = 0;
|
||||||
@@ -288,7 +301,7 @@ void CompleteDownload()
|
|||||||
|
|
||||||
void SaveFile(int attempt)
|
void SaveFile(int attempt)
|
||||||
{
|
{
|
||||||
int i, fi=0;
|
int i;
|
||||||
char notify_message[4296];
|
char notify_message[4296];
|
||||||
char file_name[URL_SIZE+96];
|
char file_name[URL_SIZE+96];
|
||||||
|
|
||||||
@@ -349,7 +362,6 @@ void SaveFile(int attempt)
|
|||||||
void Unarchive(dword _arc)
|
void Unarchive(dword _arc)
|
||||||
{
|
{
|
||||||
char folder_name[4096];
|
char folder_name[4096];
|
||||||
strcpy(#folder_name, #save_dir);
|
|
||||||
strcpy(#folder_name, #filepath+strrchr(#filepath, '/'));
|
strcpy(#folder_name, #filepath+strrchr(#filepath, '/'));
|
||||||
folder_name[strlen(#folder_name)-4] = '\0';
|
folder_name[strlen(#folder_name)-4] = '\0';
|
||||||
CreateDir(#folder_name);
|
CreateDir(#folder_name);
|
||||||
|
|||||||
@@ -5,5 +5,5 @@ void LoadIniConfig()
|
|||||||
ini.path = GetIni(#settings_file, "app.ini");
|
ini.path = GetIni(#settings_file, "app.ini");
|
||||||
ini.section = "WebView";
|
ini.section = "WebView";
|
||||||
|
|
||||||
ini.GetString("proxy", #proxy_address, sizeof(proxy_address), NULL);
|
ini.GetString("proxy_address", #proxy_address, sizeof(proxy_address), NULL);
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user