Changeset 840:b45e02ef8f29 in roaraudio for libroar/socket.c


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

added support for socat and for unix domain sockets via socat

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroar/socket.c

    r839 r840  
    812812 char   cmd[1024] = {0}, rcmd[1024] = {0}; 
    813813 int    proxy_port = 22; 
     814 int    use_socat = 0; 
    814815 int r; 
    815816 int socks[2]; 
     
    819820 
    820821 if ( *host == '/' ) 
    821   return -1; 
     822  use_socat = 1; 
    822823 
    823824 if ( mode == MODE_LISTEN ) 
     
    826827 if ( proxy_addr == NULL ) 
    827828  return -1; 
     829 
     830 if ( opts != NULL ) { 
     831  if ( !strcmp(opts, "socat") ) { 
     832   use_socat = 1; 
     833  } else if ( !strcmp(opts, "netcat") ) { 
     834   use_socat = 0; 
     835  } else { 
     836   return -1; 
     837  } 
     838 } 
    828839 
    829840 if ( (sep = strstr(proxy_addr, "@")) != NULL ) 
     
    839850  strcpy(rcmd, "roard --no-listen --client-fh 0"); 
    840851 } else { 
    841   snprintf(rcmd, 1023, "$(which netcat nc 2> /dev/null | grep -v \" \" | head -n 1) \"%s\" %i", host, port); 
     852  if ( use_socat ) { 
     853   if ( *host == '/' ) { 
     854    snprintf(rcmd, 1023, "socat stdio unix-connect:\"%s\"", host); 
     855   } else { 
     856    snprintf(rcmd, 1023, "socat stdio tcp:\"%s\":%i", host, port); 
     857   } 
     858  } else { 
     859   snprintf(rcmd, 1023, "$(which netcat nc 2> /dev/null | grep -v \" \" | head -n 1) \"%s\" %i", host, port); 
     860  } 
     861 
    842862  rcmd[1023] = 0; 
    843863 } 
Note: See TracChangeset for help on using the changeset viewer.