mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-28 12:30:58 +00:00
Overload mg_bind to bind to tunnel
PUBLISHED_FROM=f554cc63dfea12455fe5e428c6ce5f3152774f8e
This commit is contained in:
1 parent
296affc6e4
commit
e1a9ad7f82
4 files changed
+135
-118
No files matched your search
+2
-9
@@ -1,9 +1,7 @@
|
||||
#include "mongoose.h"
|
||||
|
||||
static const char *s_local_port = ":8001";
|
||||
static const char *s_dispatcher = "ws://localhost:8000";
|
||||
static const char *s_user = "foo";
|
||||
static const char *s_pass = "bar";
|
||||
static const char *s_dispatcher = "ws://foo:bar@localhost:8000";
|
||||
|
||||
void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
|
||||
struct http_message *hm = (struct http_message *) ev_data;
|
||||
@@ -41,15 +39,10 @@ int main(int argc, char **argv) {
|
||||
s_local_port = argv[++i];
|
||||
} else if (strcmp(argv[i], "-d") == 0) {
|
||||
s_dispatcher = argv[++i];
|
||||
} else if (strcmp(argv[i], "-u") == 0) {
|
||||
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_user, s_pass)) ==
|
||||
NULL) {
|
||||
if ((nc = mg_bind(&mgr, s_dispatcher, ev_handler)) == NULL) {
|
||||
fprintf(stderr, "Cannot create tunneled listening socket on [%s]\n",
|
||||
s_dispatcher);
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
Reference in new issue
Block a user