Commit 5c1da6c9 authored by vvaltman's avatar vvaltman

fixes

parent 337be909
...@@ -173,80 +173,63 @@ int fetch_comb_binlog_new_user (void *extra) { ...@@ -173,80 +173,63 @@ int fetch_comb_binlog_new_user (void *extra) {
return 0; return 0;
} }
int fetch_comb_binlog_new_user (void *extra) { int fetch_comb_binlog_user_delete (void *extra) {
peer_id_t id = MK_USER (fetch_int ()); peer_id_t id = MK_USER (fetch_int ());
peer_t *U = user_chat_get (id); peer_t *U = user_chat_get (id);
assert (U); assert (U);
U->flags |= FLAG_DELETED; U->flags |= FLAG_DELETED;
#ifdef USE_LUA #ifdef USE_LUA
lua_user_update (U); lua_user_update (&U->user);
#endif #endif
return 0; return 0;
} }
FETCH_COMBINATOR_FUNCTION (binlog_start) int fetch_comb_binlog_set_user_access_token (void *extra) {
FETCH_COMBINATOR_FUNCTION (binlog_dc_option) peer_id_t id = MK_USER (fetch_int ());
FETCH_COMBINATOR_FUNCTION (binlog_auth_key)
FETCH_COMBINATOR_FUNCTION (binlog_default_dc)
FETCH_COMBINATOR_FUNCTION (binlog_our_id)
FETCH_COMBINATOR_FUNCTION (binlog_dc_signed)
FETCH_COMBINATOR_FUNCTION (binlog_dc_salt)
FETCH_COMBINATOR_FUNCTION (binlog_new_user)
FETCH_COMBINATOR_FUNCTION (binlog_user_delete)
void replay_log_event (void) {
int *start = rptr;
in_replay_log = 1;
assert (rptr < wptr);
int op = *rptr;
if (verbosity >= 2) {
logprintf ("log_pos %lld, op 0x%08x\n", binlog_pos, op);
}
in_ptr = rptr;
in_end = wptr;
switch (op) {
case CODE_binlog_set_user_access_token:
rptr ++;
{
peer_id_t id = MK_USER (*(rptr ++));
peer_t *U = user_chat_get (id); peer_t *U = user_chat_get (id);
assert (U); assert (U);
U->user.access_hash = *(long long *)rptr; U->user.access_hash = fetch_long ();
rptr += 2;
} #ifdef USE_LUA
break; lua_user_update (&U->user);
case CODE_binlog_set_user_phone: #endif
in_ptr ++; return 0;
{ }
int fetch_comb_binlog_set_user_phone (void *extra) {
peer_id_t id = MK_USER (fetch_int ()); peer_id_t id = MK_USER (fetch_int ());
peer_t *U = user_chat_get (id); peer_t *U = user_chat_get (id);
assert (U); assert (U);
if (U->user.phone) { tfree_str (U->user.phone); } if (U->user.phone) {
tfree_str (U->user.phone);
}
U->user.phone = fetch_str_dup (); U->user.phone = fetch_str_dup ();
#ifdef USE_LUA #ifdef USE_LUA
lua_user_update (&U->user); lua_user_update (&U->user);
#endif #endif
} return 0;
rptr = in_ptr; }
break;
case CODE_binlog_set_user_friend: int fetch_comb_binlog_set_user_friend (void *extra) {
rptr ++; peer_id_t id = MK_USER (fetch_int ());
{
peer_id_t id = MK_USER (*(rptr ++));
peer_t *U = user_chat_get (id); peer_t *U = user_chat_get (id);
assert (U); assert (U);
int friend = *(rptr ++); if (U->user.phone) {
tfree_str (U->user.phone);
}
int friend = fetch_int ();
if (friend) { U->flags |= FLAG_USER_CONTACT; } if (friend) { U->flags |= FLAG_USER_CONTACT; }
else { U->flags &= ~FLAG_USER_CONTACT; } else { U->flags &= ~FLAG_USER_CONTACT; }
}
break; #ifdef USE_LUA
case CODE_binlog_user_full_photo: lua_user_update (&U->user);
in_ptr ++; #endif
{ return 0;
}
int fetch_comb_binlog_user_full_photo (void *extra) {
peer_id_t id = MK_USER (fetch_int ()); peer_id_t id = MK_USER (fetch_int ());
peer_t *U = user_chat_get (id); peer_t *U = user_chat_get (id);
assert (U); assert (U);
...@@ -254,24 +237,31 @@ void replay_log_event (void) { ...@@ -254,24 +237,31 @@ void replay_log_event (void) {
free_photo (&U->user.photo); free_photo (&U->user.photo);
} }
fetch_photo (&U->user.photo); fetch_photo (&U->user.photo);
}
rptr = in_ptr; #ifdef USE_LUA
break; lua_user_update (&U->user);
case CODE_binlog_user_blocked: #endif
rptr ++; return 0;
{ }
peer_id_t id = MK_USER (*(rptr ++));
int fetch_comb_binlog_user_blocked (void *extra) {
peer_id_t id = MK_USER (fetch_int ());
peer_t *U = user_chat_get (id); peer_t *U = user_chat_get (id);
assert (U); assert (U);
U->user.blocked = *(rptr ++);
} U->user.blocked = fetch_int ();
break;
case CODE_binlog_set_user_full_name: #ifdef USE_LUA
in_ptr ++; lua_user_update (&U->user);
{ #endif
return 0;
}
int fetch_comb_binlog_set_user_full_name (void *extra) {
peer_id_t id = MK_USER (fetch_int ()); peer_id_t id = MK_USER (fetch_int ());
peer_t *U = user_chat_get (id); peer_t *U = user_chat_get (id);
assert (U); assert (U);
if (U->user.real_first_name) { tfree_str (U->user.real_first_name); } if (U->user.real_first_name) { tfree_str (U->user.real_first_name); }
if (U->user.real_last_name) { tfree_str (U->user.real_last_name); } if (U->user.real_last_name) { tfree_str (U->user.real_last_name); }
U->user.real_first_name = fetch_str_dup (); U->user.real_first_name = fetch_str_dup ();
...@@ -280,13 +270,11 @@ void replay_log_event (void) { ...@@ -280,13 +270,11 @@ void replay_log_event (void) {
#ifdef USE_LUA #ifdef USE_LUA
lua_user_update (&U->user); lua_user_update (&U->user);
#endif #endif
} return 0;
rptr = in_ptr; }
break;
case CODE_binlog_encr_chat_delete: int fetch_comb_binlog_encr_chat_delete (void *extra) {
rptr ++; peer_id_t id = MK_ENCR_CHAT (fetch_int ());
{
peer_id_t id = MK_ENCR_CHAT (*(rptr ++));
peer_t *_U = user_chat_get (id); peer_t *_U = user_chat_get (id);
assert (_U); assert (_U);
struct secret_chat *U = &_U->encr_chat; struct secret_chat *U = &_U->encr_chat;
...@@ -301,12 +289,15 @@ void replay_log_event (void) { ...@@ -301,12 +289,15 @@ void replay_log_event (void) {
tfree_secure (U->g_key, 256); tfree_secure (U->g_key, 256);
U->g_key = 0; U->g_key = 0;
} }
}
break; #ifdef USE_LUA
case CODE_binlog_encr_chat_requested: lua_secret_chat_update (U);
rptr ++; #endif
{ return 0;
peer_id_t id = MK_ENCR_CHAT (*(rptr ++)); }
int fetch_comb_binlog_encr_chat_requested (void *extra) {
peer_id_t id = MK_ENCR_CHAT (fetch_int ());
peer_t *_U = user_chat_get (id); peer_t *_U = user_chat_get (id);
if (!_U) { if (!_U) {
_U = talloc0 (sizeof (*_U)); _U = talloc0 (sizeof (*_U));
...@@ -316,11 +307,10 @@ void replay_log_event (void) { ...@@ -316,11 +307,10 @@ void replay_log_event (void) {
assert (!(_U->flags & FLAG_CREATED)); assert (!(_U->flags & FLAG_CREATED));
} }
struct secret_chat *U = (void *)_U; struct secret_chat *U = (void *)_U;
U->access_hash = *(long long *)rptr; U->access_hash = fetch_long ();
rptr += 2; U->date = fetch_int ();
U->date = *(rptr ++); U->admin_id = fetch_int ();
U->admin_id = *(rptr ++); U->user_id = fetch_int ();
U->user_id = *(rptr ++);
peer_t *Us = user_chat_get (MK_USER (U->user_id)); peer_t *Us = user_chat_get (MK_USER (U->user_id));
assert (!U->print_name); assert (!U->print_name);
...@@ -334,47 +324,56 @@ void replay_log_event (void) { ...@@ -334,47 +324,56 @@ void replay_log_event (void) {
peer_insert_name ((void *)U); peer_insert_name ((void *)U);
U->g_key = talloc (256); U->g_key = talloc (256);
U->nonce = talloc (256); U->nonce = talloc (256);
memcpy (U->g_key, rptr, 256); fetch_ints (U->g_key, 64);
rptr += 64; fetch_ints (U->nonce, 64);
memcpy (U->nonce, rptr, 256);
rptr += 64;
U->flags |= FLAG_CREATED; U->flags |= FLAG_CREATED;
U->state = sc_request; U->state = sc_request;
}
break; #ifdef USE_LUA
case CODE_binlog_set_encr_chat_access_hash: lua_secret_chat_update (U);
rptr ++; #endif
{ return 0;
peer_id_t id = MK_ENCR_CHAT (*(rptr ++)); }
int fetch_comb_binlog_set_encr_chat_access_hash (void *extra) {
peer_id_t id = MK_ENCR_CHAT (fetch_int ());
peer_t *U = user_chat_get (id); peer_t *U = user_chat_get (id);
assert (U); assert (U);
U->encr_chat.access_hash = *(long long *)rptr; U->encr_chat.access_hash = fetch_long ();
rptr += 2;
} #ifdef USE_LUA
break; lua_secret_chat_update (&U->encr_chat);
case CODE_binlog_set_encr_chat_date: #endif
rptr ++; return 0;
{ }
peer_id_t id = MK_ENCR_CHAT (*(rptr ++));
int fetch_comb_binlog_set_encr_chat_date (void *extra) {
peer_id_t id = MK_ENCR_CHAT (fetch_int ());
peer_t *U = user_chat_get (id); peer_t *U = user_chat_get (id);
assert (U); assert (U);
U->encr_chat.date = *(rptr ++); U->encr_chat.date = fetch_int ();
}
break; #ifdef USE_LUA
case CODE_binlog_set_encr_chat_state: lua_secret_chat_update (&U->encr_chat);
rptr ++; #endif
{ return 0;
peer_id_t id = MK_ENCR_CHAT (*(rptr ++)); }
int fetch_comb_binlog_set_encr_chat_state (void *extra) {
peer_id_t id = MK_ENCR_CHAT (fetch_int ());
peer_t *U = user_chat_get (id); peer_t *U = user_chat_get (id);
assert (U); assert (U);
U->encr_chat.state = *(rptr ++); U->encr_chat.state = fetch_int ();
}
break; #ifdef USE_LUA
case CODE_binlog_encr_chat_accepted: lua_secret_chat_update (&U->encr_chat);
rptr ++; #endif
{ return 0;
peer_id_t id = MK_ENCR_CHAT (*(rptr ++)); }
int fetch_comb_binlog_encr_chat_accepted (void *extra) {
peer_id_t id = MK_ENCR_CHAT (fetch_int ());
peer_t *_U = user_chat_get (id); peer_t *_U = user_chat_get (id);
assert (_U); assert (_U);
struct secret_chat *U = &_U->encr_chat; struct secret_chat *U = &_U->encr_chat;
...@@ -384,42 +383,106 @@ void replay_log_event (void) { ...@@ -384,42 +383,106 @@ void replay_log_event (void) {
if (!U->nonce) { if (!U->nonce) {
U->nonce = talloc (256); U->nonce = talloc (256);
} }
memcpy (U->g_key, rptr, 256);
rptr += 64; fetch_ints (U->g_key, 256);
memcpy (U->nonce, rptr, 256); fetch_ints (U->nonce, 256);
rptr += 64; U->key_fingerprint = fetch_long ();
U->key_fingerprint = *(long long *)rptr;
rptr += 2;
if (U->state == sc_waiting) { if (U->state == sc_waiting) {
do_create_keys_end (U); do_create_keys_end (U);
} }
U->state = sc_ok; U->state = sc_ok;
}
break; #ifdef USE_LUA
case CODE_binlog_set_encr_chat_key: lua_secret_chat_update (U);
rptr ++; #endif
{ return 0;
peer_id_t id = MK_ENCR_CHAT (*(rptr ++)); }
int fetch_comb_binlog_set_encr_chat_key (void *extra) {
peer_id_t id = MK_ENCR_CHAT (fetch_int ());
peer_t *_U = user_chat_get (id); peer_t *_U = user_chat_get (id);
assert (_U); assert (_U);
struct secret_chat *U = &_U->encr_chat; struct secret_chat *U = &_U->encr_chat;
memcpy (U->key, rptr, 256); fetch_ints (U->key, 64);
rptr += 64; U->key_fingerprint = fetch_long ();
U->key_fingerprint = *(long long *)rptr;
rptr += 2; #ifdef USE_LUA
} lua_secret_chat_update (U);
break; #endif
case CODE_binlog_set_dh_params: return 0;
rptr ++; }
{
int fetch_comb_binlog_set_dh_params (void *extra) {
if (encr_prime) { tfree (encr_prime, 256); } if (encr_prime) { tfree (encr_prime, 256); }
encr_root = *(rptr ++); encr_root = fetch_int ();
encr_prime = talloc (256); encr_prime = talloc (256);
memcpy (encr_prime, rptr, 256); fetch_ints (encr_prime, 64);
rptr += 64; encr_param_version = fetch_int ();
encr_param_version = *(rptr ++);
return 0;
}
int fetch_comb_binlog_encr_chat_init (void *extra) {
peer_t *P = talloc0 (sizeof (*P));
P->id = MK_ENCR_CHAT (fetch_int ());
assert (!user_chat_get (P->id));
P->encr_chat.user_id = fetch_int ();
P->encr_chat.admin_id = our_id;
insert_encrypted_chat (P);
peer_t *Us = user_chat_get (MK_USER (P->encr_chat.user_id));
assert (Us);
P->print_name = create_print_name (P->id, "!", Us->user.first_name, Us->user.last_name, 0);
peer_insert_name (P);
fetch_ints (P->encr_chat.key, 64);
fetch_ints (P->encr_chat.g_key, 64);
P->flags |= FLAG_CREATED;
#ifdef USE_LUA
lua_secret_chat_update (U);
#endif
return 0;
}
FETCH_COMBINATOR_FUNCTION (binlog_start)
FETCH_COMBINATOR_FUNCTION (binlog_dc_option)
FETCH_COMBINATOR_FUNCTION (binlog_auth_key)
FETCH_COMBINATOR_FUNCTION (binlog_default_dc)
FETCH_COMBINATOR_FUNCTION (binlog_our_id)
FETCH_COMBINATOR_FUNCTION (binlog_dc_signed)
FETCH_COMBINATOR_FUNCTION (binlog_dc_salt)
FETCH_COMBINATOR_FUNCTION (binlog_new_user)
FETCH_COMBINATOR_FUNCTION (binlog_user_delete)
FETCH_COMBINATOR_FUNCTION (binlog_set_user_access_token)
FETCH_COMBINATOR_FUNCTION (binlog_set_user_phone)
FETCH_COMBINATOR_FUNCTION (binlog_set_user_friend)
FETCH_COMBINATOR_FUNCTION (binlog_user_full_photo)
FETCH_COMBINATOR_FUNCTION (binlog_user_blocked)
FETCH_COMBINATOR_FUNCTION (binlog_set_user_full_name)
FETCH_COMBINATOR_FUNCTION (binlog_encr_chat_delete)
FETCH_COMBINATOR_FUNCTION (binlog_encr_chat_requested)
FETCH_COMBINATOR_FUNCTION (binlog_set_encr_chat_access_hash)
FETCH_COMBINATOR_FUNCTION (binlog_set_encr_chat_date)
FETCH_COMBINATOR_FUNCTION (binlog_set_encr_chat_state)
FETCH_COMBINATOR_FUNCTION (binlog_encr_chat_accepted)
FETCH_COMBINATOR_FUNCTION (binlog_set_encr_chat_key)
FETCH_COMBINATOR_FUNCTION (binlog_set_dh_params)
FETCH_COMBINATOR_FUNCTION (binlog_encr_chat_init)
void replay_log_event (void) {
int *start = rptr;
in_replay_log = 1;
assert (rptr < wptr);
int op = *rptr;
if (verbosity >= 2) {
logprintf ("log_pos %lld, op 0x%08x\n", binlog_pos, op);
} }
break;
in_ptr = rptr;
in_end = wptr;
switch (op) {
case CODE_binlog_encr_chat_init: case CODE_binlog_encr_chat_init:
rptr ++; rptr ++;
{ {
......
...@@ -36,22 +36,7 @@ ...@@ -36,22 +36,7 @@
#define LOG_ENCR_CHAT_REQUESTED 0x9011011a #define LOG_ENCR_CHAT_REQUESTED 0x9011011a
#define LOG_ENCR_CHAT_OK 0x7612ce13 #define LOG_ENCR_CHAT_OK 0x7612ce13
#define CODE_binlog_user_delete 0xf7a27c79
#define CODE_binlog_set_user_access_token 0x1349f615
#define CODE_binlog_set_user_phone 0x5d3afde2
#define CODE_binlog_set_user_friend 0x75a7ec5a
#define CODE_binlog_dc_option 0x08c0ef19 #define CODE_binlog_dc_option 0x08c0ef19
#define CODE_binlog_user_full_photo 0xfaa35824
#define CODE_binlog_user_blocked 0xb2dea7cd
#define CODE_binlog_set_user_full_name 0x4ceb4cf0
#define CODE_binlog_encr_chat_delete 0xb9d33f87
#define CODE_binlog_encr_chat_requested 0xf57d1ea2
#define CODE_binlog_set_encr_chat_access_hash 0xe5612bb3
#define CODE_binlog_set_encr_chat_date 0x54f16911
#define CODE_binlog_set_encr_chat_state 0x76a6e45b
#define CODE_binlog_encr_chat_accepted 0x4627e926
#define CODE_binlog_set_encr_chat_key 0x179df2d4
#define CODE_binlog_set_dh_params 0x20ba46bc
#define CODE_binlog_encr_chat_init 0x939cd1c7 #define CODE_binlog_encr_chat_init 0x939cd1c7
#define CODE_binlog_set_pts 0x844e4c1c #define CODE_binlog_set_pts 0x844e4c1c
#define CODE_binlog_set_qts 0x3cf22b79 #define CODE_binlog_set_qts 0x3cf22b79
......
...@@ -7,5 +7,23 @@ binlog.ourId id:int = binlog.Update; ...@@ -7,5 +7,23 @@ binlog.ourId id:int = binlog.Update;
binlog.dcSigned id:int = binlog.Update; binlog.dcSigned id:int = binlog.Update;
binlog.dcSalt id:int salt:long = binlog.Update; binlog.dcSalt id:int salt:long = binlog.Update;
binlog.setDhParams root:int prime:64*[int] version:int = binlog.Update;
binlog.newUser id:int first_name:string last_name:string hash:long phone:string is_contact:int = binlog.Update; binlog.newUser id:int first_name:string last_name:string hash:long phone:string is_contact:int = binlog.Update;
binlog.userDelete id:int = binlog.Update; binlog.userDelete id:int = binlog.Update;
binlog.setUserAccessToken id:int hash:long = binlog.Update;
binlog.setUserPhone id:int phone:string = binlog.Update;
binlog.setUserFriend id:int friend:int = binlog.Update;
binlog.userFullPhoto id:int photo:Photo = binlog.Update;
binlog.userBlocked id:int blocked:int = binlog.Update;
binlog.setUserFullName id:int real_first_name:string real_last_name:string = binlog.Update;
binlog.encrChatDelete id:int = binlog.Update;
binlog.encrChatRequested id:int hash:long date:int admin:int user:int key:64*[int] nonce:64*[int] = binlog.Update;
binlog.setEncrChatAccessHash id:int hash:long = binlog.Update;
binlog.setEncrChatDate id:int date:int = binlog.Update;
binlog.setEncrChatState id:int state:int = binlog.Update;
binlog.encrChatAccepted id:int key:64*[int] nonce:64*[int] fingerprint:long = binlog.Update;
binlog.setEncrChatKey id:int key:64*[int] fingerprint:long = binlog.Update;
...@@ -13,4 +13,5 @@ void lua_chat_update (struct chat *C); ...@@ -13,4 +13,5 @@ void lua_chat_update (struct chat *C);
void lua_binlog_end (void); void lua_binlog_end (void);
void lua_diff_end (void); void lua_diff_end (void);
void lua_do_all (void); void lua_do_all (void);
#define lua_secret_chat_update(x)
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment