summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau2024-04-18 12:28:09 +0000
committerFelix Fietkau2024-04-18 12:28:09 +0000
commitc2bf660d88ece757ebc4889ef30ec2fa11fb1e9e (patch)
treeb99ad0dd0290a6c889e7e71bad43d3e12ef39d7d
parent6c16331e4bf542fbb538d62a6b5bf3d286ecbf2c (diff)
downloaduclient-c2bf660d88ece757ebc4889ef30ec2fa11fb1e9e.tar.gz
lib: add log_msg callback to get more detailed log messages
Signed-off-by: Felix Fietkau <nbd@nbd.name>
-rw-r--r--uclient-http.c6
-rw-r--r--uclient.h7
2 files changed, 13 insertions, 0 deletions
diff --git a/uclient-http.c b/uclient-http.c
index d6e9dcf..0b70ede 100644
--- a/uclient-http.c
+++ b/uclient-http.c
@@ -861,17 +861,23 @@ static void uclient_ssl_notify_state(struct ustream *us)
static void uclient_ssl_notify_error(struct ustream_ssl *ssl, int error, const char *str)
{
struct uclient_http *uh = container_of(ssl, struct uclient_http, ussl);
+ struct uclient *uc = &uh->uc;
+ if (uc->cb->log_msg)
+ uc->cb->log_msg(uc, UCLIENT_LOG_SSL_ERROR, str);
uclient_http_error(uh, UCLIENT_ERROR_CONNECT);
}
static void uclient_ssl_notify_verify_error(struct ustream_ssl *ssl, int error, const char *str)
{
struct uclient_http *uh = container_of(ssl, struct uclient_http, ussl);
+ struct uclient *uc = &uh->uc;
if (!uh->ssl_require_validation)
return;
+ if (uc->cb->log_msg)
+ uc->cb->log_msg(uc, UCLIENT_LOG_SSL_VERIFY_ERROR, str);
uclient_http_error(uh, UCLIENT_ERROR_SSL_INVALID_CERT);
}
diff --git a/uclient.h b/uclient.h
index 5ccda74..772a5bd 100644
--- a/uclient.h
+++ b/uclient.h
@@ -39,6 +39,12 @@ enum uclient_error_code {
__UCLIENT_ERROR_MAX
};
+enum uclient_log_type {
+ UCLIENT_LOG_SSL_ERROR,
+ UCLIENT_LOG_SSL_VERIFY_ERROR,
+ __UCLIENT_LOG_MAX
+};
+
union uclient_addr {
struct sockaddr sa;
struct sockaddr_in sin;
@@ -85,6 +91,7 @@ struct uclient_cb {
void (*data_eof)(struct uclient *cl);
void (*header_done)(struct uclient *cl);
void (*error)(struct uclient *cl, int code);
+ void (*log_msg)(struct uclient *cl, enum uclient_log_type type, const char *msg);
};
struct uclient *uclient_new(const char *url, const char *auth_str, const struct uclient_cb *cb);