SA-MP Forums

SA-MP Forums (
-   Plugin Development (
-   -   [Plugin] DNS Plugin (

Incognito 03/05/2009 06:46 AM

DNS Plugin
DNS Plugin

This plugin provides functionality for DNS lookups and reverse DNS lookups.

  • dns(const host[], extra = 0);
    • Resolves the hostname to an IP address

  • rdns(const ip[], extra = 0);
    • Resolves the IP address to a hostname

Note that extra is an optional argument that can pass an integer, such as a player ID, to the callbacks.

  • OnDNS(host[], ip[], extra);
    • Called upon DNS lookup

  • OnReverseDNS(ip[], host[], extra);
    • Called upon reverse DNS lookup

Stock Function
  • GetPlayerHost(playerid);
    • Wrapper for rdns that can obtain a player's hostname


Create a directory called "plugins" inside of the server directory if one does not already exist. Place the plugin file (dns.dll or inside of this directory.

Add the following line to server.cfg so that the plugin will load the next time the server starts:


plugins dns.dll

On Windows, add to the pawno\include folder. Include this file in any of the scripts the server is running:

pawn Code:
#include <dns>

Recompile the scripts with any desired natives and callbacks provided by the include file. Start the server.


The latest compiled binaries will always be here:

GitHub Releases Page

The source can be browsed here. This repository can also be cloned.

The Windows version requires the Microsoft Visual C++ 2010 Redistributable Package.

shitbird 03/05/2009 08:39 AM

Re: [REL] DNS Plugin
Hmm, let me get this right, if you create a string and use the GetPlayerHost, it will send you the ISP's information?.

Incognito 03/05/2009 09:42 AM

Re: [REL] DNS Plugin
Edit: See the example filterscript.

boylett 03/05/2009 09:45 AM

Re: [REL] DNS Plugin
[me=Boylett (]downloads[/me]

Joske_Vermeulen 03/05/2009 10:35 AM

Re: [REL] DNS Plugin
is it possible to make it work with filterscripts? my IRC script won't connect to IRC anymore when using one of those functions

kasco 03/05/2009 10:39 AM

Re: [REL] DNS Plugin
Cool Plugin

Incognito 03/05/2009 11:47 AM

Re: [REL] DNS Plugin
I fixed a small bug that was causing a runtime error in Windows. Please re-download.


Originally Posted by =Contador=
is it possible to make it work with filterscripts? my IRC script won't connect to IRC anymore when using one of those functions

Please be more specific. Which plugin are you using to connect to IRC?

Kalcor 03/05/2009 12:30 PM

Re: [REL] DNS Plugin
I wanted to make a comment about this.

Reverse DNS is obviously very useful if you need to ban players on a hostmask say: * You could check the host off on connect and Kick() them. But:

Reverse DNS takes time to resolve and it's the duty of an SA-MP script to return execution to the server as quickly as possible. Calling this function will likely delay execution and result in lag for other players while the reverse DNS lookup is occuring. The only way to do this properly is for the DNS lookup to be threaded and call a callback like OnPlayerReverseDNS(playerid, rdns_string[]).

pspleo 03/05/2009 01:15 PM

Re: [REL] DNS Plugin
Nice job! Hostname now shows on join.


Incognito 04/05/2009 04:28 AM

Re: [REL] DNS Plugin
That is true. The amount of time it takes to resolve, however, is usually not significant (on average, probably less than a second). It can vary, though. I might consider creating threads at some point in the future.

All times are GMT. The time now is 12:07 AM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.