int main(int argc, char* argv[]) { if(argc != 2) log_fatal("config file must be set on commandline"); gdmaps_t* gdmaps = gdmaps_test_init(argv[1]); unsigned tnum = 0; //datacenters => [ us, ie, sg ] gdmaps_test_lookup_check(tnum++, gdmaps, "my_prod_map", "137.138.144.168", "\2\1\3", 16); // Geneva gdmaps_test_lookup_check(tnum++, gdmaps, "my_prod_map", "69.58.186.119", "\1\2\3", 16); // US East Coast gdmaps_test_lookup_check(tnum++, gdmaps, "my_prod_map", "117.53.170.202", "\3\1\2", 20); // Australia gdmaps_destroy(gdmaps); }
int main(int argc, char* argv[]) { if(argc != 2) log_fatal("root directory must be set on commandline"); gdmaps_t* gdmaps = gdmaps_test_init(argv[1]); unsigned tnum = 0; gdmaps_test_lookup_check(tnum++, gdmaps, "my_prod_map", "192.0.2.1", "\1\2", 19); gdmaps_test_lookup_check(tnum++, gdmaps, "my_prod_map", "79.125.18.68", "\1", 17); gdmaps_test_lookup_check(tnum++, gdmaps, "my_prod_map", "69.58.186.119", "\2\1", 16); gdmaps_test_lookup_check(tnum++, gdmaps, "my_prod_map", "::69.58.186.119", "\2\1", 112); // v4-compat gdmaps_test_lookup_check(tnum++, gdmaps, "my_prod_map", "::FFFF:69.58.186.119", "\2\1", 112); // v4-mapped gdmaps_test_lookup_check(tnum++, gdmaps, "my_prod_map", "::FFFF:0:69.58.186.119", "\2\1", 112); // SIIT gdmaps_test_lookup_check(tnum++, gdmaps, "my_prod_map", "2002:453A:BA77::", "\2\1", 32); // 6to4 gdmaps_test_lookup_check(tnum++, gdmaps, "my_prod_map", "2001::BAC5:4588", "\2\1", 112); // Teredo gdmaps_test_lookup_check(tnum++, gdmaps, "my_prod_map", "2600:3c00::f03c:91ff:fe96:6a4f", "\2\1", 30); gdmaps_test_lookup_check(tnum++, gdmaps, "my_prod_map", "137.138.144.168", "\2", 16); // City, Geneva gdmaps_test_lookup_check(tnum++, gdmaps, "my_prod_map", "::FFFF:137.138.144.168", "\2", 112); // City, Geneva }
int main(int argc, char* argv[]) { const char* input_cfgdir = NULL; const char* map_name = NULL; const char* ip_arg = NULL; switch(argc) { // gdnsd_geoip_test -c x map_name ip case 5: if(strcmp(argv[1], "-c")) usage(argv[0]); input_cfgdir = argv[2]; map_name = argv[3]; ip_arg = argv[4]; break; // gdnsd_geoip_test map_name ip // -or- // gdnsd_geoip_test -c x case 3: if(!strcmp(argv[1], "-c")) { input_cfgdir = argv[2]; } else { map_name = argv[1]; ip_arg = argv[2]; } break; // no args at all case 1: break; default: usage(argv[0]); } gdmaps_t* gdmaps = gdmaps_test_init(input_cfgdir); if(map_name) { dmn_assert(ip_arg); do_lookup(gdmaps, map_name, ip_arg); } else { do_repl(gdmaps); } return 0; }
int main(int argc, char* argv[]) { if(argc != 2) log_fatal("config file must be set on commandline"); gdmaps_t* gdmaps = gdmaps_test_init(argv[1]); unsigned tnum = 0; gdmaps_test_lookup_check(tnum++, gdmaps, "my_prod_map", "192.0.2.1", "\1\2", 19); gdmaps_test_lookup_check(tnum++, gdmaps, "my_prod_map", "192.0.0.1", "\1\2", 19); gdmaps_test_lookup_check(tnum++, gdmaps, "my_prod_map", "192.0.15.1", "\1\2", 19); gdmaps_test_lookup_check(tnum++, gdmaps, "my_prod_map", "79.125.18.68", "\1", 17); gdmaps_test_lookup_check(tnum++, gdmaps, "my_prod_map", "69.58.186.119", "\2\1", 16); gdmaps_test_lookup_check(tnum++, gdmaps, "my_prod_map", "::69.58.186.119", "\2\1", 112); // v4-compat gdmaps_test_lookup_check(tnum++, gdmaps, "my_prod_map", "::FFFF:69.58.186.119", "\2\1", 112); // v4-mapped gdmaps_test_lookup_check(tnum++, gdmaps, "my_prod_map", "::FFFF:0:69.58.186.119", "\2\1", 112); // SIIT gdmaps_test_lookup_check(tnum++, gdmaps, "my_prod_map", "2002:453A:BA77::", "\2\1", 32); // 6to4 gdmaps_test_lookup_check(tnum++, gdmaps, "my_prod_map", "2001::BAC5:4588", "\2\1", 112); // Teredo gdmaps_test_lookup_check(tnum++, gdmaps, "my_prod_map", "2600:3c00::f03c:91ff:fe96:6a4f", "\1\2", 150); // native v6 gdmaps_destroy(gdmaps); }