Re: [hlds_linux] Building a daemon

2011-02-03 Thread kama

On Mon, 31 Jan 2011, Bajdechi "Nightbox" Alexandru wrote:

> Hello,
>
> I've been searching through internet but I could not some useful
> information:
>
> I would like to build a daemon for logaddress (preferably) in PHP, does
> anyone know a guide/basic infos/example about this ?

I usually only need to look it up at php.net.

Maybe this can help?

http://se.php.net/manual/en/function.socket-accept.php

Look at the 'lars at opdenkamp dot eu 29-Jan-2008 01:35' post.

/Bjorn

___
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlds_linux


Re: [hlds_linux] Building a daemon

2011-02-02 Thread Andre Müller
Thanks, I have aleady seen it. I think your Lib is powerful.
So you because you are already working on the project, I will release my code.
Long time I was thinking about it, to sell it.
At the moment I'm not happy with my own code. Maybe you all can test
it and make improvments.

http://sourceserver.info/wiki/waradmin/start [German]

Greetings DeaD_EyE

2011/2/2 frostschutz :
> On Tue, Feb 01, 2011 at 08:31:22PM +0100, Andre Müller wrote:
>> I've used Python to program a WarAdmin-Daemon. The daemon get the logs
>> via UDP and it sends on diffrent chatcommands commands via rcon
>> (SRCDS.py). For easy configure i'm using the built in ConfigParser.
>
> That's what I do too (except using my own library - SRCDS.py can choke
> on RCON sometimes). I love this approach, you can do a lot of things
> on your server without depending on plugins. And you can do things
> plugins can't do, like automatically downloading and installing maps
> that are mentioned in the chat... ;)
>
>> Python is a powerful and easy language.
>> The regex was a little bit heavy. Try out "The Regex Coach":
>> http://weitz.de/regex-coach/
>
> Some log related regexps in here:
>
> https://github.com/frostschutz/SourceLib/blob/master/SourceLog.py
>
> Regards
> frostschutz
>
> ___
> To unsubscribe, edit your list preferences, or view the list archives, please 
> visit:
> http://list.valvesoftware.com/mailman/listinfo/hlds_linux
>

___
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlds_linux


Re: [hlds_linux] Building a daemon

2011-02-01 Thread frostschutz
On Tue, Feb 01, 2011 at 08:31:22PM +0100, Andre Müller wrote:
> I've used Python to program a WarAdmin-Daemon. The daemon get the logs
> via UDP and it sends on diffrent chatcommands commands via rcon
> (SRCDS.py). For easy configure i'm using the built in ConfigParser.

That's what I do too (except using my own library - SRCDS.py can choke 
on RCON sometimes). I love this approach, you can do a lot of things 
on your server without depending on plugins. And you can do things 
plugins can't do, like automatically downloading and installing maps 
that are mentioned in the chat... ;)

> Python is a powerful and easy language.
> The regex was a little bit heavy. Try out "The Regex Coach":
> http://weitz.de/regex-coach/

Some log related regexps in here:

https://github.com/frostschutz/SourceLib/blob/master/SourceLog.py

Regards
frostschutz

___
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlds_linux


Re: [hlds_linux] Building a daemon

2011-02-01 Thread Andre Müller
I've used Python to program a WarAdmin-Daemon. The daemon get the logs
via UDP and it sends on diffrent chatcommands commands via rcon
(SRCDS.py). For easy configure i'm using the built in ConfigParser.

Here the Class for geting the Logs:

###
class UDPLogReader:
import socket
prefix = '\xff\xff\xff\xff\x52'
def __init__(self, host, port, server_ip, server_port):
self.source_ip = server_ip
self.source_port = server_port
self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.socket.bind((host,port))

def __iter__(self):
with closing(self.socket):
while True:
data, addr = self.socket.recvfrom(1024)
if addr == (self.source_ip, self.source_port) and
data.startswith(self.prefix):
try:
output =
data[len(self.prefix):].rstrip('\n\x00').decode('utf-8', 'replace')
yield output
except UnicodeDecodeError:
pass

