1
0
mirror of https://github.com/tmate-io/tmate-ssh-server.git synced 2020-11-18 19:53:51 -08:00

Add port argument in the connection command

This commit is contained in:
Nicolas Viennot 2013-11-01 13:43:40 -04:00
parent 3df24cda34
commit 4bd26896f8
3 changed files with 12 additions and 7 deletions

View File

@ -100,6 +100,7 @@ static void tmate_header(struct tmate_decoder *decoder,
struct tmate_unpacker *uk) struct tmate_unpacker *uk)
{ {
char hostname[128]; char hostname[128];
char port_arg[16] = {0};
char *client_version = xstrdup("< 1.8.6"); char *client_version = xstrdup("< 1.8.6");
decoder->protocol = unpack_int(uk); decoder->protocol = unpack_int(uk);
@ -119,11 +120,14 @@ static void tmate_header(struct tmate_decoder *decoder,
if (gethostname(hostname, sizeof(hostname)) < 0) if (gethostname(hostname, sizeof(hostname)) < 0)
tmate_fatal("cannot get hostname"); tmate_fatal("cannot get hostname");
tmate_notify("Remote session read only: ssh ro-%s@%s.%s (clear your screen if you share this)", if (tmate_port != 22)
tmate_session_token_ro, hostname, TMATE_DOMAIN); sprintf(port_arg, " -p%d", tmate_port);
tmate_notify("Remote session: ssh %s@%s.%s", tmate_notify("Remote session read only: ssh%s ro-%s@%s.%s (clear your screen if you share this)",
tmate_session_token, hostname, TMATE_DOMAIN); port_arg, tmate_session_token_ro, hostname, TMATE_DOMAIN);
tmate_notify("Remote session: ssh%s %s@%s.%s",
port_arg, tmate_session_token, hostname, TMATE_DOMAIN);
} }
extern u_int next_window_pane_id; extern u_int next_window_pane_id;

View File

@ -17,6 +17,7 @@
#include <fcntl.h> #include <fcntl.h>
#include "tmate.h" #include "tmate.h"
int tmate_port = TMATE_DEFAULT_PORT;
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";
@ -62,7 +63,6 @@ long tmate_get_random_long(void)
int main(int argc, char **argv, char **envp) int main(int argc, char **argv, char **envp)
{ {
int opt; int opt;
int port = TMATE_DEFAULT_PORT;
const char *keys_dir = "keys"; const char *keys_dir = "keys";
#ifdef TMATE_RECORD_REPLAY #ifdef TMATE_RECORD_REPLAY
const char *replay_file = NULL; const char *replay_file = NULL;
@ -71,7 +71,7 @@ int main(int argc, char **argv, char **envp)
while ((opt = getopt(argc, argv, "p:l:vk:r:")) != -1) { while ((opt = getopt(argc, argv, "p:l:vk:r:")) != -1) {
switch (opt) { switch (opt) {
case 'p': case 'p':
port = atoi(optarg); tmate_port = atoi(optarg);
break; break;
case 'l': case 'l':
log_path = optarg; log_path = optarg;
@ -117,7 +117,7 @@ int main(int argc, char **argv, char **envp)
(mkdir(TMATE_WORKDIR "/jail", 0700) < 0 && errno != EEXIST)) (mkdir(TMATE_WORKDIR "/jail", 0700) < 0 && errno != EEXIST))
tmate_fatal("Cannot prepare session in " TMATE_WORKDIR); tmate_fatal("Cannot prepare session in " TMATE_WORKDIR);
tmate_ssh_server_main(keys_dir, port); tmate_ssh_server_main(keys_dir, tmate_port);
return 0; return 0;
} }

View File

@ -160,6 +160,7 @@ extern void tmate_ssh_server_main(const char *keys_dir, int port);
#define TMATE_WORKDIR "/tmp/tmate" #define TMATE_WORKDIR "/tmp/tmate"
#define TMATE_JAIL_USER "nobody" #define TMATE_JAIL_USER "nobody"
extern int tmate_port;
extern struct tmate_encoder *tmate_encoder; extern struct tmate_encoder *tmate_encoder;
extern int tmux_socket_fd; extern int tmux_socket_fd;
extern const char *tmate_session_token; extern const char *tmate_session_token;