mIRC Home    About    Download    Register    News    Help

Print Thread
socklisten event #73134 29/02/04 02:33 AM
Joined: Nov 2003
Posts: 25
B
Biezais Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Nov 2003
Posts: 25
Is it possible to get remote IP address before establish connection (sockaccept) to reject connections from unauthorized IP addresses?

Re: socklisten event #73135 29/02/04 02:47 AM
Joined: Nov 2003
Posts: 2,327
T
tidy_trax Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
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
Re: socklisten event #73136 29/02/04 03:14 AM
Joined: Nov 2003
Posts: 25
B
Biezais Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Nov 2003
Posts: 25
Yes, I know. Thanks anyway.
It is'nt a best solution for some protocols...

Re: socklisten event #73137 29/02/04 03:29 AM
Joined: Dec 2002
Posts: 349
S
Skip Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Dec 2002
Posts: 349
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.

Re: socklisten event #73138 01/03/04 10:25 PM
Joined: Aug 2003
Posts: 27
F
fez Offline
Ameglian cow
Offline
Ameglian cow
F
Joined: Aug 2003
Posts: 27
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...


Re: socklisten event #73139 01/03/04 10:49 PM
Joined: Oct 2003
Posts: 101
root66 Offline
Vogon poet
Offline
Vogon poet
Joined: Oct 2003
Posts: 101
can you not accept it as a temporary name, get the ip, and then either close it or use /sockrename?

Re: socklisten event #73140 02/03/04 11:30 AM
Joined: Nov 2003
Posts: 2,327
T
tidy_trax Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
i suggested that, but it's not what he wants


New username: hixxy
Re: socklisten event #73141 02/03/04 08:44 PM
Joined: Nov 2003
Posts: 25
B
Biezais Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Nov 2003
Posts: 25
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.