Skip to content

Commit

Permalink
TCP test
Browse files Browse the repository at this point in the history
  • Loading branch information
expressvpn-raihaan-m committed Aug 15, 2023
1 parent e393590 commit 7dbd2b4
Show file tree
Hide file tree
Showing 18 changed files with 393 additions and 222 deletions.
4 changes: 1 addition & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ services:
server:
build:
context: .
# dockerfile: docker/Dockerfile-dtls
dockerfile: docker/Dockerfile
networks:
- perfnet
Expand All @@ -25,8 +24,7 @@ services:
cli:
build:
context: .
# dockerfile: docker/Dockerfile
dockerfile: docker/Dockerfile-dtls
dockerfile: docker/Dockerfile
depends_on:
- iperf
- server
Expand Down
3 changes: 2 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ RUN apt-get update && apt-get install -qqy --no-install-recommends \
valgrind \
wget \
strace \
vim
vim \
cmake

# Set up ceedling
RUN gem install ceedling
Expand Down
41 changes: 0 additions & 41 deletions docker/Dockerfile-dtls

This file was deleted.

157 changes: 0 additions & 157 deletions dtls.yml

This file was deleted.

6 changes: 6 additions & 0 deletions include/lw.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ typedef struct lw_state {
char const *dns_ip;
int mtu;

//TCP Client socket
uv_connect_t tcp_connect;
uv_tcp_t tcp_client;

// The external IP viewable to the outside world
uint32_t assigned_ip;

Expand All @@ -92,6 +96,8 @@ typedef struct lw_state {

// Server or not -- most things don't actually care but some do
bool is_server;
// is streaming
bool is_streaming;

} lw_state_t;

Expand Down
5 changes: 2 additions & 3 deletions project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@
:fetch:
:method: :git
:source: https://github.com/expressvpn/lightway-core.git
:tag: v1.11.0
:environment:
- CFLAGS= -DLARGE_STATIC_BUFFERS -DWOLFSSL_DTLS_ALLOW_FUTURE -DWOLFSSL_MIN_RSA_BITS=2048 -DWOLFSSL_MIN_ECC_BITS=256 -fPIC
:branch: dtls13-testing
:build:
- /usr/local/bin/ceedling verbosity[4] release project:linux
:artifacts:
Expand All @@ -87,6 +85,7 @@
:static_libraries:
- build/artifacts/release/libhelium.a
- third_party/builds/wolfssl_build/lib/libwolfssl.a
# - third_party/liboqs/build/lib/liboqs.a
- :name: libuv
:source_path: third_party/libuv
:artifact_path: third_party/builds/libuv
Expand Down
2 changes: 1 addition & 1 deletion scripts/run_iperf_client.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ echo "Resolved to target ${TARGET} server ${SERVER}"
echo "Check that we have connectivity to the lightway server"
ping -w1 "${SERVER}"

build/release/lw.out --client --protocol udp --username test --password test --server_ip ${SERVER} --server_port 19655 --cert certs/shared.crt --tun helium-test &
build/release/lw.out --client --protocol tcp --username test --password test --server_ip ${SERVER} --server_port 19655 --cert certs/shared.crt --tun helium-test &

sleep 15

Expand Down
2 changes: 1 addition & 1 deletion scripts/run_server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e
scripts/setup_nat_tun.sh

build/release/lw.out --server \
--protocol udp \
--protocol tcp \
--username test \
--password test \
--server_ip '0.0.0.0' \
Expand Down
19 changes: 15 additions & 4 deletions src/he/helium.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,14 @@ he_return_code_t state_change_cb(he_conn_t *client, he_conn_state_t new_state, v
lw_state_post_disconnect_cleanup(state);
}

if(new_state == HE_STATE_ONLINE && !state->is_server && !reneg) {
reneg = true;
he_conn_schedule_renegotiation(client);
zlogf_time(ZLOG_INFO_LOG_MSG, "SCHEDULED RENEGOTIATION\n");
if(new_state == HE_STATE_ONLINE) {
// zlogf_time(ZLOG_INFO_LOG_MSG, "CURVE: %s\n", he_conn_get_curve_name(client));

if (!state->is_server && !reneg) {
reneg = true;
he_conn_schedule_renegotiation(client);
zlogf_time(ZLOG_INFO_LOG_MSG, "SCHEDULED RENEGOTIATION\n");
}
}

return HE_SUCCESS;
Expand Down Expand Up @@ -153,6 +157,7 @@ void start_helium_server(lw_state_t *state) {

void start_helium_server_connection(lw_state_t *state) {
state->he_conn = he_conn_create();
he_conn_enable_debugging(state->he_conn, NULL);
LW_CHECK_WITH_MSG(state->he_conn, "Unable to allocate new Helium connection");

int res = he_conn_set_outside_mtu(state->he_conn, LW_MAX_WIRE_MTU);
Expand All @@ -163,6 +168,8 @@ void start_helium_server_connection(lw_state_t *state) {

res = he_conn_server_connect(state->he_conn, state->he_ctx, NULL, NULL);
LW_CHECK_WITH_MSG(res == HE_SUCCESS, "Helium connect failed");
zlogf_time(ZLOG_INFO_LOG_MSG, "Server connection start\n");
zlog_flush_buffer();
}

void configure_helium_client(lw_config_t *config, lw_state_t *state) {
Expand All @@ -180,6 +187,7 @@ void configure_helium_client(lw_config_t *config, lw_state_t *state) {
LW_CHECK_WITH_MSG(res == HE_SUCCESS, "Failed to set the server key path");

state->he_conn = he_conn_create();
he_conn_enable_debugging(state->he_conn, NULL);
LW_CHECK_WITH_MSG(state->he_conn, "Failed to create connection");

res = he_conn_set_username(state->he_conn, config->username);
Expand All @@ -203,5 +211,8 @@ void start_helium_client(lw_state_t *state) {
LW_CHECK_WITH_MSG(res == HE_SUCCESS, "Failed to start He context!");

res = he_conn_client_connect(state->he_conn, state->he_ctx, NULL, NULL);
if (res != HE_SUCCESS) {
zlogf_time(ZLOG_INFO_LOG_MSG, "CONNECT FAILED: %d\n", res);
}
LW_CHECK_WITH_MSG(res == HE_SUCCESS, "Failed to connect!");
}
Loading

0 comments on commit 7dbd2b4

Please sign in to comment.