[Plugin] DNS Plugin
#1

DNS Plugin

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

Natives
  • 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.

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
Instructions

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

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

Windows:
Код:
plugins dns.dll
Linux:
Код:
plugins dns.so
On Windows, add dns.inc to the pawno\include folder. Include this file in any of the scripts the server is running:

pawn Код:
#include <dns>
Recompile the scripts with any desired natives and callbacks provided by the include file. Start the server.

Download

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.
Reply
#2

Hmm, let me get this right, if you create a string and use the GetPlayerHost, it will send you the ISP's information?.
Reply
#3

Edit: See the example filterscript.
Reply
#4

[me=Boylett (ServerZ.co.uk)]downloads[/me]
Reply
#5

is it possible to make it work with filterscripts? my IRC script won't connect to IRC anymore when using one of those functions
Reply
#6

Cool Plugin
Reply
#7

I fixed a small bug that was causing a runtime error in Windows. Please re-download.

Quote:
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?
Reply
#8

I wanted to make a comment about this.

Reverse DNS is obviously very useful if you need to ban players on a hostmask say: *.their-isp.com. 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[]).

Reply
#9

Nice job! Hostname now shows on join.

Leopard
Reply
#10

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.
Reply
#11

dns(host[], dest[])

should probly be

dns(const host[], dest[], length=sizeof dest)

rdns should be the same,
and host[256], doesnt need to be that big
Reply
#12

Quote:
Originally Posted by [LF
Sagat ]
dns(host[], dest[])

should probly be

dns(const host[], dest[], length=sizeof dest)

rdns should be the same,
and host[256], doesnt need to be that big
The max lenght of a host is 255.. so.. yeah.
Reply
#13

I have released the second version of this plugin.

The DNS and reverse DNS functions are now threaded, and two new callbacks have been added: OnDNS and OnReverseDNS. Additionally, the stock function GetPlayerHost is now simply a wrapper for the native function rdns.

If anyone is currently using this plugin, I highly recommend downloading the newest version for the reasons that Kye stated above.
Reply
#14

Quote:
Originally Posted by Incognito
I fixed a small bug that was causing a runtime error in Windows. Please re-download.

Quote:
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?
Jacobs IRC plugin
When using any function in the IRC script, this will make the script to fail. (not when only including the include) [windows xp, didn't test on my linux server yet]
Reply
#15

I am afraid that I can't replicate that. The newest version of my plugin appears to work fine with Jacob's IRC plugin. There is probably some other conflicting element in your setup.
Reply
#16

Great job. :)
Reply
#17

Quote:
Originally Posted by Incognito
I am afraid that I can't replicate that. The newest version of my plugin appears to work fine with Jacob's IRC plugin. There is probably some other conflicting element in your setup.
did you test it with linux AND windows?
Reply
#18

Yes, I have. Try removing everything but the DNS and IRC plugins (filterscripts and custom gamemodes included, with the exception of the filterscript you are using to connect to IRC).

What exactly do you mean when you say that using this plugin makes the script "fail," by the way? The server crashes? The IRC socket closes or stops responding? Show me how you are using my natives and callbacks.
Reply
#19

everything works fine when I put it in it's old state without DNS,
all I do is #include the include and use GetPlayerHost & rdns in the !host command

it just won't connect to IRC each time I try to use the DNS plugin & include

are you using the a_sampdb include somewhere in the plugin or something? using functions in filterscripts will make them fail

EDIT: when I try to use it in a gamemode it says Run time error 19: "File or function is not found" and the IRC fs does connect (without dns in fs) and yes, dns.dll is added in server config
Reply
#20

Did the plugin load successfully? You should see "DNS Plugin by Incognito loaded" in the console output when the server starts. If not, check that dns.dll is in your plugins directory. Also, make sure that you have the newest version of the .NET Framework installed.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)