PDA

View Full Version : Getting IP from external site



Toxys
9th November 2020, 19:54
I have 2 questions:

- Can I get the current server's ip address from a GSC file somehow?
- If so, can I read a file from external site and check if the ip address in that file is the same as the current server's ip address?

I want to do a function in a gsc which checking if the current server ip is matching with the current server's ip address where is the gsc loaded

For example: I have a file named ip.txt in an external site (http://8.8.8.8/ip.txt) in the ip.txt file I have IP = 2.2.2.2 or just 2.2.2.2 nvm and in the gsc I want to request this file and the ip from this file and if the ip is same as the server ip where is the gsc is loaded then do nothing but if its not the same then just quit the server or something.

I think I can get the file contents with
fopen or
file_get_contents but I'm not sure that I can get the server ip from a gsc file where is that loaded.

maxdamage99
10th November 2020, 05:05
You try make ban by ip or what?

Can use any convenient method of reading the web file. to get the result in cod2 - use "exec" and better asynchronous: https://github.com/damage99/libcod/blob/master/gsc_exec.cpp

Toxys
10th November 2020, 08:21
No, I want to protect a mod with hide a code in some gsc in that way...

So the code would check if the server ip (where is the mod) is matches with the ip address in the txt on a webserver (ex.: http://8.8.8.8/ip.txt)

maxdamage99
10th November 2020, 08:40
No, I want to protect a mod with hide a code in some gsc in that way...

So the code would check if the server ip (where is the mod) is matches with the ip address in the txt on a webserver (ex.: http://8.8.8.8/ip.txt)

I do not really understand what you want, either because
1. you do not fully say what you need
or
2. i do not understand English well)


if you want to protect your mod in the hands of third persons, then this is a useless undertaking, because cod2 scripts are not compiled and with minimal programming skills, a person will get rid of your protection

it is best to avoid getting your code to outsiders, all protections against all exploits inside the game are included in the libcod, observe safety, be careful when creating HTTTPRedirect so that nothing superfluous gets there, that's all

Toxys
10th November 2020, 08:58
Yes I know there is no 100% security, but not everyone look into the codes, etc... so this minimal security will be ok.

Well I set sv_allowdownload to 0, so the players can download only through http. But since I'm using VPS , my VPS provider can access to the file no matter what I'm doing. So I thinking about I hide a code what I explained before.

How can I read the file contents from external site with fopen? Can you give me an example please?

maxdamage99
11th November 2020, 05:00
Yes I know there is no 100% security, but not everyone look into the codes, etc... so this minimal security will be ok.

Well I set sv_allowdownload to 0, so the players can download only through http. But since I'm using VPS , my VPS provider can access to the file no matter what I'm doing. So I thinking about I hide a code what I explained before.

How can I read the file contents from external site with fopen? Can you give me an example please?

:confused:
i think better need use methods outside cod2: php, perl, bash etc -> push result from outside into cod2 through "execute" (libcod)

https://github.com/damage99/libcod/blob/master/gsc.cpp#L156
CoD2:


file_get_contents(url)
{
url = "127.0.1.0/ip.txt"; //?arg

s = execute("php /home/scripts/file_get_contents.php " + url);
//s = execute("/home/scripts/file_get_contents.php " + url)[0]; ???????????

return s;
}


PHP file_get_contents.php:


<?php
die(file_get_contents($argv[1]));
?>


p.s:
I'm not sure if the VDS provider needs your mod. I'm not at all sure that modern technologies and methods of organizing cloud computing allow them to receive your data (in unencrypted form). I will tell you more, your provider does not even know your password (although it checks it during authorization) - this is how it should be

IzNoGoD
11th November 2020, 17:13
Why not load this at the start of a map, and just not get new changes until after?