From 624c21f4b400ec9d5be198ca9d1636895b00ec57 Mon Sep 17 00:00:00 2001 From: Tushar Pankaj Date: Tue, 6 Nov 2018 20:34:57 -0600 Subject: Write high-level TODO Signed-off-by: Tushar Pankaj --- TODO | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 TODO diff --git a/TODO b/TODO new file mode 100644 index 0000000..d0f91e6 --- /dev/null +++ b/TODO @@ -0,0 +1,10 @@ +Here are some of the TODO in loosely step-by-step order: +* Design a Cap'n Proto protocol (no compression, no packing allowed!) +* Write server side to create TCP connection +* Write client side to connect to TCP connection +* Get client side to properly configure the dynamic IP from the server (using dummy data sent by server) + - Will need to use libmnl to configure the device + - Will need to use mini wireguard library (https://git.zx2c4.com/WireGuard/tree/contrib/examples/embeddable-wg-library) to configure wireguard +* Get server side to give real dynamic IP info to client +* Get client side to handle events (up/down/etc) + - libevent -- cgit v1.2.3-59-g8ed1b From 304889695712eaa33f9471d681d2ea93aeb50e19 Mon Sep 17 00:00:00 2001 From: Tushar Pankaj Date: Wed, 7 Nov 2018 10:57:04 -0600 Subject: Write basic mains so project compiles Squashed commit of the following: commit 3e88f04eb35d1afe374389958832fd75d76b8824 Author: Tushar Pankaj Date: Wed Nov 7 09:36:00 2018 -0600 Fix typos Signed-off-by: Tushar Pankaj commit 2b7b58b2b67fa8325a21a13d9ef42ad644df1731 Author: Tushar Pankaj Date: Wed Nov 7 09:35:21 2018 -0600 Separate out server code Signed-off-by: Tushar Pankaj commit 9e6ff0536a00498652f12e28d54f1b73b974a9fd Author: Tushar Pankaj Date: Wed Nov 7 09:31:32 2018 -0600 Separate out client network code Signed-off-by: Tushar Pankaj commit 5bbd32aaefa1baacdd8edd90efd4f8b609cbbc87 Author: Tushar Pankaj Date: Tue Nov 6 23:12:56 2018 -0600 Write basic main Signed-off-by: Tushar Pankaj --- .gitignore | 4 ++++ Makefile | 14 ++++++++------ client.c | 10 ++++++++++ client.h | 11 +++++++++++ server.c | 10 ++++++++++ server.h | 11 +++++++++++ wg-dynamic-client.c | 4 ---- wg-dynamic-server.c | 4 ---- wg_dynamic_client.c | 33 +++++++++++++++++++++++++++++++++ wg_dynamic_server.c | 33 +++++++++++++++++++++++++++++++++ 10 files changed, 120 insertions(+), 14 deletions(-) create mode 100644 client.c create mode 100644 client.h create mode 100644 server.c create mode 100644 server.h delete mode 100644 wg-dynamic-client.c delete mode 100644 wg-dynamic-server.c create mode 100644 wg_dynamic_client.c create mode 100644 wg_dynamic_server.c diff --git a/.gitignore b/.gitignore index 9755cc7..841b8d5 100644 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,7 @@ dkms.conf # Editor temporaries *~ + +# Binaries +wg-dynamic-client +wg-dynamic-server diff --git a/Makefile b/Makefile index b1e2662..1e95e47 100644 --- a/Makefile +++ b/Makefile @@ -8,16 +8,18 @@ CFLAGS ?= ${CFLAGS_DEBUG} LDFLAGS ?= ${LDFLAGS_DEBUG} .PHONY: clean style PROGS = wg-dynamic-client wg-dynamic-server -CLIENT_OBJS = wg-dynamic-client.o -SERVER_OBJS = wg-dynamic-server.o +CLIENT_OBJS = wg_dynamic_client.o client.o +SERVER_OBJS = wg_dynamic_server.o server.o all: ${PROGS} -client: ${CLIENT_OBJS} +wg-dynamic-client: ${CLIENT_OBJS} ${CC} ${LDFLAGS} ${CLIENT_OBJS} -o $@ -server: ${SERVER_OBJS} +wg-dynamic-server: ${SERVER_OBJS} ${CC} ${LDFLAGS} ${SERVER_OBJS} -o $@ -wg-dynamic-client.o: wg-dynamic-client.c -wg-dynamic-server.o: wg-dynamic-server.c +wg_dynamic_client.o: wg_dynamic_client.c client.h +client.o: client.c client.h +wg_dynamic_server.o: wg_dynamic_server.c server.h +server.o: server.c server.h clean: rm -f ${PROGS} *.o *~ diff --git a/client.c b/client.c new file mode 100644 index 0000000..2c2f091 --- /dev/null +++ b/client.c @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright (C) 2018 Wireguard LLC + */ + +int connect_to_server(const char interface[]) +{ + /* TODO */ + return -1; +} diff --git a/client.h b/client.h new file mode 100644 index 0000000..996cb58 --- /dev/null +++ b/client.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright (C) 2018 Wireguard LLC + */ + +#ifndef CLIENT_H +#define CLIENT_H + +int connect_to_server(const char interface[]); + +#endif diff --git a/server.c b/server.c new file mode 100644 index 0000000..0315ccb --- /dev/null +++ b/server.c @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright (C) 2018 Wireguard LLC + */ + +int setup_server(const char interface[]) +{ + /* TODO */ + return -1; +} diff --git a/server.h b/server.h new file mode 100644 index 0000000..3ffa9c5 --- /dev/null +++ b/server.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright (C) 2018 Wireguard LLC + */ + +#ifndef SERVER_H +#define SERVER_H + +int setup_server(const char interface[]); + +#endif diff --git a/wg-dynamic-client.c b/wg-dynamic-client.c deleted file mode 100644 index 87e3946..0000000 --- a/wg-dynamic-client.c +++ /dev/null @@ -1,4 +0,0 @@ -/* SPDX-License-Identifier: MIT */ -/* - * Copyright (C) 2018 Wireguard LLC - */ diff --git a/wg-dynamic-server.c b/wg-dynamic-server.c deleted file mode 100644 index 87e3946..0000000 --- a/wg-dynamic-server.c +++ /dev/null @@ -1,4 +0,0 @@ -/* SPDX-License-Identifier: MIT */ -/* - * Copyright (C) 2018 Wireguard LLC - */ diff --git a/wg_dynamic_client.c b/wg_dynamic_client.c new file mode 100644 index 0000000..318714d --- /dev/null +++ b/wg_dynamic_client.c @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright (C) 2018 Wireguard LLC + */ + +#include "client.h" + +#include +#include + +const char *PROG_NAME; + +static void show_usage() +{ + fprintf(stderr, "Usage: %s \n\n", PROG_NAME); +} + +int main(int argc, char *argv[]) +{ + PROG_NAME = argv[0]; + + if (argc == 1) { + show_usage(); + return EXIT_FAILURE; + } + + if (connect_to_server(argv[1]) < 0) { + perror("error connecting to server"); + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} diff --git a/wg_dynamic_server.c b/wg_dynamic_server.c new file mode 100644 index 0000000..191da67 --- /dev/null +++ b/wg_dynamic_server.c @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright (C) 2018 Wireguard LLC + */ + +#include "server.h" + +#include +#include + +const char *PROG_NAME; + +static void show_usage() +{ + fprintf(stderr, "Usage: %s \n\n", PROG_NAME); +} + +int main(int argc, char *argv[]) +{ + PROG_NAME = argv[0]; + + if (argc == 1) { + show_usage(); + return EXIT_FAILURE; + } + + if (setup_server(argv[1]) < 0) { + perror("error setting up server"); + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} -- cgit v1.2.3-59-g8ed1b