New masterlist

Started by KAKAN, Nov 02, 2015, 01:01 PM

Previous topic - Next topic

KAKAN

Okay, so actually I was trying to create my own masterlist and host my server in it.
Now the problem is, how can I announce to my new masterlist?
Can I use this in server .cfg?
announce hostlink
I searched for the announce code, here's the main code link.
https://bitbucket.org/stormeus/0.4-announce/src/7375320c271d9c81dd423a9a0ca1c0fe44122c50/0.4-announce/main.c?at=master&fileviewer=file-view-default
oh no

rulk

from looking at that source, i think it's

announce HostIP

better get a dev to confirm though.
We are all god's children.

KAKAN

That's why I asked here, including the source link.
oh no

Thijn

Add this in your server.cfg
announce <host>

Something like
announce master.thijn.ovh

Then you need 2 files on your server. 1 to respond to the servers that announce, and 1 for the server browser.
While these snippets have been tested, they are dirty and do basically zero checking and keep adding the server to the list without removing or replacing the other record if it exists. Modify yourself.
/announce.php
<?php
if ( !empty($_POST['port']) ) {
        
$currentList json_decode(file_get_contents('servers.json'));
        if ( 
$currentList ) {
                
$currentList[] = array('ip' => $_SERVER['REMOTE_ADDR'], 'port' => $_POST['port'], 'is_official' => false);
        } else {
                
$currentList = array('ip' => $_SERVER['REMOTE_ADDR'], 'port' => $_POST['port']);
        }
        
file_put_contents('servers.json'json_encode($currentList));
}
?>


/servers/index.php (If you want to be pretty you can use htaccess or rewrite rules to make /servers call a file like servers.php, but for the sake of easyness I do it like this.)
<?php
$list 
json_decode(file_get_contents('../servers.json'), true);
if ( 
$list ) {
        
$result = array('success' => true'servers' => $list);
} else {
        
$result = array('success' => false'servers' => array());
}
echo 
json_encode($result);
?>


KAKAN

Wow, on a JSON file.
I was using the system made by ysc, thanks for this, anyways my problem is solved now.
So topic marked as solved
oh no