Monitoring a Half-Life (2) gameserver with the bot

Back to Module Requests

Page: 1  
From User Message Body
Mad_Clog
Post #207
user avatar
Member
Date: 2:52 pm, May 4 2006
Posts: 176


*!*!*!*!*
This mod had been released and can be downloaded in the "Mods" section of this site
*!*!*!*!*



been wanting to do this for a long time but simple dont have the time to create it right now, dont even know if im able to do it :p

But the general idea is to have the bot login to the server
This can be done by sending commands from the bot to the server and then telling the server to send the logs to the bot, live

Once you have this up and running you can parse then and do whatever you want with it really.

Good example would be letting admin talk to the server from irc.
Or making a trigger to notify the admins their help is required.

Dont know if many people would be intrested in this, but thought i'd just put it up here ;)


Geertz
Clog

Last edited by Mad_Clog at 3:54 pm, Aug 10 2006

Addramyr
Post #208
user avatar
Member
Date: 4:20 pm, May 4 2006
Posts: 43


bit like a HLSW thing for the bot??

___________
Addramyr
CEO Skieweb Technologies
http://wwww.skieweb.com
Manick
Post #209 - Reply to (#207) by Mad_Clog
user avatar
Admin
Date: 4:50 pm, May 4 2006
Posts: 223


Haha, wow, this is pretty ambitious.

I'm not quite sure how you could accomplish it though. Isn't Half Life 2's protocol proprietary (and closed)? I can tell you the bot is certainly capable of this (via the connection class), as long as you could figure out how to communicate with the server---that's always the hard part.

I don't know if I'll have any free time to try this... I also don't know too much about Half-Life 2 multiplayer modes (or servers).

How exactly would the bot log in? As a client directly to the match server? Or are you talking about something a bit more simple?

--Manick
PHP-IRC Developer
Mad_Clog
Post #210
user avatar
Member
Date: 7:55 am, May 5 2006
Posts: 176


Its a nice change from the standard irc games / quizes / news trackers and so on i thought ;)

Anyway

Yes Addramyr kinda the idea of HLSW only then you would be able to alter it to your own needs and make it 2 way traffic.
Not only from the server to irc but also from irc to the server.

I already made something for this in php but im not sure if i still have it (cant check as im at work right now).
Also created a bot like this in mIRC scripting so getting that to work i think wont be the hard part ;)
In the case of HL1 its just sending some commands over udp to the server, which then reply's and if everything is correct starts sending logs.
Then you can use the same udp connection to send commands to the server for remote administration.

The query protocols of both HL1 and HL2 are online, dont have them at hand now, but can look them up for you if your up for making this.

Will have a look when i get home if i still have that bit i worked on, was at the point i could recieve server logs (most likely in some stupid insufficiant way tho ;P)

Anyway i better get back to work ;)
Have a nice day
Clog

Mad_Clog
Post #224
user avatar
Member
Date: 1:36 pm, May 10 2006
Posts: 176


