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
6d1ac2da
Commit
6d1ac2da
authored
Jul 10, 2019
by
vvaltman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow proxy pass
parent
df658b02
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
7 deletions
+26
-7
Makefile
Makefile
+1
-1
net-connections.c
net/net-connections.c
+1
-1
net-tcp-rpc-ext-server.c
net/net-tcp-rpc-ext-server.c
+24
-5
No files found.
Makefile
View file @
6d1ac2da
...
@@ -12,7 +12,7 @@ ifeq ($m, 64)
...
@@ -12,7 +12,7 @@ ifeq ($m, 64)
ARCH
=
-m64
ARCH
=
-m64
endif
endif
CFLAGS
=
$(ARCH)
-O
3
-std
=
gnu11
-Wall
-mpclmul
-march
=
core2
-mfpmath
=
sse
-mssse3
-fno-strict-aliasing
-fno-strict-overflow
-fwrapv
-DAES
=
1
-DCOMMIT
=
\"
${
COMMIT
}
\"
-D_GNU_SOURCE
=
1
-D_FILE_OFFSET_BITS
=
64
CFLAGS
=
$(ARCH)
-O
2
-std
=
gnu11
-Wall
-mpclmul
-march
=
core2
-mfpmath
=
sse
-mssse3
-fno-strict-aliasing
-fno-strict-overflow
-fwrapv
-DAES
=
1
-DCOMMIT
=
\"
${
COMMIT
}
\"
-D_GNU_SOURCE
=
1
-D_FILE_OFFSET_BITS
=
64
LDFLAGS
=
$(ARCH)
-ggdb
-rdynamic
-lm
-lrt
-lcrypto
-lz
-lpthread
-lcrypto
LDFLAGS
=
$(ARCH)
-ggdb
-rdynamic
-lm
-lrt
-lcrypto
-lz
-lpthread
-lcrypto
LIB
=
${
OBJ
}
/lib
LIB
=
${
OBJ
}
/lib
...
...
net/net-connections.c
View file @
6d1ac2da
...
@@ -636,7 +636,7 @@ connection_job_t alloc_new_connection (int cfd, conn_target_job_t CTJ, listening
...
@@ -636,7 +636,7 @@ connection_job_t alloc_new_connection (int cfd, conn_target_job_t CTJ, listening
c
->
generation
=
new_conn_generation
();
c
->
generation
=
new_conn_generation
();
c
->
flags
=
0
;
//SS ? C_WANTWR : C_WANTRD;
c
->
flags
=
0
;
//SS ? C_WANTWR : C_WANTRD;
if
(
LC
)
{
if
(
basic_type
==
ct_inbound
)
{
c
->
flags
=
C_CONNECTED
;
c
->
flags
=
C_CONNECTED
;
}
}
...
...
net/net-tcp-rpc-ext-server.c
View file @
6d1ac2da
...
@@ -87,6 +87,7 @@ conn_type_t ct_tcp_rpc_ext_server = {
...
@@ -87,6 +87,7 @@ conn_type_t ct_tcp_rpc_ext_server = {
int
tcp_proxy_pass_parse_execute
(
connection_job_t
C
);
int
tcp_proxy_pass_parse_execute
(
connection_job_t
C
);
int
tcp_proxy_pass_close
(
connection_job_t
C
,
int
who
);
int
tcp_proxy_pass_close
(
connection_job_t
C
,
int
who
);
int
tcp_proxy_pass_connected
(
connection_job_t
C
);
int
tcp_proxy_pass_write_packet
(
connection_job_t
c
,
struct
raw_message
*
raw
);
int
tcp_proxy_pass_write_packet
(
connection_job_t
c
,
struct
raw_message
*
raw
);
conn_type_t
ct_proxy_pass
=
{
conn_type_t
ct_proxy_pass
=
{
...
@@ -95,11 +96,17 @@ conn_type_t ct_proxy_pass = {
...
@@ -95,11 +96,17 @@ conn_type_t ct_proxy_pass = {
.
title
=
"proxypass"
,
.
title
=
"proxypass"
,
.
init_accepted
=
server_failed
,
.
init_accepted
=
server_failed
,
.
parse_execute
=
tcp_proxy_pass_parse_execute
,
.
parse_execute
=
tcp_proxy_pass_parse_execute
,
.
connected
=
tcp_proxy_pass_connected
,
.
close
=
tcp_proxy_pass_close
,
.
close
=
tcp_proxy_pass_close
,
.
write_packet
=
tcp_proxy_pass_write_packet
,
.
write_packet
=
tcp_proxy_pass_write_packet
,
.
connected
=
server_noop
,
.
connected
=
server_noop
,
};
};
int
tcp_proxy_pass_connected
(
connection_job_t
C
)
{
vkprintf
(
1
,
"proxy pass connected'n"
);
return
0
;
}
int
tcp_proxy_pass_parse_execute
(
connection_job_t
C
)
{
int
tcp_proxy_pass_parse_execute
(
connection_job_t
C
)
{
struct
connection_info
*
c
=
CONN_INFO
(
C
);
struct
connection_info
*
c
=
CONN_INFO
(
C
);
if
(
!
c
->
extra
)
{
if
(
!
c
->
extra
)
{
...
@@ -111,12 +118,15 @@ int tcp_proxy_pass_parse_execute (connection_job_t C) {
...
@@ -111,12 +118,15 @@ int tcp_proxy_pass_parse_execute (connection_job_t C) {
struct
raw_message
*
r
=
malloc
(
sizeof
(
*
r
));
struct
raw_message
*
r
=
malloc
(
sizeof
(
*
r
));
rwm_move
(
r
,
&
c
->
in
);
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
));
mpq_push_w
(
e
->
out_queue
,
PTR_MOVE
(
r
),
0
);
mpq_push_w
(
e
->
out_queue
,
PTR_MOVE
(
r
),
0
);
job_signal
(
JOB_REF_PASS
(
E
),
JS_RUN
);
job_signal
(
JOB_REF_PASS
(
E
),
JS_RUN
);
return
0
;
return
0
;
}
}
int
tcp_proxy_pass_close
(
connection_job_t
C
,
int
who
)
{
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
);
struct
connection_info
*
c
=
CONN_INFO
(
C
);
if
(
c
->
extra
)
{
if
(
c
->
extra
)
{
job_t
E
=
PTR_MOVE
(
c
->
extra
);
job_t
E
=
PTR_MOVE
(
c
->
extra
);
...
@@ -841,6 +851,9 @@ static int is_allowed_timestamp (int timestamp) {
...
@@ -841,6 +851,9 @@ static int is_allowed_timestamp (int timestamp) {
}
}
static
int
proxy_connection
(
connection_job_t
C
,
const
struct
domain_info
*
info
)
{
static
int
proxy_connection
(
connection_job_t
C
,
const
struct
domain_info
*
info
)
{
struct
connection_info
*
c
=
CONN_INFO
(
C
);
assert
(
check_conn_functions
(
&
ct_proxy_pass
,
0
)
>=
0
);
const
char
zero
[
16
]
=
{};
const
char
zero
[
16
]
=
{};
if
(
info
->
target
.
s_addr
==
0
&&
!
memcmp
(
info
->
target_ipv6
,
zero
,
16
))
{
if
(
info
->
target
.
s_addr
==
0
&&
!
memcmp
(
info
->
target_ipv6
,
zero
,
16
))
{
vkprintf
(
0
,
"failed to proxy request to %s
\n
"
,
info
->
domain
);
vkprintf
(
0
,
"failed to proxy request to %s
\n
"
,
info
->
domain
);
...
@@ -848,31 +861,37 @@ static int proxy_connection (connection_job_t C, const struct domain_info *info)
...
@@ -848,31 +861,37 @@ static int proxy_connection (connection_job_t C, const struct domain_info *info)
return
0
;
return
0
;
}
}
int
port
=
c
->
remote_port
==
80
?
80
:
443
;
int
cfd
=
-
1
;
int
cfd
=
-
1
;
if
(
info
->
target
.
s_addr
)
{
if
(
info
->
target
.
s_addr
)
{
cfd
=
client_socket
(
info
->
target
.
s_addr
,
443
,
0
);
cfd
=
client_socket
(
info
->
target
.
s_addr
,
port
,
0
);
}
else
{
}
else
{
cfd
=
client_socket_ipv6
(
info
->
target_ipv6
,
443
,
0
);
cfd
=
client_socket_ipv6
(
info
->
target_ipv6
,
port
,
SM_IPV6
);
}
}
if
(
cfd
<
0
)
{
if
(
cfd
<
0
)
{
kprintf
(
"failed to create proxy pass conn: %d (%m)"
,
errno
);
fail_connection
(
C
,
-
27
);
fail_connection
(
C
,
-
27
);
return
0
;
return
0
;
}
}
struct
connection_info
*
c
=
CONN_INFO
(
C
);
c
->
type
->
crypto_free
(
C
);
c
->
type
->
crypto_free
(
C
);
job_incref
(
C
);
job_incref
(
C
);
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
,
443
);
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
)
{
if
(
!
EJ
)
{
kprintf
(
"failed to create proxy pass conn (2)"
);
job_decref_f
(
C
);
job_decref_f
(
C
);
fail_connection
(
C
,
-
37
);
fail_connection
(
C
,
-
37
);
return
0
;
return
0
;
}
}
c
->
type
=
&
ct_proxy_pass
;
c
->
type
=
&
ct_proxy_pass
;
c
->
extra
=
PTR_MOVE
(
EJ
);
c
->
extra
=
job_incref
(
EJ
);
assert
(
CONN_INFO
(
EJ
)
->
io_conn
);
unlock_job
(
JOB_REF_PASS
(
EJ
));
return
c
->
type
->
parse_execute
(
C
);
return
c
->
type
->
parse_execute
(
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