mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-16 21:29:20 +02:00
Dont need plibc
This commit is contained in:
parent
de617fb026
commit
94f412a8d8
|
@ -41,7 +41,6 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "plibc.h"
|
|
||||||
|
|
||||||
/* daemon(3) exists only in 4.4BSD or later, and in GNU libc */
|
/* daemon(3) exists only in 4.4BSD or later, and in GNU libc */
|
||||||
#if !defined(WINDOWS32) && !(defined(BSD) && (BSD >= 199306)) && !defined(__GLIBC__)
|
#if !defined(WINDOWS32) && !(defined(BSD) && (BSD >= 199306)) && !defined(__GLIBC__)
|
||||||
|
@ -114,20 +113,20 @@ open_dns(int localport, in_addr_t listen_ip)
|
||||||
/* listen_ip already in network byte order from inet_addr, or 0 */
|
/* listen_ip already in network byte order from inet_addr, or 0 */
|
||||||
addr.sin_addr.s_addr = listen_ip;
|
addr.sin_addr.s_addr = listen_ip;
|
||||||
|
|
||||||
if ((fd = SOCKET(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
|
if ((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
|
||||||
printf("got fd %d\n", fd);
|
printf("got fd %d\n", fd);
|
||||||
err(1, "socket");
|
err(1, "socket");
|
||||||
}
|
}
|
||||||
|
|
||||||
flag = 1;
|
flag = 1;
|
||||||
#ifdef SO_REUSEPORT
|
#ifdef SO_REUSEPORT
|
||||||
SETSOCKOPT(fd, SOL_SOCKET, SO_REUSEPORT, (const void*) &flag, sizeof(flag));
|
setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, (const void*) &flag, sizeof(flag));
|
||||||
#endif
|
#endif
|
||||||
SETSOCKOPT(fd, SOL_SOCKET, SO_REUSEADDR, (const void*) &flag, sizeof(flag));
|
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (const void*) &flag, sizeof(flag));
|
||||||
|
|
||||||
#ifndef WINDOWS32
|
#ifndef WINDOWS32
|
||||||
/* To get destination address from each UDP datagram, see iodined.c:read_dns() */
|
/* To get destination address from each UDP datagram, see iodined.c:read_dns() */
|
||||||
SETSOCKOPT(fd, IPPROTO_IP, DSTADDR_SOCKOPT, (const void*) &flag, sizeof(flag));
|
setsockopt(fd, IPPROTO_IP, DSTADDR_SOCKOPT, (const void*) &flag, sizeof(flag));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(bind(fd, (struct sockaddr*)&addr, sizeof(addr)) < 0)
|
if(bind(fd, (struct sockaddr*)&addr, sizeof(addr)) < 0)
|
||||||
|
|
11
src/iodine.c
11
src/iodine.c
|
@ -43,7 +43,6 @@
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "plibc.h"
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "encoding.h"
|
#include "encoding.h"
|
||||||
#include "base32.h"
|
#include "base32.h"
|
||||||
|
@ -172,13 +171,13 @@ read_dns(int fd, char *buf, int buflen)
|
||||||
{
|
{
|
||||||
struct sockaddr_in from;
|
struct sockaddr_in from;
|
||||||
char data[64*1024];
|
char data[64*1024];
|
||||||
int addrlen;
|
socklen_t addrlen;
|
||||||
struct query q;
|
struct query q;
|
||||||
int rv;
|
int rv;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
addrlen = sizeof(struct sockaddr);
|
addrlen = sizeof(struct sockaddr);
|
||||||
if ((r = RECVFROM(fd, data, sizeof(data), 0,
|
if ((r = recvfrom(fd, data, sizeof(data), 0,
|
||||||
(struct sockaddr*)&from, &addrlen)) == -1) {
|
(struct sockaddr*)&from, &addrlen)) == -1) {
|
||||||
warn("recvfrom");
|
warn("recvfrom");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -315,7 +314,7 @@ tunnel(int tun_fd, int dns_fd)
|
||||||
}
|
}
|
||||||
FD_SET(dns_fd, &fds);
|
FD_SET(dns_fd, &fds);
|
||||||
|
|
||||||
i = SELECT(MAX(tun_fd, dns_fd) + 1, &fds, NULL, NULL, &tv);
|
i = select(MAX(tun_fd, dns_fd) + 1, &fds, NULL, NULL, &tv);
|
||||||
|
|
||||||
if (running == 0)
|
if (running == 0)
|
||||||
break;
|
break;
|
||||||
|
@ -907,10 +906,6 @@ main(int argc, char **argv)
|
||||||
b32 = get_base32_encoder();
|
b32 = get_base32_encoder();
|
||||||
dataenc = get_base32_encoder();
|
dataenc = get_base32_encoder();
|
||||||
|
|
||||||
#ifdef WINDOWS32
|
|
||||||
plibc_init("Kryo", "iodine");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(BSD) && !defined(__GLIBC__)
|
#if !defined(BSD) && !defined(__GLIBC__)
|
||||||
__progname = strrchr(argv[0], '/');
|
__progname = strrchr(argv[0], '/');
|
||||||
if (__progname == NULL)
|
if (__progname == NULL)
|
||||||
|
|
|
@ -48,7 +48,6 @@
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "plibc.h"
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "dns.h"
|
#include "dns.h"
|
||||||
#include "encoding.h"
|
#include "encoding.h"
|
||||||
|
@ -780,7 +779,7 @@ static int
|
||||||
read_dns(int fd, struct query *q)
|
read_dns(int fd, struct query *q)
|
||||||
{
|
{
|
||||||
struct sockaddr_in from;
|
struct sockaddr_in from;
|
||||||
int addrlen;
|
socklen_t addrlen;
|
||||||
char packet[64*1024];
|
char packet[64*1024];
|
||||||
int r;
|
int r;
|
||||||
#ifndef WINDOWS32
|
#ifndef WINDOWS32
|
||||||
|
@ -804,7 +803,7 @@ read_dns(int fd, struct query *q)
|
||||||
r = recvmsg(fd, &msg, 0);
|
r = recvmsg(fd, &msg, 0);
|
||||||
#else
|
#else
|
||||||
addrlen = sizeof(struct sockaddr);
|
addrlen = sizeof(struct sockaddr);
|
||||||
r = RECVFROM(fd, packet, sizeof(packet), 0, (struct sockaddr*)&from, &addrlen);
|
r = recvfrom(fd, packet, sizeof(packet), 0, (struct sockaddr*)&from, &addrlen);
|
||||||
#endif /* !WINDOWS32 */
|
#endif /* !WINDOWS32 */
|
||||||
|
|
||||||
if (r > 0) {
|
if (r > 0) {
|
||||||
|
|
|
@ -14,13 +14,13 @@ link)
|
||||||
echo '-lnetwork';
|
echo '-lnetwork';
|
||||||
;;
|
;;
|
||||||
windows32)
|
windows32)
|
||||||
echo '-lplibc -lws2_32';
|
echo '-lws2_32';
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
cflags)
|
cflags)
|
||||||
case $1 in
|
case $1 in
|
||||||
BeOS)
|
BeOS | windows32)
|
||||||
echo '-Dsocklen_t=int';
|
echo '-Dsocklen_t=int';
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
15
src/tun.c
15
src/tun.c
|
@ -50,7 +50,6 @@ struct tun_data data;
|
||||||
char if_name[50];
|
char if_name[50];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "plibc.h"
|
|
||||||
#include "tun.h"
|
#include "tun.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
@ -354,11 +353,10 @@ write_tun(int tun_fd, char *data, size_t len)
|
||||||
ssize_t
|
ssize_t
|
||||||
read_tun(int tun_fd, char *buf, size_t len)
|
read_tun(int tun_fd, char *buf, size_t len)
|
||||||
{
|
{
|
||||||
#ifndef WINDOWS32
|
#if defined (FREEBSD) || defined (DARWIN) || defined(NETBSD) || defined(WINDOWS32)
|
||||||
#if defined (FREEBSD) || defined (DARWIN) || defined(NETBSD)
|
|
||||||
/* FreeBSD/Darwin/NetBSD has no header */
|
/* FreeBSD/Darwin/NetBSD has no header */
|
||||||
int bytes;
|
int bytes;
|
||||||
bytes = read(tun_fd, buf + 4, len - 4);
|
bytes = recv(tun_fd, buf + 4, len, 0);
|
||||||
if (bytes < 0) {
|
if (bytes < 0) {
|
||||||
return bytes;
|
return bytes;
|
||||||
} else {
|
} else {
|
||||||
|
@ -367,15 +365,6 @@ read_tun(int tun_fd, char *buf, size_t len)
|
||||||
#else /* !FREEBSD */
|
#else /* !FREEBSD */
|
||||||
return read(tun_fd, buf, len);
|
return read(tun_fd, buf, len);
|
||||||
#endif /* !FREEBSD */
|
#endif /* !FREEBSD */
|
||||||
#else /* !WINDOWS32 */
|
|
||||||
int bytes;
|
|
||||||
bytes = RECV(tun_fd, buf + 4, len, 0);
|
|
||||||
if (bytes < 0) {
|
|
||||||
return bytes;
|
|
||||||
} else {
|
|
||||||
return bytes + 4;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Loading…
Reference in New Issue