Changeset 833:7c11ae15df0d in roaraudio for libroar/socket.c


Ignore:
Timestamp:
09/27/08 01:21:03 (16 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

done a lot cleanup in proxy code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroar/socket.c

    r832 r833  
    599599 int    i; 
    600600 int    fh = -1; 
     601 int (* code)(int mode, int fh, char * host, int port) = NULL; 
    601602 
    602603 // TODO: change this so we support listen() proxys (ssh -R) 
     
    639640 
    640641 if ( !strcmp(proxy_type, "socks4a") ) { // for TOR, the only supported type at the moment 
    641   if ( roar_socket_open_socks4a(mode, fh, host, port) == -1 ) { 
    642    close(fh); 
    643    return -1; 
    644   } 
    645  
    646   return fh; 
     642  code = roar_socket_open_socks4a; 
    647643 } else if ( !strcmp(proxy_type, "socks4d") ) { // DECnet 
    648   if ( roar_socket_open_socks4d(mode, fh, host, port) == -1 ) { 
    649    close(fh); 
    650    return -1; 
    651   } 
    652  
    653   return fh; 
     644  code = roar_socket_open_socks4d; 
    654645 } else if ( !strcmp(proxy_type, "socks4") ) { // good old SOCKS4 
    655   if ( roar_socket_open_socks4(mode, fh, host, port) == -1 ) { 
    656    close(fh); 
    657    return -1; 
    658   } 
    659  
    660   return fh; 
     646  code = roar_socket_open_socks4; 
    661647 } else if ( !strcmp(proxy_type, "http") ) { // HTTP CONNECT 
    662   if ( roar_socket_open_http(mode, fh, host, port) == -1 ) { 
    663    close(fh); 
    664    return -1; 
    665   } 
    666  
    667   return fh; 
     648  code = roar_socket_open_http; 
    668649 } else { 
    669650  return -1; // unknown type 
    670651 } 
     652 
     653 if ( code != NULL ) { 
     654  if ( code(mode, fh, host, port) == -1 ) { 
     655   close(fh); 
     656   return -1; 
     657  } 
     658 
     659  return fh; 
     660 } 
     661 
     662 close(fh); 
     663 return -1; 
    671664} 
    672665 
Note: See TracChangeset for help on using the changeset viewer.