Mercurial > hg > nnchat
comparison network.c @ 488:bbe05594f29d
Clean up some initialization messages.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 26 May 2012 17:49:06 +0300 |
parents | 8bd6bad09fb8 |
children | ba48840b8525 |
comparison
equal
deleted
inserted
replaced
487:fed7bb8b7ccc | 488:bbe05594f29d |
---|---|
197 conn->err = nn_get_socket_errno(); | 197 conn->err = nn_get_socket_errno(); |
198 nn_conn_err(conn, "Could not open socket: %s\n", nn_get_socket_errstr(conn->err)); | 198 nn_conn_err(conn, "Could not open socket: %s\n", nn_get_socket_errstr(conn->err)); |
199 goto error; | 199 goto error; |
200 } | 200 } |
201 | 201 |
202 nn_conn_msg(conn, "Using socket %d.\n", conn->socket); | |
203 | |
204 if (connect(conn->socket, (struct sockaddr *) &dest, sizeof(dest)) == -1) | 202 if (connect(conn->socket, (struct sockaddr *) &dest, sizeof(dest)) == -1) |
205 { | 203 { |
206 conn->err = nn_get_socket_errno(); | 204 conn->err = nn_get_socket_errno(); |
207 nn_conn_err(conn, "Could not connect: %s\n", nn_get_socket_errstr(conn->err)); | 205 nn_conn_err(conn, "Could not connect: %s\n", nn_get_socket_errstr(conn->err)); |
208 goto error; | 206 goto error; |
217 struct nn_socks_t *socksh; | 215 struct nn_socks_t *socksh; |
218 size_t bufsiz = sizeof(struct nn_socks_t) + strlen(userid) + 1; | 216 size_t bufsiz = sizeof(struct nn_socks_t) + strlen(userid) + 1; |
219 char *ptr, *buf; | 217 char *ptr, *buf; |
220 int tries, status = -1; | 218 int tries, status = -1; |
221 | 219 |
220 nn_conn_msg(conn, "Initializing proxy negotiation.\n"); | |
221 | |
222 if (conn->proxy.type == NN_PROXY_SOCKS4A) | 222 if (conn->proxy.type == NN_PROXY_SOCKS4A) |
223 bufsiz += strlen(conn->host) + 1; | 223 bufsiz += strlen(conn->host) + 1; |
224 | 224 |
225 ptr = buf = th_malloc(bufsiz); | 225 ptr = buf = th_malloc(bufsiz); |
226 if (buf == NULL) | 226 if (buf == NULL) |
229 nn_conn_err(conn, "Could not allocate memory for SOCKS negotiation buffer, %d bytes.\n", bufsiz); | 229 nn_conn_err(conn, "Could not allocate memory for SOCKS negotiation buffer, %d bytes.\n", bufsiz); |
230 goto error; | 230 goto error; |
231 } | 231 } |
232 | 232 |
233 // Create SOCKS 4/4A request | 233 // Create SOCKS 4/4A request |
234 nn_conn_msg(conn, "Initializing proxy negotiation.\n"); | |
235 socksh = (struct nn_socks_t *) buf; | 234 socksh = (struct nn_socks_t *) buf; |
236 socksh->version = 4; | 235 socksh->version = 4; |
237 socksh->command = SOCKS_CMD_CONNECT; | 236 socksh->command = SOCKS_CMD_CONNECT; |
238 socksh->port = htons(port); | 237 socksh->port = htons(port); |
239 if (conn->proxy.type == NN_PROXY_SOCKS4A) | 238 if (conn->proxy.type == NN_PROXY_SOCKS4A) |