hi
is there a dnslookup script for ptokax
i did a search but could not find anything
thanks
yes there is
but not here xD
Simple DNS lookup script.
Require LuaSocket (http://forum.ptokax.org/index.php?topic=8852.0).
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
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 :)
Sorry but i don't see any good reason for script like that ::)
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
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 ::)
the os dns will work fine
thanks
Require LuaSocket (http://forum.ptokax.org/index.php?topic=8852.0).
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
Thanks
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
Get a correct version of PxLuaSocket and extract it to the libs folder (you have to create it manually).
maybe... (http://forum.ptokax.org/index.php?action=tpmod;dl=cat50)
thanks
any more help would be apreciated as we are still having problems with errors in windows 7
Sorry, i was wrong.
Newer libs are here (http://forum.ptokax.org/index.php?topic=8852#msg81265).
Quote from: ATAG on 10 September, 2012, 09:34:32
Sorry, i was wrong.
Newer libs are here (http://forum.ptokax.org/index.php?topic=8852#msg81265).
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
is the hub on linux or windows?
windows 7
You're right, runs on Xp, but not on win7 :-(
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)
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
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!
Hi PPK
can you help
WorksForMe?
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
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 :)
WorksForMe?
can you explain more in detail how you did it in windows 7 as we are still having problems
Anyway i've tested same versions on x64 win7... but x86 doesn't work for me. Tomorrow i'll try on x32 machine too :)
Hi any news yet
Quote from: ATAG on 24 September, 2012, 00:55:13
I think, you are the only one, who can find some logic between versions of libs and px builds. We are mortals =)
It is simple, when you use stable PtokaX then you have build 241 and you need libs for 240 and higher. When you are using testing PtokaX build 376 or higher then you need libs for 376 and higher.
In future probably this mess will be fixed, because libs for build 376 and higher use smart loader. They are not compiled against exact PXLua.dll/PXLua-x64.dll version, they simply search pxlua lib for needed lua functions and as long as PXLua.dll/PXLua-x64.dll contains them then they load and work.
Quote from: mars on 24 September, 2012, 01:37:12
can you explain more in detail how you did it in windows 7 as we are still having problems
I'm downloaded http://www.PtokaX.org/files/0.4.2.0b401-Lua5.1.5.7z and unpacked to e:\PtokaX\ then i'm downloaded http://www.PtokaX.org/files/Libs-376/LuaSocket-2.0.2.7z and unpacked to e:\PtokaX\libs\
Then i'm copied my cfg dir to e:\PtokaX\, added testing script to e:\PtokaX\scripts\, started PtokaX, connected with client and run script ::)
Quote from: PPK on 28 September, 2012, 18:02:07I'm downloaded http://www.PtokaX.org/files/0.4.2.0b401-Lua5.1.5.7z and unpacked to e:\PtokaX\ then i'm downloaded http://www.PtokaX.org/files/Libs-376/LuaSocket-2.0.2.7z and unpacked to e:\PtokaX\libs\
Then i'm copied my cfg dir to e:\PtokaX\, added testing script to e:\PtokaX\scripts\, started PtokaX, connected with client and run script ::)
Hi PPK
Thanks for the help but we still have the same problem. We downloaded the ptokaX version you linked and extracted it to C:\ptokaX. We then downloaded LuaSocket above and extracted to C:\ptokaX\libs. We used a blank cfg folder. Then we run ptokaX exe (32 or 64-bit) and go to the Scripts tab to add the script. As soon as we try to run any script that starts with (require "socket") we get the following error:
[01:30:15 PM] Syntax C:\ptokaX\scripts\test.lua:1: module 'socket' not found:
no field package.preload['socket']
This is on Windows 7 64-bit.
Some progress!
Visiting the LuaSocket installation homepage, I tried adding the following to my Win7 environmental variables under user variables:
LUA_CPATH=C:\PtokaX\libs\?.lua;?.lua
LUA_PATH=C:\PtokaX\libs\?.dll;?.dll
Now when I try to run the scripts with require "socket" in I get the following windows error box:
C:\PtokaX\libs\socket.lua is either not designed to run on Windows or it contains an error.
Any help?
Ok, it works now!
QuotePtokaX 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
You have to change the "require" to:
require "pxluasocket"
require "pxmime"
I hope it helps...
Wrong. You must require socket and mime to get this thing working correctly. When you directly require dlls, then it will not work as it should because big part of luasocket is in scripts (socket.lua, mime.lua and others that are loaded by these) ::)
Ok, i've found the solution ::)
There is a "scripts" folder in libs with some lua script. We have to copy the scripts to the parent directory (PtokaX\libs) and then it works fine.
(http://kepfeltoltes.hu/thumb/120929/1248261250pxsocket_www.kepfeltoltes.hu_.png) (http://kepfeltoltes.hu/view/120929/1248261250pxsocket_www.kepfeltoltes.hu_.png)
Quote from: ATAG on 29 September, 2012, 20:27:40
Ok, i've found the solution ::)
There is a "scripts" folder in libs with some lua script. We have to copy the scripts to the parent directory (PtokaX\libs) and then it works fine.
(http://kepfeltoltes.hu/thumb/120929/1248261250pxsocket_www.kepfeltoltes.hu_.png) (http://kepfeltoltes.hu/view/120929/1248261250pxsocket_www.kepfeltoltes.hu_.png)
Thank you!
While this still did not solve my problem, I tried it on 2 other PCs (Win7 64) and it now seems to work on both. I tested PPKs first dnslookup script and it ran with no errors, and allowed me to run !dnslookup from the client.
A big thanks to both of you :)
Now just one other small question about the second DNS script that PPK posted: is it possible that before kicking someone with a "nil" dnslookup, is it possible to first check another DNS? Why I ask is that sometimes our private DNS server goes down so no one has DNS, and then I do not want the script to kick everyone.
So something like this:
1 - Check DNS of IP x.x.x.x
2 - If (1) returns valid DNS, check IP of sUser
3 - If (2) returns nil value, kick sUser and send message to Ops
Is something like this possible?
Hi PPK
After many problems we finally got LuaSocket and your DNS scripts to run on out hub, but now we have another problem.
When the client runs the dnslookup, it does not use the OS DNS server (the one that is specified in TCP/IP settings). Instead it only returns the computer name that is set in Windows. This means that even if the users did not update their DNS details on out database they will not be kicked by the script because it will always return their computer name.
Is there someway to specify that the script used the OS DNS instead of just the computer name?
Thanks