diff --git a/README.md b/README.md index 2e50a5dcf2fdd5eec60c84fc0a98a226aaf135dd..bcc66fefb939c3267b9cde5586ae7e1b1288f790 100644 --- a/README.md +++ b/README.md @@ -155,3 +155,19 @@ Load Balancing Logging ------- + +Tools +----- + +### Hijack + +See the [project page](https://gitlab.hedenstroem.com/erlang-ninja/hijack) on details of how to use and where to [download](http://s3.erlang.ninja/consul_proxy/extras/hijack) from. + + +### Consul Backup + +Used to backup the KEY/VALUE data from consul to a file. It can also restore KEY/VALUE data from a file. Download it [here](http://s3.erlang.ninja/consul_proxy/extras/consul-backup). + +### Password generator + +Use the password generator to create username:password values for the Auth middleware. It must also be used to generate passwords for the hijack configuration. Download it [here](http://s3.erlang.ninja/consul_proxy/extras/genpasswd). diff --git a/apps/consul_proxy/src/consul_proxy_router.erl b/apps/consul_proxy/src/consul_proxy_router.erl index 3baacc3992fd19a7dd667f85a5a07710a9c5c28b..7e793c98f0a8937c5b8372d95a34d18072f9eca7 100644 --- a/apps/consul_proxy/src/consul_proxy_router.erl +++ b/apps/consul_proxy/src/consul_proxy_router.erl @@ -162,7 +162,13 @@ lookup_resolver(_Domain, _Upstream, _Properties, undefined, _CacheFlag) -> lookup_resolver(Domain, Upstream, Properties, ServiceResolver, _CacheFlag) -> case consul_proxy_utils:eval_script(ServiceResolver, build_script_vars(Properties, Upstream)) of {ok, Result} -> - lookup_services(Domain, Upstream, Result, false); + case consul_proxy_utils:is_proplist(Result) of + true -> + lookup_services(Domain, Upstream, Result, false); + false -> + lager:error("Script '~s' result is not a proplist: ~p", [ServiceResolver, Result]), + {error, route_lookup_failed} + end; {error, Reason} -> lager:error("Failed to evaluate '~s': ~p", [ServiceResolver, Reason]), {error, route_lookup_failed} diff --git a/apps/consul_proxy/src/consul_proxy_utils.erl b/apps/consul_proxy/src/consul_proxy_utils.erl index cb0dddda9faf8f5377aeca224e20c46cdc7bba20..e8a90f7354e7f633158c8b7ef747df46716f1b1b 100644 --- a/apps/consul_proxy/src/consul_proxy_utils.erl +++ b/apps/consul_proxy/src/consul_proxy_utils.erl @@ -12,7 +12,8 @@ cache_get/1, cache_add/2, cache_purge/0, - cache_size/0 + cache_size/0, + is_proplist/1 ]). -include("consul_proxy.hrl"). @@ -296,3 +297,11 @@ cache_purge() -> -spec cache_size() -> non_neg_integer(). cache_size() -> lru:size(consul_cache). + +-spec is_proplist(List :: term()) -> boolean(). +is_proplist([]) -> + true; +is_proplist([{_, _} | L]) -> + is_proplist(L); +is_proplist(_) -> + false.