mIRC Home    About    Download    Register    News    Help

Print Thread
Simple IRCd (need ideas) #226839 16/10/10 05:05 AM
Joined: Nov 2009
Posts: 81
V
Voglea Offline OP
Babel fish
OP Offline
Babel fish
V
Joined: Nov 2009
Posts: 81
I make a simple IRC server on mIRC. There is a many ready-made servers (find at www.mircscripts.org) and the problem at all one - $chr(32) (space), because it uses %variable, tokenize etc...

I'm using binary variables and have no problems with the implementation, I have already started to do specific commands - ping/pong, user, nick.

Source code http://83.143.33.145/scripts/ircd.mrc

Quote:
[15:56:15] * Connecting to localhost (194)
-
[15:56:15] -eggdrop.sigma- *** $Software: mIRC 7.14 $
[15:56:15] -eggdrop.sigma- *** Looking up your hostname...
[15:56:16] -eggdrop.sigma- *** Checking Identd...
[15:56:16] -eggdrop.sigma- *** Found your hostname (LOCAL).
[15:56:16] -eggdrop.sigma- *** Got Identd response (_0x538F2191__), using instead username.

nice? smile identd, dns, ping. thats all. You also can testing current server /server -m 83.143.33.145 194 or /run telnet 83.143.33.145 194

But I need ideas of how best to glue the binary variables (from client) and a text (server generate commands)...

Example, /PING [:]<parameters> command.

Code:
; ping command.
; if $isalias(ircd/ping) returns $true
; calls /ircd/ping <sockname> <parameters offset> <length>
; else sent 'unknown command' by parser in SOCKREAD event
alias ircd/ping {

  ; $+(&,%sock) - traffic/commands from user
  ; %offset for parameters
  ; %0 length with CR/LF (/breplaced to 0 byte)
  var %sock = $1, %offset = $2, %0 = $3 - 1

  ; check for ':'
  if ($bvar($+(&,%sock),%offset) == 58) var %offset = %offset + 1, %0 = %0 - 1

  ; if length > 0
  if (%0 > 0) {

    ; works fine, but i thinks thats is not pretty.
    ; need ideas for gluing binary variables and text :)
    bunset $+(&,$1,/,ping)

    ; generate IRC command: $+(:,$host) PONG $host :
    bset -t $+(&,$1,/,ping) 1 $+(:,$host) PONG $host :

    ; copy user's parameters to end
    bcopy $+(&,$1,/,ping) $calc($bvar($+(&,$1,/,ping),0) + 1) $+(&,$1) %offset %0

    ; adding CRLF
    bset $+(&,$1,/,ping) $calc($bvar($+(&,$1,/,ping),0) + 1) 13 10

    ; and sent to user
    ircdsock %sock $+(&,$1,/,ping)
  }
}

We have no more problem with spaces, but code should be beautiful smile As I said, - need ideas to "gluing" binary variables and text.

Maybe make /parser <sock> <many text &bvar text &bvar> authomation?..

Re: Simple IRCd (need ideas) [Re: Voglea] #226850 17/10/10 05:02 AM
Joined: Nov 2009
Posts: 81
V
Voglea Offline OP
Babel fish
OP Offline
Babel fish
V
Joined: Nov 2009
Posts: 81
problem is solved, if anybody no have ant ideas wink

I use asc
Code:
bset &error 1 69 82 82 79 82 32 58 67 108 111 115 105 110 103 32 108 105 110 107 58 32 $iif($hget(%sock,ip,&ip),$bvar(&ip,1-)) 32 40 34 $bvar($+(&,%sock),%offset,%0) 15 34 41 13 10
ircdsock %sock &error
because this is maximum fast and minimum code.