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
9d57c85f
Commit
9d57c85f
authored
Nov 11, 2014
by
vvaltman
Browse files
Options
Browse Files
Download
Plain Diff
Merge github.com:vysheng/tg
parents
56f002a1
47a12f1a
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
107 additions
and
84 deletions
+107
-84
Makefile.in
Makefile.in
+2
-2
binlog.c
binlog.c
+4
-4
encrypted_scheme17.tl
encrypted_scheme17.tl
+1
-0
interface.c
interface.c
+51
-48
loop.c
loop.c
+2
-0
lua-tg.c
lua-tg.c
+2
-1
queries.c
queries.c
+3
-3
structures.c
structures.c
+33
-25
tgl-layout.h
tgl-layout.h
+5
-0
tgl.h
tgl.h
+4
-1
No files found.
Makefile.in
View file @
9d57c85f
...
...
@@ -20,8 +20,8 @@ DIR_LIST=${DEP} ${AUTO} ${EXE} ${OBJ} ${LIB} ${DEP}/auto ${OBJ}/auto
EXE_LIST
=
${
EXE
}
/generate
${
EXE
}
/tlc
${
EXE
}
/telegram-cli
LIB_LIST
=
${
LIB
}
/libtgl.a
TG_OBJECTS
=
${
OBJ
}
/main.o
${
OBJ
}
/loop.o
${
OBJ
}
/interface.o
${
OBJ
}
/
lua-tg
.o
TGL_OBJECTS
=
${
OBJ
}
/
net.o
${
OBJ
}
/mtproto-common.o
${
OBJ
}
/mtproto-client.o
${
OBJ
}
/queries.o
${
OBJ
}
/structures.o
${
OBJ
}
/binlog.o
${
OBJ
}
/auto/auto.o
${
OBJ
}
/tgl.o
${
OBJ
}
/updates.o
${
OBJ
}
/tgl-timer
s.o
TG_OBJECTS
=
${
OBJ
}
/main.o
${
OBJ
}
/loop.o
${
OBJ
}
/interface.o
${
OBJ
}
/
net.o
${
OBJ
}
/lua-tg.o
${
OBJ
}
/tgl-timers
.o
TGL_OBJECTS
=
${
OBJ
}
/
mtproto-common.o
${
OBJ
}
/mtproto-client.o
${
OBJ
}
/queries.o
${
OBJ
}
/structures.o
${
OBJ
}
/binlog.o
${
OBJ
}
/auto/auto.o
${
OBJ
}
/tgl.o
${
OBJ
}
/update
s.o
TLC_OBJECTS
=
${
OBJ
}
/tlc.o
${
OBJ
}
/tl-parser.o
${
OBJ
}
/crc32.o
TLD_OBJECTS
=
${
OBJ
}
/dump-tl-file.o
GENERATE_OBJECTS
=
${
OBJ
}
/generate.o
...
...
binlog.c
View file @
9d57c85f
...
...
@@ -1422,7 +1422,7 @@ static void create_new_binlog (struct tgl_state *TLS) {
out_int
(
2
);
}
int
fd
=
open
(
get_binlog_file_name
()
,
O_WRONLY
|
O_EXCL
|
O_CREAT
,
0600
);
int
fd
=
open
(
TLS
->
binlog_name
,
O_WRONLY
|
O_EXCL
|
O_CREAT
,
0600
);
if
(
fd
<
0
)
{
perror
(
"Write new binlog"
);
exit
(
2
);
...
...
@@ -1434,11 +1434,11 @@ static void create_new_binlog (struct tgl_state *TLS) {
void
tgl_replay_log
(
struct
tgl_state
*
TLS
)
{
if
(
!
TLS
->
binlog_enabled
)
{
return
;
}
if
(
access
(
get_binlog_file_name
()
,
F_OK
)
<
0
)
{
if
(
access
(
TLS
->
binlog_name
,
F_OK
)
<
0
)
{
printf
(
"No binlog found. Creating new one
\n
"
);
create_new_binlog
(
TLS
);
}
int
fd
=
open
(
get_binlog_file_name
()
,
O_RDONLY
);
int
fd
=
open
(
TLS
->
binlog_name
,
O_RDONLY
);
if
(
fd
<
0
)
{
perror
(
"binlog open"
);
exit
(
2
);
...
...
@@ -1477,7 +1477,7 @@ void tgl_replay_log (struct tgl_state *TLS) {
static
int
b_packet_buffer
[
PACKET_BUFFER_SIZE
];
void
tgl_reopen_binlog_for_writing
(
struct
tgl_state
*
TLS
)
{
TLS
->
binlog_fd
=
open
(
get_binlog_file_name
()
,
O_WRONLY
);
TLS
->
binlog_fd
=
open
(
TLS
->
binlog_name
,
O_WRONLY
);
if
(
TLS
->
binlog_fd
<
0
)
{
perror
(
"binlog open"
);
exit
(
2
);
...
...
encrypted_scheme17.tl
View file @
9d57c85f
...
...
@@ -24,6 +24,7 @@ decryptedMessageActionScreenshotMessages#8ac1f475 random_ids:Vector<long> = Decr
decryptedMessageActionFlushHistory#6719e45c = DecryptedMessageAction;
decryptedMessageActionNotifyLayer#f3048883 layer:int = DecryptedMessageAction;
decryptedMessageActionResend#511110b0 start_seq_no:int end_seq_no:int = DecryptedMessageAction;
decryptedMessageActionTyping#ccb27641 action:SendMessageAction = DecryptedMessageAction;
...
...
interface.c
View file @
9d57c85f
This diff is collapsed.
Click to expand it.
loop.c
View file @
9d57c85f
...
...
@@ -699,6 +699,7 @@ static void accept_incoming (evutil_socket_t efd, short what, void *arg) {
bufferevent_enable
(
bev
,
EV_READ
|
EV_WRITE
);
}
char
*
get_downloads_directory
(
void
);
int
loop
(
void
)
{
//on_start ();
tgl_set_callback
(
TLS
,
&
upd_cb
);
...
...
@@ -707,6 +708,7 @@ int loop (void) {
tgl_set_ev_base
(
TLS
,
ev
);
tgl_set_net_methods
(
TLS
,
&
tgl_conn_methods
);
tgl_set_timer_methods
(
TLS
,
&
tgl_libevent_timers
);
tgl_set_download_directory
(
TLS
,
get_downloads_directory
());
tgl_init
(
TLS
);
if
(
binlog_enabled
)
{
...
...
lua-tg.c
View file @
9d57c85f
...
...
@@ -287,7 +287,7 @@ void push_media (struct tgl_message_media *M) {
}
}
void
push_message
(
struct
tgl_message
*
M
)
{
void
push_message
(
struct
tgl_message
*
M
)
{
assert
(
M
);
my_lua_checkstack
(
luaState
,
10
);
lua_newtable
(
luaState
);
...
...
@@ -295,6 +295,7 @@ void push_message (struct tgl_message *M) {
static
char
s
[
30
];
snprintf
(
s
,
30
,
"%lld"
,
M
->
id
);
lua_add_string_field
(
"id"
,
s
);
if
(
!
(
M
->
flags
&
FLAG_CREATED
))
{
return
;
}
lua_add_num_field
(
"flags"
,
M
->
flags
);
if
(
tgl_get_peer_type
(
M
->
fwd_from_id
))
{
...
...
queries.c
View file @
9d57c85f
...
...
@@ -61,7 +61,7 @@
#endif
//int want_dc_num;
char
*
get_downloads_directory
(
void
);
//
char *get_downloads_directory (void);
//extern int offline_mode;
//long long cur_uploading_bytes;
...
...
@@ -2492,9 +2492,9 @@ static void load_next_part (struct tgl_state *TLS, struct download *D, void *cal
static
char
buf
[
PATH_MAX
];
int
l
;
if
(
!
D
->
id
)
{
l
=
tsnprintf
(
buf
,
sizeof
(
buf
),
"%s/download_%lld_%d
"
,
get_downloads_directory
()
,
D
->
volume
,
D
->
local_id
);
l
=
tsnprintf
(
buf
,
sizeof
(
buf
),
"%s/download_%lld_%d
.jpg"
,
TLS
->
downloads_directory
,
D
->
volume
,
D
->
local_id
);
}
else
{
l
=
tsnprintf
(
buf
,
sizeof
(
buf
),
"%s/download_%lld"
,
get_downloads_directory
()
,
D
->
id
);
l
=
tsnprintf
(
buf
,
sizeof
(
buf
),
"%s/download_%lld"
,
TLS
->
downloads_directory
,
D
->
id
);
}
if
(
l
>=
(
int
)
sizeof
(
buf
))
{
vlogprintf
(
E_ERROR
,
"Download filename is too long"
);
...
...
structures.c
View file @
9d57c85f
...
...
@@ -1010,6 +1010,11 @@ void tglf_fetch_message_action_encrypted (struct tgl_state *TLS, struct tgl_mess
M
->
type
=
tgl_message_action_typing
;
M
->
typing
=
tglf_fetch_typing
();
break
;
case
CODE_decrypted_message_action_resend
:
M
->
type
=
tgl_message_action_resend
;
M
->
start_seq_no
=
fetch_int
();
M
->
end_seq_no
=
fetch_int
();
break
;
default:
vlogprintf
(
E_ERROR
,
"x = 0x%08x
\n
"
,
x
);
assert
(
0
);
...
...
@@ -1250,35 +1255,37 @@ void tglf_fetch_encrypted_message (struct tgl_state *TLS, struct tgl_message *M)
vlogprintf
(
E_DEBUG
-
2
,
"layer = %d, in = %d, out = %d
\n
"
,
layer
,
in_seq_no
,
out_seq_no
);
}
if
(
!
(
x
==
CODE_decrypted_message
||
x
==
CODE_decrypted_message_service
||
x
==
CODE_decrypted_message_l16
||
x
==
CODE_decrypted_message_service_l16
))
{
vlogprintf
(
E_ERROR
,
"x = 0x%08x
\n
"
,
x
);
assert
(
x
==
CODE_decrypted_message
||
x
==
CODE_decrypted_message_service
||
x
==
CODE_decrypted_message_l16
||
x
==
CODE_decrypted_message_service_l16
)
;
vlogprintf
(
E_ERROR
,
"
Incorrect message:
x = 0x%08x
\n
"
,
x
);
drop
=
1
;
}
//assert (id == fetch_long ());
long
long
new_id
=
fetch_long
();
if
(
P
&&
P
->
encr_chat
.
layer
>=
17
)
{
assert
(
new_id
==
id
);
}
if
(
x
==
CODE_decrypted_message
||
x
==
CODE_decrypted_message_service
)
{
if
(
x
==
CODE_decrypted_message
)
{
fetch_int
();
// ttl
if
(
!
drop
)
{
long
long
new_id
=
fetch_long
();
if
(
P
&&
P
->
encr_chat
.
layer
>=
17
)
{
assert
(
new_id
==
id
);
}
}
else
{
ll
=
prefetch_strlen
();
fetch_str
(
ll
);
// random_bytes
}
if
(
x
==
CODE_decrypted_message
||
x
==
CODE_decrypted_message_l16
)
{
l
=
prefetch_strlen
();
s
=
fetch_str
(
l
);
start
=
in_ptr
;
assert
(
skip_type_any
(
TYPE_TO_PARAM
(
decrypted_message_media
))
>=
0
);
end
=
in_ptr
;
}
else
{
start
=
in_ptr
;
if
(
skip_type_any
(
TYPE_TO_PARAM
(
decrypted_message_action
))
<
0
)
{
vlogprintf
(
E_ERROR
,
"Can not decrypt: Skipped %ld int out of %ld. Magic = 0x%08x
\n
"
,
(
long
)(
in_ptr
-
start
),
(
long
)(
in_end
-
start
),
*
start
);
drop
=
1
;
if
(
x
==
CODE_decrypted_message
||
x
==
CODE_decrypted_message_service
)
{
if
(
x
==
CODE_decrypted_message
)
{
fetch_int
();
// ttl
}
}
else
{
ll
=
prefetch_strlen
();
fetch_str
(
ll
);
// random_bytes
}
if
(
x
==
CODE_decrypted_message
||
x
==
CODE_decrypted_message_l16
)
{
l
=
prefetch_strlen
();
s
=
fetch_str
(
l
);
start
=
in_ptr
;
assert
(
skip_type_any
(
TYPE_TO_PARAM
(
decrypted_message_media
))
>=
0
);
end
=
in_ptr
;
}
else
{
start
=
in_ptr
;
if
(
skip_type_any
(
TYPE_TO_PARAM
(
decrypted_message_action
))
<
0
)
{
vlogprintf
(
E_ERROR
,
"Can not decrypt: Skipped %ld int out of %ld. Magic = 0x%08x
\n
"
,
(
long
)(
in_ptr
-
start
),
(
long
)(
in_end
-
start
),
*
start
);
drop
=
1
;
}
end
=
in_ptr
;
}
end
=
in_ptr
;
}
in_ptr
=
save_in_ptr
;
in_end
=
save_in_end
;
...
...
@@ -1661,6 +1668,7 @@ void tgls_free_message_action (struct tgl_state *TLS, struct tgl_message_action
case
tgl_message_action_delete_messages
:
case
tgl_message_action_screenshot_messages
:
case
tgl_message_action_flush_history
:
case
tgl_message_action_resend
:
case
tgl_message_action_notify_layer
:
break
;
...
...
tgl-layout.h
View file @
9d57c85f
...
...
@@ -119,6 +119,7 @@ enum tgl_message_action_type {
tgl_message_action_delete_messages
,
tgl_message_action_screenshot_messages
,
tgl_message_action_flush_history
,
tgl_message_action_resend
,
tgl_message_action_notify_layer
,
tgl_message_action_typing
};
...
...
@@ -386,6 +387,10 @@ struct tgl_message_action {
int
delete_cnt
;
int
screenshot_cnt
;
enum
tgl_typing_status
typing
;
struct
{
int
start_seq_no
;
int
end_seq_no
;
};
};
};
...
...
tgl.h
View file @
9d57c85f
...
...
@@ -30,11 +30,12 @@
#define TG_SERVER_3 "174.140.142.6"
#define TG_SERVER_4 "149.154.167.91"
#define TG_SERVER_5 "149.154.171.5"
#define TG_SERVER_DEFAULT 4
#define TG_SERVER_TEST_1 "173.240.5.253"
#define TG_SERVER_TEST_2 "149.154.167.40"
#define TG_SERVER_TEST_3 "174.140.142.5"
#define TG_SERVER_TEST_DEFAULT 2
// JUST RANDOM STRING
#define TGL_BUILD "2590"
...
...
@@ -201,6 +202,8 @@ struct tgl_state {
void
*
pubKey
;
struct
tree_query
*
queries_tree
;
char
*
base_path
;
};
#pragma pack(pop)
//extern struct tgl_state tgl_state;
...
...
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