mirror of
https://github.com/tmate-io/tmate-ssh-server.git
synced 2020-11-18 19:53:51 -08:00
List client command.
This commit is contained in:
parent
98e7e79e4c
commit
25e94a0526
8
CHANGES
8
CHANGES
@ -1,3 +1,9 @@
|
|||||||
|
23 October 2007
|
||||||
|
|
||||||
|
* (nicm) Show size in session/window lists.
|
||||||
|
* (nicm) Pass tty up to server when client identifies and add a list-clients
|
||||||
|
command to list connected clients.
|
||||||
|
|
||||||
20 October 2007
|
20 October 2007
|
||||||
|
|
||||||
* (nicm) Add default-command option and change default to be $SHELL rather than
|
* (nicm) Add default-command option and change default to be $SHELL rather than
|
||||||
@ -144,5 +150,5 @@
|
|||||||
(including mutt, emacs). No status bar yet and no key remapping or other
|
(including mutt, emacs). No status bar yet and no key remapping or other
|
||||||
customisation.
|
customisation.
|
||||||
|
|
||||||
$Id: CHANGES,v 1.46 2007-10-20 09:57:08 nicm Exp $
|
$Id: CHANGES,v 1.47 2007-10-23 09:36:19 nicm Exp $
|
||||||
|
|
||||||
|
4
Makefile
4
Makefile
@ -1,4 +1,4 @@
|
|||||||
# $Id: Makefile,v 1.29 2007-10-19 20:47:09 nicm Exp $
|
# $Id: Makefile,v 1.30 2007-10-23 09:36:19 nicm Exp $
|
||||||
|
|
||||||
.SUFFIXES: .c .o .y .h
|
.SUFFIXES: .c .o .y .h
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
@ -23,7 +23,7 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \
|
|||||||
cmd-unbind-key.c cmd-previous-window.c cmd-last-window.c cmd-list-keys.c \
|
cmd-unbind-key.c cmd-previous-window.c cmd-last-window.c cmd-list-keys.c \
|
||||||
cmd-set-option.c cmd-rename-window.c cmd-select-window.c \
|
cmd-set-option.c cmd-rename-window.c cmd-select-window.c \
|
||||||
cmd-list-windows.c cmd-attach-session.c cmd-send-prefix.c \
|
cmd-list-windows.c cmd-attach-session.c cmd-send-prefix.c \
|
||||||
cmd-refresh-session.c cmd-kill-window.c
|
cmd-refresh-session.c cmd-kill-window.c cmd-list-clients.c
|
||||||
|
|
||||||
YACC= yacc -d
|
YACC= yacc -d
|
||||||
|
|
||||||
|
4
TODO
4
TODO
@ -34,7 +34,6 @@
|
|||||||
- CLIENT_HOLD sucks
|
- CLIENT_HOLD sucks
|
||||||
- session with CMD_NOSESSION should be an error
|
- session with CMD_NOSESSION should be an error
|
||||||
- each command should have a print op as well for list keys
|
- each command should have a print op as well for list keys
|
||||||
- get rid of MAXNAMELEN limits (sessid)
|
|
||||||
- List available commands on ambigous command
|
- List available commands on ambigous command
|
||||||
- Implicitly add exec to the commands for new windows (switch to disable it)
|
- Implicitly add exec to the commands for new windows (switch to disable it)
|
||||||
- nested sessions, ie session as window - moving to it moves into session
|
- nested sessions, ie session as window - moving to it moves into session
|
||||||
@ -44,9 +43,11 @@
|
|||||||
kill-window to limit accidental presses
|
kill-window to limit accidental presses
|
||||||
- status-fg/status-bg should be to set attributes: bold, etc
|
- status-fg/status-bg should be to set attributes: bold, etc
|
||||||
- show-options command
|
- show-options command
|
||||||
|
- fix resize(1)
|
||||||
|
|
||||||
-- For 0.1 --------------------------------------------------------------------
|
-- For 0.1 --------------------------------------------------------------------
|
||||||
- man page
|
- man page
|
||||||
|
- get rid of MAXNAMELEN limits (sessid)
|
||||||
- commands:
|
- commands:
|
||||||
list clients (session, window, tty?)
|
list clients (session, window, tty?)
|
||||||
rename sessions
|
rename sessions
|
||||||
@ -54,7 +55,6 @@
|
|||||||
link/copy windows
|
link/copy windows
|
||||||
unlink window (error if window only linked to one session)
|
unlink window (error if window only linked to one session)
|
||||||
kill session (no not bind by default)
|
kill session (no not bind by default)
|
||||||
set shell -- default-command (don't forget to rm -l)
|
|
||||||
- check for some reqd terminfo caps on startup
|
- check for some reqd terminfo caps on startup
|
||||||
|
|
||||||
-- For 0.2 --------------------------------------------------------------------
|
-- For 0.2 --------------------------------------------------------------------
|
||||||
|
4
client.c
4
client.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: client.c,v 1.15 2007-10-22 13:16:36 nicm Exp $ */
|
/* $Id: client.c,v 1.16 2007-10-23 09:36:19 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -115,6 +115,8 @@ retry:
|
|||||||
|
|
||||||
data.sx = ws.ws_col;
|
data.sx = ws.ws_col;
|
||||||
data.sy = ws.ws_row;
|
data.sy = ws.ws_row;
|
||||||
|
if (ttyname_r(STDIN_FILENO, data.tty, sizeof data.tty) != 0)
|
||||||
|
fatal("ttyname_r failed");
|
||||||
client_write_server(cctx, MSG_IDENTIFY, &data, sizeof data);
|
client_write_server(cctx, MSG_IDENTIFY, &data, sizeof data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
60
cmd-list-clients.c
Normal file
60
cmd-list-clients.c
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/* $Id: cmd-list-clients.c,v 1.1 2007-10-23 09:36:19 nicm Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <getopt.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#include "tmux.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* List all clients.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void cmd_list_clients_exec(void *, struct cmd_ctx *);
|
||||||
|
|
||||||
|
const struct cmd_entry cmd_list_clients_entry = {
|
||||||
|
"list-clients", "lsc", "",
|
||||||
|
CMD_NOSESSION,
|
||||||
|
NULL,
|
||||||
|
cmd_list_clients_exec,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_list_clients_exec(unused void *ptr, struct cmd_ctx *ctx)
|
||||||
|
{
|
||||||
|
struct client *c;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
|
c = ARRAY_ITEM(&clients, i);
|
||||||
|
if (c == NULL || c->session == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
ctx->print(ctx,
|
||||||
|
"%s: %s [%ux%u]", c->tty, c->session->name, c->sx, c->sy);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(ctx->flags & CMD_KEY))
|
||||||
|
server_write_client(ctx->client, MSG_EXIT, NULL, 0);
|
||||||
|
}
|
3
cmd.c
3
cmd.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd.c,v 1.18 2007-10-19 11:10:35 nicm Exp $ */
|
/* $Id: cmd.c,v 1.19 2007-10-23 09:36:19 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -29,6 +29,7 @@ const struct cmd_entry *cmd_table[] = {
|
|||||||
&cmd_detach_session_entry,
|
&cmd_detach_session_entry,
|
||||||
&cmd_kill_window_entry,
|
&cmd_kill_window_entry,
|
||||||
&cmd_last_window_entry,
|
&cmd_last_window_entry,
|
||||||
|
&cmd_list_clients_entry,
|
||||||
&cmd_list_keys_entry,
|
&cmd_list_keys_entry,
|
||||||
&cmd_list_sessions_entry,
|
&cmd_list_sessions_entry,
|
||||||
&cmd_list_windows_entry,
|
&cmd_list_windows_entry,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: server-msg.c,v 1.27 2007-10-12 17:50:33 nicm Exp $ */
|
/* $Id: server-msg.c,v 1.28 2007-10-23 09:36:19 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -160,6 +160,9 @@ server_msg_fn_identify(struct hdr *hdr, struct client *c)
|
|||||||
c->sx = data.sx;
|
c->sx = data.sx;
|
||||||
c->sy = data.sy;
|
c->sy = data.sy;
|
||||||
|
|
||||||
|
data.tty[(sizeof data.tty) - 1] = '\0';
|
||||||
|
c->tty = xstrdup(data.tty);
|
||||||
|
|
||||||
c->flags |= CLIENT_TERMINAL;
|
c->flags |= CLIENT_TERMINAL;
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
4
server.c
4
server.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: server.c,v 1.29 2007-10-19 20:47:09 nicm Exp $ */
|
/* $Id: server.c,v 1.30 2007-10-23 09:36:19 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -309,6 +309,8 @@ server_lost_client(struct client *c)
|
|||||||
ARRAY_SET(&clients, i, NULL);
|
ARRAY_SET(&clients, i, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (c->tty != NULL)
|
||||||
|
xfree(c->tty);
|
||||||
close(c->fd);
|
close(c->fd);
|
||||||
buffer_destroy(c->in);
|
buffer_destroy(c->in);
|
||||||
buffer_destroy(c->out);
|
buffer_destroy(c->out);
|
||||||
|
7
tmux.h
7
tmux.h
@ -1,4 +1,4 @@
|
|||||||
/* $Id: tmux.h,v 1.62 2007-10-19 20:36:08 nicm Exp $ */
|
/* $Id: tmux.h,v 1.63 2007-10-23 09:36:19 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -297,6 +297,8 @@ struct msg_command_data {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct msg_identify_data {
|
struct msg_identify_data {
|
||||||
|
char tty[TTY_NAME_MAX];
|
||||||
|
|
||||||
u_int sx;
|
u_int sx;
|
||||||
u_int sy;
|
u_int sy;
|
||||||
};
|
};
|
||||||
@ -426,6 +428,8 @@ ARRAY_DECL(sessions, struct session *);
|
|||||||
|
|
||||||
/* Client connection. */
|
/* Client connection. */
|
||||||
struct client {
|
struct client {
|
||||||
|
char *tty;
|
||||||
|
|
||||||
int fd;
|
int fd;
|
||||||
struct buffer *in;
|
struct buffer *in;
|
||||||
struct buffer *out;
|
struct buffer *out;
|
||||||
@ -529,6 +533,7 @@ extern const struct cmd_entry cmd_bind_key_entry;
|
|||||||
extern const struct cmd_entry cmd_detach_session_entry;
|
extern const struct cmd_entry cmd_detach_session_entry;
|
||||||
extern const struct cmd_entry cmd_kill_window_entry;
|
extern const struct cmd_entry cmd_kill_window_entry;
|
||||||
extern const struct cmd_entry cmd_last_window_entry;
|
extern const struct cmd_entry cmd_last_window_entry;
|
||||||
|
extern const struct cmd_entry cmd_list_clients_entry;
|
||||||
extern const struct cmd_entry cmd_list_keys_entry;
|
extern const struct cmd_entry cmd_list_keys_entry;
|
||||||
extern const struct cmd_entry cmd_list_sessions_entry;
|
extern const struct cmd_entry cmd_list_sessions_entry;
|
||||||
extern const struct cmd_entry cmd_list_windows_entry;
|
extern const struct cmd_entry cmd_list_windows_entry;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user