This commit is contained in:
ruti 2024-08-22 17:53:17 +03:00
parent bd2eb4e4e1
commit 7700791053
2 changed files with 10 additions and 13 deletions

View File

@ -150,7 +150,7 @@ ssize_t send_fake(int sfd, char *buffer,
{ {
struct sockaddr_in6 addr = {}; struct sockaddr_in6 addr = {};
socklen_t addr_size = sizeof(addr); socklen_t addr_size = sizeof(addr);
#ifdef __linux__ #ifdef __linux__
if (opt->md5sig) { if (opt->md5sig) {
if (getpeername(sfd, if (getpeername(sfd,
(struct sockaddr *)&addr, &addr_size) < 0) { (struct sockaddr *)&addr, &addr_size) < 0) {
@ -158,7 +158,7 @@ ssize_t send_fake(int sfd, char *buffer,
return -1; return -1;
} }
} }
#endif #endif
struct packet pkt; struct packet pkt;
if (opt->fake_data.data) { if (opt->fake_data.data) {
pkt = opt->fake_data; pkt = opt->fake_data;
@ -174,13 +174,11 @@ ssize_t send_fake(int sfd, char *buffer,
else pkt.size = 0; else pkt.size = 0;
} }
#ifdef __linux__
int ffd = memfd_create("name", 0); int ffd = memfd_create("name", 0);
if (ffd < 0) { if (ffd < 0) {
uniperror("memfd_create"); uniperror("memfd_create");
return -1; return -1;
} }
#endif
char *p = 0; char *p = 0;
ssize_t len = -1; ssize_t len = -1;
@ -201,7 +199,7 @@ ssize_t send_fake(int sfd, char *buffer,
break; break;
} }
#ifdef __linux__ #ifdef __linux__
if (opt->md5sig) { if (opt->md5sig) {
struct tcp_md5sig md5 = { struct tcp_md5sig md5 = {
.tcpm_keylen = 5 .tcpm_keylen = 5
@ -214,20 +212,19 @@ ssize_t send_fake(int sfd, char *buffer,
break; break;
} }
} }
#endif #endif
if (opt->ip_options && fa == AF_INET if (opt->ip_options && fa == AF_INET
&& setsockopt(sfd, IPPROTO_IP, IP_OPTIONS, && setsockopt(sfd, IPPROTO_IP, IP_OPTIONS,
opt->ip_options, opt->ip_options_len) < 0) { opt->ip_options, opt->ip_options_len) < 0) {
uniperror("setsockopt IP_OPTIONS"); uniperror("setsockopt IP_OPTIONS");
break; break;
} }
#ifdef __linux__
len = sendfile(sfd, ffd, 0, pos); len = sendfile(sfd, ffd, 0, pos);
if (len < 0) { if (len < 0) {
uniperror("sendfile"); uniperror("sendfile");
break; break;
} }
#endif
wait_send(sfd); wait_send(sfd);
memcpy(p, buffer, pos); memcpy(p, buffer, pos);
@ -240,7 +237,7 @@ ssize_t send_fake(int sfd, char *buffer,
uniperror("setsockopt IP_OPTIONS"); uniperror("setsockopt IP_OPTIONS");
break; break;
} }
#ifdef __linux__ #ifdef __linux__
if (opt->md5sig) { if (opt->md5sig) {
struct tcp_md5sig md5 = { struct tcp_md5sig md5 = {
.tcpm_keylen = 0 .tcpm_keylen = 0
@ -253,7 +250,7 @@ ssize_t send_fake(int sfd, char *buffer,
break; break;
} }
} }
#endif #endif
break; break;
} }
if (p) munmap(p, pos); if (p) munmap(p, pos);

View File

@ -395,11 +395,11 @@ int create_conn(struct poolhd *pool,
} }
val->pair = pair; val->pair = pair;
pair->pair = val; pair->pair = val;
#ifdef __NetBSD__ #ifdef __NetBSD__
pair->in6 = addr.in6; pair->in6 = addr.in6;
#else #else
pair->in6 = dst->in6; pair->in6 = dst->in6;
#endif #endif
pair->flag = FLAG_CONN; pair->flag = FLAG_CONN;
val->type = EV_IGNORE; val->type = EV_IGNORE;