SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 03/05/2009, 07:46 AM   #1
Incognito
Huge Clucker
 
Join Date: May 2006
Posts: 449
Reputation: 487
Default 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.

Last edited by Incognito; 31/01/2016 at 10:45 PM.
Incognito is offline   Reply With Quote
Old 03/05/2009, 09:39 AM   #2
shitbird
High-roller
 
shitbird's Avatar
 
Join Date: Nov 2007
Posts: 1,288
Reputation: 31
Default 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?.
shitbird is offline   Reply With Quote
Old 03/05/2009, 10:42 AM   #3
Incognito
Huge Clucker
 
Join Date: May 2006
Posts: 449
Reputation: 487
Default Re: [REL] DNS Plugin

Edit: See the example filterscript.

Last edited by Incognito; 07/08/2012 at 10:51 AM.
Incognito is offline   Reply With Quote
Old 03/05/2009, 10:45 AM   #4
boylett
Gangsta
 
Join Date: Jul 2006
Posts: 656
Reputation: 0
Default Re: [REL] DNS Plugin

[me=Boylett (ServerZ.co.uk)]downloads[/me]
boylett is offline   Reply With Quote
Old 03/05/2009, 11:35 AM   #5
Joske_Vermeulen
Big Clucker
 
Joske_Vermeulen's Avatar
 
Join Date: Mar 2007
Posts: 145
Reputation: 6
Default 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
Joske_Vermeulen is offline   Reply With Quote
Old 03/05/2009, 11:39 AM   #6
kasco
Big Clucker
 
Join Date: Mar 2009
Posts: 160
Reputation: 0
Default Re: [REL] DNS Plugin

Cool Plugin
kasco is offline   Reply With Quote
Old 03/05/2009, 12:47 PM   #7
Incognito
Huge Clucker
 
Join Date: May 2006
Posts: 449
Reputation: 487
Default 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?
Incognito is offline   Reply With Quote
Old 03/05/2009, 01:30 PM   #8
Kalcor
SA-MP Developer
 
Join Date: Apr 2005
Location: Oblivion
Posts: 809
Reputation: 2502
Default 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[]).

Kalcor is offline   Reply With Quote
Old 03/05/2009, 02:15 PM   #9
pspleo
High-roller
 
Join Date: Nov 2007
Posts: 1,766
Reputation: 4
Default Re: [REL] DNS Plugin

Nice job! Hostname now shows on join.

Leopard
pspleo is offline   Reply With Quote
Old 04/05/2009, 05:28 AM   #10
Incognito
Huge Clucker
 
Join Date: May 2006
Posts: 449
Reputation: 487
Default 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.
Incognito is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Very good plugin suggestion (for scripters) and easy to make for the Plugin Developers! Xentiarox Plugin Development 5 29/07/2012 11:48 PM
[help][plugin] Can't load mysql plugin mariomako Help Archive 8 16/07/2011 03:37 PM
mysql plugin. loading plugin failed ikkentim Help Archive 2 10/02/2011 03:32 PM


All times are GMT. The time now is 11:45 PM.


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