GeoIP [Unmaintained]

Discussion in 'Plugin Support' started by Wulf, Oct 3, 2015.

  1. Wulf

    Wulf Community Admin

    Wulf submitted a new resource:

    GeoIP - Provides a geographic information API for IP addresses

    Read more about this resource...
     
  2. Wulf

    Wulf Community Admin

    Wulf updated GeoIP with a new update entry:

    0.1.1

     
  3. @Wulf perfect for Notifications :) Thanks. Makes stuff easier for me.
     
  4. Wulf

    Wulf Community Admin

  5. Im not sure but, the debug is still true @Wulf

    I will take a look at this and perhaps add support to Notifier. :)
     
  6. Wulf

    Wulf Community Admin

    Ah, forgot to disable that. The previous update was the commands.
     
  7. Wulf

    Wulf Community Admin

    Wulf updated GeoIP with a new update entry:

    0.1.2

     
  8. Hey wulf,

    I have setup this piece of code here, which is fairly easy for any programmer to understand really:
    Code:
            # Is GeoIP loaded?
            if GeoIP:            # Player UID and IP
                uid = self.playerid(player)
                pip = self.players[uid]['ip'].split(':')[0]            # Cache Player Country And Country Code
                self.players[uid]['country'] = GeoIP.Call('GetCountry', pip)
                self.players[uid]['country_short'] = GeoIP.Call('GetCountryCode', pip)            # Debug Messages
                print('GeoIP: %s' % 'Loaded' if GeoIP else 'Not Loaded')
                print('Player ID: ' + uid)
                print('Player IP: ' + pip)
                print('Player Country: %s' % self.players[uid]['country'])
                print('Player Country Code: %s' % self.players[uid]['country_short'])            print(GeoIP.Call('GetCountry', pip))
                print(GeoIP.Call('GetCountryCode', pip))
    
    And this is the output of it:
    Code:
    [Oxide] 8:01 AM [Info] GeoIP: Loaded
    [Oxide] 8:01 AM [Info] Player ID: 76561197999302614
    [Oxide] 8:01 AM [Info] Player IP: 188.82.58.52
    [Oxide] 8:01 AM [Info] Player Country: None
    [Oxide] 8:01 AM [Info] Player Country Code: None
    [Oxide] 8:01 AM [Info] None
    [Oxide] 8:01 AM [Info] None
    
    And as you can see if quite sure I'm doing everything right, but for some reason when calling your plugin's functions I get nothing.

    Am I doing something wrong or is this some sort of connection issue? ...Your code maybe?

    P.S: Either .Call() or CallHook() return the same
     
  9. Wulf

    Wulf Community Admin

    Check to make sure you have GeoIP-Locations.json and GeoIP-Blocks.json in your oxide/data folder, and that they are larger than 1kb.
     
  10. Yes I do sir, both full of data.
     
  11. Wulf

    Wulf Community Admin

    Wulf updated GeoIP with a new update entry:

    0.1.3

     
  12. @Wulf I got an issues with this right now. I've sent you a message.
    Code:
    string country = "Unknown";
                var geoIP = plugins.Find("GeoIP");
                if(geoIP) country = geoIP?.Call("GetCountryCode", player.net.connection.ipaddress).ToString();
                else Puts("GeoIP is not loaded!");
    country seems to be returning Unknown eventhough GeoIP is loaded and the hook seemed to be called.
    Nevermind. It propably is because its my local server so the ip is localhost...
     
    Last edited by a moderator: Oct 8, 2015
  13. Wulf

    Wulf Community Admin

    Yeah, localhost won't have a country. Add an exclusion or test IP address such as 8.8.8.8 (Google) for localhost or local network users.
     
  14. Sometimes it shows the tags but most of the time it just shows Unknown.
     
  15. Wulf

    Wulf Community Admin

    When using what? I need details. It works 100% of the time for me when using a valid IP address that isn't a local one.
     
  16. Well. In my Notifications plugin.
    Code:
    void OnPlayerInit(BasePlayer player)
            {
                var geoIP = plugins.Find("GeoIP");
               
                string country = geoIP ? geoIP.Call("GetCountryCode", player.net.connection.ipaddress).ToString() : "Unknown";
                if(player.net.connection.ipaddress.Contains("127.0.0.1:")) country = "Local";
               
                NextTick(() => {
                    //    Send Welcome Message
                    if((bool)Config["Settings", "Enable Welcome Message"])
                    {
                        List<object> msgObject = Config["Messages", "Welcome"] as List<object>;
                       
                        List<string> messages = new List<string>();
                        foreach(string curMsg in msgObject)    messages.Add(curMsg);
                       
                        string name = GetFormattedName(player);
                        string msg = ListToString(messages, 0, "\n").ToString().Replace("{player}", name);
                        msg = ReplaceTags(msg);
                        msg = $"<color={Config["Colors", "Welcome"].ToString()}>{msg}</color>";
                       
                        SendChatMessage(player, msg);
                    }
                   
                    //    Broadcast Join Message
                    if((bool)Config["Settings", "Enable Join Message"])
                    {
                        string name = GetFormattedName(player);
                        string msg = Config["Messages", "Join"].ToString().Replace("{player}", name).Replace("{country}", country);
                       
                        BroadcastChat($"<color={Config["Colors", "Join"].ToString()}>{msg}</color>");
                        SendConsole(msg);
                    }
                });
               
            }
     
  17. Wulf

    Wulf Community Admin

    I'd try printing out the IP you have when connection so you can see what it's trying to use.
     
  18. well I'd need to get somebody who shows Unknown. I gotta send you the details per PM then.
     
  19. Wulf

    Wulf Community Admin

    If they show Unknown, then it's most likely that their IP isn't in the database. Not much I can really do about that. You can manually check the region .json file to verify, but that's most likely the case.