mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-02-10 00:37:00 +08:00
added seclog_hex
This commit is contained in:
26
src/log.c
26
src/log.c
@@ -28,6 +28,7 @@
|
||||
#include <vpn.h>
|
||||
#include <worker.h>
|
||||
#include <main.h>
|
||||
#include <sec-mod.h>
|
||||
|
||||
char *human_addr2(const struct sockaddr *sa, socklen_t salen,
|
||||
void *_buf, size_t buflen, unsigned full)
|
||||
@@ -224,3 +225,28 @@ void oclog_hex(const worker_st* ws, int priority,
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void seclog_hex(const struct sec_mod_st* sec, int priority,
|
||||
const char *prefix, uint8_t* bin, unsigned bin_size, unsigned b64)
|
||||
{
|
||||
char buf[512];
|
||||
int ret;
|
||||
size_t buf_size;
|
||||
gnutls_datum_t data = {bin, bin_size};
|
||||
|
||||
if (priority == LOG_DEBUG && sec->config->debug == 0)
|
||||
return;
|
||||
|
||||
if (b64) {
|
||||
base64_encode((char*)bin, bin_size, (char*)buf, sizeof(buf));
|
||||
} else {
|
||||
buf_size = sizeof(buf);
|
||||
ret = gnutls_hex_encode(&data, buf, &buf_size);
|
||||
if (ret < 0)
|
||||
return;
|
||||
}
|
||||
|
||||
seclog(sec, priority, "%s %s", prefix, buf);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -94,6 +94,9 @@ void cleanup_client_entries(sec_mod_st *sec);
|
||||
}
|
||||
#endif
|
||||
|
||||
void seclog_hex(const struct sec_mod_st* sec, int priority,
|
||||
const char *prefix, uint8_t* bin, unsigned bin_size, unsigned b64);
|
||||
|
||||
void sec_auth_init(sec_mod_st *sec, struct cfg_st *config);
|
||||
void sec_auth_reinit(sec_mod_st *sec, struct cfg_st *config);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user