mirror of
https://github.com/tmate-io/tmate-ssh-server.git
synced 2020-11-18 19:53:51 -08:00
master -> proxy
This commit is contained in:
parent
6c62b10e0a
commit
07ba45297f
@ -183,7 +183,7 @@ dist_tmate_slave_SOURCES = \
|
|||||||
tmate-daemon-decoder.c \
|
tmate-daemon-decoder.c \
|
||||||
tmate-daemon-encoder.c \
|
tmate-daemon-encoder.c \
|
||||||
tmate-msgpack.c \
|
tmate-msgpack.c \
|
||||||
tmate-master.c \
|
tmate-proxy.c \
|
||||||
tmate-slave.c \
|
tmate-slave.c \
|
||||||
tmate-ssh-client-pty.c \
|
tmate-ssh-client-pty.c \
|
||||||
tmate-ssh-daemon.c \
|
tmate-ssh-daemon.c \
|
||||||
|
10
resize.c
10
resize.c
@ -78,11 +78,11 @@ recalculate_sizes(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TMATE_SLAVE
|
#ifdef TMATE_SLAVE
|
||||||
if (tmate_has_master()) {
|
if (tmate_has_proxy()) {
|
||||||
if (tmate_session->master_sy < ssy)
|
if (tmate_session->proxy_sy < ssy)
|
||||||
ssy = tmate_session->master_sy;
|
ssy = tmate_session->proxy_sy;
|
||||||
if (tmate_session->master_sx < ssx)
|
if (tmate_session->proxy_sx < ssx)
|
||||||
ssx = tmate_session->master_sx;
|
ssx = tmate_session->proxy_sx;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmate_client_resize(ssx, ssy);
|
tmate_client_resize(ssx, ssy);
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#define CONTROL_PROTOCOL_VERSION 1
|
#define CONTROL_PROTOCOL_VERSION 1
|
||||||
|
|
||||||
#define pack(what, ...) _pack(&tmate_session->master_encoder, what, __VA_ARGS__)
|
#define pack(what, ...) _pack(&tmate_session->proxy_encoder, what, __VA_ARGS__)
|
||||||
|
|
||||||
static void ctl_daemon_fwd_msg(struct tmate_session *session,
|
static void ctl_daemon_fwd_msg(struct tmate_session *session,
|
||||||
struct tmate_unpacker *uk)
|
struct tmate_unpacker *uk)
|
||||||
@ -142,13 +142,13 @@ static void ctl_pane_keys(struct tmate_session *session,
|
|||||||
static void ctl_resize(struct tmate_session *session,
|
static void ctl_resize(struct tmate_session *session,
|
||||||
struct tmate_unpacker *uk)
|
struct tmate_unpacker *uk)
|
||||||
{
|
{
|
||||||
session->master_sx = (u_int)unpack_int(uk);
|
session->proxy_sx = (u_int)unpack_int(uk);
|
||||||
session->master_sy = (u_int)unpack_int(uk);
|
session->proxy_sy = (u_int)unpack_int(uk);
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmate_dispatch_master_message(struct tmate_session *session,
|
void tmate_dispatch_proxy_message(struct tmate_session *session,
|
||||||
struct tmate_unpacker *uk)
|
struct tmate_unpacker *uk)
|
||||||
{
|
{
|
||||||
int cmd = unpack_int(uk);
|
int cmd = unpack_int(uk);
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
@ -157,14 +157,14 @@ void tmate_dispatch_master_message(struct tmate_session *session,
|
|||||||
dispatch(TMATE_CTL_REQUEST_SNAPSHOT, ctl_daemon_request_snapshot);
|
dispatch(TMATE_CTL_REQUEST_SNAPSHOT, ctl_daemon_request_snapshot);
|
||||||
dispatch(TMATE_CTL_PANE_KEYS, ctl_pane_keys);
|
dispatch(TMATE_CTL_PANE_KEYS, ctl_pane_keys);
|
||||||
dispatch(TMATE_CTL_RESIZE, ctl_resize);
|
dispatch(TMATE_CTL_RESIZE, ctl_resize);
|
||||||
default: tmate_warn("Bad master message type: %d", cmd);
|
default: tmate_warn("Bad proxy message type: %d", cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmate_notify_client_join(struct tmate_session *session,
|
void tmate_notify_client_join(struct tmate_session *session,
|
||||||
struct client *c)
|
struct client *c)
|
||||||
{
|
{
|
||||||
if (!tmate_has_master())
|
if (!tmate_has_proxy())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pack(array, 4);
|
pack(array, 4);
|
||||||
@ -177,7 +177,7 @@ void tmate_notify_client_join(struct tmate_session *session,
|
|||||||
void tmate_notify_client_left(struct tmate_session *session,
|
void tmate_notify_client_left(struct tmate_session *session,
|
||||||
struct client *c)
|
struct client *c)
|
||||||
{
|
{
|
||||||
if (!tmate_has_master())
|
if (!tmate_has_proxy())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pack(array, 2);
|
pack(array, 2);
|
||||||
@ -185,13 +185,13 @@ void tmate_notify_client_left(struct tmate_session *session,
|
|||||||
pack(int, c->id);
|
pack(int, c->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmate_send_master_daemon_msg(struct tmate_session *session,
|
void tmate_send_proxy_daemon_msg(struct tmate_session *session,
|
||||||
struct tmate_unpacker *uk)
|
struct tmate_unpacker *uk)
|
||||||
{
|
{
|
||||||
struct timespec time_diff, current_time;
|
struct timespec time_diff, current_time;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!tmate_has_master())
|
if (!tmate_has_proxy())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pack(array, 2);
|
pack(array, 2);
|
||||||
@ -202,9 +202,9 @@ void tmate_send_master_daemon_msg(struct tmate_session *session,
|
|||||||
pack(object, uk->argv[i]);
|
pack(object, uk->argv[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmate_send_master_header(struct tmate_session *session)
|
void tmate_send_proxy_header(struct tmate_session *session)
|
||||||
{
|
{
|
||||||
if (!tmate_has_master())
|
if (!tmate_has_proxy())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pack(array, 6);
|
pack(array, 6);
|
||||||
@ -216,16 +216,16 @@ void tmate_send_master_header(struct tmate_session *session)
|
|||||||
pack(string, session->session_token_ro);
|
pack(string, session->session_token_ro);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmate_init_master_session(struct tmate_session *session)
|
void tmate_init_proxy_session(struct tmate_session *session)
|
||||||
{
|
{
|
||||||
if (!tmate_has_master())
|
if (!tmate_has_proxy())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
session->master_sx = -1;
|
session->proxy_sx = -1;
|
||||||
session->master_sy = -1;
|
session->proxy_sy = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _tmate_connect_to_master(const char *hostname, int port)
|
static int _tmate_connect_to_proxy(const char *hostname, int port)
|
||||||
{
|
{
|
||||||
int sockfd = -1;
|
int sockfd = -1;
|
||||||
struct sockaddr_in servaddr;
|
struct sockaddr_in servaddr;
|
||||||
@ -245,22 +245,22 @@ static int _tmate_connect_to_master(const char *hostname, int port)
|
|||||||
servaddr.sin_port = htons(port);
|
servaddr.sin_port = htons(port);
|
||||||
|
|
||||||
if (connect(sockfd, (struct sockaddr*)&servaddr, sizeof(servaddr)) < 0)
|
if (connect(sockfd, (struct sockaddr*)&servaddr, sizeof(servaddr)) < 0)
|
||||||
tmate_fatal("Cannot connect to master at %s:%d", hostname, port);
|
tmate_fatal("Cannot connect to proxy at %s:%d", hostname, port);
|
||||||
|
|
||||||
int flag = 1;
|
int flag = 1;
|
||||||
if (setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(flag)) < 0)
|
if (setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(flag)) < 0)
|
||||||
tmate_fatal("Can't set master socket to TCP_NODELAY");
|
tmate_fatal("Can't set proxy socket to TCP_NODELAY");
|
||||||
|
|
||||||
if (fcntl(sockfd, F_SETFL, O_NONBLOCK) < 0)
|
if (fcntl(sockfd, F_SETFL, O_NONBLOCK) < 0)
|
||||||
tmate_fatal("Can't set master socket to non-blocking");
|
tmate_fatal("Can't set proxy socket to non-blocking");
|
||||||
|
|
||||||
tmate_notice("Connected to master at %s:%d", hostname, port);
|
tmate_notice("Connected to proxy at %s:%d", hostname, port);
|
||||||
|
|
||||||
return sockfd;
|
return sockfd;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tmate_connect_to_master(void)
|
int tmate_connect_to_proxy(void)
|
||||||
{
|
{
|
||||||
return _tmate_connect_to_master(tmate_settings->master_hostname,
|
return _tmate_connect_to_proxy(tmate_settings->proxy_hostname,
|
||||||
tmate_settings->master_port);
|
tmate_settings->proxy_port);
|
||||||
}
|
}
|
@ -33,8 +33,8 @@ extern int client_connect(char *path, int start_server);
|
|||||||
struct tmate_settings _tmate_settings = {
|
struct tmate_settings _tmate_settings = {
|
||||||
.keys_dir = TMATE_SSH_DEFAULT_KEYS_DIR,
|
.keys_dir = TMATE_SSH_DEFAULT_KEYS_DIR,
|
||||||
.ssh_port = TMATE_SSH_DEFAULT_PORT,
|
.ssh_port = TMATE_SSH_DEFAULT_PORT,
|
||||||
.master_hostname = NULL,
|
.proxy_hostname = NULL,
|
||||||
.master_port = TMATE_DEFAULT_MASTER_PORT,
|
.proxy_port = TMATE_DEFAULT_PROXY_PORT,
|
||||||
.tmate_host = NULL,
|
.tmate_host = NULL,
|
||||||
.log_level = LOG_NOTICE,
|
.log_level = LOG_NOTICE,
|
||||||
.use_syslog = false,
|
.use_syslog = false,
|
||||||
@ -44,7 +44,7 @@ struct tmate_settings *tmate_settings = &_tmate_settings;
|
|||||||
|
|
||||||
static void usage(void)
|
static void usage(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "usage: tmate-slave [-k keys_dir] [-p port] [-m master_hostname] [-q master_port] [-s] [-v]\n");
|
fprintf(stderr, "usage: tmate-slave [-k keys_dir] [-p port] [-x proxy_hostname] [-q proxy_port] [-s] [-v]\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmate_get_random_bytes(void *buffer, ssize_t len)
|
void tmate_get_random_bytes(void *buffer, ssize_t len)
|
||||||
@ -76,7 +76,7 @@ int main(int argc, char **argv, char **envp)
|
|||||||
{
|
{
|
||||||
int opt;
|
int opt;
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "k:p:lvm:q:")) != -1) {
|
while ((opt = getopt(argc, argv, "k:p:lvx:q:")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'p':
|
case 'p':
|
||||||
tmate_settings->ssh_port = atoi(optarg);
|
tmate_settings->ssh_port = atoi(optarg);
|
||||||
@ -90,11 +90,11 @@ int main(int argc, char **argv, char **envp)
|
|||||||
case 'v':
|
case 'v':
|
||||||
tmate_settings->log_level++;
|
tmate_settings->log_level++;
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'x':
|
||||||
tmate_settings->master_hostname = xstrdup(optarg);
|
tmate_settings->proxy_hostname = xstrdup(optarg);
|
||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
tmate_settings->master_port = atoi(optarg);
|
tmate_settings->proxy_port = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
tmate_settings->tmate_host = xstrdup(optarg);
|
tmate_settings->tmate_host = xstrdup(optarg);
|
||||||
@ -351,7 +351,7 @@ static void tmate_spawn_slave_daemon(struct tmate_session *session)
|
|||||||
close_fds_except((int[]){session->tmux_socket_fd,
|
close_fds_except((int[]){session->tmux_socket_fd,
|
||||||
ssh_get_fd(session->ssh_client.session),
|
ssh_get_fd(session->ssh_client.session),
|
||||||
log_file ? fileno(log_file) : -1,
|
log_file ? fileno(log_file) : -1,
|
||||||
session->master_fd}, 4);
|
session->proxy_fd}, 4);
|
||||||
|
|
||||||
jail();
|
jail();
|
||||||
event_reinit(ev_base);
|
event_reinit(ev_base);
|
||||||
@ -420,7 +420,7 @@ static void tmate_spawn_slave_pty_client(struct tmate_session *session)
|
|||||||
|
|
||||||
tmate_client_pty_init(session);
|
tmate_client_pty_init(session);
|
||||||
|
|
||||||
/* the unused session->master_fd will get closed automatically */
|
/* the unused session->proxy_fd will get closed automatically */
|
||||||
|
|
||||||
close_fds_except((int[]){STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO,
|
close_fds_except((int[]){STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO,
|
||||||
session->tmux_socket_fd,
|
session->tmux_socket_fd,
|
||||||
|
@ -1,55 +1,55 @@
|
|||||||
#include "tmate.h"
|
#include "tmate.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
static void on_master_decoder_read(void *userdata, struct tmate_unpacker *uk)
|
static void on_proxy_decoder_read(void *userdata, struct tmate_unpacker *uk)
|
||||||
{
|
{
|
||||||
struct tmate_session *session = userdata;
|
struct tmate_session *session = userdata;
|
||||||
tmate_dispatch_master_message(session, uk);
|
tmate_dispatch_proxy_message(session, uk);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_master_read(struct bufferevent *bev, void *_session)
|
static void on_proxy_read(struct bufferevent *bev, void *_session)
|
||||||
{
|
{
|
||||||
struct tmate_session *session = _session;
|
struct tmate_session *session = _session;
|
||||||
struct evbuffer *master_in;
|
struct evbuffer *proxy_in;
|
||||||
ssize_t written;
|
ssize_t written;
|
||||||
char *buf;
|
char *buf;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
master_in = bufferevent_get_input(session->bev_master);
|
proxy_in = bufferevent_get_input(session->bev_proxy);
|
||||||
|
|
||||||
while (evbuffer_get_length(master_in)) {
|
while (evbuffer_get_length(proxy_in)) {
|
||||||
tmate_decoder_get_buffer(&session->master_decoder, &buf, &len);
|
tmate_decoder_get_buffer(&session->proxy_decoder, &buf, &len);
|
||||||
|
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
tmate_fatal("No more room in client decoder. Message too big?");
|
tmate_fatal("No more room in client decoder. Message too big?");
|
||||||
|
|
||||||
written = evbuffer_remove(master_in, buf, len);
|
written = evbuffer_remove(proxy_in, buf, len);
|
||||||
if (written < 0)
|
if (written < 0)
|
||||||
tmate_fatal("Cannot read master buffer");
|
tmate_fatal("Cannot read proxy buffer");
|
||||||
|
|
||||||
tmate_decoder_commit(&session->master_decoder, written);
|
tmate_decoder_commit(&session->proxy_decoder, written);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_master_encoder_write(void *userdata, struct evbuffer *buffer)
|
static void on_proxy_encoder_write(void *userdata, struct evbuffer *buffer)
|
||||||
{
|
{
|
||||||
struct tmate_session *session = userdata;
|
struct tmate_session *session = userdata;
|
||||||
struct evbuffer *master_out;
|
struct evbuffer *proxy_out;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
master_out = bufferevent_get_output(session->bev_master);
|
proxy_out = bufferevent_get_output(session->bev_proxy);
|
||||||
|
|
||||||
if (evbuffer_add_buffer(master_out, buffer) < 0)
|
if (evbuffer_add_buffer(proxy_out, buffer) < 0)
|
||||||
tmate_fatal("Cannot write to master buffer");
|
tmate_fatal("Cannot write to proxy buffer");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_master_event(struct bufferevent *bev, short events, void *_session)
|
static void on_proxy_event(struct bufferevent *bev, short events, void *_session)
|
||||||
{
|
{
|
||||||
if (events & BEV_EVENT_EOF)
|
if (events & BEV_EVENT_EOF)
|
||||||
tmate_fatal("Connection to master closed");
|
tmate_fatal("Connection to proxy closed");
|
||||||
|
|
||||||
if (events & BEV_EVENT_ERROR)
|
if (events & BEV_EVENT_ERROR)
|
||||||
tmate_fatal("Connection to master error: %s",
|
tmate_fatal("Connection to proxy error: %s",
|
||||||
evutil_socket_error_to_string(EVUTIL_SOCKET_ERROR()));
|
evutil_socket_error_to_string(EVUTIL_SOCKET_ERROR()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ static void on_daemon_decoder_read(void *userdata, struct tmate_unpacker *uk)
|
|||||||
{
|
{
|
||||||
struct tmate_session *session = userdata;
|
struct tmate_session *session = userdata;
|
||||||
|
|
||||||
tmate_send_master_daemon_msg(session, uk);
|
tmate_send_proxy_daemon_msg(session, uk);
|
||||||
tmate_dispatch_daemon_message(session, uk);
|
tmate_dispatch_daemon_message(session, uk);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,23 +117,23 @@ static void on_daemon_encoder_write(void *userdata, struct evbuffer *buffer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_master(struct tmate_session *session)
|
static void init_proxy(struct tmate_session *session)
|
||||||
{
|
{
|
||||||
/* session->master_fd is already connected */
|
/* session->proxy_fd is already connected */
|
||||||
session->bev_master = bufferevent_socket_new(ev_base, session->master_fd,
|
session->bev_proxy = bufferevent_socket_new(ev_base, session->proxy_fd,
|
||||||
BEV_OPT_CLOSE_ON_FREE);
|
BEV_OPT_CLOSE_ON_FREE);
|
||||||
if (!session->bev_master)
|
if (!session->bev_proxy)
|
||||||
tmate_fatal("Cannot setup socket bufferevent");
|
tmate_fatal("Cannot setup socket bufferevent");
|
||||||
|
|
||||||
bufferevent_setcb(session->bev_master,
|
bufferevent_setcb(session->bev_proxy,
|
||||||
on_master_read, NULL, on_master_event, session);
|
on_proxy_read, NULL, on_proxy_event, session);
|
||||||
bufferevent_enable(session->bev_master, EV_READ | EV_WRITE);
|
bufferevent_enable(session->bev_proxy, EV_READ | EV_WRITE);
|
||||||
|
|
||||||
tmate_encoder_init(&session->master_encoder, on_master_encoder_write, session);
|
tmate_encoder_init(&session->proxy_encoder, on_proxy_encoder_write, session);
|
||||||
tmate_decoder_init(&session->master_decoder, on_master_decoder_read, session);
|
tmate_decoder_init(&session->proxy_decoder, on_proxy_decoder_read, session);
|
||||||
|
|
||||||
tmate_init_master_session(session);
|
tmate_init_proxy_session(session);
|
||||||
tmate_send_master_header(session);
|
tmate_send_proxy_header(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmate_daemon_init(struct tmate_session *session)
|
void tmate_daemon_init(struct tmate_session *session)
|
||||||
@ -149,6 +149,6 @@ void tmate_daemon_init(struct tmate_session *session)
|
|||||||
tmate_encoder_init(&session->daemon_encoder, on_daemon_encoder_write, session);
|
tmate_encoder_init(&session->daemon_encoder, on_daemon_encoder_write, session);
|
||||||
tmate_decoder_init(&session->daemon_decoder, on_daemon_decoder_read, session);
|
tmate_decoder_init(&session->daemon_decoder, on_daemon_decoder_read, session);
|
||||||
|
|
||||||
if (tmate_has_master())
|
if (tmate_has_proxy())
|
||||||
init_master(session);
|
init_proxy(session);
|
||||||
}
|
}
|
||||||
|
@ -305,8 +305,8 @@ void tmate_ssh_server_main(struct tmate_session *session,
|
|||||||
|
|
||||||
setup_signals();
|
setup_signals();
|
||||||
|
|
||||||
if (tmate_has_master())
|
if (tmate_has_proxy())
|
||||||
close(tmate_connect_to_master());
|
close(tmate_connect_to_proxy());
|
||||||
|
|
||||||
bind = prepare_ssh(keys_dir, port);
|
bind = prepare_ssh(keys_dir, port);
|
||||||
|
|
||||||
@ -323,12 +323,12 @@ void tmate_ssh_server_main(struct tmate_session *session,
|
|||||||
tmate_fatal("Error accepting connection: %s", ssh_get_error(bind));
|
tmate_fatal("Error accepting connection: %s", ssh_get_error(bind));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We should die if we can't connect to master. This way the
|
* We should die if we can't connect to proxy. This way the
|
||||||
* tmate daemon will pick another server to work on.
|
* tmate daemon will pick another server to work on.
|
||||||
*/
|
*/
|
||||||
session->master_fd = -1;
|
session->proxy_fd = -1;
|
||||||
if (tmate_has_master())
|
if (tmate_has_proxy())
|
||||||
session->master_fd = tmate_connect_to_master();
|
session->proxy_fd = tmate_connect_to_proxy();
|
||||||
|
|
||||||
if (get_ip(ssh_get_fd(client->session),
|
if (get_ip(ssh_get_fd(client->session),
|
||||||
client->ip_address, sizeof(client->ip_address)) < 0)
|
client->ip_address, sizeof(client->ip_address)) < 0)
|
||||||
@ -341,7 +341,7 @@ void tmate_ssh_server_main(struct tmate_session *session,
|
|||||||
tmate_info("Child spawned pid=%d, ip=%s",
|
tmate_info("Child spawned pid=%d, ip=%s",
|
||||||
pid, client->ip_address);
|
pid, client->ip_address);
|
||||||
ssh_free(client->session);
|
ssh_free(client->session);
|
||||||
close(session->master_fd);
|
close(session->proxy_fd);
|
||||||
} else {
|
} else {
|
||||||
ssh_bind_free(bind);
|
ssh_bind_free(bind);
|
||||||
session->session_token = "init";
|
session->session_token = "init";
|
||||||
|
32
tmate.h
32
tmate.h
@ -166,7 +166,7 @@ extern void tmate_ssh_server_main(struct tmate_session *session,
|
|||||||
|
|
||||||
#define TMATE_SSH_DEFAULT_KEYS_DIR "keys"
|
#define TMATE_SSH_DEFAULT_KEYS_DIR "keys"
|
||||||
|
|
||||||
#define TMATE_DEFAULT_MASTER_PORT 7000
|
#define TMATE_DEFAULT_PROXY_PORT 4002
|
||||||
|
|
||||||
#define TMATE_TOKEN_LEN 25
|
#define TMATE_TOKEN_LEN 25
|
||||||
#define TMATE_WORKDIR "/tmp/tmate"
|
#define TMATE_WORKDIR "/tmp/tmate"
|
||||||
@ -175,8 +175,8 @@ extern void tmate_ssh_server_main(struct tmate_session *session,
|
|||||||
struct tmate_settings {
|
struct tmate_settings {
|
||||||
const char *keys_dir;
|
const char *keys_dir;
|
||||||
int ssh_port;
|
int ssh_port;
|
||||||
const char *master_hostname;
|
const char *proxy_hostname;
|
||||||
int master_port;
|
int proxy_port;
|
||||||
const char *tmate_host;
|
const char *tmate_host;
|
||||||
int log_level;
|
int log_level;
|
||||||
bool use_syslog;
|
bool use_syslog;
|
||||||
@ -196,11 +196,11 @@ struct tmate_session {
|
|||||||
int client_protocol_version;
|
int client_protocol_version;
|
||||||
struct event ev_notify_timer;
|
struct event ev_notify_timer;
|
||||||
|
|
||||||
int master_fd;
|
int proxy_fd;
|
||||||
struct bufferevent *bev_master;
|
struct bufferevent *bev_proxy;
|
||||||
struct tmate_encoder master_encoder;
|
struct tmate_encoder proxy_encoder;
|
||||||
struct tmate_decoder master_decoder;
|
struct tmate_decoder proxy_decoder;
|
||||||
u_int master_sx, master_sy;
|
u_int proxy_sx, proxy_sy;
|
||||||
|
|
||||||
/* only for client-pty */
|
/* only for client-pty */
|
||||||
int pty;
|
int pty;
|
||||||
@ -214,20 +214,20 @@ extern long tmate_get_random_long(void);
|
|||||||
extern void request_server_termination(void);
|
extern void request_server_termination(void);
|
||||||
extern void tmate_spawn_slave(struct tmate_session *session);
|
extern void tmate_spawn_slave(struct tmate_session *session);
|
||||||
|
|
||||||
/* tmate-master.c */
|
/* tmate-proxy.c */
|
||||||
|
|
||||||
extern void tmate_dispatch_master_message(struct tmate_session *session,
|
extern void tmate_dispatch_proxy_message(struct tmate_session *session,
|
||||||
struct tmate_unpacker *uk);
|
struct tmate_unpacker *uk);
|
||||||
|
|
||||||
extern void tmate_send_master_daemon_msg(struct tmate_session *session,
|
extern void tmate_send_proxy_daemon_msg(struct tmate_session *session,
|
||||||
struct tmate_unpacker *uk);
|
struct tmate_unpacker *uk);
|
||||||
extern void tmate_send_master_header(struct tmate_session *session);
|
extern void tmate_send_proxy_header(struct tmate_session *session);
|
||||||
extern void tmate_init_master_session(struct tmate_session *session);
|
extern void tmate_init_proxy_session(struct tmate_session *session);
|
||||||
|
|
||||||
extern int tmate_connect_to_master(void);
|
extern int tmate_connect_to_proxy(void);
|
||||||
static inline bool tmate_has_master(void)
|
static inline bool tmate_has_proxy(void)
|
||||||
{
|
{
|
||||||
return !!tmate_settings->master_hostname;
|
return !!tmate_settings->proxy_hostname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user