diff --git a/teller.cc b/teller.cc index 0db48b5..c9fdec9 100644 --- a/teller.cc +++ b/teller.cc @@ -14,6 +14,7 @@ using namespace std; struct TrackerConf { + string name; // superfluous but makes life easier double freq{400}; double balance{0.5}; // 0 is left, 1 is right std::atomic counter{0}; @@ -86,6 +87,7 @@ int main(int argc, char** argv) auto tellerarr = conftbl.as_table(); for(const auto& t : *tellerarr) { auto& entry = trackerdb[(string)t.first]; + entry.name = t.first; entry.balance = conftbl[t.first]["balance"].value_or(0.5); entry.freq = conftbl[t.first]["freq"].value_or(500); cout <<"Want to play sound for tracker "<'); if(pos == string::npos) continue; - auto pos2 = line.find('.', pos); + auto pos2 = line.find('.', pos); // this misses out on IPv6 ICMP if(pos2 == string::npos) continue; line.resize(pos2); string ip = line.substr(pos+2, pos2 - pos - 2); - if(tracksneg.lookup(&line.at(pos+2))) { - cout<name<<")"<counter++; + else if(auto fptr = trackspos.lookup(ip.c_str())) { + auto ptr = (TrackerConf*)fptr; + cout<name<<")"<counter++; } } else { @@ -179,13 +183,15 @@ int main(int argc, char** argv) line.resize(pos2); string ip=line.substr(pos+2, pos2 - pos - 2); - // cout<<&line.at(pos+2)<name<<")"<counter++; + else if(auto fptr = trackspos.lookup(ip.c_str())) { + auto ptr = (TrackerConf*)fptr; + cout<name<<")"<counter++; } }