mIRC Home    About    Download    Register    News    Help

Topic Options
#73134 - 29/02/04 02:33 AM socklisten event
Biezais Offline
Ameglian cow

Registered: 24/11/03
Posts: 25
Loc: Riga, Latvia
Is it possible to get remote IP address before establish connection (sockaccept) to reject connections from unauthorized IP addresses?

Top
#73135 - 29/02/04 02:47 AM Re: socklisten event
tidy_trax Offline
Hoopy frood

Registered: 02/11/03
Posts: 2327
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 }
}
_________________________
New username: hixxy

Top
#73136 - 29/02/04 03:14 AM Re: socklisten event
Biezais Offline
Ameglian cow

Registered: 24/11/03
Posts: 25
Loc: Riga, Latvia
Yes, I know. Thanks anyway.
It is'nt a best solution for some protocols...

Top
#73137 - 29/02/04 03:29 AM Re: socklisten event
Skip Offline
Fjord artisan

Registered: 09/12/02
Posts: 349
Loc: Darwin, Australia
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.

Top
#73138 - 01/03/04 10:25 PM Re: socklisten event
fez Offline
Ameglian cow

Registered: 22/08/03
Posts: 27
Loc: Minneapolis, MN, USA
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...


Top
#73139 - 01/03/04 10:49 PM Re: socklisten event
root66 Offline
Vogon poet

Registered: 14/10/03
Posts: 101
can you not accept it as a temporary name, get the ip, and then either close it or use /sockrename?

Top
#73140 - 02/03/04 11:30 AM Re: socklisten event
tidy_trax Offline
Hoopy frood

Registered: 02/11/03
Posts: 2327
i suggested that, but it's not what he wants
_________________________
New username: hixxy

Top
#73141 - 02/03/04 08:44 PM Re: socklisten event
Biezais Offline
Ameglian cow

Registered: 24/11/03
Posts: 25
Loc: Riga, Latvia
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.

Top