ezelkow1 commented on a change in pull request #6980: URL: https://github.com/apache/trafficserver/pull/6980#discussion_r453843447
########## File path: plugins/experimental/maxmind_acl/mmdb.cc ########## @@ -0,0 +1,563 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "mmdb.h" + +/////////////////////////////////////////////////////////////////////////////// +// Load the config file from param +// check for basics +// Clear out any existing data since this may be a reload +bool +Acl::init(char const *filename) +{ + std::string configloc; + struct stat s; + bool status = false; + + YAML::Node maxmind; + + if (filename[0] != '/') { + // relative file + configloc = TSConfigDirGet(); + configloc += "/"; + configloc.append(filename); + } else { + configloc.assign(filename); + } + + if (stat(configloc.c_str(), &s) < 0) { + TSDebug(PLUGIN_NAME, "Could not stat %s", configloc.c_str()); + return status; + } + + try { + _config = YAML::LoadFile(configloc.c_str()); + + if (_config.IsNull()) { + TSDebug(PLUGIN_NAME, "Config file not found or unreadable"); + return status; + } + if (!_config["maxmind"]) { + TSDebug(PLUGIN_NAME, "Config file not in maxmind namespace"); + return status; + } + + // Get our root maxmind node + maxmind = _config["maxmind"]; +#if 0 + // Test junk + for (YAML::const_iterator it = maxmind.begin(); it != maxmind.end(); ++it) { + const std::string &name = it->first.as<std::string>(); + YAML::NodeType::value type = it->second.Type(); + TSDebug(PLUGIN_NAME, "name: %s, value: %d", name.c_str(), type); + } +#endif Review comment: Oh also all these #if'd blocks are basically just informational printouts. Mostly to print out structures inside the maxminddb file or to print out structures from the yaml config files for if/when we want to add new supported fields from the database files. Thats why they are all #if'd out since we normally dont need to see them even when just debugging issues Just trying to avoid having to remember how to do debug like that in the future by leaving them in there ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
