From 8fb7f0bc0d3300637c2db8499efbf193ffebf28f Mon Sep 17 00:00:00 2001 From: Test_User Date: Fri, 25 Aug 2023 17:36:07 -0400 Subject: No more TLS --- server_network.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 6 deletions(-) (limited to 'server_network.c') diff --git a/server_network.c b/server_network.c index 1327916..9d0d7d6 100644 --- a/server_network.c +++ b/server_network.c @@ -26,12 +26,11 @@ // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR // OTHER DEALINGS IN THE SOFTWARE. -#include #include #include #include -#include #include +#include #include #include #include @@ -39,7 +38,6 @@ #include "network.h" #include "types.h" #include "table.h" -#include "tls.h" #include "config.h" #include "utils.h" #include "commands.h" @@ -65,6 +63,8 @@ int resolve(char *address, char *port, struct sockaddr *sockaddr) { return success; } +int server_fd = -1; + struct table server_network_commands = {0}; struct table server_list = {0}; struct table user_list = {0}; @@ -899,9 +899,20 @@ int initservernetwork(void) { init_user_commands(); - int retval = connect_tls(); - if (retval != 0) { - printf("connect_tls(): %d\n", retval); + server_fd = socket(AF_UNIX, SOCK_STREAM, 0); + if (server_fd < 0) { + WRITES(2, STRING("Unable to open unix socket!\n")); + return 1; + } + + struct sockaddr_un socket = { + .sun_family = AF_UNIX, + .sun_path = "./s2s", + }; + + int retval = connect(server_fd, (struct sockaddr*)&socket, sizeof(socket)); + if (retval == -1) { + WRITES(2, STRING("Unable to connect unix socket!\n")); return 1; } @@ -934,3 +945,33 @@ int initservernetwork(void) { return 0; } + +extern inline size_t RECV(char *buf, size_t buflen, char *timeout); // Should force it to get compiled into here + +#if LOGALL +ssize_t SEND(struct string msg) { + static char printprefix = 1; + if (printprefix) { +#if COLORIZE + WRITES(1, STRING("\x1b[33m[Us->Server] \x1b[34m")); +#else + WRITES(1, STRING("[Us->Server] ")); +#endif + + printprefix = 0; + } + + WRITES(1, msg); + + if (msg.len == 0 || msg.data[msg.len - 1] == '\n') { + printprefix = 1; +#if COLORIZE + WRITES(1, STRING("\x1b[0m\n")); +#else + WRITES(1, STRING("\n")); +#endif + } + + return WRITES(server_fd, msg); +} +#endif -- cgit v1.2.3