mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-08 01:13:16 +00:00
use common send_query function
This commit is contained in:
parent
e8b2310fae
commit
25e51c666a
28
src/iodine.c
28
src/iodine.c
|
@ -75,24 +75,31 @@ sighandler(int sig)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
send_packet(int fd, char cmd, const char *data, const size_t datalen)
|
send_query(int fd, char *hostname)
|
||||||
{
|
{
|
||||||
char packet[4096];
|
char packet[4096];
|
||||||
struct query q;
|
struct query q;
|
||||||
char buf[4096];
|
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
q.id = ++chunkid;
|
q.id = ++chunkid;
|
||||||
q.type = T_NULL;
|
q.type = T_NULL;
|
||||||
|
|
||||||
buf[0] = cmd;
|
len = dns_encode(packet, sizeof(packet), &q, QR_QUERY, hostname, strlen(hostname));
|
||||||
|
|
||||||
len = build_hostname(buf + 1, sizeof(buf) - 1, data, datalen, topdomain, b32);
|
|
||||||
len = dns_encode(packet, sizeof(packet), &q, QR_QUERY, buf, strlen(buf));
|
|
||||||
|
|
||||||
sendto(fd, packet, len, 0, (struct sockaddr*)&peer, sizeof(peer));
|
sendto(fd, packet, len, 0, (struct sockaddr*)&peer, sizeof(peer));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
send_packet(int fd, char cmd, const char *data, const size_t datalen)
|
||||||
|
{
|
||||||
|
char buf[4096];
|
||||||
|
|
||||||
|
buf[0] = cmd;
|
||||||
|
|
||||||
|
build_hostname(buf + 1, sizeof(buf) - 1, data, datalen, topdomain, b32);
|
||||||
|
send_query(fd, buf);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
build_hostname(char *buf, size_t buflen,
|
build_hostname(char *buf, size_t buflen,
|
||||||
const char *data, const size_t datalen,
|
const char *data, const size_t datalen,
|
||||||
|
@ -265,16 +272,10 @@ static void
|
||||||
send_chunk(int fd)
|
send_chunk(int fd)
|
||||||
{
|
{
|
||||||
char hex[] = "0123456789ABCDEF";
|
char hex[] = "0123456789ABCDEF";
|
||||||
char data[4096];
|
|
||||||
struct query q;
|
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
int avail;
|
int avail;
|
||||||
int code;
|
int code;
|
||||||
char *p;
|
char *p;
|
||||||
int len;
|
|
||||||
|
|
||||||
q.id = ++chunkid;
|
|
||||||
q.type = T_NULL;
|
|
||||||
|
|
||||||
p = packet.data;
|
p = packet.data;
|
||||||
p += packet.offset;
|
p += packet.offset;
|
||||||
|
@ -289,9 +290,8 @@ send_chunk(int fd)
|
||||||
|
|
||||||
code |= (userid << 1);
|
code |= (userid << 1);
|
||||||
buf[0] = hex[code];
|
buf[0] = hex[code];
|
||||||
len = dns_encode(data, sizeof(data), &q, QR_QUERY, buf, strlen(buf));
|
|
||||||
|
|
||||||
sendto(fd, data, len, 0, (struct sockaddr*)&peer, sizeof(peer));
|
send_query(fd, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in a new issue