Skip to content

Commit 8e20fea

Browse files
authored
Improvements in DNS TTL, platform ID and proxy authentication (#78)
- Use TTL from DNS response, cache resolved addresses for that period - Identify Windows vs POSIX and C vs C++ (vs Qt) for reporting to the server - Detect authenticating proxy that works incorrectly, mostly the kind of broken proxy that keeps asking for the credentials over and over again, as-if we're not providing them.
1 parent 4dee357 commit 8e20fea

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1232
-590
lines changed

.pubnub.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
name: c-core
2-
version: 2.8.2
2+
version: 2.8.3
33
scm: github.com/pubnub/c-core
44
changelog:
5+
- version: v2.8.3
6+
date: May 31, 2019
7+
changes:
8+
- type: enhancement
9+
text: Use TTL from DNS response (cache resolved addresses)
10+
- type: enhancement
11+
text: Better identification of the platform we run on
12+
- type: enhancement
13+
text: Detect authenticating proxy that works incorrectly
514
- version: v2.8.2
615
date: Apr 29, 2019
716
changes:

core/pbgzip_compress.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ static enum pubnub_res deflate_total_to_context_buffer(pubnub_t* pb,
3333
if (message_size == unpacked_size) {
3434
uint32_t crc;
3535
size_t packed_size = GZIP_HEADER_LENGTH_BYTES + compressed + GZIP_FOOTER_LENGTH_BYTES;
36-
long diff = unpacked_size - packed_size;
36+
long diff = (long)unpacked_size - (long)packed_size;
3737

3838
PUBNUB_LOG_TRACE("deflate_total_to_context_buffer(pb=%p) - "
3939
"Length after compression: %zu bytes - "
40-
"compression ratio=%ld o/oo\n",
40+
"compression ratio=%zd o/oo\n",
4141
pb,
4242
packed_size,
4343
(diff*1000)/unpacked_size);

core/pbgzip_decompress.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ static enum pubnub_res inflate_total_to_context_buffer(pubnub_t* pb,
3030
return PNR_OK;
3131
}
3232
else {
33-
PUBNUB_LOG_ERROR("Decompressed length[%u] is smaller than the "
34-
"'unpacked_size' value[%u]!\n"
33+
PUBNUB_LOG_ERROR("Decompressed length[%zu] is smaller than the "
34+
"'unpacked_size' value[%zu]!\n"
3535
"(Unpacked:['%.*s'])\n",
36-
(unsigned)dst_buf_size,
37-
(unsigned)out_len,
38-
(int)dst_buf_size,
36+
dst_buf_size,
37+
out_len,
38+
(long)dst_buf_size,
3939
pb->core.decomp_http_reply);
4040
}
4141
break;
@@ -69,8 +69,8 @@ static enum pubnub_res inflate_total_to_context_buffer(pubnub_t* pb,
6969
static void swap_reply_buffer(pubnub_t* pb)
7070
{
7171
#if PUBNUB_DYNAMIC_REPLY_BUFFER
72-
char* aux_buf = pb->core.http_reply;
73-
unsigned aux_buf_len = pb->core.http_buf_len;
72+
char* aux_buf = pb->core.http_reply;
73+
size_t aux_buf_len = pb->core.http_buf_len;
7474
pb->core.http_reply = pb->core.decomp_http_reply;
7575
pb->core.http_buf_len = pb->core.decomp_buf_size;
7676
pb->core.decomp_http_reply = aux_buf;
@@ -85,6 +85,7 @@ static void swap_reply_buffer(pubnub_t* pb)
8585
return;
8686
}
8787

88+
8889
static enum pubnub_res inflate_total(pubnub_t* pb,
8990
const uint8_t* p_in_buf_next,
9091
size_t in_buf_size,
@@ -96,7 +97,7 @@ static enum pubnub_res inflate_total(pubnub_t* pb,
9697
char* newbuf = (char*)realloc(pb->core.decomp_http_reply, out_len + 1);
9798
if (NULL == newbuf) {
9899
PUBNUB_LOG_ERROR("Failed to reallocate decompression buffer!\n"
99-
"Out length:%lu\n",
100+
"Out length:%zu\n",
100101
out_len);
101102
return PNR_REPLY_TOO_BIG;
102103
}
@@ -105,7 +106,7 @@ static enum pubnub_res inflate_total(pubnub_t* pb,
105106
#else
106107
if (out_len >= sizeof pb->core.decomp_http_reply) {
107108
PUBNUB_LOG_ERROR("Decompression buffer too small!\n"
108-
"Size of buffer:%lu - Out length:%lu\n",
109+
"Size of buffer:%zu - Out length:%zu\n",
109110
sizeof pb->core.decomp_http_reply,
110111
out_len);
111112
return PNR_REPLY_TOO_BIG;
@@ -120,6 +121,7 @@ static enum pubnub_res inflate_total(pubnub_t* pb,
120121
return result;
121122
}
122123

124+
123125
enum pubnub_res pbgzip_decompress(pubnub_t* pb)
124126
{
125127
const uint8_t* data = (uint8_t*)pb->core.http_reply;
@@ -132,16 +134,14 @@ enum pubnub_res pbgzip_decompress(pubnub_t* pb)
132134
return PNR_BAD_COMPRESSION_FORMAT;
133135
}
134136
if (data[2] != 8) {
135-
PUBNUB_LOG_ERROR("Not used 'deflate' compression method(8)!\n"
136-
"Compression method value:%u\n",
137+
PUBNUB_LOG_ERROR("Unknown compression method %uX - only 'deflate'(8) "
138+
"is supported!\n",
137139
(unsigned)data[2]);
138140
return PNR_BAD_COMPRESSION_FORMAT;
139141
}
140142
if (data[3] != 0) {
141-
PUBNUB_LOG_ERROR(
142-
"Pubnub gzip doesn't expect any flags on filename and extras!\n"
143-
"Got gzip flags:%u\n",
144-
(unsigned)data[3]);
143+
PUBNUB_LOG_ERROR("GZIP flags should be 0, but are %uX\n",
144+
(unsigned)data[3]);
145145
return PNR_BAD_COMPRESSION_FORMAT;
146146
}
147147
/* Unpacked message size is placed at the end of the 'gzip' formated message
@@ -151,11 +151,11 @@ enum pubnub_res pbgzip_decompress(pubnub_t* pb)
151151
unpacked_size |= (uint32_t)data[size - 3] << 8;
152152
unpacked_size |= (uint32_t)data[size - 2] << 16;
153153
unpacked_size |= (uint32_t)data[size - 1] << 24;
154-
PUBNUB_LOG_TRACE("pbgzip_decompress(pb=%p)-Length before:%lu and after "
154+
PUBNUB_LOG_TRACE("pbgzip_decompress(pb=%p)-Length before:%zu and after "
155155
"decompresion:%lu\n",
156156
pb,
157-
(long unsigned)size,
158-
(long unsigned)unpacked_size);
157+
size,
158+
(unsigned long)unpacked_size);
159159
size -= (GZIP_HEADER_LENGTH_BYTES + GZIP_FOOTER_LENGTH_BYTES);
160160

161161
return inflate_total(

0 commit comments

Comments
 (0)