支持自定义远程主机IP地址 -s 127.0.0.1:80 或者 -s 80 这时默认 -s 0.0.0.0:80
This commit is contained in:
parent
b8f20c3a09
commit
32b7b5bda0
BIN
forward-tunnel
BIN
forward-tunnel
Binary file not shown.
@ -12,7 +12,7 @@ char *server_ssh_passwd = "123456";
|
||||
const char *local_listenip = "0.0.0.0";
|
||||
unsigned int local_listenport = 3009;
|
||||
|
||||
const char *remote_desthost = "0.0.0.0"; /* resolved by the server */
|
||||
char *remote_desthost = "0.0.0.0"; /* resolved by the server */
|
||||
unsigned int remote_destport = 3306;
|
||||
|
||||
enum {
|
||||
@ -279,6 +279,7 @@ int main(int argc, char *argv[], char **env)
|
||||
int listensock = -1, forwardsock = -1;
|
||||
int daemon_ = 0;
|
||||
int opt;
|
||||
char *p = NULL;
|
||||
|
||||
|
||||
char optstring[] = ":dr:s:p:l:u:e:h?";
|
||||
@ -291,7 +292,24 @@ int main(int argc, char *argv[], char **env)
|
||||
server_ssh_ip = strdup(optarg);
|
||||
break;
|
||||
case 's':
|
||||
p = strchr(optarg, ':');
|
||||
if (p != NULL) {
|
||||
remote_destport = atoi(p + 1);
|
||||
|
||||
*p = '\0';
|
||||
remote_desthost = optarg;
|
||||
|
||||
} else {
|
||||
if (NULL == (p = strchr(optarg, '.')))
|
||||
{
|
||||
remote_destport =atoi(optarg);
|
||||
remote_desthost = "0.0.0.0";
|
||||
} else {
|
||||
help_info();
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case 'p':
|
||||
server_ssh_port = atoi(optarg);
|
||||
@ -315,6 +333,19 @@ int main(int argc, char *argv[], char **env)
|
||||
}
|
||||
}
|
||||
|
||||
int i, j;
|
||||
for (i = 1; i < argc; i++) {
|
||||
|
||||
if (0 == strcmp(argv[i], "-e") || 0 == strcmp(argv[i], "-u") || 0 == strcmp(argv[i], "-p"))
|
||||
{
|
||||
for (j = strlen(argv[i+1]) - 1; j >= 0; j--) {
|
||||
argv[i+1][j] = 'x';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
printf("SSH Server: %s:%d, Local listen: %s:%d, User&Passwd: [%s]['%s']\n", server_ssh_ip, remote_destport, local_listenip, local_listenport, server_ssh_user, server_ssh_passwd);
|
||||
|
||||
|
BIN
forward-tunnel.o
BIN
forward-tunnel.o
Binary file not shown.
BIN
reverse-tunnel
BIN
reverse-tunnel
Binary file not shown.
BIN
reverse-tunnel.o
BIN
reverse-tunnel.o
Binary file not shown.
Loading…
Reference in New Issue
Block a user