DnsLookup
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

DnsLookup

Started by mars, 03 June, 2012, 18:09:16

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

mars

hi
is there a dnslookup script for ptokax
i did a search but could not find anything

thanks

Nando

yes there is
but not here xD

PPK

Simple DNS lookup script.
Require LuaSocket.
Use it with command !dnslookup hostname 8)
require "socket"

function ChatArrival(tUser, sData)
   if Core.GetUserValue(tUser, 11) == true and string.find(SetMan.GetString(29), string.sub(sData, 4+string.len(tUser.sNick), 4+string.len(tUser.sNick)), 1, true) then
      if string.sub(sData, 5+string.len(tUser.sNick), 14+string.len(tUser.sNick), true) ~= "dnslookup " then
         return false
      end

      dnstolookup = string.sub(sData, 15+string.len(tUser.sNick), sData:len()-1, true)

      if dnstolookup:len() == 0 then
         Core.SendToUser(tUser, "<"..Core.GetHubSecAlias().."> Error, no DNS specified!|")
         return true
      end

      result, msg = socket.dns.toip(dnstolookup)
      if result then
         Core.SendToUser(tUser, "<"..Core.GetHubSecAlias().."> "..dnstolookup.." have IP address: "..result)
      else
         Core.SendToUser(tUser, "<"..Core.GetHubSecAlias().."> DNS lookup failed because: "..msg)
      end

      return true
   end
end
"Most of you are familiar with the virtues of a programmer. There are three, of course: laziness, impatience, and hubris." - Larry Wall

mars

Thank you :)

However I did not explain what I was looking for properly.

What I am trying to do is have a script that checks when a user logs into the hub and does an NSLookUp on his IP address (using a name server that I can provide). If lookup returns a DNS entry then its ok, but if it comes back empty it must warn or kick the user.

This is for a hub running on a private network with its own nameserver :)

PPK

Sorry but i don't see any good reason for script like that ::)
"Most of you are familiar with the virtues of a programmer. There are three, of course: laziness, impatience, and hubris." - Larry Wall

mars

Hi
as we have our own wireless network with about 4000 people it is very important for us that the client details is upto date and he must have a dns and ips on the network before he can join dc
The script will check his dns and will allow him on the network if all his details is upto date
This will save us the time to check each persons details

thanks

PPK

Huh, now it is getting really complicated.
I can create simple script that will use user ip to resolve dns and disconnect user without dns. I can't do that with dns server you provide, it will use os dns settings because i don't know any library with support for custom dns servers  ::)
"Most of you are familiar with the virtues of a programmer. There are three, of course: laziness, impatience, and hubris." - Larry Wall

mars

the os dns will work fine

thanks

PPK

Require LuaSocket.
require "socket"

function UserConnected(tUser)
   if socket.dns.tohostname(tUser.sIP) == nil then
      Core.SendToUser(tUser, "<"..Core.GetHubSecAlias().."> Sorry, we don't accept users without updated DNS!|")
      Core.Disconnect(tUser)

      return true
   end
end
"Most of you are familiar with the virtues of a programmer. There are three, of course: laziness, impatience, and hubris." - Larry Wall

mars


mars

Hi PPK

Could you please explain to me how to install LuaSocket on a Windows PC running PtokaX 4.2.0. I've tried extracting the archive into PtokaX/scripts, but when I try and run it it tells me there are missing files.

Thanks

ATAG

Get a correct version of PxLuaSocket and extract it to the libs folder (you have to create it manually).
maybe...


mars

thanks
any more help would be apreciated as we are still having problems with errors in windows 7

ATAG

Sorry, i was wrong.

Newer libs are here.

mars

Quote from: ATAG on 10 September, 2012, 09:34:32
Sorry, i was wrong.

Newer libs are here.

Hi there

I extracted the new libs you provides into /PtokaX/scripts/libs, and put the dnslookup.lua script into the /PtokaX/scripts folder. When attempting to start the dnslookup script, I get the following error:

