PtokaX forum

Development Section => Your Developing Problems => Topic started by: Dessamator on 20 April, 2005, 20:43:37

Title: How to find the localhost of a pc?
Post by: Dessamator on 20 April, 2005, 20:43:37
the question is simple how to find the localhost of a pc, it changes depending on ur settings, and the firewall etc etc, so whats the best method to do so?

the ip, specifically  !!
Title:
Post by: kepp on 20 April, 2005, 20:48:12
either run cmd.exe and type ipconfig or look in router for ip's shared amongst network computers
Title:
Post by: jiten on 20 April, 2005, 20:54:25
QuoteOriginally posted by kepp
either run cmd.exe and type ipconfig or look in router for ip's shared amongst network computers
I think he meant by Lua scripting ;)
Title:
Post by: kepp on 20 April, 2005, 21:19:21
os.execute("ipconfig > filename.txt")

then read it :)
I think that will work
Title:
Post by: uffetjur on 20 April, 2005, 21:21:27
why don't try 127.0.0.1    LooooooooooooooL
Title:
Post by: plop on 20 April, 2005, 21:38:20
QuoteOriginally posted by Dessamator
the question is simple how to find the localhost of a pc, it changes depending on ur settings, and the firewall etc etc, so whats the best method to do so?

the ip, specifically  !!
it doesn't change, it's always 127.0.0.1 unless you have changed it yourself.
and then you are still bound to 127.0.0.xxx.
only on special linux/bsd server setups those other local hosts are used (shared server).

plop
Title:
Post by: Dessamator on 20 April, 2005, 22:50:59
QuoteOriginally posted by plop
QuoteOriginally posted by Dessamator
the question is simple how to find the localhost of a pc, it changes depending on ur settings, and the firewall etc etc, so whats the best method to do so?

the ip, specifically  !!
it doesn't change, it's always 127.0.0.1 unless you have changed it yourself.
and then you are still bound to 127.0.0.xxx.
only on special linux/bsd server setups those other local hosts are used (shared server).
plop

well the thing is, i created a script which gets the hub ip, and using it finds out which user has it, when i test it with another hub somehow it doesnt find the ip, if the person with the server logs in with localhost,

anyways heres the script for reference:::

     
--By Dessamator
--SIMPLE Online ip checker
bot=frmHub:GetHubBotName()

function ChatArrival(user, data)

data = string.sub(data,1,string.len(data)-1)
s,e,cmd = string.find(data, "%b<>%s+(%S+)")

local s,e,ip = string.find(data, "%b<>%s+%S+%s+(.+)")
if cmd=="!findip" and user.bOperator then
findip(user,ip,1)
return 1
elseif cmd=="!getserver" and user.bOperator then
local hubip=frmHub:GetHubIp()
findip(user,hubip,0)
return 1
end
end
ToArrival=ChatArrival

function findip(user,ip,i)
local check =""
if i==1 and ip then
temp= "\r\n".."\t".."The ip: "..ip.." Belongs to :".."\r\n"
else
temp= "\r\n".."\t".."The Current server is: ".."\r\n"
end
if ip==nil or ip=="" then
user:SendPM(bot,"Syntax error. Correct Syntax is : !findip ")
else
temp=temp.."\t".."??????????????????????".."\r\n"
for _,nick in frmHub:GetOnlineUsers() do
serverip=string.sub(nick.sIP,1,4)
if nick.sIP==ip then
temp=temp.."\t\t".."•"..nick.sName.."\r\n"
check=check..nick.sName
elseif i==0 and serverip=="127." then
temp=temp.."\t\t".."•"..nick.sName.."\r\n"
check=check..nick.sName
elseif (i==0) and not(nick.sIP==ip )  then
temp="The person with the server isnt online!!"
end
end
if check=="" then
user:SendPM(bot,"The User with that ip isnt online")
else
user:SendPM(bot,temp)
temp=nil
serverip=""
check=""
end
end
end
 
Title:
Post by: bastya_elvtars on 20 April, 2005, 23:23:17
This could only be retrieved by a script which does a ping -a on the hubs DNS thus retrieves the IP andcompares it with userstable.
Title:
Post by: Dessamator on 20 April, 2005, 23:29:42
QuoteOriginally posted by bastya_elvtars
This could only be retrieved by a script which does a ping -a on the hubs DNS thus retrieves the IP andcompares it with userstable.

well generally that would work, and it already does work in that script, the prob arises when the server connects through localhost !!, when i test it , it works, but not with the other guy who handles the server of our hub !!
Title:
Post by: plop on 21 April, 2005, 00:17:51
why not search with 2 key's??
127.0.0.1 and the ip from frmHub:GetHubIP()

plop
Title:
Post by: Dessamator on 21 April, 2005, 00:43:07
QuoteOriginally posted by plop
why not search with 2 key's??
127.0.0.1 and the ip from frmHub:GetHubIP()

plop

great idea, will do !!