Had a good look around on my harddrives but was unable to find my old scripts :(
Most likely lost them in my last format.

Having a look at the modules that come with the bot by default for learning purposes at the moment.
Once i have succeeded in creating a simple module ill try and have a go at this.

The part that most likely is gonna be a problem for me tho is how to keep the module reading the socket, i mean you need to trigger it somehow right?
And setting up the socket might be a problem, but thats just cause i haven't looked at the socket class which is included with the bot (there is 1 right?) and never really did much with sockets.

If anyone would be so kind to create the basic for me that would help a lot.
Like opening a socket, keep reading from it all the time and send the output to a file.

Greetz,
Clog

Mad_Clog
Post #228
user avatar
Member
Date: 7:50 am, May 12 2006
Posts: 176


Im just gonna keep on rambling here... :p

Had a few attempts on creating a socket but failed badly i think.
So here it is, for yall entertainment:
Code
<?php

class clog_mod extends module {

    public $title = "Test mod";
    public $author = "Mad_Clog";
    public $version = "0.1a";
    
    private $conn;
    private $sockInt;

    public function init()
    {
        $conn = new connection("udp://212.203.23.71", "27035", CONNECT_TIMEOUT);
        //$conn = new connection(NULL, "7131", 0);
        
        $conn->setSocketClass($this->socketClass);
        $conn->setIrcClass($this->ircClass);
        $conn->setTimerClass($this->timerClass);
        
        $conn->setCallbackClass($this);
        
        $conn->init();
        
        if ($conn->getError())
      {
        echo "Error connecting: " . $conn->getErrorMsg();
      }
        
        $this->sockInt = $conn->getSockInt();
        
        $conn->connect();
        
        echo "Sending RCON Challange\n";
        var_dump($this->socketClass->sendSocket($this->sockInt, "ÿÿÿÿchallenge rcon");
        // Returns NULL, guess thats bad cause the data doesnt show up on the server console

        
        $this->conn = $conn;
    }

    public function destroy()
    {
        $this->conn->disconnect();
    }

  public function onTransferTimeout($connection)
  {
      echo 'onTransferTimeout'."\n";
  }

  public function onConnectTimeout($connection)
  {
      echo 'onConnectTimeout'."\n";
  }

  public function onConnect($connection)
  {
      echo 'onConnect'."\n";
  }

  public function onRead($connection)
  {
    echo 'onRead'."\n";
    return true;
  }

  public function onWrite($connection)
  {
      echo 'onWrite'."\n";
  }

  public function onAccept($listener, $newConnection)
  {
      echo 'onAccept'."\n";
  }

  public function onDead($connection)
  {
      echo 'onDead'."\n";
  }
    
    //Methods here:
    public function priv_clog($line, $args) 
    {
        $this->ircClass->privMsg($line['to'], $this->socketClass->getHost($this->sockInt));
    }
    
}

?>


When i reload the bot i do see the socket being created
Then i get my echo's where im trying to send data (Which returns NULL)
Then after that i get onDead from the onDead callback obviously

Just thought i'd share this wonderfull peace of entertainment ;)

Have a nice day,
Clog

Manick
Post #229
user avatar
Admin
Date: 4:33 pm, May 12 2006
Posts: 223


Yes, unfortunately the connection class only works with TCP right now. I will try to add UDP for 2.2.2, but for now you're going to have to manually work with the socket_create, etc stuff in order to do udp.


--Manick
PHP-IRC Developer
Mad_Clog
Post #238 - Reply to (#229) by Manick
user avatar
Member
Date: 2:14 pm, May 17 2006
Posts: 176


Would it be much work / difficult to add UDP support to the socket class?
Would i be able to do so myself? (Have to say my knowledge of sockets is pretty limited)

Manick
Post #239 - Reply to (#238) by Mad_Clog
user avatar
Admin
Date: 7:01 pm, May 17 2006
Posts: 223


Honestly I don't know. The whole socket class would need to be rewritten to support the udp protocol because udp is a totally different type of connection than tcp. udp does not actually "connect" to a host, whereas tcp does. udp just sends packets and hopes they get somewhere. I'll add it to my 2.2.2 list, but honestly i don't know when i'll get time to do it. you can look at the "socket_create" functions over at php.net and at the socket class and see if you can figure it out, but i doubt it'll be an easy task. it may just be easier to call the socket_create etc commands yourself from your module instead of going through a socket class.

--Manick
PHP-IRC Developer
Mad_Clog
Post #242
user avatar
Member
Date: 8:35 pm, May 22 2006
Posts: 176


once again i turn to you, good people of phpbots.org, for help!

had a go at setting up a socket manually, but got stuck at sending commands (everything seems to be fine till i try and send)
posted on some good forums where people normally are able to help and asked in irc aswell (freenode and quakenet with a combined total of about 800 users online) but no help their either.
Think sockets are a big of a dark area for avarage joe the php coder.

anyway here's what i had so far (not much tho)
Code
<?php

    $host = '81.171.85.11';
    $port = 27015;
    
    $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP) or die('socket create error: '.socket_strerror(socket_last_error()));

    socket_bind($socket,'10.53.171.15',$port) or die('socket_bind error: '.socket_strerror(socket_last_error()));
    
    socket_connect($socket,$host,$port) or die('socket_connect error: '.socket_strerror(socket_last_error()));

    $packet = chr(255).chr(255).chr(255).chr(255)."challange rcon\n";
   
    socket_send($socket, $packet, strlen($packet), "0x100") or die('socket_send error: '.socket_strerror(socket_last_error()));

?>


and this is the error msg im getting:
Warning: socket_send(): unable to write to socket [0]: The attempted operation is not supported for the type of object referenced.

Hope someone here will be able to help me out, really would like to see this working in the bot :p

Greetz,
clog

   

  Pages (3) [ 1 2 3 ] Next Page

Back to Module Requests