* export selector and transformer of resolve-ip? field in httpd-options

* import dns to httpd-logging
* add dns-lookup facility to logging
This commit is contained in:
interp 2002-08-22 16:40:10 +00:00
parent e0af4da4d6
commit 64d4705ab3
2 changed files with 16 additions and 4 deletions

View File

@ -21,12 +21,16 @@
*http-log-port*) *http-log-port*)
(define (set-http-log-port! port) (define (set-http-log-port! port)
(set! *http-log-port* port)) (set! *http-log-port* port))
(define dns-lookup? #f) ; perform DNS lookups (write names instead of ips)?
(define (init-http-log! options) (define (init-http-log! options)
;; syslog has to be initialized befor CLF-logging ;; syslog has to be initialized befor CLF-logging
;; because it may generate syslog-messages ;; because it may generate syslog-messages
(init-http-syslog! (httpd-options-syslog? options)) (init-http-syslog! (httpd-options-syslog? options))
(init-http-port-log! (httpd-options-logfile options))) (init-http-port-log! (httpd-options-logfile options))
(if (httpd-options-resolve-ips? options)
(set! dns-lookup? #t)
(set! dns-lookup? #f)))
(define (init-http-port-log! logfile) (define (init-http-port-log! logfile)
(let ((logport (let ((logport
@ -116,7 +120,7 @@
; note: till now, we do not log the user's time zone code ; note: till now, we do not log the user's time zone code
(define (make-CLF remote-ip request-type requested-file protocol http-code filesize referer user-agent) (define (make-CLF remote-ip request-type requested-file protocol http-code filesize referer user-agent)
(format #f "~A - - ~A ~S ~A ~A ~S ~S~%" (format #f "~A - - ~A ~S ~A ~A ~S ~S~%"
(or remote-ip "-") (or (maybe-dns-lookup remote-ip) "-")
(format-date "[~d/~b/~Y:~H:~M:~S +0000]" (date)) ; +0000 as we don't know (format-date "[~d/~b/~Y:~H:~M:~S +0000]" (date)) ; +0000 as we don't know
(string-join (list request-type (string-join (list request-type
(string-append "/" requested-file) (string-append "/" requested-file)
@ -132,3 +136,8 @@
""))) "")))
(define (maybe-dns-lookup remote-ip)
(if dns-lookup?
(or (dns-lookup-ip remote-ip)
remote-ip)
remote-ip))

View File

@ -259,7 +259,8 @@
with-server-admin with-server-admin
with-simultaneous-requests with-simultaneous-requests
with-logfile with-logfile
with-syslog?)) with-syslog?
with-resolve-ips?))
(define-interface httpd-read-options-interface (define-interface httpd-read-options-interface
(export httpd-options-port (export httpd-options-port
@ -270,7 +271,8 @@
httpd-options-server-admin httpd-options-server-admin
httpd-options-simultaneous-requests httpd-options-simultaneous-requests
httpd-options-logfile httpd-options-logfile
httpd-options-syslog?)) httpd-options-syslog?
httpd-options-resolve-ips?))
(define-interface httpd-access-control-interface (define-interface httpd-access-control-interface
(export access-denier (export access-denier
@ -688,6 +690,7 @@
rfc822 ; get-header rfc822 ; get-header
sunet-utilities ; on-interrupt sunet-utilities ; on-interrupt
threads ; spawn threads ; spawn
dns ; dns-lookup-ip
scsh scsh
scheme) scheme)
(files (httpd logging))) (files (httpd logging)))