0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-07-06 02:28:38 +02:00

sslproc: likewise

This commit is contained in:
William Pitcock 2015-12-10 23:44:31 -06:00
parent 408a29c65a
commit 196740c42b
2 changed files with 26 additions and 26 deletions

View file

@ -29,8 +29,8 @@ typedef struct _ssl_ctl ssl_ctl_t;
void init_ssld(void);
int start_ssldaemon(int count, const char *ssl_cert, const char *ssl_private_key, const char *ssl_dh_params);
ssl_ctl_t *start_ssld_accept(rb_fde_t *sslF, rb_fde_t *plainF, int id);
ssl_ctl_t *start_ssld_connect(rb_fde_t *sslF, rb_fde_t *plainF, int id);
ssl_ctl_t *start_ssld_accept(rb_fde_t *sslF, rb_fde_t *plainF, uint32_t id);
ssl_ctl_t *start_ssld_connect(rb_fde_t *sslF, rb_fde_t *plainF, uint32_t id);
void start_zlib_session(void *data);
void send_new_ssl_certs(const char *ssl_cert, const char *ssl_private_key, const char *ssl_dh_params);
void ssld_decrement_clicount(ssl_ctl_t *ctl);

View file

@ -77,16 +77,16 @@ static void send_certfp_method(ssl_ctl_t *ctl, int method);
static rb_dlink_list ssl_daemons;
static inline int32_t
buf_to_int32(char *buf)
static inline uint32_t
buf_to_uint32(char *buf)
{
int32_t x;
uint32_t x;
memcpy(&x, buf, sizeof(x));
return x;
}
static inline void
int32_to_buf(char *buf, int32_t x)
uint32_to_buf(char *buf, uint32_t x)
{
memcpy(buf, &x, sizeof(x));
return;
@ -358,12 +358,12 @@ ssl_process_dead_fd(ssl_ctl_t * ctl, ssl_ctl_buf_t * ctl_buf)
{
struct Client *client_p;
char reason[256];
int32_t fd;
uint32_t fd;
if(ctl_buf->buflen < 6)
return; /* bogus message..drop it.. XXX should warn here */
fd = buf_to_int32(&ctl_buf->buf[1]);
fd = buf_to_uint32(&ctl_buf->buf[1]);
rb_strlcpy(reason, &ctl_buf->buf[5], sizeof(reason));
client_p = find_cli_fd_hash(fd);
if(client_p == NULL)
@ -388,8 +388,8 @@ static void
ssl_process_certfp(ssl_ctl_t * ctl, ssl_ctl_buf_t * ctl_buf)
{
struct Client *client_p;
int32_t fd;
int32_t len;
uint32_t fd;
uint32_t len;
uint8_t *certfp;
char *certfp_string;
int i;
@ -397,8 +397,8 @@ ssl_process_certfp(ssl_ctl_t * ctl, ssl_ctl_buf_t * ctl_buf)
if(ctl_buf->buflen > 5 + RB_SSL_CERTFP_LEN)
return; /* bogus message..drop it.. XXX should warn here */
fd = buf_to_int32(&ctl_buf->buf[1]);
len = buf_to_int32(&ctl_buf->buf[5]);
fd = buf_to_uint32(&ctl_buf->buf[1]);
len = buf_to_uint32(&ctl_buf->buf[5]);
certfp = (uint8_t *)&ctl_buf->buf[9];
client_p = find_cli_fd_hash(fd);
if(client_p == NULL)
@ -638,7 +638,7 @@ send_certfp_method(ssl_ctl_t *ctl, int method)
char buf[5];
buf[0] = 'F';
int32_to_buf(&buf[1], method);
uint32_to_buf(&buf[1], method);
ssl_cmd_write_queue(ctl, NULL, 0, buf, sizeof(buf));
}
@ -660,7 +660,7 @@ send_new_ssl_certs(const char *ssl_cert, const char *ssl_private_key, const char
ssl_ctl_t *
start_ssld_accept(rb_fde_t * sslF, rb_fde_t * plainF, int32_t id)
start_ssld_accept(rb_fde_t * sslF, rb_fde_t * plainF, uint32_t id)
{
rb_fde_t *F[2];
ssl_ctl_t *ctl;
@ -669,7 +669,7 @@ start_ssld_accept(rb_fde_t * sslF, rb_fde_t * plainF, int32_t id)
F[1] = plainF;
buf[0] = 'A';
int32_to_buf(&buf[1], id);
uint32_to_buf(&buf[1], id);
ctl = which_ssld();
ctl->cli_count++;
ssl_cmd_write_queue(ctl, F, 2, buf, sizeof(buf));
@ -677,7 +677,7 @@ start_ssld_accept(rb_fde_t * sslF, rb_fde_t * plainF, int32_t id)
}
ssl_ctl_t *
start_ssld_connect(rb_fde_t * sslF, rb_fde_t * plainF, int32_t id)
start_ssld_connect(rb_fde_t * sslF, rb_fde_t * plainF, uint32_t id)
{
rb_fde_t *F[2];
ssl_ctl_t *ctl;
@ -686,7 +686,7 @@ start_ssld_connect(rb_fde_t * sslF, rb_fde_t * plainF, int32_t id)
F[1] = plainF;
buf[0] = 'C';
int32_to_buf(&buf[1], id);
uint32_to_buf(&buf[1], id);
ctl = which_ssld();
ctl->cli_count++;
@ -730,7 +730,7 @@ start_zlib_session(void *data)
char buf2[9];
void *recvq_start;
size_t hdr = (sizeof(uint8_t) * 2) + sizeof(int32_t);
size_t hdr = (sizeof(uint8_t) * 2) + sizeof(uint32_t);
size_t len;
int cpylen, left;
@ -753,7 +753,7 @@ start_zlib_session(void *data)
buf = rb_malloc(len);
level = ConfigFileEntry.compression_level;
int32_to_buf(&buf[1], rb_get_fd(server->localClient->F));
uint32_to_buf(&buf[1], rb_get_fd(server->localClient->F));
buf[5] = (char) level;
recvq_start = &buf[6];
@ -784,8 +784,8 @@ start_zlib_session(void *data)
{
/* tell ssld the new connid for the ssl part*/
buf2[0] = 'Y';
int32_to_buf(&buf2[1], rb_get_fd(server->localClient->F));
int32_to_buf(&buf2[5], rb_get_fd(xF2));
uint32_to_buf(&buf2[1], rb_get_fd(server->localClient->F));
uint32_to_buf(&buf2[5], rb_get_fd(xF2));
ssl_cmd_write_queue(server->localClient->ssl_ctl, NULL, 0, buf2, sizeof(buf2));
}
@ -795,7 +795,7 @@ start_zlib_session(void *data)
del_from_cli_fd_hash(server);
server->localClient->F = xF2;
/* need to redo as what we did before isn't valid now */
int32_to_buf(&buf[1], rb_get_fd(server->localClient->F));
uint32_to_buf(&buf[1], rb_get_fd(server->localClient->F));
add_to_cli_fd_hash(server);
server->localClient->z_ctl = which_ssld();
@ -809,13 +809,13 @@ collect_zipstats(void *unused)
{
rb_dlink_node *ptr;
struct Client *target_p;
char buf[sizeof(uint8_t) + sizeof(int32_t) + HOSTLEN];
char buf[sizeof(uint8_t) + sizeof(uint32_t) + HOSTLEN];
void *odata;
size_t len;
int32_t id;
uint32_t id;
buf[0] = 'S';
odata = buf + sizeof(uint8_t) + sizeof(int32_t);
odata = buf + sizeof(uint8_t) + sizeof(uint32_t);
RB_DLINK_FOREACH(ptr, serv_list.head)
{
@ -825,7 +825,7 @@ collect_zipstats(void *unused)
len = sizeof(uint8_t) + sizeof(uint32_t);
id = rb_get_fd(target_p->localClient->F);
int32_to_buf(&buf[1], id);
uint32_to_buf(&buf[1], id);
rb_strlcpy(odata, target_p->name, (sizeof(buf) - len));
len += strlen(odata) + 1; /* Get the \0 as well */
ssl_cmd_write_queue(target_p->localClient->z_ctl, NULL, 0, buf, len);