diff options
author | Tushar Pankaj <tushar.s.pankaj@gmail.com> | 2018-11-07 10:59:13 -0600 |
---|---|---|
committer | Tushar Pankaj <tushar.s.pankaj@gmail.com> | 2018-11-07 10:59:13 -0600 |
commit | 1f73168641d92917dc942c3d6cc200fb7f557674 (patch) | |
tree | 6d3116a873b4b9d6cd06cc3cb4781204133950c8 | |
parent | Add Makefile library includes for capnp (diff) | |
parent | Write basic mains so project compiles (diff) | |
download | wg-dynamic-1f73168641d92917dc942c3d6cc200fb7f557674.tar.xz wg-dynamic-1f73168641d92917dc942c3d6cc200fb7f557674.zip |
Merge branch 'master' into tp/protocol_draft
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | Makefile | 11 | ||||
-rw-r--r-- | TODO | 10 | ||||
-rw-r--r-- | client.c (renamed from wg-dynamic-server.c) | 6 | ||||
-rw-r--r-- | client.h | 11 | ||||
-rw-r--r-- | server.c (renamed from wg-dynamic-client.c) | 6 | ||||
-rw-r--r-- | server.h | 11 | ||||
-rw-r--r-- | wg_dynamic_client.c | 33 | ||||
-rw-r--r-- | wg_dynamic_server.c | 33 |
9 files changed, 121 insertions, 4 deletions
@@ -53,3 +53,7 @@ dkms.conf # Editor temporaries *~ + +# Binaries +wg-dynamic-client +wg-dynamic-server @@ -10,16 +10,19 @@ CFLAGS ?= ${CFLAGS_DEBUG} ${LIBRARY_INCLUDES} LDFLAGS ?= ${LDFLAGS_DEBUG} ${LIBRARY_LDFLAGS} .PHONY: clean style PROGS = wg-dynamic-client wg-dynamic-server -CLIENT_OBJS = wg-dynamic-client.o protocol.capnp.o -SERVER_OBJS = wg-dynamic-server.o protocol.capnp.o +CLIENT_OBJS = wg_dynamic_client.o client.o protocol.capnp.o +SERVER_OBJS = wg_dynamic_server.o server.o protocol.capnp.o all: ${PROGS} wg-dynamic-client: ${CLIENT_OBJS} ${CC} ${LDFLAGS} ${CLIENT_OBJS} -o $@ 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 protocol.capnp.o: protocol.capnp.c # capnproto @@ -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 diff --git a/wg-dynamic-server.c b/client.c index 87e3946..2c2f091 100644 --- a/wg-dynamic-server.c +++ b/client.c @@ -2,3 +2,9 @@ /* * 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/wg-dynamic-client.c b/server.c index 87e3946..0315ccb 100644 --- a/wg-dynamic-client.c +++ b/server.c @@ -2,3 +2,9 @@ /* * 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 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 <stdlib.h> +#include <stdio.h> + +const char *PROG_NAME; + +static void show_usage() +{ + fprintf(stderr, "Usage: %s <interface>\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 <stdlib.h> +#include <stdio.h> + +const char *PROG_NAME; + +static void show_usage() +{ + fprintf(stderr, "Usage: %s <interface>\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; +} |