Skip to content

Commit

Permalink
Finish v1, add some comments(docs)
Browse files Browse the repository at this point in the history
  • Loading branch information
radkesvat committed Jun 15, 2024
1 parent 7720e86 commit de0f473
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 13 deletions.
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Waterwall!

A simple core for tunneling and even direct user-server connections. based on high-performance, fully customizeable nodes for creating any kind of protocol without writing code for it.

Currently on beta, to start please read the [docs](https://github.com/radkesvat/WaterWall/wiki). (The documents are currently in Persian language.)
To start please read the [docs](https://github.com/radkesvat/WaterWall/wiki). (The documents are currently only in Persian language.)

# Donation

Expand Down
2 changes: 1 addition & 1 deletion tunnels/client/http2/http2_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,13 +443,13 @@ static void downStream(tunnel_t *self, context_t *c)
assert(false);
deleteHttp2Connection(con);
self->up->upStream(self->up, newFinContext(c->line));
reuseContextBuffer(c);
destroyContext(c);
return;
}

if (nghttp2_session_want_write(con->session) != 0)
{

while (trySendRequest(self, con, 0, NULL))
{
if (! isAlive(c->line))
Expand Down
2 changes: 2 additions & 0 deletions tunnels/server/http2/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ static void onStreamLineResumed(void *arg)
static void onH2LinePaused(void *arg)
{
http2_server_con_state_t *con = (http2_server_con_state_t *) arg;
// this kind of buffer actually reduces the speed instead of increasing it
// so its now disabled
// ++(con->pause_counter);
// if (con->pause_counter > 8)
// {
Expand Down
1 change: 1 addition & 0 deletions tunnels/server/http2/http2_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ static void upStream(tunnel_t *self, context_t *c)
assert(false);
deleteHttp2Connection(con);
self->dw->downStream(self->dw, newFinContext(c->line));
reuseContextBuffer(c);
destroyContext(c);
return;
}
Expand Down
3 changes: 2 additions & 1 deletion ww/buffer_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
so the pool width is affected by ww memory profile
for performance reasons, this pool dose not inherit from generic_pool and 80% of the code is the same
for performance reasons, this pool dose not inherit from generic_pool, so 80% of the code is the same
but also it has its own differences ofcourse
*/

Expand Down
9 changes: 6 additions & 3 deletions ww/buffer_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
#include <stdint.h>

/*
buffers look like packets , you want a stream? you want to read the length you want?
then use buffer stream! put every buffer into this mix box and now you have a flow of bytes
which you can read but not consume, save and keep appending data to it untill it statisfy your protocol
This implements a simple container that holds buffers, some opmizations are also applied.
you can for example check byte index 1 or 5 of the buffers without concating them, then
you'll be able to read only when your protocol is satisfied, the size you want
*/

Expand Down
9 changes: 7 additions & 2 deletions ww/cacert.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#ifndef CACERT_H
#define CACERT_H

// i don't have time to impleme... nah i just don't trust the user trusted certs :)
// that also makes it much harder for the bad users to steal encrypted configs
/*
Currently, waterwall uses its own CA and dose not trust user trusted certs
this also makes it much harder for the bad users to steal encrypted configs (IMO)
todo (hash verify), in order to make it even harder, do some hash verify of bytes
*/


extern unsigned char cacert_bytes[];
extern unsigned int cacert_len;
Expand Down
5 changes: 4 additions & 1 deletion ww/idle_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
you also can keep updating the item timeout
The time checking has no cost and won't syscall at all, and the checking is synced by the
eventloop which by default wakes up every 100 ms. (debug note: current interval is set to 1s)
eventloop which by default wakes up every 100 ms. (debug note: current idletable interval is set to 1s)
idle item is a threadlocal item, it belongs to the thread that created it
and other threads must not change , remove or do anything to it
because of that, tid parameter is required in order to find the item
-- valgrind unfriendly, since we required 64byte alignment, so it says "possibly lost"
but the pointer is saved in "memptr" field inside the object
*/

struct idle_item_s;
Expand All @@ -38,6 +40,7 @@ struct idle_item_s
uint8_t tid;
bool removed;
};

typedef struct idle_table_s idle_table_t;

idle_table_t *newIdleTable(hloop_t *loop);
Expand Down
4 changes: 2 additions & 2 deletions ww/pipe_line.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static void lock(pipe_line_t *pl)
if (old_refc == 0)
{
// this should not happen, otherwise we must change memory order
// but i think its ok because threads synchronize around mutex
// but i think its ok because threads synchronize around the mutex in eventloop
LOGF("PipeLine: thread-safety done incorrectly lock()");
exit(1);
}
Expand All @@ -66,7 +66,7 @@ static void unlock(pipe_line_t *pl)
if (! atomic_load_explicit(&(pl->closed), memory_order_relaxed))
{
// this should not happen, otherwise we must change memory order
// but i think its ok because threads synchronize around mutex
// but i think its ok because threads synchronize around the mutex in eventloop
LOGF("PipeLine: thread-safety done incorrectly unlock()");
exit(1);
}
Expand Down
11 changes: 9 additions & 2 deletions ww/pipe_line.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@

/*
<--------------- Down Line ------------------>
----------------------------|------------------|
<- con -> Pipe 1 thread 1 |
----------------------------|------------------|
<---------------- Up Line ------------------>
|------------------|----------------------------
| Pipe 1 thread 2 <- con ->
|------------------|----------------------------
Expand All @@ -27,7 +33,8 @@
i hope you don't use it, currently only used for halfduplex server since there were no other way...
-- valgrind unfriendly, mem align is not detected correctly , so it might log leaks
-- valgrind unfriendly, since we required 64byte alignment, so it says "possibly lost"
but the pointer is saved in "memptr" field inside the object
*/

Expand Down

0 comments on commit de0f473

Please sign in to comment.