Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
b5dd0e80
Commit
b5dd0e80
authored
Oct 19, 2017
by
Бобби
Committed by
Cesanta Bot
Oct 19, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use verbose flags in both socks client and server
PUBLISHED_FROM=d17e96a97e1621e9788844bcd627c3143d37315c
parent
9b24fdfd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
10 deletions
+11
-10
mongoose.c
mongoose.c
+8
-10
mongoose.h
mongoose.h
+3
-0
No files found.
mongoose.c
View file @
b5dd0e80
...
...
@@ -4056,9 +4056,6 @@ const struct mg_iface_vtable mg_default_iface_vtable = MG_SOCKET_IFACE_VTABLE;
#if MG_ENABLE_SOCKS
#define MG_SOCKS_HANDSHAKE_DONE MG_F_USER_1
#define MG_SOCKS_CONNECT_DONE MG_F_USER_2
struct
socksdata
{
char
*
proxy_addr
;
/* HOST:PORT of the socks5 proxy server */
struct
mg_connection
*
s
;
/* Respective connection to the server */
...
...
@@ -12807,8 +12804,8 @@ struct mg_connection *mg_sntp_get_time(struct mg_mgr *mgr,
#if MG_ENABLE_SOCKS
/* Amalgamated: #include "mongoose/src/internal.h" */
/* Amalgamated: #include "mongoose/src/socks.h" */
/* Amalgamated: #include "mongoose/src/internal.h" */
/*
* https://www.ietf.org/rfc/rfc1928.txt paragraph 3, handle client handshake
...
...
@@ -12833,7 +12830,7 @@ static void mg_socks5_handshake(struct mg_connection *c) {
}
mbuf_remove
(
r
,
2
+
r
->
buf
[
1
]);
mg_send
(
c
,
reply
,
sizeof
(
reply
));
c
->
flags
|=
MG_
F_USER_1
;
/* Mark handshake done */
c
->
flags
|=
MG_
SOCKS_HANDSHAKE_DONE
;
/* Mark handshake done */
}
}
...
...
@@ -12937,17 +12934,18 @@ static void mg_socks5_handle_request(struct mg_connection *c) {
}
mg_send
(
c
,
r
->
buf
+
3
,
addr_len
+
1
+
2
);
mbuf_remove
(
r
,
6
+
addr_len
);
/* Remove request from the input stream */
c
->
flags
|=
MG_
F_USER_2
;
/* Mark ourselves as connected */
mbuf_remove
(
r
,
6
+
addr_len
);
/* Remove request from the input stream */
c
->
flags
|=
MG_
SOCKS_CONNECT_DONE
;
/* Mark ourselves as connected */
}
static
void
socks_handler
(
struct
mg_connection
*
c
,
int
ev
,
void
*
ev_data
)
{
if
(
ev
==
MG_EV_RECV
)
{
if
(
!
(
c
->
flags
&
MG_F_USER_1
))
mg_socks5_handshake
(
c
);
if
(
c
->
flags
&
MG_F_USER_1
&&
!
(
c
->
flags
&
MG_F_USER_2
))
{
if
(
!
(
c
->
flags
&
MG_SOCKS_HANDSHAKE_DONE
))
mg_socks5_handshake
(
c
);
if
(
c
->
flags
&
MG_SOCKS_HANDSHAKE_DONE
&&
!
(
c
->
flags
&
MG_SOCKS_CONNECT_DONE
))
{
mg_socks5_handle_request
(
c
);
}
if
(
c
->
flags
&
MG_
F_USER_2
)
relay_data
(
c
);
if
(
c
->
flags
&
MG_
SOCKS_CONNECT_DONE
)
relay_data
(
c
);
}
else
if
(
ev
==
MG_EV_CLOSE
)
{
disband
(
c
);
}
...
...
mongoose.h
View file @
b5dd0e80
...
...
@@ -6051,6 +6051,9 @@ struct mg_connection *mg_sntp_get_time(struct mg_mgr *mgr,
#define MG_SOCKS_VERSION 5
#define MG_SOCKS_HANDSHAKE_DONE MG_F_USER_1
#define MG_SOCKS_CONNECT_DONE MG_F_USER_2
/* SOCKS5 handshake methods */
enum
mg_socks_handshake_method
{
MG_SOCKS_HANDSHAKE_NOAUTH
=
0
,
/* Handshake method - no authentication */
...
...
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