mIRC Homepage
Posted By: Biezais socklisten event - 29/02/04 02:33 AM
Is it possible to get remote IP address before establish connection (sockaccept) to reject connections from unauthorized IP addresses?
Posted By: tidy_trax Re: socklisten event - 29/02/04 02:47 AM
nope, but you could do:

on *:socklisten:blah:{
sockaccept blah2
if $sock(blah2).ip <whatever checks if it's not an authorized connection> { sockclose blah2 }
}
Posted By: Biezais Re: socklisten event - 29/02/04 03:14 AM
Yes, I know. Thanks anyway.
It is'nt a best solution for some protocols...
Posted By: Skip Re: socklisten event - 29/02/04 03:29 AM
I've found /sockaccepting and /sockclosing in the same socklisten event produces the same effect had you not /sockaccept'ed in the first place:

Code:
alias test {
  if $sock(listen) { sockclose listen }
  socklisten -d 127.0.0.1 listen 12345

  if $sock(open) { sockclose open }
  sockopen open 127.0.0.1 12345
}

on *:socklisten:listen:{
  if $sock(accept) { sockclose accept }
  sockaccept accept
  sockclose accept

  sockclose listen
}

on *:sockopen:open:{
  if $sockerr { echo -s error: $sock($sockname).wsmsg }
  else { echo -s connected normally }
}

on *:sockclose:open:{ echo -s closed: $iif($sockerr,$sock($sockname).wsmsg,no error) }


connected normally
closed: no error

After /test'ing that, comment out these lines:

Code:
  ;if $sock(accept) { sockclose accept }
  ;sockaccept accept
  ;sockclose accept


And /test again.

connected normally
closed: no error

Your mileage may vary however.
Posted By: fez Re: socklisten event - 01/03/04 10:25 PM
unfortunately, you cannot get the ip of a connecting host before accepting it. It just doesn't work that way...
even in C, one must accept() before the address information can be evaluated...

Posted By: root66 Re: socklisten event - 01/03/04 10:49 PM
can you not accept it as a temporary name, get the ip, and then either close it or use /sockrename?
Posted By: tidy_trax Re: socklisten event - 02/03/04 11:30 AM
i suggested that, but it's not what he wants
Posted By: Biezais Re: socklisten event - 02/03/04 08:44 PM
Accepting a TCP connection is a resource valuable operation. DoS attacks can be performed.

How works Z-lines on some IRC servers (for example PtLink)?

P.S. Thanks all, for a replies.
© mIRC Discussion Forums