def __del__(self):
self.socket.close()

log = UDPLogReader('ip-of-the-daemon', 27500, 'serverip', 27015)

for line in log:
print line

###END

Here is the regex-part, if you whis to get some informations, when a
player says something:


import re
re_command = re.compile(r'L \d{2}/\d{2}/\d{4} - \d{2}:\d{2}:\d{2}:
"(.+?)<[0-9]+><(STEAM_\d:\d:\d+)><.+?>" say "(.+?)"')
if re.match(re_command, line):
player, steamid, chatcmd = re.match(re_command, line).groups()
#  A little fix: i've got an error, when an admin with unicode chars
executes a command.
player = player.encode("iso-8859-15", "replace")


Python is a powerful and easy language.
The regex was a little bit heavy. Try out "The Regex Coach":
http://weitz.de/regex-coach/

Here you can find a little Chat-Parser for logfiles:
http://sourceserver.info/viewtopic.php?p=27134#p27134

Greetings
DeaD_EyE

2011/2/1 Eric Riemers :
>
> Or just take a peek at the code from hlxce, perl daemon.
>
> On Tue, 1 Feb 2011 07:55:08 +0100, Björn Rohlén 
> wrote:
>> Or, you could just use netcat, open port, set logaddressthen read the
> logs
>> as any other without doing the socketstuff yourself. Worked very well
> when
>> we did the first pickup/gather-bot.
>>
>> -TheG
>>
>> On Tue, Feb 1, 2011 at 12:40 AM, doc  wrote:
>>
>>> Not to turn this into programming chat but Python as a language is
>>> pretty simple to pick up. If you've learned the atrocities of PHP then
>>> it should be a walk in the park.
>>>
>>> On Mon, Jan 31, 2011 at 2:51 PM, Bajdechi "Nightbox" Alexandru
>>>  wrote:
>>> > I've gussed PHP will have to run as a stand alone procces. The only
>>> problem
>>> > with Python is that I find it complicated to learn.
>>> >
>>> > 2011/1/31 frostschutz 
>>> >
>>> >> On Mon, Jan 31, 2011 at 10:41:56PM +0200, Bajdechi "Nightbox"
>>> >> Alexandru
>>> >> wrote:
>>> >> > I would like to build a daemon for logaddress (preferably) in PHP,
>>> does
>>> >> > anyone know a guide/basic infos/example about this ?
>>> >>
>>> >> PHP would have to run as a stand alone process (not webserver)
>>> >> because you need a persistent socket to listen to the incoming
>>> >> UDP packets.
>>> >>
>>> >> I only have an implementation in Python (SourceLib/SourceLog.py).
>>> >> It's more a log parser than just a listener though.
>>> >>
>>> >> Regards
>>> >> frostschutz
>>> >>
>>> >> ___
>>> >> To unsubscribe, edit your list preferences, or view the list
> archives,
>>> >> please visit:
>>> >> http://list.valvesoftware.com/mailman/listinfo/hlds_linux
>>> >>
>>> > ___
>>> > To unsubscribe, edit your list preferences, or view the list archives,
>>> please visit:
>>> > http://list.valvesoftware.com/mailman/listinfo/hlds_linux
>>> >
>>>
>>> ___
>>> To unsubscribe, edit your list preferences, or view the list archives,
>>> please visit:
>>> http://list.valvesoftware.com/mailman/listinfo/hlds_linux
>>>
>> ___
>> To unsubscribe, edit your list preferences, or view the list archives,
>> please visit:
>> http://list.valvesoftware.com/mailman/listinfo/hlds_linux
>
> ___
> To unsubscribe, edit your list preferences, or view the list archives, please 
> visit:
> http://list.valvesoftware.com/mailman/listinfo/hlds_linux
>

___
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlds_linux


Re: [hlds_linux] Building a daemon

2011-02-01 Thread Eric Riemers

Or just take a peek at the code from hlxce, perl daemon.

On Tue, 1 Feb 2011 07:55:08 +0100, Björn Rohlén 
wrote:
> Or, you could just use netcat, open port, set logaddressthen read the
logs
> as any other without doing the socketstuff yourself. Worked very well
when
> we did the first pickup/gather-bot.
> 
> -TheG
> 
> On Tue, Feb 1, 2011 at 12:40 AM, doc  wrote:
> 
>> Not to turn this into programming chat but Python as a language is
>> pretty simple to pick up. If you've learned the atrocities of PHP then
>> it should be a walk in the park.
>>
>> On Mon, Jan 31, 2011 at 2:51 PM, Bajdechi "Nightbox" Alexandru
>>  wrote:
>> > I've gussed PHP will have to run as a stand alone procces. The only
>> problem
>> > with Python is that I find it complicated to learn.
>> >
>> > 2011/1/31 frostschutz 
>> >
>> >> On Mon, Jan 31, 2011 at 10:41:56PM +0200, Bajdechi "Nightbox"
>> >> Alexandru
>> >> wrote:
>> >> > I would like to build a daemon for logaddress (preferably) in PHP,
>> does
>> >> > anyone know a guide/basic infos/example about this ?
>> >>
>> >> PHP would have to run as a stand alone process (not webserver)
>> >> because you need a persistent socket to listen to the incoming
>> >> UDP packets.
>> >>
>> >> I only have an implementation in Python (SourceLib/SourceLog.py).
>> >> It's more a log parser than just a listener though.
>> >>
>> >> Regards
>> >> frostschutz
>> >>
>> >> ___
>> >> To unsubscribe, edit your list preferences, or view the list
archives,
>> >> please visit:
>> >> http://list.valvesoftware.com/mailman/listinfo/hlds_linux
>> >>
>> > ___
>> > To unsubscribe, edit your list preferences, or view the list archives,
>> please visit:
>> > http://list.valvesoftware.com/mailman/listinfo/hlds_linux
>> >
>>
>> ___
>> To unsubscribe, edit your list preferences, or view the list archives,
>> please visit:
>> http://list.valvesoftware.com/mailman/listinfo/hlds_linux
>>
> ___
> To unsubscribe, edit your list preferences, or view the list archives,
> please visit:
> http://list.valvesoftware.com/mailman/listinfo/hlds_linux

___
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlds_linux


Re: [hlds_linux] Building a daemon

2011-01-31 Thread Björn Rohlén
Or, you could just use netcat, open port, set logaddressthen read the logs
as any other without doing the socketstuff yourself. Worked very well when
we did the first pickup/gather-bot.

-TheG

On Tue, Feb 1, 2011 at 12:40 AM, doc  wrote:

> Not to turn this into programming chat but Python as a language is
> pretty simple to pick up. If you've learned the atrocities of PHP then
> it should be a walk in the park.
>
> On Mon, Jan 31, 2011 at 2:51 PM, Bajdechi "Nightbox" Alexandru
>  wrote:
> > I've gussed PHP will have to run as a stand alone procces. The only
> problem
> > with Python is that I find it complicated to learn.
> >
> > 2011/1/31 frostschutz 
> >
> >> On Mon, Jan 31, 2011 at 10:41:56PM +0200, Bajdechi "Nightbox" Alexandru
> >> wrote:
> >> > I would like to build a daemon for logaddress (preferably) in PHP,
> does
> >> > anyone know a guide/basic infos/example about this ?
> >>
> >> PHP would have to run as a stand alone process (not webserver)
> >> because you need a persistent socket to listen to the incoming
> >> UDP packets.
> >>
> >> I only have an implementation in Python (SourceLib/SourceLog.py).
> >> It's more a log parser than just a listener though.
> >>
> >> Regards
> >> frostschutz
> >>
> >> ___
> >> To unsubscribe, edit your list preferences, or view the list archives,
> >> please visit:
> >> http://list.valvesoftware.com/mailman/listinfo/hlds_linux
> >>
> > ___
> > To unsubscribe, edit your list preferences, or view the list archives,
> please visit:
> > http://list.valvesoftware.com/mailman/listinfo/hlds_linux
> >
>
> ___
> To unsubscribe, edit your list preferences, or view the list archives,
> please visit:
> http://list.valvesoftware.com/mailman/listinfo/hlds_linux
>
___
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlds_linux


Re: [hlds_linux] Building a daemon

2011-01-31 Thread doc
Not to turn this into programming chat but Python as a language is
pretty simple to pick up. If you've learned the atrocities of PHP then
it should be a walk in the park.

On Mon, Jan 31, 2011 at 2:51 PM, Bajdechi "Nightbox" Alexandru
 wrote:
> I've gussed PHP will have to run as a stand alone procces. The only problem
> with Python is that I find it complicated to learn.
>
> 2011/1/31 frostschutz 
>
>> On Mon, Jan 31, 2011 at 10:41:56PM +0200, Bajdechi "Nightbox" Alexandru
>> wrote:
>> > I would like to build a daemon for logaddress (preferably) in PHP, does
>> > anyone know a guide/basic infos/example about this ?
>>
>> PHP would have to run as a stand alone process (not webserver)
>> because you need a persistent socket to listen to the incoming
>> UDP packets.
>>
>> I only have an implementation in Python (SourceLib/SourceLog.py).
>> It's more a log parser than just a listener though.
>>
>> Regards
>> frostschutz
>>
>> ___
>> To unsubscribe, edit your list preferences, or view the list archives,
>> please visit:
>> http://list.valvesoftware.com/mailman/listinfo/hlds_linux
>>
> ___
> To unsubscribe, edit your list preferences, or view the list archives, please 
> visit:
> http://list.valvesoftware.com/mailman/listinfo/hlds_linux
>

___
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlds_linux


Re: [hlds_linux] Building a daemon

2011-01-31 Thread Bajdechi "Nightbox" Alexandru
I've gussed PHP will have to run as a stand alone procces. The only problem
with Python is that I find it complicated to learn.

2011/1/31 frostschutz 

> On Mon, Jan 31, 2011 at 10:41:56PM +0200, Bajdechi "Nightbox" Alexandru
> wrote:
> > I would like to build a daemon for logaddress (preferably) in PHP, does
> > anyone know a guide/basic infos/example about this ?
>
> PHP would have to run as a stand alone process (not webserver)
> because you need a persistent socket to listen to the incoming
> UDP packets.
>
> I only have an implementation in Python (SourceLib/SourceLog.py).
> It's more a log parser than just a listener though.
>
> Regards
> frostschutz
>
> ___
> To unsubscribe, edit your list preferences, or view the list archives,
> please visit:
> http://list.valvesoftware.com/mailman/listinfo/hlds_linux
>
___
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlds_linux


Re: [hlds_linux] Building a daemon

2011-01-31 Thread frostschutz
On Mon, Jan 31, 2011 at 10:41:56PM +0200, Bajdechi "Nightbox" Alexandru wrote:
> I would like to build a daemon for logaddress (preferably) in PHP, does
> anyone know a guide/basic infos/example about this ?

PHP would have to run as a stand alone process (not webserver) 
because you need a persistent socket to listen to the incoming 
UDP packets.

I only have an implementation in Python (SourceLib/SourceLog.py). 
It's more a log parser than just a listener though.

Regards
frostschutz

___
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlds_linux


[hlds_linux] Building a daemon

2011-01-31 Thread Bajdechi "Nightbox" Alexandru
Hello,

I've been searching through internet but I could not some useful
information:

I would like to build a daemon for logaddress (preferably) in PHP, does
anyone know a guide/basic infos/example about this ?

Thanks,
Nightbox
___
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlds_linux