Mercurial > hg > th-libs
comparison th_network.c @ 123:c8584cf52c98
Various bugfixes in proxy handling.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 22 Jun 2014 02:48:33 +0300 |
parents | 452adc41ccf5 |
children | 61d882a9758b |
comparison
equal
deleted
inserted
replaced
122:452adc41ccf5 | 123:c8584cf52c98 |
---|---|
307 goto out; | 307 goto out; |
308 } | 308 } |
309 | 309 |
310 th_growbuf_puts(&buf, conn->proxy.userid, TRUE); | 310 th_growbuf_puts(&buf, conn->proxy.userid, TRUE); |
311 if (conn->proxy.addr_type == TH_PROXY_ADDR_DOMAIN) | 311 if (conn->proxy.addr_type == TH_PROXY_ADDR_DOMAIN) |
312 th_growbuf_puts(&buf, conn->host, TRUE); | 312 th_growbuf_puts(&buf, host, TRUE); |
313 | 313 |
314 // Send request | 314 // Send request |
315 if ((err = th_conn_proxy_send(conn, &buf)) != THERR_OK) | 315 if ((err = th_conn_proxy_send(conn, &buf)) != THERR_OK) |
316 goto out; | 316 goto out; |
317 | 317 |
488 "Proxy server chose an unsupported SOCKS 5 authentication method %d.\n", | 488 "Proxy server chose an unsupported SOCKS 5 authentication method %d.\n", |
489 auth); | 489 auth); |
490 goto out; | 490 goto out; |
491 } | 491 } |
492 | 492 |
493 #if 1 | 493 |
494 // Form client connection request packet | 494 // Form client connection request packet |
495 th_growbuf_clear(&buf); | 495 th_growbuf_clear(&buf); |
496 th_growbuf_put_u8(&buf, 0x05); // Protocol version | 496 th_growbuf_put_u8(&buf, 0x05); // Protocol version |
497 th_growbuf_put_u8(&buf, cmd); // Command | 497 th_growbuf_put_u8(&buf, cmd); // Command |
498 th_growbuf_put_u8(&buf, 0x00); // Reserved | 498 th_growbuf_put_u8(&buf, 0x00); // Reserved |
499 | 499 |
500 switch (conn->proxy.addr_type) | 500 switch (conn->proxy.addr_type) |
501 { | 501 { |
502 case TH_PROXY_ADDR_IPV4: | 502 case TH_PROXY_ADDR_IPV4: |
508 th_growbuf_put_u8(&buf, SOCKS5_ADDR_IPV6); | 508 th_growbuf_put_u8(&buf, SOCKS5_ADDR_IPV6); |
509 //th_growbuf_put_str(&buf, (uint8_t *) &(conn->addr.s_addr), sizeof(conn->addr.s_addr)); | 509 //th_growbuf_put_str(&buf, (uint8_t *) &(conn->addr.s_addr), sizeof(conn->addr.s_addr)); |
510 break; | 510 break; |
511 | 511 |
512 case TH_PROXY_ADDR_DOMAIN: | 512 case TH_PROXY_ADDR_DOMAIN: |
513 cmd = strlen(conn->host); | 513 cmd = strlen(host); |
514 if (cmd < 1 || cmd > 255) | 514 if (cmd < 1 || cmd > 255) |
515 { | 515 { |
516 err = THERR_NOT_SUPPORTED; | 516 err = THERR_NOT_SUPPORTED; |
517 th_conn_err(conn, err, | 517 th_conn_err(conn, err, |
518 "Domain address type requested, but domain name longer than 255 characters (%d).\n", cmd); | 518 "Domain address type requested, but domain name longer than 255 characters (%d).\n", cmd); |
519 goto out; | 519 goto out; |
520 } | 520 } |
521 | 521 |
522 th_growbuf_put_u8(&buf, SOCKS5_ADDR_DOMAIN); | 522 th_growbuf_put_u8(&buf, SOCKS5_ADDR_DOMAIN); |
523 th_growbuf_put_u8(&buf, cmd); | 523 th_growbuf_put_u8(&buf, cmd); |
524 th_growbuf_put_str(&buf, conn->host, cmd); | 524 th_growbuf_put_str(&buf, host, cmd); |
525 break; | 525 break; |
526 } | 526 } |
527 | 527 |
528 th_growbuf_put_u16_be(&buf, port); | 528 th_growbuf_put_u16_be(&buf, port); |
529 | 529 |