SA-MP Forums

SA-MP Forums (http://forum.sa-mp.com/index.php)
-   Plugin Development (http://forum.sa-mp.com/forumdisplay.php?f=18)
-   -   [Plugin] DNS Plugin (http://forum.sa-mp.com/showthread.php?t=75605)

Incognito 03/05/2009 07:46 AM

DNS Plugin
 
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:
Code:

plugins dns.dll
Linux:
Code:

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:

Code:

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

shitbird 03/05/2009 09: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 10:42 AM

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

boylett 03/05/2009 10:45 AM

Re: [REL] DNS Plugin
 
[me=Boylett (ServerZ.co.uk)]downloads[/me]

Joske_Vermeulen 03/05/2009 11: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 11:39 AM

Re: [REL] DNS Plugin
 
Cool Plugin

Incognito 03/05/2009 12:47 PM

Re: [REL] DNS Plugin
 
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?

Kalcor 03/05/2009 01: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: *.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[]).


pspleo 03/05/2009 02:15 PM

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

Leopard

Incognito 04/05/2009 05: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 07:06 AM.

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