Skip to content

Commit

Permalink
some more assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
radkesvat committed May 9, 2024
1 parent 393a5d8 commit 8a7cc2f
Showing 1 changed file with 2 additions and 44 deletions.
46 changes: 2 additions & 44 deletions tunnels/client/reality/reality_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ static void upStream(tunnel_t *self, context_t *c)
appendTlsHeader(chunk);
context_t *cout = newContextFrom(c);
cout->payload = chunk;
assert(bufLen(chunk) % 16 == 5);
self->up->upStream(self->up, cout);
}
reuseContextBuffer(c);
Expand Down Expand Up @@ -384,7 +385,6 @@ static void downStream(tunnel_t *self, context_t *c)
bufferStreamPush(cstate->read_stream, c->payload);
c->payload = NULL;
uint8_t tls_header[1 + 2 + 2];

while (bufferStreamLen(cstate->read_stream) >= sizeof(tls_header))
{
bufferStreamViewBytesAt(cstate->read_stream, 0, tls_header, sizeof(tls_header));
Expand Down Expand Up @@ -527,50 +527,8 @@ static void downStream(tunnel_t *self, context_t *c)
flushWriteQueue(self, c);
// queue is flushed and we are done
}

reuseContextBuffer(c);
destroyContext(c);
return;
}

/* The encrypted data is now in the input bio so now we can perform actual
* read of unencrypted data. */

do
{
shift_buffer_t *buf = popBuffer(getContextBufferPool(c));
shiftl(buf, 8192 / 2);
setLen(buf, 0);
int avail = (int) rCap(buf);
n = SSL_read(cstate->ssl, rawBufMut(buf), avail);

if (n > 0)
{
setLen(buf, n);
context_t *data_ctx = newContextFrom(c);
data_ctx->payload = buf;
self->dw->downStream(self->dw, data_ctx);
if (! isAlive(c->line))
{
reuseContextBuffer(c);
destroyContext(c);
return;
}
}
else
{
reuseBuffer(getContextBufferPool(c), buf);
}

} while (n > 0);

status = getSslStatus(cstate->ssl, n);

if (status == kSslstatusFail)
{
reuseContextBuffer(c);
goto failed;
}

}
// done with socket data
reuseContextBuffer(c);
Expand Down

0 comments on commit 8a7cc2f

Please sign in to comment.