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

host name is now an input argument

Closes #7
This commit is contained in:
Paolo Mainardi 2013-11-02 18:02:39 +01:00 committed by Nicolas Viennot
parent be2e8c7c2a
commit aebbf047d2
3 changed files with 19 additions and 11 deletions

View File

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

View File

@ -18,6 +18,8 @@
#include "tmate.h"
int tmate_port = TMATE_DEFAULT_PORT;
char *tmate_host;
struct tmate_encoder *tmate_encoder;
int tmux_socket_fd;
const char *tmate_session_token = "main";
@ -39,7 +41,7 @@ extern int client_connect(char *path, int start_server);
static void usage(void)
{
fprintf(stderr, "usage: tmate-slave [-k keys_dir] [-l logfile] [-p PORT] [-r logfile] [-v]\n");
fprintf(stderr, "usage: tmate-slave [-k keys_dir] [-l logfile] [-p port] [-r logfile] [-h host] [-v]\n");
}
void tmate_reopen_logfile(void)
@ -68,7 +70,7 @@ int main(int argc, char **argv, char **envp)
const char *replay_file = NULL;
#endif
while ((opt = getopt(argc, argv, "p:l:vk:r:")) != -1) {
while ((opt = getopt(argc, argv, "p:l:vk:r:h:")) != -1) {
switch (opt) {
case 'p':
tmate_port = atoi(optarg);
@ -89,12 +91,22 @@ int main(int argc, char **argv, char **envp)
fprintf(stderr, "Record/Replay not enabled\n");
#endif
break;
case 'h':
tmate_host = xstrdup(optarg);
break;
default:
usage();
return 1;
}
}
if (!tmate_host) {
char hostname[255];
if (gethostname(hostname, sizeof(hostname)) < 0)
tmate_fatal("cannot get hostname");
tmate_host = xstrdup(hostname);
}
cmdline = *argv;
cmdline_end = *envp;

View File

@ -21,7 +21,6 @@ do { \
/* tmate-encoder.c */
#define TMATE_LATEST_VERSION "1.8.9"
#define TMATE_DOMAIN "tmate.io"
enum tmate_client_commands {
TMATE_NOTIFY,
@ -163,6 +162,7 @@ extern void tmate_ssh_server_main(const char *keys_dir, int port);
extern int tmate_port;
extern struct tmate_encoder *tmate_encoder;
extern int tmux_socket_fd;
extern char *tmate_host;
extern const char *tmate_session_token;
extern const char *tmate_session_token_ro;