[07:26:12 PM] Syntax C:\Users\mars\Desktop\ptokaX\scripts\dns.lua:1: module 'socket' not found:
   no field package.preload['socket']
   no file 'C:\Users\mars\Desktop\PtokaX\scripts\libs'
   no file 'C:\Users\mars\Desktop\PtokaX\scripts\libs'

Any help would be appreciated.

Thanks

the-master

is the hub on linux or windows?
keep on sharing :)

mars


the-master

You're right, runs on Xp, but not on win7 :-(
keep on sharing :)

ATAG

Try to extract the whole LuaSocket-2.0.2.7z into "PtokaX\libs".

Quote[15:59:49] No syntax errors in script file dns.lua
[15:59:49] Script started.

(tested on Win7 x64 & 64 bit Px)

mars

ATAG: I have tried extracting the entire LuaSocket-2.0.2.7z into PtokaX\libs directory and PtokaX\scripts\libs directory, but still get the same problem.

Can you perhaps explain what you did to test it in more detail?

Thanks

ATAG

It seems like x86 version doesn't work for me (too)...

Quote[21:26:51] Syntax D:\PtokaX\libs\socket.lua:18: attempt to index local 'socket' (a boolean value)

It returns only a true boolean (instead of userdata type), ask PPK for help!

mars


PPK

WorksForMe?
Code: Testing script
require "socket"
require "mime"

Core.SendToOps("PtokaX version: "..Core.Version
               .."\nPtokaX build: "..Core.BuildNumber
               .."\nLua version: ".._VERSION

               .."\n\nLoaded Lua libraries:\n"

               .."\nLuaSocket version: "..socket._VERSION
               .."\nLuaMime version: "..mime._VERSION
            )


With stable PtokaX http://www.ptokax.org/files/0.4.2.0.7z and correct LuaSocket lib http://www.ptokax.org/files/Libs-240/LuaSocket-2.0.2.7z
Quote from: Result[2012-09-23 23:08:34] PtokaX version: 0.4.2.0
PtokaX build: 241
Lua version: Lua 5.1

Loaded Lua libraries:

LuaSocket version: LuaSocket 2.0.2
LuaMime version: MIME 1.0.2

With testing PtokaX with Lua 5.1.5 http://www.ptokax.org/files/0.4.2.0b401-Lua5.1.5.7z and correct LuaSocket lib http://www.ptokax.org/files/Libs-376/LuaSocket-2.0.2.7z

Quote from: Result[2012-09-23 23:09:44] PtokaX version: 0.4.2.0
PtokaX build: 401
Lua version: Lua 5.1

Loaded Lua libraries:

LuaSocket version: LuaSocket 2.0.2
LuaMime version: MIME 1.0.2

With testing PtokaX with Lua 5.2.1 http://www.ptokax.org/files/0.4.2.0b401-Lua5.2.1.7z and correct LuaSocket lib http://www.ptokax.org/files/Libs-376/LuaSocket-2.0.2.7z

Quote from: Result[2012-09-23 23:10:24] PtokaX version: 0.4.2.0
PtokaX build: 401
Lua version: Lua 5.2

Loaded Lua libraries:

LuaSocket version: LuaSocket 2.0.2
LuaMime version: MIME 1.0.2
"Most of you are familiar with the virtues of a programmer. There are three, of course: laziness, impatience, and hubris." - Larry Wall

ATAG

#23
Quote from: PPK on 23 September, 2012, 23:20:50
WorksForMe?
I think, you are the only one, who can find some logic between versions of libs and px builds. We are mortals =)

Anyway i've tested same versions on x64 win7... but x86 doesn't work for me. Tomorrow i'll try on x32 machine too :)

mars


WorksForMe?

can you explain more in detail how you did it in windows 7 as we are still having problems

SMF spam blocked by CleanTalk