summaryrefslogtreecommitdiff
path: root/server_network.c
diff options
context:
space:
mode:
Diffstat (limited to 'server_network.c')
-rw-r--r--server_network.c53
1 files changed, 6 insertions, 47 deletions
diff --git a/server_network.c b/server_network.c
index 27c43a6..32277d2 100644
--- a/server_network.c
+++ b/server_network.c
@@ -26,11 +26,12 @@
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
+#include <gnutls/gnutls.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <sys/types.h>
+#include <netinet/in.h>
#include <sys/socket.h>
-#include <sys/un.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
@@ -38,6 +39,7 @@
#include "network.h"
#include "types.h"
#include "table.h"
+#include "tls.h"
#include "config.h"
#include "utils.h"
#include "commands.h"
@@ -63,8 +65,6 @@ 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,20 +899,9 @@ int initservernetwork(void) {
init_user_commands();
- 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"));
+ int retval = connect_tls();
+ if (retval != 0) {
+ printf("connect_tls(): %d\n", retval);
return 1;
}
@@ -952,33 +941,3 @@ 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