Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
MTProxy2
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
MTProxy2
Commits
04282c7e
Commit
04282c7e
authored
Jul 11, 2019
by
levlam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve logging.Z
parent
6d1ac2da
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
30 deletions
+19
-30
mtproto-proxy.c
mtproto/mtproto-proxy.c
+1
-1
net-connections.c
net/net-connections.c
+11
-9
net-tcp-rpc-ext-server.c
net/net-tcp-rpc-ext-server.c
+7
-19
net-tcp-rpc-ext-server.h
net/net-tcp-rpc-ext-server.h
+0
-1
No files found.
mtproto/mtproto-proxy.c
View file @
04282c7e
...
...
@@ -2094,7 +2094,7 @@ void mtfront_pre_loop (void) {
assert
(
LC
);
CONN_INFO
(
LC
)
->
window_clamp
=
window_clamp
;
if
(
setsockopt
(
http_sfd
[
i
],
IPPROTO_TCP
,
TCP_WINDOW_CLAMP
,
&
window_clamp
,
4
)
<
0
)
{
vkprintf
(
0
,
"error while setting window size for socket %d to %d: %m
\n
"
,
http_sfd
[
i
],
window_clamp
);
vkprintf
(
0
,
"error while setting window size for socket
#
%d to %d: %m
\n
"
,
http_sfd
[
i
],
window_clamp
);
}
}
// create_all_outbound_connections ();
...
...
net/net-connections.c
View file @
04282c7e
...
...
@@ -602,7 +602,7 @@ connection_job_t alloc_new_connection (int cfd, conn_target_job_t CTJ, listening
unsigned
flags
;
if
((
flags
=
fcntl
(
cfd
,
F_GETFL
,
0
)
<
0
)
||
fcntl
(
cfd
,
F_SETFL
,
flags
|
O_NONBLOCK
)
<
0
)
{
kprintf
(
"cannot set O_NONBLOCK on accepted socket %d: %m
\n
"
,
cfd
);
kprintf
(
"cannot set O_NONBLOCK on accepted socket
#
%d: %m
\n
"
,
cfd
);
MODULE_STAT
->
accept_nonblock_set_failed
++
;
close
(
cfd
);
return
NULL
;
...
...
@@ -697,9 +697,9 @@ connection_job_t alloc_new_connection (int cfd, conn_target_job_t CTJ, listening
//c->out_packet_queue = alloc_mp_queue_w ();
if
(
basic_type
==
ct_outbound
)
{
vkprintf
(
1
,
"New
connection %s:%d -> %s:%d
\n
"
,
show_our_ip
(
C
),
c
->
our_port
,
show_remote_ip
(
C
),
c
->
remote_port
);
vkprintf
(
1
,
"New
outbound connection #%d %s:%d -> %s:%d
\n
"
,
c
->
fd
,
show_our_ip
(
C
),
c
->
our_port
,
show_remote_ip
(
C
),
c
->
remote_port
);
}
else
{
vkprintf
(
1
,
"New
connection %s:%d -> %s:%d
\n
"
,
show_remote_ip
(
C
),
c
->
remote_port
,
show_our_ip
(
C
),
c
->
our_port
);
vkprintf
(
1
,
"New
inbound connection #%d %s:%d -> %s:%d
\n
"
,
c
->
fd
,
show_remote_ip
(
C
),
c
->
remote_port
,
show_our_ip
(
C
),
c
->
our_port
);
}
...
...
@@ -750,13 +750,13 @@ connection_job_t alloc_new_connection (int cfd, conn_target_job_t CTJ, listening
}
if
(
c
->
window_clamp
)
{
if
(
setsockopt
(
cfd
,
IPPROTO_TCP
,
TCP_WINDOW_CLAMP
,
&
c
->
window_clamp
,
4
)
<
0
)
{
vkprintf
(
0
,
"error while setting window size for socket %d to %d: %m
\n
"
,
cfd
,
c
->
window_clamp
);
vkprintf
(
0
,
"error while setting window size for socket
#
%d to %d: %m
\n
"
,
cfd
,
c
->
window_clamp
);
}
else
{
int
t1
=
-
1
,
t2
=
-
1
;
socklen_t
s1
=
4
,
s2
=
4
;
getsockopt
(
cfd
,
IPPROTO_TCP
,
TCP_WINDOW_CLAMP
,
&
t1
,
&
s1
);
getsockopt
(
cfd
,
SOL_SOCKET
,
SO_RCVBUF
,
&
t2
,
&
s2
);
vkprintf
(
2
,
"window clamp for socket %d is %d, receive buffer is %d
\n
"
,
cfd
,
t1
,
t2
);
vkprintf
(
2
,
"window clamp for socket
#
%d is %d, receive buffer is %d
\n
"
,
cfd
,
t1
,
t2
);
}
}
...
...
@@ -1132,7 +1132,7 @@ int net_server_socket_read_write_gateway (int fd, void *data, event_t *ev) /* {{
return
EVA_REMOVE
;
}
if
(
ev
->
epoll_ready
&
(
EPOLLHUP
|
EPOLLERR
|
EPOLLRDHUP
|
EPOLLPRI
))
{
vkprintf
(
!
(
ev
->
epoll_ready
&
EPOLLPRI
),
"socket %d: disconnected (epoll_ready=%02x), cleaning
\n
"
,
c
->
fd
,
ev
->
epoll_ready
);
vkprintf
(
!
(
ev
->
epoll_ready
&
EPOLLPRI
),
"socket
#
%d: disconnected (epoll_ready=%02x), cleaning
\n
"
,
c
->
fd
,
ev
->
epoll_ready
);
job_signal
(
JOB_REF_CREATE_PASS
(
C
),
JS_ABORT
);
return
EVA_REMOVE
;
...
...
@@ -1720,12 +1720,14 @@ int create_new_connections (conn_target_job_t CTJ) /* {{{ */ {
}
while
(
CT
->
outbound_connections
<
need_c
)
{
int
cfd
=
-
1
;
if
(
CT
->
target
.
s_addr
)
{
vkprintf
(
1
,
"Creating NEW connection to %s:%d
\n
"
,
inet_ntoa
(
CT
->
target
),
CT
->
port
);
cfd
=
client_socket
(
CT
->
target
.
s_addr
,
CT
->
port
,
0
);
vkprintf
(
1
,
"Created NEW connection #%d to %s:%d
\n
"
,
cfd
,
inet_ntoa
(
CT
->
target
),
CT
->
port
);
}
else
{
vkprintf
(
1
,
"Creating NEW ipv6 connection to [%s]:%d
\n
"
,
show_ipv6
(
CT
->
target_ipv6
),
CT
->
port
);
cfd
=
client_socket_ipv6
(
CT
->
target_ipv6
,
CT
->
port
,
SM_IPV6
);
vkprintf
(
1
,
"Created NEW ipv6 connection #%d to [%s]:%d
\n
"
,
cfd
,
show_ipv6
(
CT
->
target_ipv6
),
CT
->
port
);
}
int
cfd
=
CT
->
target
.
s_addr
?
client_socket
(
CT
->
target
.
s_addr
,
CT
->
port
,
0
)
:
client_socket_ipv6
(
CT
->
target_ipv6
,
CT
->
port
,
SM_IPV6
);
if
(
cfd
<
0
)
{
if
(
CT
->
target
.
s_addr
)
{
vkprintf
(
1
,
"error connecting to %s:%d: %m
\n
"
,
inet_ntoa
(
CT
->
target
),
CT
->
port
);
...
...
net/net-tcp-rpc-ext-server.c
View file @
04282c7e
...
...
@@ -103,7 +103,8 @@ conn_type_t ct_proxy_pass = {
};
int
tcp_proxy_pass_connected
(
connection_job_t
C
)
{
vkprintf
(
1
,
"proxy pass connected'n"
);
struct
connection_info
*
c
=
CONN_INFO
(
C
);
vkprintf
(
1
,
"proxy pass connected #%d %s:%d -> %s:%d
\n
"
,
c
->
fd
,
show_our_ip
(
C
),
c
->
our_port
,
show_remote_ip
(
C
),
c
->
remote_port
);
return
0
;
}
...
...
@@ -119,15 +120,15 @@ int tcp_proxy_pass_parse_execute (connection_job_t C) {
struct
raw_message
*
r
=
malloc
(
sizeof
(
*
r
));
rwm_move
(
r
,
&
c
->
in
);
rwm_init
(
&
c
->
in
,
0
);
vkprintf
(
3
,
"proxying %d bytes to %s
\n
"
,
r
->
total_bytes
,
show_remote_ip
(
E
)
);
vkprintf
(
3
,
"proxying %d bytes to %s
:%d
\n
"
,
r
->
total_bytes
,
show_remote_ip
(
E
),
e
->
remote_port
);
mpq_push_w
(
e
->
out_queue
,
PTR_MOVE
(
r
),
0
);
job_signal
(
JOB_REF_PASS
(
E
),
JS_RUN
);
return
0
;
}
int
tcp_proxy_pass_close
(
connection_job_t
C
,
int
who
)
{
vkprintf
(
1
,
"closing proxy pass conn
\n
"
);
struct
connection_info
*
c
=
CONN_INFO
(
C
);
vkprintf
(
1
,
"closing proxy pass connection #%d %s:%d -> %s:%d
\n
"
,
c
->
fd
,
show_our_ip
(
C
),
c
->
our_port
,
show_remote_ip
(
C
),
c
->
remote_port
);
if
(
c
->
extra
)
{
job_t
E
=
PTR_MOVE
(
c
->
extra
);
fail_connection
(
E
,
-
23
);
...
...
@@ -151,19 +152,6 @@ void tcp_rpcs_set_ext_secret (unsigned char secret[16]) {
memcpy
(
ext_secret
[
ext_secret_cnt
++
],
secret
,
16
);
}
/*
struct tcp_rpc_server_functions default_tcp_rpc_ext_server = {
.execute = tcp_rpcs_default_execute,
.check_ready = server_check_ready,
.flush_packet = tcp_rpc_flush_packet,
.rpc_wakeup = tcp_rpcs_do_wakeup,
.rpc_alarm = tcp_rpcs_do_wakeup,
.rpc_check_perm = tcp_rpcs_default_check_perm,
.rpc_init_crypto = tcp_rpcs_init_crypto,
.rpc_ready = server_noop,
};
*/
static
int
allow_only_tls
;
struct
domain_info
{
...
...
@@ -861,7 +849,7 @@ static int proxy_connection (connection_job_t C, const struct domain_info *info)
return
0
;
}
int
port
=
c
->
remote
_port
==
80
?
80
:
443
;
int
port
=
c
->
our
_port
==
80
?
80
:
443
;
int
cfd
=
-
1
;
if
(
info
->
target
.
s_addr
)
{
...
...
@@ -871,7 +859,7 @@ static int proxy_connection (connection_job_t C, const struct domain_info *info)
}
if
(
cfd
<
0
)
{
kprintf
(
"failed to create proxy pass conn: %d (%m)"
,
errno
);
kprintf
(
"failed to create proxy pass conn
ection
: %d (%m)"
,
errno
);
fail_connection
(
C
,
-
27
);
return
0
;
}
...
...
@@ -881,7 +869,7 @@ static int proxy_connection (connection_job_t C, const struct domain_info *info)
job_t
EJ
=
alloc_new_connection
(
cfd
,
NULL
,
NULL
,
ct_outbound
,
&
ct_proxy_pass
,
C
,
ntohl
(
*
(
int
*
)
&
info
->
target
.
s_addr
),
(
void
*
)
info
->
target_ipv6
,
port
);
if
(
!
EJ
)
{
kprintf
(
"failed to create proxy pass conn (2)"
);
kprintf
(
"failed to create proxy pass conn
ection
(2)"
);
job_decref_f
(
C
);
fail_connection
(
C
,
-
37
);
return
0
;
...
...
net/net-tcp-rpc-ext-server.h
View file @
04282c7e
...
...
@@ -26,7 +26,6 @@
#include "net/net-connections.h"
extern
conn_type_t
ct_tcp_rpc_ext_server
;
// extern struct tcp_rpc_server_functions default_tcp_rpc_server;
int
tcp_rpcs_compact_parse_execute
(
connection_job_t
c
);
...
...
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