Raised This Month: $32 Target: $400
 8% 

DNS Lookup


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
fakuivan
Senior Member
Join Date: Nov 2015
Old 07-30-2016 , 15:39   DNS Lookup
Reply With Quote #1

How do I perform a DNS Lookup from a plugin to get an IP address?
fakuivan is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-30-2016 , 18:10   Re: DNS Lookup
Reply With Quote #2

I don't think SourceMod has the ability to do this built in.

Probably needs an extension to do it. Not sure how hard that would be to write, but it should just need to wrap the various OS's inet_pton and gethostbyname/getnameinfo calls.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 07-30-2016 at 18:10.
Powerlord is offline
fakuivan
Senior Member
Join Date: Nov 2015
Old 08-25-2016 , 23:52   Re: DNS Lookup
Reply With Quote #3

Quote:
Originally Posted by Powerlord View Post
I don't think SourceMod has the ability to do this built in.

Probably needs an extension to do it. Not sure how hard that would be to write, but it should just need to wrap the various OS's inet_pton and gethostbyname/getnameinfo calls.
I scrapped an extension (I've never coded extensions but I am quite familiar with c++). It only works on linux afaik. Any recomendations?

extension.cpp


include


Test plugin


Testing:
Code:
test_fqdn_to_ip_resolve "forums.alliedmods.net"
[SM-TEST] Returned: 197007720 | 104.25.190.11
fakuivan is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 08-26-2016 , 00:30   Re: DNS Lookup
Reply With Quote #4

I think the include for gethostbyname is different on windows. Let me check...

Yeah, it appears to be in winsock2.h on Windows.

I know SourceMod has ifdefs for Linux versus Windows but I don't remember what they are off the top of my head.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 08-26-2016 at 00:32.
Powerlord is offline
Impact123
Veteran Member
Join Date: Oct 2011
Location: Germany
Old 08-26-2016 , 00:36   Re: DNS Lookup
Reply With Quote #5

It's probably a good idea to make this callback based so you don't block the game server.
__________________

Last edited by Impact123; 08-26-2016 at 00:46.
Impact123 is offline
fakuivan
Senior Member
Join Date: Nov 2015
Old 08-26-2016 , 01:16   Re: DNS Lookup
Reply With Quote #6

Quote:
Originally Posted by Powerlord View Post
I think the include for gethostbyname is different on windows. Let me check...

Yeah, it appears to be in winsock2.h on Windows.

I know SourceMod has ifdefs for Linux versus Windows but I don't remember what they are off the top of my head.
I don't plan to offer windows support any time soon, maybe on a pre release state. (I appreciate any kind of help tho)

Quote:
Originally Posted by Impact123 View Post
It's probably a good idea to make this callback based so you don't block the game server.
I plan on doing so, but I think that gethostbyname is not thread safe :/.

Last edited by fakuivan; 08-26-2016 at 01:20.
fakuivan is offline
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

Forum Jump


All times are GMT -4. The time now is 22:27.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode