Better connection logging
parent
82b2f36416
commit
78008e9904
|
@ -2,10 +2,10 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: continuations destructors kernel math math.parser
|
||||
namespaces parser sequences strings prettyprint debugger
|
||||
quotations combinators logging calendar assocs
|
||||
quotations combinators logging calendar assocs present
|
||||
fry accessors arrays io io.sockets io.encodings.ascii
|
||||
io.sockets.secure io.files io.streams.duplex io.timeouts
|
||||
io.encodings threads concurrency.combinators
|
||||
io.encodings threads make concurrency.combinators
|
||||
concurrency.semaphores concurrency.flags
|
||||
combinators.short-circuit ;
|
||||
IN: io.servers.connection
|
||||
|
@ -56,11 +56,17 @@ GENERIC: handle-client* ( threaded-server -- )
|
|||
[ secure>> >secure ] [ insecure>> >insecure ] bi
|
||||
[ resolve-host ] bi@ append ;
|
||||
|
||||
LOG: accepted-connection NOTICE
|
||||
: accepted-connection ( remote local -- )
|
||||
[
|
||||
[ "remote: " % present % ", " % ]
|
||||
[ "local: " % present % ]
|
||||
bi*
|
||||
] "" make
|
||||
\ accepted-connection NOTICE log-message ;
|
||||
|
||||
: log-connection ( remote local -- )
|
||||
[ accepted-connection ]
|
||||
[ [ remote-address set ] [ local-address set ] bi* ]
|
||||
[ 2array accepted-connection ]
|
||||
2bi ;
|
||||
|
||||
M: threaded-server handle-client* handler>> call ;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors kernel symbols namespaces continuations
|
||||
destructors io.sockets sequences summary calendar delegate
|
||||
system vocabs.loader combinators ;
|
||||
system vocabs.loader combinators present ;
|
||||
IN: io.sockets.secure
|
||||
|
||||
SYMBOL: secure-socket-timeout
|
||||
|
@ -43,6 +43,8 @@ TUPLE: secure addrspec ;
|
|||
|
||||
C: <secure> secure
|
||||
|
||||
M: secure present addrspec>> present " (secure)" append ;
|
||||
|
||||
CONSULT: inet secure addrspec>> ;
|
||||
|
||||
M: secure resolve-host ( secure -- seq )
|
||||
|
|
|
@ -5,8 +5,8 @@ USING: generic kernel io.backend namespaces continuations
|
|||
sequences arrays io.encodings io.ports io.streams.duplex
|
||||
io.encodings.ascii alien.strings io.binary accessors destructors
|
||||
classes debugger byte-arrays system combinators parser
|
||||
alien.c-types math.parser splitting grouping
|
||||
math assocs summary system vocabs.loader combinators ;
|
||||
alien.c-types math.parser splitting grouping math assocs summary
|
||||
system vocabs.loader combinators present ;
|
||||
IN: io.sockets
|
||||
|
||||
<< {
|
||||
|
@ -40,7 +40,14 @@ TUPLE: local path ;
|
|||
: <local> ( path -- addrspec )
|
||||
normalize-path local boa ;
|
||||
|
||||
TUPLE: inet4 host port ;
|
||||
M: local present path>> "Unix domain socket: " prepend ;
|
||||
|
||||
TUPLE: abstract-inet host port ;
|
||||
|
||||
M: abstract-inet present
|
||||
[ host>> ":" ] [ port>> number>string ] bi 3append ;
|
||||
|
||||
TUPLE: inet4 < abstract-inet ;
|
||||
|
||||
C: <inet4> inet4
|
||||
|
||||
|
@ -81,7 +88,7 @@ M: inet4 parse-sockaddr
|
|||
>r dup sockaddr-in-addr <uint> r> inet-ntop
|
||||
swap sockaddr-in-port ntohs <inet4> ;
|
||||
|
||||
TUPLE: inet6 host port ;
|
||||
TUPLE: inet6 < abstract-inet ;
|
||||
|
||||
C: <inet6> inet6
|
||||
|
||||
|
@ -255,7 +262,7 @@ HOOK: addrinfo-error io-backend ( n -- )
|
|||
|
||||
GENERIC: resolve-host ( addrspec -- seq )
|
||||
|
||||
TUPLE: inet host port ;
|
||||
TUPLE: inet < abstract-inet ;
|
||||
|
||||
C: <inet> inet
|
||||
|
||||
|
|
Loading…
Reference in New Issue