Skip to content

Commit

Permalink
plugin: add httpd plugin
Browse files Browse the repository at this point in the history
Signed-off-by: staylightblow8 <liudf0716@gmail.com>
  • Loading branch information
liudf0716 committed Dec 3, 2023
1 parent 969c0a1 commit 46e3f7d
Show file tree
Hide file tree
Showing 9 changed files with 12,066 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,13 @@ set(src_xfrpc
proxy.c
tcpmux.c
tcp_redir.c
mongoose.c
)

set(src_xfrpc_plugins
plugins/telnetd.c
plugins/instaloader.c)
plugins/instaloader.c
plugins/httpd.c)

set(libs
ssl
Expand Down
2 changes: 2 additions & 0 deletions client.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ struct proxy_service {
char *plugin_user;
char *plugin_pwd;

char *s_root_dir;

// private arguments
UT_hash_handle hh;
};
Expand Down
13 changes: 13 additions & 0 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ new_proxy_service(const char *name)
ps->plugin_user = NULL;
ps->plugin_pwd = NULL;

ps->s_root_dir = NULL;

return ps;
}

Expand Down Expand Up @@ -333,6 +335,15 @@ process_plugin_conf(struct proxy_service *ps)
ps->remote_port == XFRPC_PLUGIN_INSTALOADER_ROMOTE_PORT;
if (ps->local_ip == NULL)
ps->local_ip = strdup("0.0.0.0");
} else if (strcmp(ps->plugin, "httpd") == 0) {
if (ps->local_port == 0)
ps->local_port = XFRPC_PLUGIN_HTTPD_PORT;
if (ps->local_ip == NULL)
ps->local_ip = strdup("0.0.0.0");
if (ps->remote_port == 0)
ps->remote_port = XFRPC_PLUGIN_HTTPD_REMOTE_PORT;
if (ps->s_root_dir == NULL)
ps->s_root_dir = strdup("/var/www/html");
} else {
debug(LOG_INFO, "plugin %s is not supportted", ps->plugin);
}
Expand Down Expand Up @@ -412,6 +423,8 @@ proxy_service_handler(void *user, const char *sect, const char *nm, const char *
ps->plugin_user = strdup(value);
} else if (MATCH_NAME("plugin_pwd")) {
ps->plugin_pwd = strdup(value);
} else if (MATCH_NAME("root_dir")) {
ps->s_root_dir = strdup(value);
} else {
debug(LOG_ERR, "unknown option %s in section %s", nm, section);
SAFE_FREE(section);
Expand Down
2 changes: 2 additions & 0 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#define XFRPC_PLUGIN_TELNETD_PORT 23
#define XFRPC_PLUGIN_INSTALOADER_PORT 10000
#define XFRPC_PLUGIN_INSTALOADER_ROMOTE_PORT 10001
#define XFRPC_PLUGIN_HTTPD_PORT 8000
#define XFRPC_PLUGIN_HTTPD_REMOTE_PORT 8001

#define FTP_RMT_CTL_PROXY_SUFFIX "_ftp_remote_ctl_proxy"

Expand Down
Loading

0 comments on commit 46e3f7d

Please sign in to comment.