Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Improve zone server configurability.

  • Loading branch information...
commit 4f8eb67cd2dda5cef133a46471e151fcbbae5bcf 1 parent b5afc54
@aeden aeden authored
View
2  ebin/erldns.app
@@ -1,6 +1,6 @@
{application,erldns,
[{description,"Erlang Authoritative DNS Server"},
- {vsn,"67d537d"},
+ {vsn,"b5afc54"},
{mod,{erldns_app,[]}},
{applications,[kernel,stdlib,inets,crypto,ssl]},
{start_phases,[{post_start,[]}]},
View
4 erldns.config.example
@@ -5,7 +5,9 @@
{inet6, "::1"},
{catch_exceptions, false},
{credentials, {"indentifier", "token"}},
- {zone_server_host, "your-zone-server.example.com"},
+ {zone_server, [
+ {host, "your-zone-server.example.com"}
+ ]},
{zones, "zones.json"},
{pools, [
{tcp_worker_pool, [
View
2  src/erldns_app.erl
@@ -18,7 +18,7 @@ start_phase(post_start, _StartType, _PhaseArgs) ->
lager:info("Loading zones from local file"),
erldns_metrics:measure(none, erldns_zone_loader, load_zones, []),
- case application:get_env(erldns, zone_server_host) of
+ case application:get_env(erldns, zone_server) of
{ok, _} ->
lager:info("Loading zones from remote server"),
erldns_metrics:measure(none, erldns_zone_client, fetch_zones, []);
View
2  src/erldns_sup.erl
@@ -36,7 +36,7 @@ init(_Args) ->
?CHILD(sample_custom_handler, worker, [])
],
- OptionalProcs = case application:get_env(erldns, zone_server_host) of
+ OptionalProcs = case application:get_env(erldns, zone_server) of
{ok, _} -> [?CHILD(erldns_zone_client, worker, [])];
_ -> []
end,
View
39 src/erldns_zone_client.erl
@@ -17,8 +17,12 @@
% Public API
start_link() ->
- lager:info("Starting websocket client"),
- StartLinkResult = websocket_client:start_link(?MODULE, wss, zone_server_host(), 443, "/ws", []),
+ WsProtocol = websocket_protocol(),
+ WsHost = websocket_host(),
+ WsPort = websocket_port(),
+ WsPath = websocket_path(),
+ lager:info("Starting websocket client (protocol=~p, host=~p, port=~p, path=~p)", [WsProtocol, WsHost, WsPort, WsPath]),
+ StartLinkResult = websocket_client:start_link(?MODULE, WsProtocol, WsHost, WsPort, WsPath, []),
{ok, StartLinkResult}.
fetch_zones() ->
@@ -98,12 +102,37 @@ websocket_terminate(Message, State) ->
ok.
%% Internal functions
+
+zone_server_env() ->
+ {ok, ZoneServerEnv} = application:get_env(erldns, zone_server),
+ ZoneServerEnv.
+
+zone_server_protocol() ->
+ proplists:get_value(protocol, zone_server_env(), "https").
+
zone_server_host() ->
- {ok, ZoneServerHost} = application:get_env(erldns, zone_server_host),
- ZoneServerHost.
+ proplists:get_value(host, zone_server_env(), "localhost").
+
+zone_server_port() ->
+ proplists:get_value(port, zone_server_env(), 433).
+
+websocket_env() ->
+ proplists:get_value(websocket, zone_server_env(), []).
+
+websocket_protocol() ->
+ proplists:get_value(protocol, websocket_env(), "wss").
+
+websocket_host() ->
+ proplists:get_value(host, websocket_env(), zone_server_host()).
+
+websocket_port() ->
+ proplists:get_value(port, websocket_env(), zone_server_port()).
+
+websocket_path() ->
+ proplists:get_value(path, websocket_env(), "/ws").
zones_url() ->
- "https://" ++ zone_server_host() ++ "/zones/".
+ zone_server_protocol() ++ "://" ++ zone_server_host() ++ ":" ++ integer_to_list(zone_server_port()) ++ "/zones/".
encoded_credentials() ->
case application:get_env(erldns, credentials) of
Please sign in to comment.
Something went wrong with that request. Please try again.