This commit is contained in:
aixiao 2024-05-13 17:46:18 +08:00
parent c2c96465f1
commit ff67d2568b
2 changed files with 25 additions and 4 deletions

View File

@ -52,6 +52,12 @@ void *forward_tunnel(void *sock_)
return NULL;
}
int optval = SO_REUSEADDR;
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)) < 0) {
perror("setsockopt");
return NULL;
}
memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = inet_addr(server_ssh_ip);
@ -283,8 +289,6 @@ int modif_argv(int argc, char *argv[])
int get_threads()
{
pid_t pid;
char line[256];
char path[256];
@ -379,6 +383,12 @@ int main(int argc, char *argv[], char **env)
return -1;
}
int optval = SO_REUSEADDR;
if (setsockopt(listensock, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)) < 0) {
perror("setsockopt");
return -1;
}
sin.sin_family = AF_INET;
sin.sin_port = htons(local_listenport);
sin.sin_addr.s_addr = inet_addr(local_listenip);
@ -415,7 +425,6 @@ int main(int argc, char *argv[], char **env)
return -1;
}
}
// 进程优先级
if (-1 == (nice_(-20)))
perror("nice_");

View File

@ -19,11 +19,23 @@
#include <sys/resource.h>
#include <sys/poll.h>
#define MAX_EVENTS 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/epoll.h>
#include <libssh2.h>
#define BUILD(fmt...) do { fprintf(stderr,"%s %s ",__DATE__,__TIME__); fprintf(stderr, ##fmt); } while(0)
#ifndef INADDR_NONE
#define INADDR_NONE (in_addr_t)-1
#endif
#endif