Skip to content

Commit

Permalink
use bufferStreamPushContextPayload
Browse files Browse the repository at this point in the history
  • Loading branch information
radkesvat committed Jun 20, 2024
1 parent c22b04c commit 6e7a618
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 19 deletions.
3 changes: 1 addition & 2 deletions tunnels/client/protobuf/protobuf_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ static void downStream(tunnel_t *self, context_t *c)
if (c->payload != NULL)
{
buffer_stream_t *bstream = cstate->stream_buf;
bufferStreamPush(bstream, c->payload);
c->payload = NULL;
bufferStreamPushContextPayload(bstream, c);

while (true)
{
Expand Down
3 changes: 1 addition & 2 deletions tunnels/client/reality/reality_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,7 @@ static void downStream(tunnel_t *self, context_t *c)

if (cstate->handshake_completed)
{
bufferStreamPush(cstate->read_stream, c->payload);
c->payload = NULL;
bufferStreamPushContextPayload(cstate->read_stream, c);
uint8_t tls_header[1 + 2 + 2];
while (isAlive(c->line) && bufferStreamLen(cstate->read_stream) >= kTLSHeaderlen)
{
Expand Down
3 changes: 1 addition & 2 deletions tunnels/server/protobuf/protobuf_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ static void upStream(tunnel_t *self, context_t *c)
if (c->payload != NULL)
{
buffer_stream_t *bstream = cstate->stream_buf;
bufferStreamPush(bstream, c->payload);
c->payload = NULL;
bufferStreamPushContextPayload(bstream, c);

while (true)
{
Expand Down
3 changes: 1 addition & 2 deletions tunnels/server/reality/reality_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ static void upStream(tunnel_t *self, context_t *c)

break;
case kConAuthorized: {
bufferStreamPush(cstate->read_stream, c->payload);
c->payload = NULL;
bufferStreamPushContextPayload(cstate->read_stream,c);
authorized:;
uint8_t tls_header[1 + 2 + 2];
while (isAlive(c->line) && bufferStreamLen(cstate->read_stream) >= kTLSHeaderlen)
Expand Down
10 changes: 4 additions & 6 deletions tunnels/server/reverse/reverse_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,12 @@ static void upStream(tunnel_t *self, context_t *c)
{
if (dcstate->handshaked)
{
bufferStreamPush(dcstate->wait_stream, c->payload);
c->payload = NULL;
bufferStreamPushContextPayload(dcstate->wait_stream, c);
destroyContext(c);
}
else
{
bufferStreamPush(dcstate->wait_stream, c->payload);
c->payload = NULL;
bufferStreamPushContextPayload(dcstate->wait_stream, c);

if (bufferStreamLen(dcstate->wait_stream) >= 96)
{
Expand Down Expand Up @@ -196,8 +194,8 @@ static void downStream(tunnel_t *self, context_t *c)
}
if (bufferStreamLen(dcstate->wait_stream) > 0)
{
bufferStreamPush(dcstate->wait_stream, c->payload);
c->payload = NULL;
bufferStreamPushContextPayload(dcstate->wait_stream,c);

context_t *data_waiting_ctx = newContext(c->line);
data_waiting_ctx->payload = bufferStreamFullRead(dcstate->wait_stream);
self->up->upStream(self->up, data_waiting_ctx);
Expand Down
6 changes: 2 additions & 4 deletions tunnels/server/trojan/socks/trojan_socks_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,7 @@ static void upStream(tunnel_t *self, context_t *c)
}
if (dest_context->address_protocol == kSapUdp)
{
bufferStreamPush(cstate->udp_stream, c->payload);
c->payload = NULL;
bufferStreamPushContextPayload(cstate->udp_stream, c);

if (! processUdp(self, cstate, c->line))
{
Expand Down Expand Up @@ -491,8 +490,7 @@ static void upStream(tunnel_t *self, context_t *c)

if (c->line->dest_ctx.address_protocol == kSapUdp)
{
bufferStreamPush(cstate->udp_stream, c->payload);
c->payload = NULL;
bufferStreamPushContextPayload(cstate->udp_stream, c);

if (! processUdp(self, cstate, c->line))
{
Expand Down
2 changes: 1 addition & 1 deletion ww/buffer_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static inline void bufferStreamPushContextPayload(buffer_stream_t *self,context_
{
assert(c->payload);
bufferStreamPush(self,c->payload);
//todo (disabled optimize) this can work but currently disabled, also looc at tunnel.h
//todo (disabled optimize) this can work but currently disabled, also look at tunnel.h
#if !defined(RELEASE) || 1
c->payload = NULL;
#endif
Expand Down

0 comments on commit 6e7a618

Please sign in to comment.