aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2010-05-10 22:44:06 +0200
committerAris Adamantiadis <aris@0xbadc0de.be>2010-05-10 22:44:06 +0200
commit74c9c1afa9db2ea9045196b39be0e2aeb847c0ee (patch)
treeb37a94472e83bdde3fd296cb4ae1fbd8ec89a71f /examples
parente159f04df899dcf18f376d19a3146b4ba890d35a (diff)
downloadlibssh-74c9c1afa9db2ea9045196b39be0e2aeb847c0ee.tar.gz
libssh-74c9c1afa9db2ea9045196b39be0e2aeb847c0ee.tar.xz
libssh-74c9c1afa9db2ea9045196b39be0e2aeb847c0ee.zip
Added code to test proxycommand
Conflicts: examples/sample.c
Diffstat (limited to 'examples')
-rw-r--r--examples/sample.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/examples/sample.c b/examples/sample.c
index 20abe31..b7f6074 100644
--- a/examples/sample.c
+++ b/examples/sample.c
@@ -42,6 +42,8 @@ struct termios terminal;
char *pcap_file=NULL;
+char *proxycommand;
+
static int auth_callback(const char *prompt, char *buf, size_t len,
int echo, int verify, void *userdata) {
char *answer = NULL;
@@ -92,6 +94,9 @@ static void usage(){
#ifdef WITH_PCAP
" -P file : create a pcap debugging file\n"
#endif
+#ifndef _WIN32
+ " -T proxycommand : command to execute as a socket proxy\n"
+#endif
,
ssh_version(0));
exit(0);
@@ -102,11 +107,16 @@ static int opts(int argc, char **argv){
// for(i=0;i<argc;i++)
// printf("%d : %s\n",i,argv[i]);
/* insert your own arguments here */
- while((i=getopt(argc,argv,"P:"))!=-1){
+ while((i=getopt(argc,argv,"T:P:"))!=-1){
switch(i){
case 'P':
pcap_file=optarg;
break;
+#ifndef _WIN32
+ case 'T':
+ proxycommand=optarg;
+ break;
+#endif
default:
fprintf(stderr,"unknown option %c\n",optopt);
usage();
@@ -438,7 +448,10 @@ static int client(ssh_session session){
return -1;
if (ssh_options_set(session, SSH_OPTIONS_HOST ,host) < 0)
return -1;
-
+ if (proxycommand != NULL){
+ if(ssh_options_set(session, SSH_OPTIONS_PROXYCOMMAND, proxycommand))
+ return -1;
+ }
ssh_options_parse_config(session, NULL);
if(ssh_connect(session)){