--- deliantra/server/ext/tcp.ext 2008/05/25 21:15:44 1.12 +++ deliantra/server/ext/tcp.ext 2012/02/03 03:01:45 1.20 @@ -1,34 +1,31 @@ -#! perl # MANDATORY +#! perl # mandatory # this listens for new tcp connections and hands them over to the server core -# wether this being an extension introduces or reduces stability problems +# whether this being an extension introduces or reduces stability problems # is unknown as of today. use Socket; use AnyEvent::Socket; -our $BIND = $cf::CFG{bind_addresses} || [[undef, 13327]]; +CONF BIND_ADDRESSES = [[undef, 13327]]; -for (@$BIND) { +our @LISTENERS; + +for (@$BIND_ADDRESSES) { my ($host, $port) = @$_; - warn "listening on $host:$port\n"; + cf::info "listening on ", (format_hostport $host, $port), "\n"; - tcp_server $host, $port, sub { + push @LISTENERS, tcp_server $host, $port, sub { my ($fh, $host, $port) = @_ or return; - my $fd = fileno $fh; + my $lhost = AnyEvent::Socket::format_address + +(AnyEvent::Socket::unpack_sockaddr getsockname $fh)[1]; - warn "new connection from [$host]:$port\n"; + cf::info "new connection from ", (format_hostport $host, $port), "\n" + if $lhost ne $host; # do not log connections from the host, e.g. for watchdogs - # HACK to avoid blocking on common files on log-in. - # remove once async - cf::async {#d# - warn "HACK ext/tcp.ext: $cf::CONFDIR/$_\n" and Coro::AIO::aio_load "$cf::CONFDIR/$_", my $dummy for qw(rules news motd);#d# - warn "HACK ext/tcp.ext: $cf::LOCALDIR/crossfiremail\n" and Coro::AIO::aio_load "$cf::LOCALDIR/crossfiremail", my $dummy;#d# - cf::client::create $fd, $host; - undef $fh;#d# - };#d#d + cf::client::create fileno $fh, $host; }; }