mirror of
https://github.com/tmate-io/tmate-ssh-server.git
synced 2020-11-18 19:53:51 -08:00
Send SSH connection strings over
This commit is contained in:
parent
4a29c99e12
commit
baafe40cbb
@ -101,6 +101,7 @@ static void tmate_header(struct tmate_decoder *decoder,
|
|||||||
{
|
{
|
||||||
char port_arg[16] = {0};
|
char port_arg[16] = {0};
|
||||||
char *client_version = xstrdup("< 1.8.6");
|
char *client_version = xstrdup("< 1.8.6");
|
||||||
|
char tmp[512];
|
||||||
|
|
||||||
decoder->protocol = unpack_int(uk);
|
decoder->protocol = unpack_int(uk);
|
||||||
if (decoder->protocol >= 3) {
|
if (decoder->protocol >= 3) {
|
||||||
@ -111,19 +112,25 @@ static void tmate_header(struct tmate_decoder *decoder,
|
|||||||
tmate_debug("new master, client version: %s, protocol version: %d",
|
tmate_debug("new master, client version: %s, protocol version: %d",
|
||||||
client_version, decoder->protocol);
|
client_version, decoder->protocol);
|
||||||
|
|
||||||
|
#if 0
|
||||||
if (strcmp(client_version, TMATE_LATEST_VERSION))
|
if (strcmp(client_version, TMATE_LATEST_VERSION))
|
||||||
tmate_notify_later(10, "A new version is available, please upgrade :)");
|
tmate_notify_later(10, "A new version is available, please upgrade :)");
|
||||||
|
#endif
|
||||||
|
|
||||||
free(client_version);
|
free(client_version);
|
||||||
|
|
||||||
if (tmate_port != 22)
|
if (tmate_port != 22)
|
||||||
sprintf(port_arg, " -p%d", tmate_port);
|
sprintf(port_arg, " -p%d", tmate_port);
|
||||||
|
|
||||||
tmate_notify("Remote session read only: ssh%s ro-%s@%s (clear your screen if you share this)",
|
sprintf(tmp, "ssh%s ro-%s@%s", port_arg, tmate_session_token_ro, tmate_host);
|
||||||
port_arg, tmate_session_token_ro, tmate_host);
|
tmate_notify("Remote session read only: %s (clear your screen if you share this)", tmp);
|
||||||
|
tmate_send_env("tmate_ssh_ro", tmp);
|
||||||
|
|
||||||
tmate_notify("Remote session: ssh%s %s@%s",
|
sprintf(tmp, "ssh%s %s@%s", port_arg, tmate_session_token, tmate_host);
|
||||||
port_arg, tmate_session_token, tmate_host);
|
tmate_notify("Remote session: %s", tmp);
|
||||||
|
tmate_send_env("tmate_ssh", tmp);
|
||||||
|
|
||||||
|
tmate_send_client_ready();
|
||||||
}
|
}
|
||||||
|
|
||||||
extern u_int next_window_pane_id;
|
extern u_int next_window_pane_id;
|
||||||
|
@ -125,6 +125,26 @@ void tmate_notify_client_left(struct client *c)
|
|||||||
mate_notify_message(c, 0);
|
mate_notify_message(c, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tmate_send_client_ready(void)
|
||||||
|
{
|
||||||
|
if (tmate_decoder && tmate_decoder->protocol < 4)
|
||||||
|
return;
|
||||||
|
|
||||||
|
pack(array, 1);
|
||||||
|
pack(int, TMATE_CLIENT_READY);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tmate_send_env(const char *name, const char *value)
|
||||||
|
{
|
||||||
|
if (tmate_decoder && tmate_decoder->protocol < 4)
|
||||||
|
return;
|
||||||
|
|
||||||
|
pack(array, 3);
|
||||||
|
pack(int, TMATE_CLIENT_ENV);
|
||||||
|
pack(string, name);
|
||||||
|
pack(string, value);
|
||||||
|
}
|
||||||
|
|
||||||
void tmate_client_resize(u_int sx, u_int sy)
|
void tmate_client_resize(u_int sx, u_int sy)
|
||||||
{
|
{
|
||||||
pack(array, 3);
|
pack(array, 3);
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
int tmate_port = TMATE_DEFAULT_PORT;
|
int tmate_port = TMATE_DEFAULT_PORT;
|
||||||
char *tmate_host;
|
char *tmate_host;
|
||||||
|
|
||||||
|
struct tmate_decoder *tmate_decoder;
|
||||||
struct tmate_encoder *tmate_encoder;
|
struct tmate_encoder *tmate_encoder;
|
||||||
int tmux_socket_fd;
|
int tmux_socket_fd;
|
||||||
const char *tmate_session_token = "main";
|
const char *tmate_session_token = "main";
|
||||||
@ -369,6 +370,7 @@ static void tmate_spawn_slave_server(struct tmate_ssh_client *client)
|
|||||||
tmate_encoder_init(&encoder);
|
tmate_encoder_init(&encoder);
|
||||||
tmate_decoder_init(&decoder);
|
tmate_decoder_init(&decoder);
|
||||||
tmate_encoder = &encoder;
|
tmate_encoder = &encoder;
|
||||||
|
tmate_decoder = &decoder;
|
||||||
|
|
||||||
tmate_ssh_client_init(client, &encoder, &decoder);
|
tmate_ssh_client_init(client, &encoder, &decoder);
|
||||||
|
|
||||||
|
7
tmate.h
7
tmate.h
@ -20,13 +20,15 @@ do { \
|
|||||||
|
|
||||||
/* tmate-encoder.c */
|
/* tmate-encoder.c */
|
||||||
|
|
||||||
#define TMATE_LATEST_VERSION "1.8.9"
|
#define TMATE_LATEST_VERSION "1.8.10"
|
||||||
|
|
||||||
enum tmate_client_commands {
|
enum tmate_client_commands {
|
||||||
TMATE_NOTIFY,
|
TMATE_NOTIFY,
|
||||||
TMATE_CLIENT_PANE_KEY,
|
TMATE_CLIENT_PANE_KEY,
|
||||||
TMATE_CLIENT_RESIZE,
|
TMATE_CLIENT_RESIZE,
|
||||||
TMATE_CLIENT_EXEC_CMD,
|
TMATE_CLIENT_EXEC_CMD,
|
||||||
|
TMATE_CLIENT_ENV,
|
||||||
|
TMATE_CLIENT_READY,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct tmate_encoder {
|
struct tmate_encoder {
|
||||||
@ -48,6 +50,8 @@ extern void tmate_client_pane_key(int pane_id, int key);
|
|||||||
extern void tmate_client_cmd(int client_id, const char *cmd);
|
extern void tmate_client_cmd(int client_id, const char *cmd);
|
||||||
extern void tmate_client_set_active_pane(int client_id, int win_idx, int pane_id);
|
extern void tmate_client_set_active_pane(int client_id, int win_idx, int pane_id);
|
||||||
extern int tmate_should_exec_cmd_locally(const struct cmd_entry *cmd);
|
extern int tmate_should_exec_cmd_locally(const struct cmd_entry *cmd);
|
||||||
|
extern void tmate_send_env(const char *name, const char *value);
|
||||||
|
extern void tmate_send_client_ready(void);
|
||||||
|
|
||||||
/* tmate-decoder.c */
|
/* tmate-decoder.c */
|
||||||
|
|
||||||
@ -161,6 +165,7 @@ extern void tmate_ssh_server_main(const char *keys_dir, int port);
|
|||||||
|
|
||||||
extern int tmate_port;
|
extern int tmate_port;
|
||||||
extern struct tmate_encoder *tmate_encoder;
|
extern struct tmate_encoder *tmate_encoder;
|
||||||
|
extern struct tmate_decoder *tmate_decoder;
|
||||||
extern int tmux_socket_fd;
|
extern int tmux_socket_fd;
|
||||||
extern char *tmate_host;
|
extern char *tmate_host;
|
||||||
extern const char *tmate_session_token;
|
extern const char *tmate_session_token;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user