Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/dns_server_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,17 +257,17 @@ static int get_tcp_listen_sock(struct addrinfo *listen_addrinfo) {
}

if (listen(sock, LISTEN_BACKLOG) == -1) {
FLOG("Error listaning on %s:%d TCP: %s (%d)", ipstr, port,
FLOG("Error listening on %s:%d TCP: %s (%d)", ipstr, port,
strerror(errno), errno);
}

int flags = fcntl(sock, F_GETFL, 0);
if (flags == -1) {
FLOG("Error getting TCP socket flags: %s (%d)", ipstr, port,
FLOG("Error getting TCP socket flags on %s:%d: %s (%d)", ipstr, port,
strerror(errno), errno);
}
if (fcntl(sock, F_SETFL, flags | O_NONBLOCK) == -1) {
FLOG("Error setting TCP socket to non-blocking: %s (%d)", ipstr, port,
FLOG("Error setting TCP socket to non-blocking on %s:%d: %s (%d)", ipstr, port,
strerror(errno), errno);
}

Expand Down Expand Up @@ -344,6 +344,7 @@ void dns_server_tcp_respond(dns_server_tcp_t *d,
remove_client(client);
return;
}
continue;
}
sent += len;

Expand Down
2 changes: 1 addition & 1 deletion src/https_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ static void https_client_multi_init(https_client_t *c, struct curl_slist *header
c->curlm = curl_multi_init(); // if fails, first setopt will fail
c->header_list = header_list;

ASSERT_CURL_MULTI_SETOPT(c->curlm, CURLMOPT_PIPELINING, CURLPIPE_HTTP1 | CURLPIPE_MULTIPLEX);
ASSERT_CURL_MULTI_SETOPT(c->curlm, CURLMOPT_PIPELINING, CURLPIPE_MULTIPLEX);
ASSERT_CURL_MULTI_SETOPT(c->curlm, CURLMOPT_MAX_TOTAL_CONNECTIONS, HTTPS_CONNECTION_LIMIT);
ASSERT_CURL_MULTI_SETOPT(c->curlm, CURLMOPT_MAX_HOST_CONNECTIONS, HTTPS_CONNECTION_LIMIT);
ASSERT_CURL_MULTI_SETOPT(c->curlm, CURLMOPT_SOCKETDATA, c);
Expand Down
20 changes: 11 additions & 9 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,15 @@ static int hostname_from_url(const char* url_in,
if (rc == CURLUE_OK) {
char *host = NULL;
rc = curl_url_get(url, CURLUPART_HOST, &host, 0);
const size_t host_len = strlen(host);
if (rc == CURLUE_OK && host_len < hostname_len &&
host[0] != '[' && host[host_len-1] != ']' && // skip IPv6 address
!is_ipv4_address(host)) {
strncpy(hostname, host, hostname_len-1);
hostname[hostname_len-1] = '\0';
res = 1; // success
if (rc == CURLUE_OK && host != NULL) {
const size_t host_len = strlen(host);
if (host_len < hostname_len &&
host[0] != '[' && host[host_len-1] != ']' && // skip IPv6 address
!is_ipv4_address(host)) {
strncpy(hostname, host, hostname_len-1);
hostname[hostname_len-1] = '\0';
res = 1; // success
}
}
curl_free(host);
}
Expand All @@ -88,10 +90,10 @@ static void sigpipe_cb(struct ev_loop __attribute__((__unused__)) *loop,

static void https_resp_cb(void *data, char *buf, size_t buflen) {
request_t *req = (request_t *)data;
DLOG("Received response for id: %hX, len: %zu", req->tx_id, buflen);
if (req == NULL) {
FLOG("%04hX: data NULL", req->tx_id);
FLOG("data NULL, buflen: %zu", buflen);
}
DLOG("Received response for id: %hX, len: %zu", req->tx_id, buflen);
if (buf != NULL) { // May be NULL for timeout, DNS failure, or something similar.
if (buflen < DNS_HEADER_LENGTH) {
WLOG("%04hX: Malformed response received, too short: %u", req->tx_id, buflen);
Expand Down