1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#include "log.h"
#include "log_colored.h"
#include "server.h"
#include "server_ssh.h"
#include "forward.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
int main(int argc, char *argv[])
{
const size_t srv_siz = 3;
const char *ssh_ports[srv_siz];
server_ctx *srv[srv_siz];
forward_ctx *ssh_fwd = NULL;
int epoll_fd;
(void) argc;
(void) argv;
LOG_SET_FUNCS_VA(LOG_COLORED_FUNCS);
N("%s (C) 2018 Toni Uhlig (%s)", PACKAGE_STRING, PACKAGE_BUGREPORT);
{
ABORT_ON_FATAL( fwd_init_ctx(&ssh_fwd, ssh_init_cb),
"Forwarder initialisation" );
ABORT_ON_FATAL( fwd_setup(ssh_fwd, "127.0.0.1", "22"),
"Forwarder setup" );
ABORT_ON_FATAL( fwd_validate_ctx( ssh_fwd ),
"Forwarder validation" );
}
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_fwd),
"Server initialisation" );
ABORT_ON_FATAL( server_setup(srv[i], NULL, ssh_ports[i]),
"Server setup" );
ABORT_ON_FATAL( server_validate_ctx(srv[i]),
"Server validation" );
}
D2("%s", "Server epoll setup");
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, srv_siz ),
"Server epoll mainloop" );
return 0;
}
|