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
b9cf49e9
Commit
b9cf49e9
authored
Sep 27, 2014
by
vvaltman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hardcoded default ip's for all DC
parent
ddcd8ad4
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
94 additions
and
27 deletions
+94
-27
binlog.c
binlog.c
+48
-8
loop.c
loop.c
+13
-3
mtproto-client.c
mtproto-client.c
+19
-12
net.c
net.c
+4
-0
tgl.h
tgl.h
+10
-4
No files found.
binlog.c
View file @
b9cf49e9
...
@@ -1316,13 +1316,53 @@ static void create_new_binlog (void) {
...
@@ -1316,13 +1316,53 @@ static void create_new_binlog (void) {
static
int
s
[
1000
];
static
int
s
[
1000
];
packet_ptr
=
s
;
packet_ptr
=
s
;
out_int
(
CODE_binlog_start
);
out_int
(
CODE_binlog_start
);
out_int
(
CODE_binlog_dc_option
);
if
(
tgl_state
.
test_mode
)
{
out_int
(
tgl_state
.
test_mode
?
TG_SERVER_TEST_DC
:
TG_SERVER_DC
);
out_int
(
CODE_binlog_dc_option
);
out_string
(
""
);
out_int
(
1
);
out_string
(
tgl_state
.
test_mode
?
TG_SERVER_TEST
:
TG_SERVER
);
out_string
(
""
);
out_int
(
443
);
out_string
(
TG_SERVER_TEST_1
);
out_int
(
CODE_binlog_default_dc
);
out_int
(
443
);
out_int
(
tgl_state
.
test_mode
?
TG_SERVER_TEST_DC
:
TG_SERVER_DC
);
out_int
(
CODE_binlog_dc_option
);
out_int
(
2
);
out_string
(
""
);
out_string
(
TG_SERVER_TEST_2
);
out_int
(
443
);
out_int
(
CODE_binlog_dc_option
);
out_int
(
3
);
out_string
(
""
);
out_string
(
TG_SERVER_TEST_3
);
out_int
(
443
);
out_int
(
CODE_binlog_default_dc
);
out_int
(
2
);
}
else
{
out_int
(
CODE_binlog_dc_option
);
out_int
(
1
);
out_string
(
""
);
out_string
(
TG_SERVER_1
);
out_int
(
443
);
out_int
(
CODE_binlog_dc_option
);
out_int
(
2
);
out_string
(
""
);
out_string
(
TG_SERVER_2
);
out_int
(
443
);
out_int
(
CODE_binlog_dc_option
);
out_int
(
3
);
out_string
(
""
);
out_string
(
TG_SERVER_3
);
out_int
(
443
);
out_int
(
CODE_binlog_dc_option
);
out_int
(
4
);
out_string
(
""
);
out_string
(
TG_SERVER_4
);
out_int
(
443
);
out_int
(
CODE_binlog_dc_option
);
out_int
(
5
);
out_string
(
""
);
out_string
(
TG_SERVER_5
);
out_int
(
443
);
out_int
(
CODE_binlog_default_dc
);
out_int
(
2
);
}
int
fd
=
open
(
get_binlog_file_name
(),
O_WRONLY
|
O_EXCL
|
O_CREAT
,
0600
);
int
fd
=
open
(
get_binlog_file_name
(),
O_WRONLY
|
O_EXCL
|
O_CREAT
,
0600
);
if
(
fd
<
0
)
{
if
(
fd
<
0
)
{
...
@@ -1542,7 +1582,7 @@ void bl_do_user_set_friend (struct tgl_user *U, int friend) {
...
@@ -1542,7 +1582,7 @@ void bl_do_user_set_friend (struct tgl_user *U, int friend) {
void
bl_do_dc_option
(
int
id
,
int
l1
,
const
char
*
name
,
int
l2
,
const
char
*
ip
,
int
port
)
{
void
bl_do_dc_option
(
int
id
,
int
l1
,
const
char
*
name
,
int
l2
,
const
char
*
ip
,
int
port
)
{
struct
tgl_dc
*
DC
=
tgl_state
.
DC_list
[
id
];
struct
tgl_dc
*
DC
=
tgl_state
.
DC_list
[
id
];
if
(
DC
)
{
return
;
}
if
(
DC
&&
!
strncmp
(
ip
,
DC
->
ip
,
l2
)
)
{
return
;
}
clear_packet
();
clear_packet
();
out_int
(
CODE_binlog_dc_option
);
out_int
(
CODE_binlog_dc_option
);
...
...
loop.c
View file @
b9cf49e9
...
@@ -500,9 +500,19 @@ void read_dc (int auth_file_fd, int id, unsigned ver) {
...
@@ -500,9 +500,19 @@ void read_dc (int auth_file_fd, int id, unsigned ver) {
}
}
void
empty_auth_file
(
void
)
{
void
empty_auth_file
(
void
)
{
char
*
ip
=
tgl_state
.
test_mode
?
TG_SERVER_TEST
:
TG_SERVER
;
if
(
tgl_state
.
test_mode
)
{
bl_do_dc_option
(
tgl_state
.
test_mode
?
TG_SERVER_TEST_DC
:
TG_SERVER_DC
,
0
,
""
,
strlen
(
ip
),
ip
,
443
);
bl_do_dc_option
(
1
,
0
,
""
,
strlen
(
TG_SERVER_TEST_1
),
TG_SERVER_TEST_1
,
443
);
bl_do_set_working_dc
(
tgl_state
.
test_mode
?
TG_SERVER_TEST_DC
:
TG_SERVER_DC
);
bl_do_dc_option
(
2
,
0
,
""
,
strlen
(
TG_SERVER_TEST_2
),
TG_SERVER_TEST_2
,
443
);
bl_do_dc_option
(
3
,
0
,
""
,
strlen
(
TG_SERVER_TEST_3
),
TG_SERVER_TEST_3
,
443
);
bl_do_set_working_dc
(
2
);
}
else
{
bl_do_dc_option
(
1
,
0
,
""
,
strlen
(
TG_SERVER_1
),
TG_SERVER_1
,
443
);
bl_do_dc_option
(
2
,
0
,
""
,
strlen
(
TG_SERVER_2
),
TG_SERVER_2
,
443
);
bl_do_dc_option
(
3
,
0
,
""
,
strlen
(
TG_SERVER_3
),
TG_SERVER_3
,
443
);
bl_do_dc_option
(
4
,
0
,
""
,
strlen
(
TG_SERVER_4
),
TG_SERVER_4
,
443
);
bl_do_dc_option
(
5
,
0
,
""
,
strlen
(
TG_SERVER_5
),
TG_SERVER_5
,
443
);
bl_do_set_working_dc
(
2
);
}
}
}
int
need_dc_list_update
;
int
need_dc_list_update
;
...
...
mtproto-client.c
View file @
b9cf49e9
...
@@ -1341,19 +1341,26 @@ static void regen_temp_key_gw (evutil_socket_t fd, short what, void *arg) {
...
@@ -1341,19 +1341,26 @@ static void regen_temp_key_gw (evutil_socket_t fd, short what, void *arg) {
}
}
struct
tgl_dc
*
tglmp_alloc_dc
(
int
id
,
char
*
ip
,
int
port
UU
)
{
struct
tgl_dc
*
tglmp_alloc_dc
(
int
id
,
char
*
ip
,
int
port
UU
)
{
assert
(
!
tgl_state
.
DC_list
[
id
]);
//assert (!tgl_state.DC_list[id]);
struct
tgl_dc
*
DC
=
talloc0
(
sizeof
(
*
DC
));
if
(
!
tgl_state
.
DC_list
[
id
])
{
DC
->
id
=
id
;
struct
tgl_dc
*
DC
=
talloc0
(
sizeof
(
*
DC
));
DC
->
ip
=
ip
;
DC
->
id
=
id
;
DC
->
port
=
port
;
DC
->
ip
=
ip
;
tgl_state
.
DC_list
[
id
]
=
DC
;
DC
->
port
=
port
;
if
(
id
>
tgl_state
.
max_dc_num
)
{
tgl_state
.
DC_list
[
id
]
=
DC
;
tgl_state
.
max_dc_num
=
id
;
if
(
id
>
tgl_state
.
max_dc_num
)
{
tgl_state
.
max_dc_num
=
id
;
}
DC
->
ev
=
evtimer_new
(
tgl_state
.
ev_base
,
regen_temp_key_gw
,
DC
);
static
struct
timeval
p
;
event_add
(
DC
->
ev
,
&
p
);
return
DC
;
}
else
{
struct
tgl_dc
*
DC
=
tgl_state
.
DC_list
[
id
];
tfree_str
(
DC
->
ip
);
DC
->
ip
=
tstrdup
(
ip
);
return
DC
;
}
}
DC
->
ev
=
evtimer_new
(
tgl_state
.
ev_base
,
regen_temp_key_gw
,
DC
);
static
struct
timeval
p
;
event_add
(
DC
->
ev
,
&
p
);
return
DC
;
}
}
static
struct
mtproto_methods
mtproto_methods
=
{
static
struct
mtproto_methods
mtproto_methods
=
{
...
...
net.c
View file @
b9cf49e9
...
@@ -345,6 +345,10 @@ static void restart_connection (struct connection *c) {
...
@@ -345,6 +345,10 @@ static void restart_connection (struct connection *c) {
struct
sockaddr_in
addr
;
struct
sockaddr_in
addr
;
addr
.
sin_family
=
AF_INET
;
addr
.
sin_family
=
AF_INET
;
addr
.
sin_port
=
htons
(
c
->
port
);
addr
.
sin_port
=
htons
(
c
->
port
);
if
(
strcmp
(
c
->
ip
,
c
->
dc
->
ip
))
{
tfree_str
(
c
->
ip
);
c
->
ip
=
tstrdup
(
c
->
dc
->
ip
);
}
addr
.
sin_addr
.
s_addr
=
inet_addr
(
c
->
ip
);
addr
.
sin_addr
.
s_addr
=
inet_addr
(
c
->
ip
);
...
...
tgl.h
View file @
b9cf49e9
...
@@ -24,10 +24,16 @@
...
@@ -24,10 +24,16 @@
#include <string.h>
#include <string.h>
#define TGL_MAX_DC_NUM 100
#define TGL_MAX_DC_NUM 100
#define TG_SERVER "149.154.167.50"
#define TG_SERVER_1 "173.240.5.1"
#define TG_SERVER_TEST "149.154.167.40"
#define TG_SERVER_2 "149.154.167.51"
#define TG_SERVER_DC 2
#define TG_SERVER_3 "174.140.142.6"
#define TG_SERVER_TEST_DC 2
#define TG_SERVER_4 "149.154.167.91"
#define TG_SERVER_5 "149.154.171.5"
#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"
// JUST RANDOM STRING
// JUST RANDOM STRING
#define TGL_BUILD "2014"
#define TGL_BUILD "2014"
...
...
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