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
59348468
Commit
59348468
authored
8 years ago
by
Marko Mikulicic
Committed by
Cesanta Bot
8 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make mg_tun_bind take separate user+pass
PUBLISHED_FROM=3ee9478275c4b9253b1dd4f98a69cecc89290bce
parent
5045dfab
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
13 deletions
+24
-13
tun.c
examples/tun/tun.c
+8
-4
mongoose.c
mongoose.c
+11
-7
mongoose.h
mongoose.h
+5
-2
No files found.
examples/tun/tun.c
View file @
59348468
...
...
@@ -2,7 +2,8 @@
static
const
char
*
s_local_port
=
":8001"
;
static
const
char
*
s_dispatcher
=
"ws://localhost:8000"
;
static
const
char
*
s_auth
=
"foo:bar"
;
static
const
char
*
s_user
=
"foo"
;
static
const
char
*
s_pass
=
"bar"
;
void
ev_handler
(
struct
mg_connection
*
nc
,
int
ev
,
void
*
ev_data
)
{
struct
http_message
*
hm
=
(
struct
http_message
*
)
ev_data
;
...
...
@@ -36,16 +37,19 @@ int main(int argc, char **argv) {
for
(
i
=
1
;
i
<
argc
;
i
++
)
{
if
(
strcmp
(
argv
[
i
],
"-D"
)
==
0
)
{
mgr
.
hexdump_file
=
argv
[
++
i
];
}
else
if
(
strcmp
(
argv
[
i
],
"-
p
"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-
l
"
)
==
0
)
{
s_local_port
=
argv
[
++
i
];
}
else
if
(
strcmp
(
argv
[
i
],
"-d"
)
==
0
)
{
s_dispatcher
=
argv
[
++
i
];
}
else
if
(
strcmp
(
argv
[
i
],
"-u"
)
==
0
)
{
s_auth
=
argv
[
++
i
];
s_user
=
argv
[
++
i
];
}
else
if
(
strcmp
(
argv
[
i
],
"-p"
)
==
0
)
{
s_pass
=
argv
[
++
i
];
}
}
if
((
nc
=
mg_tuna_bind
(
&
mgr
,
ev_handler
,
s_dispatcher
,
s_auth
))
==
NULL
)
{
if
((
nc
=
mg_tuna_bind
(
&
mgr
,
ev_handler
,
s_dispatcher
,
s_user
,
s_pass
))
==
NULL
)
{
fprintf
(
stderr
,
"Cannot create tunneled listening socket on [%s]
\n
"
,
s_dispatcher
);
exit
(
EXIT_FAILURE
);
...
...
This diff is collapsed.
Click to expand it.
mongoose.c
View file @
59348468
...
...
@@ -10557,11 +10557,12 @@ static void mg_tun_reconnect(struct mg_tun_client *client);
static
void
mg_tun_init_client
(
struct
mg_tun_client
*
client
,
struct
mg_mgr
*
mgr
,
struct
mg_iface
*
iface
,
const
char
*
dispatcher
,
const
char
*
auth
)
{
const
char
*
user
,
const
char
*
pass
)
{
client
->
mgr
=
mgr
;
client
->
iface
=
iface
;
client
->
disp_url
=
dispatcher
;
client
->
auth
=
auth
;
client
->
user
=
user
;
client
->
pass
=
pass
;
client
->
last_stream_id
=
0
;
client
->
disp
=
NULL
;
/* will be set by mg_tun_reconnect */
...
...
@@ -10671,7 +10672,7 @@ static void mg_tun_do_reconnect(struct mg_tun_client *client) {
mbuf_init
(
&
headers
,
0
);
/* HTTP/Websocket listener */
mg_basic_auth_header
(
client
->
auth
,
NULL
,
&
headers
);
mg_basic_auth_header
(
client
->
user
,
client
->
pass
,
&
headers
);
mbuf_append
(
&
headers
,
""
,
1
);
/* nul terminate */
if
((
dc
=
mg_connect_ws
(
client
->
mgr
,
mg_tun_client_handler
,
client
->
disp_url
,
"mg_tun"
,
headers
.
buf
))
==
NULL
)
{
...
...
@@ -10709,7 +10710,8 @@ static void mg_tun_reconnect(struct mg_tun_client *client) {
static
struct
mg_tun_client
*
mg_tun_create_client
(
struct
mg_mgr
*
mgr
,
const
char
*
dispatcher
,
const
char
*
auth
)
{
const
char
*
user
,
const
char
*
pass
)
{
struct
mg_tun_client
*
client
=
NULL
;
struct
mg_iface
*
iface
=
mg_find_iface
(
mgr
,
&
mg_tun_iface_vtable
,
NULL
);
if
(
iface
==
NULL
)
{
...
...
@@ -10719,7 +10721,7 @@ static struct mg_tun_client *mg_tun_create_client(struct mg_mgr *mgr,
}
client
=
(
struct
mg_tun_client
*
)
MG_MALLOC
(
sizeof
(
*
client
));
mg_tun_init_client
(
client
,
mgr
,
iface
,
dispatcher
,
auth
);
mg_tun_init_client
(
client
,
mgr
,
iface
,
dispatcher
,
user
,
pass
);
iface
->
data
=
client
;
mg_tun_do_reconnect
(
client
);
...
...
@@ -10744,8 +10746,10 @@ static struct mg_connection *mg_tuna_do_bind(struct mg_tun_client *client,
struct
mg_connection
*
mg_tuna_bind
(
struct
mg_mgr
*
mgr
,
mg_event_handler_t
handler
,
const
char
*
dispatcher
,
const
char
*
auth
)
{
struct
mg_tun_client
*
client
=
mg_tun_create_client
(
mgr
,
dispatcher
,
auth
);
const
char
*
dispatcher
,
const
char
*
user
,
const
char
*
pass
)
{
struct
mg_tun_client
*
client
=
mg_tun_create_client
(
mgr
,
dispatcher
,
user
,
pass
);
if
(
client
==
NULL
)
{
return
NULL
;
}
...
...
This diff is collapsed.
Click to expand it.
mongoose.h
View file @
59348468
...
...
@@ -5560,7 +5560,9 @@ struct mg_tun_client {
struct
mg_mgr
*
mgr
;
struct
mg_iface
*
iface
;
const
char
*
disp_url
;
const
char
*
auth
;
const
char
*
user
;
const
char
*
pass
;
uint32_t
last_stream_id
;
/* stream id of most recently accepted connection */
struct
mg_connection
*
disp
;
...
...
@@ -5573,7 +5575,8 @@ extern "C" {
struct
mg_connection
*
mg_tuna_bind
(
struct
mg_mgr
*
mgr
,
mg_event_handler_t
handler
,
const
char
*
dispatcher
,
const
char
*
auth
);
const
char
*
dispatcher
,
const
char
*
user
,
const
char
*
pass
);
int
mg_tun_parse_frame
(
void
*
data
,
size_t
len
,
struct
mg_tun_frame
*
frame
);
...
...
This diff is collapsed.
Click to expand it.
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