usleep to nanosleep

This commit is contained in:
ruti 2023-06-12 10:01:40 +02:00
parent 901548ba0e
commit 5c6d706cea
4 changed files with 10 additions and 4 deletions

View File

@ -1,6 +1,6 @@
TARGET = ciadpi
CC ?= gcc
CFLAGS += -std=c99 -O2
CFLAGS += -std=c99 -O2 -D_XOPEN_SOURCE=500
SOURCES = packets.c main.c conev.c proxy.c desync.c
all:

View File

@ -1,5 +1,8 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/tcp.h>
@ -57,7 +60,10 @@ int fake_attack(int sfd, char *buffer, ssize_t n, int cnt, int pos)
perror("sendfile");
break;
}
usleep(params.sfdelay);
struct timespec delay = {
.tv_nsec = params.sfdelay * 1000
};
nanosleep(&delay, 0);
memcpy(p, buffer, pos);
if (setsockopt(sfd, IPPROTO_IP, IP_TTL,

2
main.c
View File

@ -341,7 +341,7 @@ int main(int argc, char **argv)
case 'w': //
params.sfdelay = strtoul(optarg, &end, 0);
if (optarg == end || *end)
if (optarg == end || params.sfdelay > 1000000 || *end)
invalid = 1;
break;

View File

@ -47,4 +47,4 @@ extern struct packet fake_http;
#define LOG_L 2
#define LOG(s, str, ...) \
if (params.debug >= s) printf(str, ##__VA_ARGS__)
if (params.debug >= s) printf(str, ##__VA_ARGS__)