mirror of
https://github.com/hufrea/byedpi.git
synced 2024-11-24 07:45:32 +03:00
fix headers, sa_size macros, replace getopt_long_only
This commit is contained in:
parent
99e2d9b648
commit
d61756dd95
12 changed files with 21 additions and 25 deletions
2
Makefile
2
Makefile
|
@ -1,6 +1,6 @@
|
|||
TARGET = ciadpi
|
||||
|
||||
CPPFLAGS = -D_XOPEN_SOURCE=500
|
||||
#CPPFLAGS = -D_XOPEN_SOURCE=500
|
||||
CFLAGS += -I. -std=c99 -Wall -Wno-unused -O2
|
||||
WIN_LDFLAGS = -lws2_32 -lmswsock
|
||||
|
||||
|
|
1
conev.c
1
conev.c
|
@ -1,4 +1,3 @@
|
|||
|
||||
#include "conev.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
|
1
extend.c
1
extend.c
|
@ -1,4 +1,3 @@
|
|||
|
||||
#include "extend.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
|
1
extend.h
1
extend.h
|
@ -3,7 +3,6 @@
|
|||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "conev.h"
|
||||
#include "proxy.h"
|
||||
|
||||
int connect_hook(struct poolhd *pool, struct eval *val,
|
||||
|
|
5
main.c
5
main.c
|
@ -16,8 +16,9 @@
|
|||
#include <unistd.h>
|
||||
#include <netdb.h>
|
||||
#include <fcntl.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/socket.h>
|
||||
#else
|
||||
#include <ws2tcpip.h>
|
||||
#include "win_service.h"
|
||||
|
@ -441,7 +442,7 @@ int main(int argc, char **argv)
|
|||
return -1;
|
||||
}
|
||||
|
||||
while (!invalid && (rez = getopt_long_only(
|
||||
while (!invalid && (rez = getopt_long(
|
||||
argc, argv, opt, options, 0)) != -1) {
|
||||
switch (rez) {
|
||||
|
||||
|
|
2
mpool.c
2
mpool.c
|
@ -1,11 +1,9 @@
|
|||
|
||||
#include "mpool.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
|
||||
static inline int scmp(const struct elem *p, const struct elem *q)
|
||||
{
|
||||
if (p->len != q ->len) {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#define _GNU_SOURCE
|
||||
|
||||
#include "packets.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
@ -8,6 +6,7 @@
|
|||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
|
|
3
params.h
3
params.h
|
@ -10,6 +10,9 @@
|
|||
#include <ws2tcpip.h>
|
||||
#else
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) || defined(_WIN32)
|
||||
|
|
16
proxy.c
16
proxy.c
|
@ -346,7 +346,7 @@ int create_conn(struct poolhd *pool,
|
|||
}
|
||||
}
|
||||
if (bind(sfd, (struct sockaddr *)¶ms.baddr,
|
||||
sizeof(params.baddr)) < 0) {
|
||||
SA_SIZE(¶ms.baddr)) < 0) {
|
||||
uniperror("bind");
|
||||
close(sfd);
|
||||
return -1;
|
||||
|
@ -376,7 +376,7 @@ int create_conn(struct poolhd *pool,
|
|||
close(sfd);
|
||||
return -1;
|
||||
}
|
||||
int status = connect(sfd, &addr.sa, sizeof(addr));
|
||||
int status = connect(sfd, &addr.sa, SA_SIZE(&addr));
|
||||
if (status == 0 && params.tfo) {
|
||||
LOG(LOG_S, "TFO supported!\n");
|
||||
}
|
||||
|
@ -432,7 +432,7 @@ int udp_associate(struct poolhd *pool,
|
|||
map_fix(&addr, 6);
|
||||
}
|
||||
if (bind(ufd, (struct sockaddr *)¶ms.baddr,
|
||||
sizeof(params.baddr)) < 0) {
|
||||
SA_SIZE(¶ms.baddr)) < 0) {
|
||||
uniperror("bind");
|
||||
close(ufd);
|
||||
return -1;
|
||||
|
@ -443,7 +443,7 @@ int udp_associate(struct poolhd *pool,
|
|||
return -1;
|
||||
}
|
||||
if (dst->in6.sin6_port != 0) {
|
||||
if (connect(ufd, &addr.sa, sizeof(addr)) < 0) {
|
||||
if (connect(ufd, &addr.sa, SA_SIZE(&addr)) < 0) {
|
||||
uniperror("connect");
|
||||
del_event(pool, pair);
|
||||
return -1;
|
||||
|
@ -465,7 +465,7 @@ int udp_associate(struct poolhd *pool,
|
|||
del_event(pool, pair);
|
||||
return -1;
|
||||
}
|
||||
if (bind(cfd, &addr.sa, sizeof(addr)) < 0) {
|
||||
if (bind(cfd, &addr.sa, SA_SIZE(&addr)) < 0) {
|
||||
uniperror("bind");
|
||||
del_event(pool, pair);
|
||||
close(cfd);
|
||||
|
@ -670,7 +670,7 @@ int on_udp_tunnel(struct eval *val, char *buffer, size_t bfsize)
|
|||
if (!addr_equ(&addr, (struct sockaddr_ina *)&val->in6)) {
|
||||
return 0;
|
||||
}
|
||||
if (connect(val->fd, &addr.sa, sizeof(addr)) < 0) {
|
||||
if (connect(val->fd, &addr.sa, SA_SIZE(&addr)) < 0) {
|
||||
uniperror("connect");
|
||||
return -1;
|
||||
}
|
||||
|
@ -691,7 +691,7 @@ int on_udp_tunnel(struct eval *val, char *buffer, size_t bfsize)
|
|||
if (params.baddr.sin6_family != addr.sa.sa_family) {
|
||||
return -1;
|
||||
}
|
||||
if (connect(val->pair->fd, &addr.sa, sizeof(addr)) < 0) {
|
||||
if (connect(val->pair->fd, &addr.sa, SA_SIZE(&addr)) < 0) {
|
||||
uniperror("connect");
|
||||
return -1;
|
||||
}
|
||||
|
@ -940,7 +940,7 @@ int listen_socket(struct sockaddr_ina *srv)
|
|||
close(srvfd);
|
||||
return -1;
|
||||
}
|
||||
if (bind(srvfd, &srv->sa, sizeof(*srv)) < 0) {
|
||||
if (bind(srvfd, &srv->sa, SA_SIZE(srv)) < 0) {
|
||||
uniperror("bind");
|
||||
close(srvfd);
|
||||
return -1;
|
||||
|
|
5
proxy.h
5
proxy.h
|
@ -7,10 +7,15 @@
|
|||
#include <ws2tcpip.h>
|
||||
#else
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
#include "conev.h"
|
||||
|
||||
#define SA_SIZE(s) \
|
||||
(((struct sockaddr *)s)->sa_family == AF_INET6) ? \
|
||||
sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in)
|
||||
|
||||
struct sockaddr_ina {
|
||||
union {
|
||||
struct sockaddr sa;
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
#include "win_service.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
|
|
@ -1,7 +1 @@
|
|||
#ifndef WIN_SERVICE_H
|
||||
#define WIN_SERVICE_H
|
||||
|
||||
int register_winsvc(int argc, char *argv[]);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue