Seite 1 von 1

lua problem, how to get the IP of the player

Verfasst: 6. Dez 2007, 22:40
von FlyCat
Hi, all!

I am from China inSky LOFC squadron. Happy to find here although I can't read German, because I think here must have someone can help me out of the problem. The ATC is really good and is the best plugin I have seen for LOFC.

The situation is there is a new dedicated LOFC open host set up for couple days. I planned to build up a stats for it. This part is almost done in fact. The script is based on the . I did some change and extract all the key data to mysql.

in export.lua it looks like this:

[codek1u]g_startTime = os.date( "%c");
lastRow = 0;

function LuaExportStart()
dofile( "Config/Export/calcRows.lua" );
calcRows();
end

function LuaExportBeforeNextFrame()
end

function LuaExportAfterNextFrame()
end

function LuaExportStop()
dofile( "Config/Export/ExportData.lua" );
ExportData();
end
[/codek1u]
the data can be imported into mysql via luasql. here is the table in mysql looks like:
[imgk1u]http://www.insky.cn/bbs/attachments/month_0712/20071206_f28c0dee0b2331ec12a4qcdCQMKtJ2Cc.jpg[/imgk1u]

okay, got the data, the other part is easy to take care.

But today I met a situation. Somebody uses other's name login the host to make some trouble. I don't want this happen in the stats system, it will cause big mess. an idea comes up and I think maybe there should be a webbased user register page running in the host and share the same database with the LOFC stats to record the user's last login IP address which can compare with the player's IP address in LOFC. if people want their stats data(records or points ) remain in the stats system, the IP address he last login the web must be the same as the IP address in LOFC. and the valid stats data will belong to the ID registered in the web.

sorry for so many words and my English. I am not native english speaker too. In simply words:

[bk1u]how to export the player's connected IP address in LOFC via script? [/bk1u]

I checked the AsyncNet.log, from this log, IP address can be extracted but how to tell it belongs to which player's?

really thanks if anybody can help me of this. or somebody can give me the better solution.
I know here have good programmers. waiting for the reply....[/b][/code]

Re: lua problem, how to get the IP of the player

Verfasst: 6. Dez 2007, 22:41
von FlyCat
[quote="FlyCat"]Hi, all!

I am from China inSky LOFC squadron. Happy to find here although I can't read German, because I think here must have someone can help me out of the problem. The ATC is really good and is the best plugin I have seen for LOFC.

The situation is there is a new dedicated LOFC open host set up for couple days. I planned to build up a stats for it. This part is almost done in fact. The script is based on the [url=https://forum.lockon.ru/showthread.php?t=5669Jetfire's script[/url]. I did some change and extract all the key data to mysql.

in export.lua it looks like this:

[codemyv]g_startTime = os.date( "%c");
lastRow = 0;

function LuaExportStart()
dofile( "Config/Export/calcRows.lua" );
calcRows();
end

function LuaExportBeforeNextFrame()
end

function LuaExportAfterNextFrame()
end

function LuaExportStop()
dofile( "Config/Export/ExportData.lua" );
ExportData();
end
[/codemyv]
the data can be imported into mysql via luasql. here is the table in mysql looks like:
[imgmyv]http://www.insky.cn/bbs/attachments/mon ... KtJ2Cc.jpg[/imgmyv]

okay, got the data, the other part is easy to take care.

But today I met a situation. Somebody uses other's name login the host to make some trouble. I don't want this happen in the stats system, it will cause big mess. an idea comes up and I think maybe there should be a webbased user register page running in the host and share the same database with the LOFC stats to record the user's last login IP address which can compare with the player's IP address in LOFC. if people want their stats data(records or points ) remain in the stats system, the IP address he last login the web must be the same as the IP address in LOFC. and the valid stats data will belong to the ID registered in the web.

sorry for so many words and my English. I am not native english speaker too. In simply words:

[bmyv]how to export the player's connected IP address in LOFC via script? [/bmyv]

I checked the AsyncNet.log, from this log, IP address can be extracted but how to tell it belongs to which player's?

really thanks if anybody can help me of this. or somebody can give me the better solution.
I know here have good programmers. waiting for the reply....

Verfasst: 8. Dez 2007, 21:32
von Zillion
You can only parse the asyncNet.log for all connected addresses and the corresponding Client ID, which is a random but unique number (mostly integer between 1-100, called CNumber in the java source), but there is no way to relate back to the players Name from that Number, at least not that I know of... sorry

I used java as the server Backbone and have these functions to periodically check the IP's connected to the game by parsing the asyncNet.log and comparing them to the radarServer client IP's to remove cheaters.

EDIT:

You could taylor a small app that sends the username and IP of the connecting client to your Stats Server and block all connections on the Game Server if the IP was not registered on the Stats Server beforehand.

[IDIOT CODE]
[coderzc]
//client side
server = connect("MyStatServer.dyndns.org")
//after hyperlobby close
server.send("$PilotName, $MyIP)

//GameServer
for i=0 i<all i++ in StatLog
if(Async.current == StatLog)
break
if(i == StatLog.size && ...)
block Async.current until timeout
[/coderzc]
[/IDIOT CODE]


[coderzc]
//--------------------------------------------------------------------------------------------
// Reads the AsyncNet.log file to determine the total listed pilots.
public static synchronized void getPilots() {
String subline = null;
String Cnumber = null;
int Lnumber = 0;
String mark = "mark";
Pilots.clear();
PilotsAll.clear();

try {

Reader input = new FileReader("AsyncNet.log");
LineNumberReader linenumberR = new LineNumberReader( input );

for (String line; (line = linenumberR.readLine()) != null;){

if (line.startsWith( "server has started" )) {
PilotsAll.addElement(mark);
}
if (line.startsWith( "accepting connection from" )) {
int delimiter = line.indexOf('/');
subline = line.substring(26,delimiter);
Lnumber = linenumberR.getLineNumber();
linenumberR.setLineNumber(Lnumber+1);
}
if (line.startsWith( "append: client" )) {
Cnumber = line.substring(15);
PilotsAll.addElement(subline+"/"+Cnumber);
}
}
linenumberR.close();


if(PilotsAll.lastIndexOf(mark) != -1){
for ( int i=PilotsAll.lastIndexOf(mark); i<PilotsAll.size(); i++ ) {
String CurrElement = PilotsAll.get(i).toString();
Pilots.addElement(CurrElement);
}
}
}

catch (FileNotFoundException ex) {
ex.printStackTrace();
} catch (IOException ex){
ex.printStackTrace();
}

//System.out.println(Pilots.toString());


}
//--------------------------------------------------------------------------------------------
// Reads the AsyncNet.log, checks for removal of Pilots and does the same in the pilots array
public static synchronized Vector removePilots() {

String Cnumber = null;


try {

Reader input = new FileReader("AsyncNet.log");
BufferedReader linenumberR = new BufferedReader( input );

for (String line; (line = linenumberR.readLine()) != null;){

if (line.startsWith( "remove: client" )) {
Cnumber = line.substring(15);

for ( int i=Pilots.size()-(Pilots.size()-1); i<Pilots.size(); i++ ) {
String[] CurrElementSplit = Pilots.get(i).toString().split("/");
if(CurrElementSplit[1].equals(Cnumber)){
Pilots.removeElementAt(i);
break;
}
}

}

}
linenumberR.close();
}

catch (FileNotFoundException ex) {
ex.printStackTrace();
} catch (IOException ex){
ex.printStackTrace();
}

//System.out.println(Pilots.toString());

return Pilots;
}

//--------------------------------------------------------------------------------------------
class PilotGetter extends TimerTask{
public void run() {
//writeActivity("Checking AsyncNet.log for new Pilots");
getPilots();
removePilots();
Enumeration enumeration = clients.elements();
while (enumeration.hasMoreElements()) {
CSClient client = (CSClient)enumeration.nextElement();
client.Punkbuster(Pilots);
}
}
}
//--------------------------------------------------------------------------------------------
public void TimeReader(boolean start) {

Timer timer = new Timer();

if(start){
timer.schedule(new PilotGetter(), 0, 10000);
}else if(!start){
timer.cancel();
}
}[/coderzc]

Verfasst: 9. Dez 2007, 13:24
von FlyCat
really thanks your reply!

I got your points but I am not a coder... can't handle this programming job :-(

maybe I need to study at least one programm language.

Its seemed that I have to find another way.

Verfasst: 9. Dez 2007, 13:48
von FlyCat
I prefer to use the embeded lua engine to parse the asycnet.log file. I can do this code. So I think I have to put the code between the :

function LuaExportBeforeNextFrame()
end

function LuaExportAfterNextFrame()
end

Don't know what the effect will be. I will give it a try.

Verfasst: 11. Dez 2007, 01:22
von Zillion
https://lockon.co.uk/index.php?end_pos= ... lt&lang=en
https://www.lua.org/pil/

to your question:

LuaExportBeforeNextFrame() exports before the frame is rendered

LuaExportAfterNextFrame() exports after the frame is rendered...

...which means in most 3d engines a frame (a GPU 3d rendered frame) is a unit in which after or before its rendered by the GPU a CPU calculation can be made. There is no real difference in exporting your data before or after.

But yes, I'm quite sure (1st If you really want... and 2nd Try hard enough) there is a way (there is always a way) to accomplish the task of sending the user name and IP completly via LUA... so to say as an easy to install "cheat-safe ChinaInSkyLOFC-StatMod" (CSCIS_LOFC_SM) :D

all you have to do is send username and IP to your stat server via LUA and find a firewall on your game server to block IP's which have not sent their IP to the stat server beforehand...

good luck

Verfasst: 14. Dez 2007, 20:35
von FlyCat
thank your reply!

I got a friend to help me out of this, a real coder.

After study your ATC code, I put the code under the function LuaExportActivityNextEvent(t), it works good enough.

Thank your help!