Changeset e1cfc6b69e75c5f3ac564bf116e68bac9735db77
- Timestamp:
- 18/08/07 19:55:51
(1 year ago)
- Author:
- Rémi Denis-Courmont <rem@videolan.org>
- git-committer:
- Rémi Denis-Courmont <rem@videolan.org> 1187459751 +0000
- git-parent:
[c92a74565af6e57bbd6c29d00702ac04bdf3a5aa]
- git-author:
- Rémi Denis-Courmont <rem@videolan.org> 1187459751 +0000
- Message:
Make sure SOCKS is only attempted with TCP
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rc4c6895 |
re1cfc6b |
|
| 85 | 85 | hints.ai_socktype = SOCK_STREAM; |
|---|
| 86 | 86 | |
|---|
| 87 | | psz_socks = var_CreateGetString( p_this, "socks" ); |
|---|
| 88 | | if( *psz_socks && *psz_socks != ':' ) |
|---|
| | 87 | psz_socks = var_CreateGetNonEmptyString( p_this, "socks" ); |
|---|
| | 88 | if( psz_socks != NULL ) |
|---|
| 89 | 89 | { |
|---|
| 90 | 90 | char *psz = strchr( psz_socks, ':' ); |
|---|
| … | … | |
| 96 | 96 | i_realport = ( psz != NULL ) ? atoi( psz ) : 1080; |
|---|
| 97 | 97 | |
|---|
| 98 | | msg_Dbg( p_this, "net: connecting to %s port %d for %s port %d", |
|---|
| | 98 | msg_Dbg( p_this, "net: connecting to %s port %d (SOCKS) for %s port %d", |
|---|
| 99 | 99 | psz_realhost, i_realport, psz_host, i_port ); |
|---|
| | 100 | |
|---|
| | 101 | /* We only implement TCP with SOCKS */ |
|---|
| | 102 | switch( type ) |
|---|
| | 103 | { |
|---|
| | 104 | case 0: |
|---|
| | 105 | type = SOCK_STREAM; |
|---|
| | 106 | case SOCK_STREAM: |
|---|
| | 107 | break; |
|---|
| | 108 | default: |
|---|
| | 109 | msg_Err( p_this, "Socket type not supported through SOCKS" ); |
|---|
| | 110 | free( psz_socks ); |
|---|
| | 111 | return -1; |
|---|
| | 112 | } |
|---|
| | 113 | switch( proto ) |
|---|
| | 114 | { |
|---|
| | 115 | case 0: |
|---|
| | 116 | proto = IPPROTO_TCP; |
|---|
| | 117 | case IPPROTO_TCP: |
|---|
| | 118 | break; |
|---|
| | 119 | default: |
|---|
| | 120 | msg_Err( p_this, "Transport not supported through SOCKS" ); |
|---|
| | 121 | free( psz_socks ); |
|---|
| | 122 | return -1; |
|---|
| | 123 | } |
|---|
| 100 | 124 | } |
|---|
| 101 | 125 | else |
|---|
| … | … | |
| 109 | 133 | |
|---|
| 110 | 134 | i_val = vlc_getaddrinfo( p_this, psz_realhost, i_realport, &hints, &res ); |
|---|
| | 135 | free( psz_socks ); |
|---|
| | 136 | |
|---|
| 111 | 137 | if( i_val ) |
|---|
| 112 | 138 | { |
|---|
| 113 | 139 | msg_Err( p_this, "cannot resolve %s port %d : %s", psz_realhost, |
|---|
| 114 | 140 | i_realport, vlc_gai_strerror( i_val ) ); |
|---|
| 115 | | free( psz_socks ); |
|---|
| 116 | 141 | return -1; |
|---|
| 117 | 142 | } |
|---|
| … | … | |
| 170 | 195 | net_Close( fd ); |
|---|
| 171 | 196 | vlc_freeaddrinfo( res ); |
|---|
| 172 | | free( psz_socks ); |
|---|
| 173 | 197 | return -1; |
|---|
| 174 | 198 | } |
|---|
| … | … | |
| 231 | 255 | msg_Err( p_this, "Connection to %s port %d failed: %s", psz_host, |
|---|
| 232 | 256 | i_port, net_strerror( i_saved_errno ) ); |
|---|
| 233 | | free( psz_socks ); |
|---|
| 234 | 257 | return -1; |
|---|
| 235 | 258 | } |
|---|
| 236 | 259 | |
|---|
| 237 | | if( *psz_socks && *psz_socks != ':' ) |
|---|
| 238 | | { |
|---|
| | 260 | if( psz_socks != NULL ) |
|---|
| | 261 | { |
|---|
| | 262 | /* NOTE: psz_socks already free'd! */ |
|---|
| 239 | 263 | char *psz_user = var_CreateGetString( p_this, "socks-user" ); |
|---|
| 240 | 264 | char *psz_pwd = var_CreateGetString( p_this, "socks-pwd" ); |
|---|
| … | … | |
| 251 | 275 | free( psz_pwd ); |
|---|
| 252 | 276 | } |
|---|
| 253 | | free( psz_socks ); |
|---|
| 254 | 277 | |
|---|
| 255 | 278 | return i_handle; |
|---|