Skip to content

Commit 46e3f7d

Browse files
committed
plugin: add httpd plugin
Signed-off-by: staylightblow8 <liudf0716@gmail.com>
1 parent 969c0a1 commit 46e3f7d

File tree

9 files changed

+12066
-1
lines changed

9 files changed

+12066
-1
lines changed

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,13 @@ set(src_xfrpc
8080
proxy.c
8181
tcpmux.c
8282
tcp_redir.c
83+
mongoose.c
8384
)
8485

8586
set(src_xfrpc_plugins
8687
plugins/telnetd.c
87-
plugins/instaloader.c)
88+
plugins/instaloader.c
89+
plugins/httpd.c)
8890

8991
set(libs
9092
ssl

client.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ struct proxy_service {
106106
char *plugin_user;
107107
char *plugin_pwd;
108108

109+
char *s_root_dir;
110+
109111
// private arguments
110112
UT_hash_handle hh;
111113
};

config.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ new_proxy_service(const char *name)
194194
ps->plugin_user = NULL;
195195
ps->plugin_pwd = NULL;
196196

197+
ps->s_root_dir = NULL;
198+
197199
return ps;
198200
}
199201

@@ -333,6 +335,15 @@ process_plugin_conf(struct proxy_service *ps)
333335
ps->remote_port == XFRPC_PLUGIN_INSTALOADER_ROMOTE_PORT;
334336
if (ps->local_ip == NULL)
335337
ps->local_ip = strdup("0.0.0.0");
338+
} else if (strcmp(ps->plugin, "httpd") == 0) {
339+
if (ps->local_port == 0)
340+
ps->local_port = XFRPC_PLUGIN_HTTPD_PORT;
341+
if (ps->local_ip == NULL)
342+
ps->local_ip = strdup("0.0.0.0");
343+
if (ps->remote_port == 0)
344+
ps->remote_port = XFRPC_PLUGIN_HTTPD_REMOTE_PORT;
345+
if (ps->s_root_dir == NULL)
346+
ps->s_root_dir = strdup("/var/www/html");
336347
} else {
337348
debug(LOG_INFO, "plugin %s is not supportted", ps->plugin);
338349
}
@@ -412,6 +423,8 @@ proxy_service_handler(void *user, const char *sect, const char *nm, const char *
412423
ps->plugin_user = strdup(value);
413424
} else if (MATCH_NAME("plugin_pwd")) {
414425
ps->plugin_pwd = strdup(value);
426+
} else if (MATCH_NAME("root_dir")) {
427+
ps->s_root_dir = strdup(value);
415428
} else {
416429
debug(LOG_ERR, "unknown option %s in section %s", nm, section);
417430
SAFE_FREE(section);

config.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
#define XFRPC_PLUGIN_TELNETD_PORT 23
3535
#define XFRPC_PLUGIN_INSTALOADER_PORT 10000
3636
#define XFRPC_PLUGIN_INSTALOADER_ROMOTE_PORT 10001
37+
#define XFRPC_PLUGIN_HTTPD_PORT 8000
38+
#define XFRPC_PLUGIN_HTTPD_REMOTE_PORT 8001
3739

3840
#define FTP_RMT_CTL_PROXY_SUFFIX "_ftp_remote_ctl_proxy"
3941

0 commit comments

Comments
 (0)