diff --git a/Makefile b/Makefile index a2921f2..5998a41 100644 --- a/Makefile +++ b/Makefile @@ -34,3 +34,16 @@ $(BIN)/%.o: %.c clean: rm -rf $(APP) rm -rf $(BIN) + +install: + cp bin/app /usr/local/bin/wrapper + +uninstall: + rm /usr/local/bin/wrapper + +openrc-install: install + cp service/openrc /etc/init.d/wrapper + chmod +x /etc/init.d/wrapper + +openrc-uninstall: uninstall + rm /etc/init.d/wrapper diff --git a/service/openrc b/service/openrc new file mode 100644 index 0000000..c357a0b --- /dev/null +++ b/service/openrc @@ -0,0 +1,13 @@ +#!/sbin/openrc-run +name="WrapperDNS" +description="Wrapper dns server" +command=/usr/local/bin/wrapper +supervisor=supervise-daemon + +depend() { + need net +} + +#start_pre() { +# export PORT=53 +#} diff --git a/src/io/config.c b/src/io/config.c index bf9d96a..d6cb6c3 100644 --- a/src/io/config.c +++ b/src/io/config.c @@ -475,10 +475,11 @@ static void config_push_record(Record** buf, Record record, uint16_t* capacity, bool load_config(const char* path, RecordMap* map) { FILE* file = fopen(path, "r"); if (file == NULL) { - ERROR("Failed to open file %s: %s", path, strerror(errno)); return false; } + INFO("Using config file at path: %s", path); + line = 0; record_map_init(map); diff --git a/src/server/server.c b/src/server/server.c index bcb070d..c02a645 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -21,7 +21,16 @@ void server_init(uint16_t port, Server* server) { INFO("Server port set to %hu", port); create_binding(UDP, port, &server->udp); create_binding(TCP, port, &server->tcp); - load_config("config", &map); + + if (load_config("/etc/wrapper.conf", &map)) { + return; + } + + if (load_config("config", &map)) { + return; + } + + WARN("No dns config files were found"); } struct DnsRequest {