diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 19 |
1 files changed, 10 insertions, 9 deletions
@@ -11,7 +11,7 @@ int main(int argc, char *argv[]) { const size_t srv_siz = 3; const char *ssh_ports[srv_siz]; - server_ctx srv[srv_siz]; + server_ctx *srv[srv_siz]; struct addrinfo *netifs = NULL; int epoll_fd; @@ -21,37 +21,38 @@ int main(int argc, char *argv[]) LOG_SET_FUNCS_VA(LOG_COLORED_FUNCS); N("%s (C) 2018 Toni Uhlig (%s)", PACKAGE_STRING, PACKAGE_BUGREPORT); - memset(&srv[0], 0, sizeof(srv)); + memset(srv, 0, sizeof(srv)); ssh_ports[0] = "2222"; ssh_ports[1] = "2223"; ssh_ports[2] = "22050"; + for (size_t i = 0; i < srv_siz; ++i) { D("Initialising redirector service on port %s", ssh_ports[i]); - ABORT_ON_FATAL( server_init_ctx(&srv[i], ssh_init_cb), + ABORT_ON_FATAL( server_init_ctx(&srv[i], ssh_init_cb) == 0, "Server initialisation" ); - server_validate_ctx(&srv[i]); + server_validate_ctx(srv[i]); GAI_ABORT_ON_FATAL( socket_init_in(NULL, ssh_ports[i], &netifs), "Socket initialisation" ); - ABORT_ON_FATAL( socket_bind_in(&srv[i].sock, netifs), + ABORT_ON_FATAL( socket_bind_in(&srv[i]->sock, netifs), "Socket bind" ); - ABORT_ON_FATAL( socket_listen_in(&srv[i].sock), + ABORT_ON_FATAL( socket_listen_in(&srv[i]->sock), "Socket listen" ); - ABORT_ON_FATAL( srv[i].server_cbs.on_listen(&srv[i].server_dat), + ABORT_ON_FATAL( srv[i]->server_cbs.on_listen(&srv[i]->server_dat), "Socket on listen callback" ); } D2("%s", "Server epoll setup"); - epoll_fd = server_setup_epoll( &srv[0], srv_siz ); + epoll_fd = server_setup_epoll( srv, srv_siz ); D2("epoll_fd: %d", epoll_fd); ABORT_ON_FATAL( epoll_fd < 0, "Server epoll setup" ); N("%s", "Server epoll mainloop"); - ABORT_ON_FATAL( server_mainloop_epoll( epoll_fd, &srv[0], srv_siz ), + ABORT_ON_FATAL( server_mainloop_epoll( epoll_fd, srv, srv_siz ), "Server epoll mainloop" ); return 0; |