New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
router: Add configurable forward zones #35
Conversation
@GoelDeepak @drewkerrigan ready for review. Also, ideas on how to test this change? I've only manually tested it for now. |
Codecov Report
@@ Coverage Diff @@
## master #35 +/- ##
==========================================
+ Coverage 59.61% 60.12% +0.51%
==========================================
Files 12 12
Lines 463 484 +21
==========================================
+ Hits 276 291 +15
- Misses 187 193 +6
Continue to review full report at Codecov.
|
402d476
to
c7027ac
Compare
src/spartan_router.erl
Outdated
@@ -7,7 +7,8 @@ | |||
-include_lib("dns/include/dns_records.hrl"). | |||
|
|||
%% API | |||
-export([upstreams_from_questions/1]). | |||
%-export([upstreams_from_questions/1]). | |||
-compile(export_all). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any specific reason for using export_all?
src/spartan_router.erl
Outdated
find_custom_upstream(QueryLabels) -> | ||
ForwardZones = spartan_config:forward_zones(), | ||
|
||
UpstreamFilter = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this to its own function for readability. Somthing like mk_fun_upstream_filter..
src/spartan_app.erl
Outdated
@@ -125,6 +129,9 @@ load_json_config(FileBin) -> | |||
process_config_tuple({<<"upstream_resolvers">>, UpstreamResolvers}) -> | |||
UpstreamIPsAndPorts = lists:map(fun (Resolver) -> parse_ipv4_address_with_port(Resolver, 53) end, UpstreamResolvers), | |||
application:set_env(?APP, upstream_resolvers, UpstreamIPsAndPorts); | |||
process_config_tuple({<<"forward_zones">>, Upstreams0}) -> | |||
Upstreams1 = lists:foldl(fun parse_upstream/2, #{}, Upstreams0), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My personal preference is to use maps:new() instead of #{} that way we safeguard ourselves from internal changes to maps module
src/spartan_config.erl
Outdated
@@ -28,6 +28,10 @@ tcp_port() -> | |||
udp_port() -> | |||
application:get_env(?APP, udp_port, 5454). | |||
|
|||
-spec(forward_zones() -> #{[dns:label()] => [{string(), integer()}]}). | |||
forward_zones() -> | |||
application:get_env(?APP, forward_zones, #{}). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maps:new()
c7027ac
to
e2583f0
Compare
@GoelDeepak addressed comments. also make a new type raw_upstream(). As well as pulled out the label parsing into a separate function. |
No description provided.