mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-07-29 13:01:13 +03:00
Added code to test proxycommand
Conflicts: examples/sample.c
This commit is contained in:
@ -42,6 +42,8 @@ struct termios terminal;
|
|||||||
|
|
||||||
char *pcap_file=NULL;
|
char *pcap_file=NULL;
|
||||||
|
|
||||||
|
char *proxycommand;
|
||||||
|
|
||||||
static int auth_callback(const char *prompt, char *buf, size_t len,
|
static int auth_callback(const char *prompt, char *buf, size_t len,
|
||||||
int echo, int verify, void *userdata) {
|
int echo, int verify, void *userdata) {
|
||||||
char *answer = NULL;
|
char *answer = NULL;
|
||||||
@ -91,6 +93,9 @@ static void usage(){
|
|||||||
" -r : use RSA to verify host public key\n"
|
" -r : use RSA to verify host public key\n"
|
||||||
#ifdef WITH_PCAP
|
#ifdef WITH_PCAP
|
||||||
" -P file : create a pcap debugging file\n"
|
" -P file : create a pcap debugging file\n"
|
||||||
|
#endif
|
||||||
|
#ifndef _WIN32
|
||||||
|
" -T proxycommand : command to execute as a socket proxy\n"
|
||||||
#endif
|
#endif
|
||||||
,
|
,
|
||||||
ssh_version(0));
|
ssh_version(0));
|
||||||
@ -102,11 +107,16 @@ static int opts(int argc, char **argv){
|
|||||||
// for(i=0;i<argc;i++)
|
// for(i=0;i<argc;i++)
|
||||||
// printf("%d : %s\n",i,argv[i]);
|
// printf("%d : %s\n",i,argv[i]);
|
||||||
/* insert your own arguments here */
|
/* insert your own arguments here */
|
||||||
while((i=getopt(argc,argv,"P:"))!=-1){
|
while((i=getopt(argc,argv,"T:P:"))!=-1){
|
||||||
switch(i){
|
switch(i){
|
||||||
case 'P':
|
case 'P':
|
||||||
pcap_file=optarg;
|
pcap_file=optarg;
|
||||||
break;
|
break;
|
||||||
|
#ifndef _WIN32
|
||||||
|
case 'T':
|
||||||
|
proxycommand=optarg;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,"unknown option %c\n",optopt);
|
fprintf(stderr,"unknown option %c\n",optopt);
|
||||||
usage();
|
usage();
|
||||||
@ -438,7 +448,10 @@ static int client(ssh_session session){
|
|||||||
return -1;
|
return -1;
|
||||||
if (ssh_options_set(session, SSH_OPTIONS_HOST ,host) < 0)
|
if (ssh_options_set(session, SSH_OPTIONS_HOST ,host) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
if (proxycommand != NULL){
|
||||||
|
if(ssh_options_set(session, SSH_OPTIONS_PROXYCOMMAND, proxycommand))
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
ssh_options_parse_config(session, NULL);
|
ssh_options_parse_config(session, NULL);
|
||||||
|
|
||||||
if(ssh_connect(session)){
|
if(ssh_connect(session)){
|
||||||
|
Reference in New Issue
Block a user