mirror of
https://github.com/tmate-io/tmate.git
synced 2025-06-11 04:06:54 +02:00
update libssh/msgpack APIs
This commit is contained in:
parent
1670d15e8a
commit
f0d60cb1c8
@ -49,11 +49,12 @@ static void unpack_raw(struct tmate_unpacker *uk,
|
|||||||
if (uk->argc == 0)
|
if (uk->argc == 0)
|
||||||
decoder_error();
|
decoder_error();
|
||||||
|
|
||||||
if (uk->argv[0].type != MSGPACK_OBJECT_RAW)
|
if (uk->argv[0].type != MSGPACK_OBJECT_STR &&
|
||||||
|
uk->argv[0].type != MSGPACK_OBJECT_BIN)
|
||||||
decoder_error();
|
decoder_error();
|
||||||
|
|
||||||
*len = uk->argv[0].via.raw.size;
|
*len = uk->argv[0].via.str.size;
|
||||||
*buf = uk->argv[0].via.raw.ptr;
|
*buf = uk->argv[0].via.str.ptr;
|
||||||
|
|
||||||
uk->argv++;
|
uk->argv++;
|
||||||
uk->argc--;
|
uk->argc--;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#define DEFAULT_ENCODER (&tmate_session.encoder)
|
#define DEFAULT_ENCODER (&tmate_session.encoder)
|
||||||
|
|
||||||
static int msgpack_write(void *data, const char *buf, unsigned int len)
|
static int msgpack_write(void *data, const char *buf, size_t len)
|
||||||
{
|
{
|
||||||
struct tmate_encoder *encoder = data;
|
struct tmate_encoder *encoder = data;
|
||||||
|
|
||||||
@ -25,8 +25,8 @@ void tmate_encoder_init(struct tmate_encoder *encoder)
|
|||||||
|
|
||||||
#define msgpack_pack_string(pk, str) do { \
|
#define msgpack_pack_string(pk, str) do { \
|
||||||
int __strlen = strlen(str); \
|
int __strlen = strlen(str); \
|
||||||
msgpack_pack_raw(pk, __strlen); \
|
msgpack_pack_str(pk, __strlen); \
|
||||||
msgpack_pack_raw_body(pk, str, __strlen); \
|
msgpack_pack_str_body(pk, str, __strlen); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#define pack(what, ...) msgpack_pack_##what(&DEFAULT_ENCODER->pk, __VA_ARGS__)
|
#define pack(what, ...) msgpack_pack_##what(&DEFAULT_ENCODER->pk, __VA_ARGS__)
|
||||||
@ -125,8 +125,8 @@ void tmate_pty_data(struct window_pane *wp, const char *buf, size_t len)
|
|||||||
pack(array, 3);
|
pack(array, 3);
|
||||||
pack(int, TMATE_PTY_DATA);
|
pack(int, TMATE_PTY_DATA);
|
||||||
pack(int, wp->id);
|
pack(int, wp->id);
|
||||||
pack(raw, to_write);
|
pack(str, to_write);
|
||||||
pack(raw_body, buf, to_write);
|
pack(str_body, buf, to_write);
|
||||||
|
|
||||||
buf += to_write;
|
buf += to_write;
|
||||||
len -= to_write;
|
len -= to_write;
|
||||||
|
@ -223,7 +223,10 @@ static void on_session_event(struct tmate_ssh_client *client)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case SSH_AUTH_SERVER:
|
case SSH_AUTH_SERVER:
|
||||||
if ((hash_len = ssh_get_pubkey_hash(session, &hash)) < 0) {
|
if (ssh_get_publickey(session, &pubkey) < 0)
|
||||||
|
tmate_fatal("ssh_get_publickey");
|
||||||
|
|
||||||
|
if (ssh_get_publickey_hash(pubkey, SSH_PUBLICKEY_HASH_MD5, &hash, &hash_len) < 0) {
|
||||||
kill_session(client, "Cannot authenticate server");
|
kill_session(client, "Cannot authenticate server");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -232,9 +235,6 @@ static void on_session_event(struct tmate_ssh_client *client)
|
|||||||
if (!hash_str)
|
if (!hash_str)
|
||||||
tmate_fatal("malloc failed");
|
tmate_fatal("malloc failed");
|
||||||
|
|
||||||
if (ssh_get_publickey(session, &pubkey) < 0)
|
|
||||||
tmate_fatal("ssh_get_publickey");
|
|
||||||
|
|
||||||
key_type = ssh_key_type(pubkey);
|
key_type = ssh_key_type(pubkey);
|
||||||
|
|
||||||
switch (key_type) {
|
switch (key_type) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user