added 'resolve' option

This commit is contained in:
Unbit
2014-05-29 09:50:50 +02:00
parent fd663aedbd
commit bae1ade00a
3 changed files with 20 additions and 0 deletions
+16
View File
@@ -816,3 +816,19 @@ char *uwsgi_manage_placeholder(char *key) {
return current_value;
}
void uwsgi_opt_resolve(char *opt, char *value, void *foo) {
char *equal = strchr(value, '=');
if (!equal) {
uwsgi_log("invalid resolve syntax, must be placeholder=domain\n");
exit(1);
}
char *ip = uwsgi_resolve_ip(equal+1);
if (!ip) {
uwsgi_log("unable to resolve name %s\n", equal+1);
uwsgi_error("uwsgi_resolve_ip()");
exit(1);
}
char *new_opt = uwsgi_concat2n(value, (equal-value)+1, ip, strlen(ip));
uwsgi_opt_set_placeholder(opt, new_opt, (void *) 1);
}
+2
View File
@@ -101,6 +101,8 @@ static struct uwsgi_option uwsgi_base_options[] = {
{"declare-option", required_argument, 0, "declare a new uWSGI custom option", uwsgi_opt_add_custom_option, NULL, UWSGI_OPT_IMMEDIATE},
{"declare-option2", required_argument, 0, "declare a new uWSGI custom option (non-immediate)", uwsgi_opt_add_custom_option, NULL, 0},
{"resolve", required_argument, 0, "place the result of a dns query in the specified placeholder, sytax: placeholder=name (immediate option)", uwsgi_opt_resolve, NULL, UWSGI_OPT_IMMEDIATE},
{"for", required_argument, 0, "(opt logic) for cycle", uwsgi_opt_logic, (void *) uwsgi_logic_opt_for, UWSGI_OPT_IMMEDIATE},
{"for-glob", required_argument, 0, "(opt logic) for cycle (expand glob)", uwsgi_opt_logic, (void *) uwsgi_logic_opt_for_glob, UWSGI_OPT_IMMEDIATE},
{"for-times", required_argument, 0, "(opt logic) for cycle (expand the specified num to a list starting from 1)", uwsgi_opt_logic, (void *) uwsgi_logic_opt_for_times, UWSGI_OPT_IMMEDIATE},
+2
View File
@@ -3792,6 +3792,8 @@ int uwsgi_logic_opt_if_plugin(char *, char *);
int uwsgi_logic_opt_if_not_plugin(char *, char *);
void uwsgi_opt_resolve(char *, char *, void *);
#ifdef UWSGI_CAP
void uwsgi_opt_set_cap(char *, char *, void *);
void uwsgi_opt_set_emperor_cap(char *, char *, void *);