Mercurial > hg > nnchat
diff network.c @ 606:2cc5434a8ce0
Change proxy authentication handling.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 20 May 2014 04:34:23 +0300 |
parents | ad00f2bbb615 |
children | 019a54b07f60 |
line wrap: on
line diff
--- a/network.c Tue May 20 02:11:05 2014 +0300 +++ b/network.c Tue May 20 04:34:23 2014 +0300 @@ -133,7 +133,7 @@ void (*errfunc)(nn_conn_t *conn, const char *msg), void (*msgfunc)(nn_conn_t *conn, const char *msg)) { - nn_conn_t *conn = th_calloc(1, sizeof(nn_conn_t)); + nn_conn_t *conn = th_malloc0(sizeof(nn_conn_t)); if (conn == NULL) return NULL; @@ -160,16 +160,17 @@ } -int nn_conn_set_proxy(nn_conn_t *conn, int type, int port, const char *host, const char *userid, const char *passwd) +int nn_conn_set_proxy(nn_conn_t *conn, int type, int port, const char *host, int auth_type) { if (conn == NULL) return -1; conn->proxy.type = type; conn->proxy.port = port; + conn->proxy.auth_type = auth_type; + + th_free(conn->proxy.host); conn->proxy.host = th_strdup(host); - conn->proxy.userid = th_strdup(userid); - conn->proxy.passwd = th_strdup(passwd); if (host != NULL) { @@ -183,6 +184,20 @@ } +int nn_conn_set_proxy_auth_user(nn_conn_t *conn, const char *userid, const char *passwd) +{ + if (conn == NULL) + return -1; + + th_free(conn->proxy.userid); + conn->proxy.userid = th_strdup(userid); + th_free(conn->proxy.passwd); + conn->proxy.passwd = th_strdup(passwd); + + return 0; +} + + int nn_conn_open(nn_conn_t *conn, const int port, const char *host) { struct sockaddr_in dest;