struct loc_network* network = NULL;
int r;
- Database* self = luaL_checkdatabase(L, 0);
+ Database* self = luaL_checkdatabase(L, 1);
// Require a string
- const char* address = luaL_checkstring(L, 1);
+ const char* address = luaL_checkstring(L, 2);
// Perform lookup
r = loc_database_lookup_from_string(self->db, address, &network);
// ASN
static int Network_get_asn(lua_State* L) {
- Network* self = luaL_checknetwork(L, 0);
+ Network* self = luaL_checknetwork(L, 1);
uint32_t asn = loc_network_get_asn(self->network);
// Family
static int Network_get_family(lua_State* L) {
- Network* self = luaL_checknetwork(L, 0);
+ Network* self = luaL_checknetwork(L, 1);
// Push family
lua_pushnumber(L, loc_network_address_family(self->network));
// Country Code
static int Network_get_country_code(lua_State* L) {
- Network* self = luaL_checknetwork(L, 0);
+ Network* self = luaL_checknetwork(L, 1);
const char* country_code = loc_network_get_country_code(self->network);
n1 = location.Network.new("10.0.0.0/8")
-- The ASN should be nul
- luaunit.assertNil(n1.get_asn())
+ luaunit.assertNil(n1:get_asn())
-- The family should be IPv4
- luaunit.assertEquals(n1.get_family(), 2)
+ luaunit.assertEquals(n1:get_family(), 2)
-- The country code should be empty
- luaunit.assertNil(n1.get_country_code())
+ luaunit.assertNil(n1:get_country_code())
end
os.exit(luaunit.LuaUnit.run())