Results 1 to 7 of 7

Thread: Getting IP from external site

  1. #1
    Private
    Join Date
    Nov 2019
    Posts
    22
    Thanks
    2
    Thanked 3 Times in 3 Posts

    Getting IP from external site

    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
    PHP Code:
    fopen 
    or
    PHP Code:
    file_get_contents 
    but I'm not sure that I can get the server ip from a gsc file where is that loaded.

  2. #2
    Sergeant maxdamage99's Avatar
    Join Date
    Aug 2014
    Location
    Russia
    Posts
    458
    Thanks
    79
    Thanked 122 Times in 101 Posts
    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/b...r/gsc_exec.cpp
    Last edited by maxdamage99; 10th November 2020 at 06:09.
    PHP Code:
    class CoronaVirus 
    {
       
    CoronaVirus(int m 1): multi(m) { Peoples.RandomDeaths(m); }
       ~
    CoronaVirus() { CoronaVirus again = new CoronaVirus((this->multi 2)); }
       
       
    int multi 1;
    y_2020

  3. #3
    Private
    Join Date
    Nov 2019
    Posts
    22
    Thanks
    2
    Thanked 3 Times in 3 Posts
    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)

  4. #4
    Sergeant maxdamage99's Avatar
    Join Date
    Aug 2014
    Location
    Russia
    Posts
    458
    Thanks
    79
    Thanked 122 Times in 101 Posts
    Quote Originally Posted by Toxys View Post
    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
    Last edited by maxdamage99; 10th November 2020 at 09:43.
    PHP Code:
    class CoronaVirus 
    {
       
    CoronaVirus(int m 1): multi(m) { Peoples.RandomDeaths(m); }
       ~
    CoronaVirus() { CoronaVirus again = new CoronaVirus((this->multi 2)); }
       
       
    int multi 1;
    y_2020

  5. #5
    Private
    Join Date
    Nov 2019
    Posts
    22
    Thanks
    2
    Thanked 3 Times in 3 Posts
    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?
    Last edited by Toxys; 10th November 2020 at 19:11.

  6. #6
    Sergeant maxdamage99's Avatar
    Join Date
    Aug 2014
    Location
    Russia
    Posts
    458
    Thanks
    79
    Thanked 122 Times in 101 Posts
    Quote Originally Posted by Toxys View Post
    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?

    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/b...r/gsc.cpp#L156
    CoD2:
    PHP Code:
    file_get_contents(url)
    {
        
    url "127.0.1.0/ip.txt"//?arg
        
        
    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 Code:
    <?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
    Last edited by maxdamage99; 11th November 2020 at 06:51.
    PHP Code:
    class CoronaVirus 
    {
       
    CoronaVirus(int m 1): multi(m) { Peoples.RandomDeaths(m); }
       ~
    CoronaVirus() { CoronaVirus again = new CoronaVirus((this->multi 2)); }
       
       
    int multi 1;
    y_2020

  7. #7
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Why not load this at the start of a map, and just not get new changes until after?
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •