Skip to content

Commit

Permalink
Rename discover_proxies_for_url back to get_proxies_for_url.
Browse files Browse the repository at this point in the history
  • Loading branch information
nmoinvaz committed Jul 11, 2023
1 parent 5271384 commit 2de4115
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 41 deletions.
16 changes: 8 additions & 8 deletions resolver.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static void proxy_resolver_get_proxies_for_url_threadpool(void *arg) {
proxy_resolver_s *proxy_resolver = (proxy_resolver_s *)arg;
if (!proxy_resolver)
return;
g_proxy_resolver.proxy_resolver_i->discover_proxies_for_url(proxy_resolver->base, proxy_resolver->url);
g_proxy_resolver.proxy_resolver_i->get_proxies_for_url(proxy_resolver->base, proxy_resolver->url);
}

static bool proxy_resolver_get_proxies_for_url_from_system_config(void *ctx, const char *url) {
Expand All @@ -73,7 +73,7 @@ static bool proxy_resolver_get_proxies_for_url_from_system_config(void *ctx, con
// Use scheme associated with the URL when determining proxy
scheme = get_url_scheme(url, "http");
if (!scheme) {
LOG_ERROR("Unable to allocate memory for %s (%" PRId32 ")\n", "scheme");
LOG_ERROR("Unable to allocate memory for scheme\n");
goto config_done;
}

Expand Down Expand Up @@ -115,18 +115,18 @@ bool proxy_resolver_get_proxies_for_url(void *ctx, const char *url) {
free(proxy_resolver->list);
proxy_resolver->list = NULL;

// Check if discover already takes into account system configuration
if (!g_proxy_resolver.proxy_resolver_i->discover_uses_system_config) {
// Check if OS resolver already takes into account system configuration
if (!g_proxy_resolver.proxy_resolver_i->uses_system_config) {
// Check if auto-discovery is necessary
if (proxy_resolver_get_proxies_for_url_from_system_config(ctx, url)) {
// Use system proxy configuration if no auto-discovery mechanism is necessary
return true;
}
}

// Automatically discover proxy configuration asynchronously if supported, otherwise spool to thread pool
if (g_proxy_resolver.proxy_resolver_i->discover_is_async)
return g_proxy_resolver.proxy_resolver_i->discover_proxies_for_url(proxy_resolver->base, url);
// Discover proxy auto-config asynchronously if supported, otherwise spool to thread pool
if (g_proxy_resolver.proxy_resolver_i->is_async)
return g_proxy_resolver.proxy_resolver_i->get_proxies_for_url(proxy_resolver->base, url);

free(proxy_resolver->url);
proxy_resolver->url = strdup(url);
Expand Down Expand Up @@ -266,7 +266,7 @@ bool proxy_resolver_global_init(void) {
}

// No need to create thread pool since underlying implementation is already asynchronous
if (g_proxy_resolver.proxy_resolver_i->is_discover_async) {
if (g_proxy_resolver.proxy_resolver_i->is_async) {
g_proxy_resolver.ref_count++;
return true;
}
Expand Down
8 changes: 4 additions & 4 deletions resolver_gnome3.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static bool proxy_resolver_gnome3_get_proxies(proxy_resolver_gnome3_s *proxy_res
return true;
}

bool proxy_resolver_gnome3_discover_proxies_for_url(void *ctx, const char *url) {
bool proxy_resolver_gnome3_get_proxies_for_url(void *ctx, const char *url) {
proxy_resolver_gnome3_s *proxy_resolver = (proxy_resolver_gnome3_s *)ctx;
GError *error = NULL;
char **proxies = NULL;
Expand Down Expand Up @@ -262,15 +262,15 @@ bool proxy_resolver_gnome3_global_cleanup(void) {

proxy_resolver_i_s *proxy_resolver_gnome3_get_interface(void) {
static proxy_resolver_i_s proxy_resolver_gnome3_i = {
proxy_resolver_gnome3_discover_proxies_for_url,
proxy_resolver_gnome3_get_proxies_for_url,
proxy_resolver_gnome3_get_list,
proxy_resolver_gnome3_get_error,
proxy_resolver_gnome3_wait,
proxy_resolver_gnome3_cancel,
proxy_resolver_gnome3_create,
proxy_resolver_gnome3_delete,
false /* discover_proxies_for_url should be spooled to another thread */,
true /* discover_proxies_for_url takes into account system config */,
false /* get_proxies_for_url should be spooled to another thread */,
true /* get_proxies_for_url takes into account system config */,
proxy_resolver_gnome3_global_init,
proxy_resolver_gnome3_global_cleanup};
return &proxy_resolver_gnome3_i;
Expand Down
2 changes: 1 addition & 1 deletion resolver_gnome3.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

bool proxy_resolver_gnome3_discover_proxies_for_url(void *ctx, const char *url);
bool proxy_resolver_gnome3_get_proxies_for_url(void *ctx, const char *url);
const char *proxy_resolver_gnome3_get_list(void *ctx);
int32_t proxy_resolver_gnome3_get_error(void *ctx);
bool proxy_resolver_gnome3_wait(void *ctx, int32_t timeout_ms);
Expand Down
6 changes: 3 additions & 3 deletions resolver_i.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

typedef struct proxy_resolver_i_s {
bool (*discover_proxies_for_url)(void *ctx, const char *url);
bool (*get_proxies_for_url)(void *ctx, const char *url);

const char *(*get_list)(void *ctx);
int32_t (*get_error)(void *ctx);
Expand All @@ -11,8 +11,8 @@ typedef struct proxy_resolver_i_s {
void *(*create)(void);
bool (*delete)(void **ctx);

bool discover_is_async;
bool discover_uses_system_config;
bool is_async;
bool uses_system_config;

bool (*global_init)(void);
bool (*global_cleanup)(void);
Expand Down
8 changes: 4 additions & 4 deletions resolver_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ static void proxy_resolver_mac_auto_config_result_callback(void *client, CFArray
return;
}

bool proxy_resolver_mac_discover_proxies_for_url(void *ctx, const char *url) {
bool proxy_resolver_mac_get_proxies_for_url(void *ctx, const char *url) {
proxy_resolver_mac_s *proxy_resolver = (proxy_resolver_mac_s *)ctx;
CFURLRef target_url_ref = NULL;
CFURLRef url_ref = NULL;
Expand Down Expand Up @@ -236,15 +236,15 @@ bool proxy_resolver_mac_global_cleanup(void) {

proxy_resolver_i_s *proxy_resolver_mac_get_interface(void) {
static proxy_resolver_i_s proxy_resolver_mac_i = {
proxy_resolver_mac_discover_proxies_for_url,
proxy_resolver_mac_get_proxies_for_url,
proxy_resolver_mac_get_list,
proxy_resolver_mac_get_error,
proxy_resolver_mac_wait,
proxy_resolver_mac_cancel,
proxy_resolver_mac_create,
proxy_resolver_mac_delete,
false /* discover_proxies_for_url should be spooled to another thread */,
true /* discover_proxies_for_url does not take into account system config */,
false /* get_proxies_for_url should be spooled to another thread */,
true /* get_proxies_for_url does not take into account system config */,
proxy_resolver_mac_global_init,
proxy_resolver_mac_global_cleanup};
return &proxy_resolver_mac_i;
Expand Down
2 changes: 1 addition & 1 deletion resolver_mac.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

bool proxy_resolver_mac_discover_proxies_for_url(void *ctx, const char *url);
bool proxy_resolver_mac_get_proxies_for_url(void *ctx, const char *url);
const char *proxy_resolver_mac_get_list(void *ctx);
int32_t proxy_resolver_mac_get_error(void *ctx);
bool proxy_resolver_mac_wait(void *ctx, int32_t timeout_ms);
Expand Down
8 changes: 4 additions & 4 deletions resolver_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ static char *proxy_resolver_posix_fetch_pac(const char *auto_config_url, int32_t
return script;
}

bool proxy_resolver_posix_discover_proxies_for_url(void *ctx, const char *url) {
bool proxy_resolver_posix_get_proxies_for_url(void *ctx, const char *url) {
proxy_resolver_posix_s *proxy_resolver = (proxy_resolver_posix_s *)ctx;
char *auto_config_url = NULL;
char *proxy = NULL;
Expand Down Expand Up @@ -289,15 +289,15 @@ bool proxy_resolver_posix_global_cleanup(void) {

proxy_resolver_i_s *proxy_resolver_posix_get_interface(void) {
static proxy_resolver_i_s proxy_resolver_posix_i = {
proxy_resolver_posix_discover_proxies_for_url,
proxy_resolver_posix_get_proxies_for_url,
proxy_resolver_posix_get_list,
proxy_resolver_posix_get_error,
proxy_resolver_posix_wait,
proxy_resolver_posix_cancel,
proxy_resolver_posix_create,
proxy_resolver_posix_delete,
false /* discover_proxies_for_url should be spooled to another thread */,
true /* discover_proxies_for_url does not take into account system config */,
false /* get_proxies_for_url should be spooled to another thread */,
true /* get_proxies_for_url does not take into account system config */,
proxy_resolver_posix_global_init,
proxy_resolver_posix_global_cleanup};
return &proxy_resolver_posix_i;
Expand Down
2 changes: 1 addition & 1 deletion resolver_posix.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

bool proxy_resolver_posix_get_proxies_for_url(void *ctx, const char *url);
bool proxy_resolver_posix_discover_proxies_for_url(void *ctx, const char *url);
bool proxy_resolver_posix_get_proxies_for_url(void *ctx, const char *url);
const char *proxy_resolver_posix_get_list(void *ctx);
int32_t proxy_resolver_posix_get_error(void *ctx);
bool proxy_resolver_posix_wait(void *ctx, int32_t timeout_ms);
Expand Down
8 changes: 4 additions & 4 deletions resolver_win8.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void CALLBACK proxy_resolver_win8_winhttp_status_callback(HINTERNET Internet, DW
event_set(proxy_resolver->complete);
}

bool proxy_resolver_win8_discover_proxies_for_url(void *ctx, const char *url) {
bool proxy_resolver_win8_get_proxies_for_url(void *ctx, const char *url) {
proxy_resolver_win8_s *proxy_resolver = (proxy_resolver_win8_s *)ctx;
WINHTTP_AUTOPROXY_OPTIONS options = {0};
WINHTTP_PROXY_INFO proxy_info = {0};
Expand Down Expand Up @@ -357,15 +357,15 @@ bool proxy_resolver_win8_global_cleanup(void) {

proxy_resolver_i_s *proxy_resolver_win8_get_interface(void) {
static proxy_resolver_i_s proxy_resolver_win8_i = {
proxy_resolver_win8_discover_proxies_for_url,
proxy_resolver_win8_get_proxies_for_url,
proxy_resolver_win8_get_list,
proxy_resolver_win8_get_error,
proxy_resolver_win8_wait,
proxy_resolver_win8_cancel,
proxy_resolver_win8_create,
proxy_resolver_win8_delete,
true /* discover_proxies_for_url is handled asynchronously */,
false /* discover_proxies_for_url does not take into account system config */,
true /* get_proxies_for_url is handled asynchronously */,
false /* get_proxies_for_url does not take into account system config */,
proxy_resolver_win8_global_init,
proxy_resolver_win8_global_cleanup};
return &proxy_resolver_win8_i;
Expand Down
2 changes: 1 addition & 1 deletion resolver_win8.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

bool proxy_resolver_win8_discover_proxies_for_url(void *ctx, const char *url);
bool proxy_resolver_win8_get_proxies_for_url(void *ctx, const char *url);
const char *proxy_resolver_win8_get_list(void *ctx);
int32_t proxy_resolver_win8_get_error(void *ctx);
bool proxy_resolver_win8_wait(void *ctx, int32_t timeout_ms);
Expand Down
8 changes: 4 additions & 4 deletions resolver_winrt.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ static WinRT_IUriRuntimeClass *create_uri_from_string(const char *url) {
return uri;
}

bool proxy_resolver_winrt_discover_proxies_for_url(void *ctx, const char *url) {
bool proxy_resolver_winrt_get_proxies_for_url(void *ctx, const char *url) {
proxy_resolver_winrt_s *proxy_resolver = (proxy_resolver_winrt_s *)ctx;
WinRT_INetworkInformationStatics *network_info_statics = NULL;
WinRT_IUriRuntimeClass *uri = NULL;
Expand Down Expand Up @@ -398,15 +398,15 @@ bool proxy_resolver_winrt_global_cleanup(void) {

proxy_resolver_i_s *proxy_resolver_winrt_get_interface(void) {
static proxy_resolver_i_s proxy_resolver_winrt_i = {
proxy_resolver_winrt_discover_proxies_for_url,
proxy_resolver_winrt_get_proxies_for_url,
proxy_resolver_winrt_get_list,
proxy_resolver_winrt_get_error,
proxy_resolver_winrt_wait,
proxy_resolver_winrt_cancel,
proxy_resolver_winrt_create,
proxy_resolver_winrt_delete,
true /* discover_proxies_for_url is handled asynchronously */,
true /* discover_proxies_for_url takes into account system config */,
true /* get_proxies_for_url is handled asynchronously */,
true /* get_proxies_for_url takes into account system config */,
proxy_resolver_winrt_global_init,
proxy_resolver_winrt_global_cleanup};
return &proxy_resolver_winrt_i;
Expand Down
2 changes: 1 addition & 1 deletion resolver_winrt.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

bool proxy_resolver_winrt_get_proxies_for_url(void *ctx, const char *url);
bool proxy_resolver_winrt_discover_proxies_for_url(void *ctx, const char *url);
bool proxy_resolver_winrt_get_proxies_for_url(void *ctx, const char *url);
const char *proxy_resolver_winrt_get_list(void *ctx);
int32_t proxy_resolver_winrt_get_error(void *ctx);
bool proxy_resolver_winrt_wait(void *ctx, int32_t timeout_ms);
Expand Down
8 changes: 4 additions & 4 deletions resolver_winxp.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ typedef struct proxy_resolver_winxp_s {
char *list;
} proxy_resolver_winxp_s;

bool proxy_resolver_winxp_discover_proxies_for_url(void *ctx, const char *url) {
bool proxy_resolver_winxp_get_proxies_for_url(void *ctx, const char *url) {
proxy_resolver_winxp_s *proxy_resolver = (proxy_resolver_winxp_s *)ctx;
WINHTTP_AUTOPROXY_OPTIONS options = {0};
WINHTTP_PROXY_INFO proxy_info = {0};
Expand Down Expand Up @@ -227,15 +227,15 @@ bool proxy_resolver_winxp_global_cleanup(void) {

proxy_resolver_i_s *proxy_resolver_winxp_get_interface(void) {
static proxy_resolver_i_s proxy_resolver_winxp_i = {
proxy_resolver_winxp_discover_proxies_for_url,
proxy_resolver_winxp_get_proxies_for_url,
proxy_resolver_winxp_get_list,
proxy_resolver_winxp_get_error,
proxy_resolver_winxp_wait,
proxy_resolver_winxp_cancel,
proxy_resolver_winxp_create,
proxy_resolver_winxp_delete,
false /* discover_proxies_for_url should be spooled to another thread */,
false /* discover_proxies_for_url does not take into account system config */,
false /* get_proxies_for_url should be spooled to another thread */,
false /* get_proxies_for_url does not take into account system config */,
proxy_resolver_winxp_global_init,
proxy_resolver_winxp_global_cleanup};
return &proxy_resolver_winxp_i;
Expand Down
2 changes: 1 addition & 1 deletion resolver_winxp.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

bool proxy_resolver_winxp_discover_proxies_for_url(void *ctx, const char *url);
bool proxy_resolver_winxp_get_proxies_for_url(void *ctx, const char *url);
const char *proxy_resolver_winxp_get_list(void *ctx);
int32_t proxy_resolver_winxp_get_error(void *ctx);
bool proxy_resolver_winxp_wait(void *ctx, int32_t timeout_ms);
Expand Down

0 comments on commit 2de4115

Please sign in to comment.