Changeset 835:2dd85f8453a7 in roaraudio for libroar/socket.c
- Timestamp:
- 09/27/08 02:32:53 (16 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libroar/socket.c
r834 r835 599 599 int i; 600 600 int fh = -1; 601 char * user = NULL, * pw = NULL, * opts = NULL; 602 static struct passwd * passwd; 601 603 int (* code)(int mode, int fh, char * host, int port, char * user, char * pw, char * opts) = NULL; 604 605 if ( passwd == NULL ) { 606 passwd = getpwuid(getuid()); 607 } 608 609 if ( passwd != NULL ) 610 user = passwd->pw_name; 611 612 if ( user == NULL ) 613 user = getenv("USER"); 602 614 603 615 // TODO: change this so we support listen() proxys (ssh -R) … … 652 664 653 665 if ( code != NULL ) { 654 if ( code(mode, fh, host, port, NULL, NULL, NULL) == -1 ) {666 if ( code(mode, fh, host, port, user, pw, opts) == -1 ) { 655 667 close(fh); 656 668 return -1; … … 699 711 int roar_socket_open_socks4x(int mode, int fh, char host[4], int port, char * app, size_t app_len, char * user) { 700 712 char buf[9]; 713 int len; 701 714 702 715 buf[0] = 0x04; … … 704 717 *((uint16_t*)&buf[2]) = htons(port); 705 718 memcpy(buf+4, host, 4); 706 buf[8] = 0x00; 707 708 if ( write(fh, buf, 9) != 9 ) 709 return -1; 719 720 if ( user == NULL ) { 721 buf[8] = 0x00; 722 len = 9; 723 } else { 724 len = 8; 725 } 726 727 if ( write(fh, buf, len) != len ) 728 return -1; 729 730 if ( user != NULL ) { 731 len = strlen(user) + 1; 732 if ( write(fh, user, len) != len ) 733 return -1; 734 } 710 735 711 736 if ( app_len > 0 )
Note: See TracChangeset
for help on using the changeset viewer.