Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
tg
Commits
04630cb0
Commit
04630cb0
authored
Sep 18, 2014
by
Vysheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added reset authorization key
parent
c7174159
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
40 additions
and
3 deletions
+40
-3
binlog.c
binlog.c
+20
-0
binlog.h
binlog.h
+2
-0
binlog.tl
binlog.tl
+2
-0
loop.c
loop.c
+10
-1
main.c
main.c
+5
-1
tgl-layout.h
tgl-layout.h
+1
-1
No files found.
binlog.c
View file @
04630cb0
...
...
@@ -1198,6 +1198,20 @@ static int fetch_comb_binlog_msg_update (void *extra) {
return
0
;
}
static
int
fetch_comb_binlog_reset_authorization
(
void
*
extra
)
{
int
i
;
for
(
i
=
0
;
i
<=
tgl_state
.
max_dc_num
;
i
++
)
if
(
tgl_state
.
DC_list
[
i
])
{
struct
tgl_dc
*
D
=
tgl_state
.
DC_list
[
i
];
D
->
flags
=
0
;
D
->
state
=
st_init
;
D
->
auth_key_id
=
D
->
temp_auth_key_id
=
0
;
D
->
has_auth
=
0
;
}
tgl_state
.
seq
=
0
;
tgl_state
.
qts
=
0
;
return
0
;
}
#define FETCH_COMBINATOR_FUNCTION(NAME) \
case CODE_ ## NAME:\
ok = fetch_comb_ ## NAME (0); \
...
...
@@ -1288,6 +1302,7 @@ static void replay_log_event (void) {
FETCH_COMBINATOR_FUNCTION
(
binlog_delete_msg
)
FETCH_COMBINATOR_FUNCTION
(
binlog_msg_seq_update
)
FETCH_COMBINATOR_FUNCTION
(
binlog_msg_update
)
FETCH_COMBINATOR_FUNCTION
(
binlog_reset_authorization
)
default:
vlogprintf
(
E_ERROR
,
"Unknown op 0x%08x
\n
"
,
op
);
assert
(
0
);
...
...
@@ -2102,6 +2117,11 @@ void bl_do_msg_update (long long id) {
add_log_event
(
packet_buffer
,
4
*
(
packet_ptr
-
packet_buffer
));
}
void
bl_do_reset_authorization
(
void
)
{
clear_packet
();
out_int
(
CODE_binlog_reset_authorization
);
add_log_event
(
packet_buffer
,
4
*
(
packet_ptr
-
packet_buffer
));
}
/*void bl_do_add_dc (int id, const char *ip, int l, int port, long long auth_key_id, const char *auth_key) {
clear_packet ();
out_int (CODE_binlog_add_dc);
...
...
binlog.h
View file @
04630cb0
...
...
@@ -93,5 +93,7 @@ void bl_do_delete_msg (struct tgl_message *M);
void
bl_do_msg_seq_update
(
long
long
id
);
void
bl_do_msg_update
(
long
long
id
);
void
bl_do_reset_authorization
(
void
);
//void bl_do_add_dc (int id, const char *ip, int l, int port, long long auth_key_id, const char *auth_key);
#endif
binlog.tl
View file @
04630cb0
...
...
@@ -74,4 +74,6 @@ binlog.deleteMsg id:long = binlog.Update;
binlog.msgSeqUpdate id:long = binlog.Update;
binlog.msgUpdate id:long = binlog.Update;
binlog.resetAuthorization = binlog.Update;
//binlog.addDc id:int ip:string port:int auth_key_id:long auth_key:64*[int] = binlog.Update;
loop.c
View file @
04630cb0
...
...
@@ -73,6 +73,7 @@ extern int safe_quit;
extern
int
sync_from_start
;
extern
int
disable_output
;
extern
int
reset_authorization
;
void
got_it
(
char
*
line
,
int
len
);
void
write_state_file
(
void
);
...
...
@@ -610,6 +611,14 @@ int loop (void) {
#endif
update_prompt
();
if
(
reset_authorization
)
{
tgl_peer_t
*
P
=
tgl_peer_get
(
TGL_MK_USER
(
tgl_state
.
our_id
));
if
(
P
&&
P
->
user
.
phone
&&
reset_authorization
==
1
)
{
set_default_username
(
P
->
user
.
phone
);
}
bl_do_reset_authorization
();
}
net_loop
(
0
,
all_authorized
);
int
i
;
...
...
main.c
View file @
04630cb0
...
...
@@ -97,6 +97,7 @@ char *lua_file;
int
disable_colors
;
int
readline_disabled
;
int
disable_output
;
int
reset_authorization
;
void
set_default_username
(
const
char
*
s
)
{
if
(
default_username
)
{
...
...
@@ -519,7 +520,7 @@ int change_user_group () {
void
args_parse
(
int
argc
,
char
**
argv
)
{
int
opt
=
0
;
while
((
opt
=
getopt
(
argc
,
argv
,
"u:hk:vNl:fEwWCRdL:DU:G:"
while
((
opt
=
getopt
(
argc
,
argv
,
"u:hk:vNl:fEwWCRdL:DU:G:
q
"
#ifdef HAVE_LIBCONFIG
"c:p:"
#else
...
...
@@ -599,6 +600,9 @@ void args_parse (int argc, char **argv) {
case
'D'
:
disable_output
++
;
break
;
case
'q'
:
reset_authorization
++
;
break
;
case
'h'
:
default:
usage
();
...
...
tgl-layout.h
View file @
04630cb0
...
...
@@ -72,7 +72,7 @@ struct tgl_dc {
int
flags
;
enum
tgl_dc_state
state
;
char
*
ip
;
char
*
user
;
//
char *user;
struct
tgl_session
*
sessions
[
MAX_DC_SESSIONS
];
char
auth_key
[
256
];
char
temp_auth_key
[
256
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment