*delete GET-SOCKET-HOSTNAME-AND-PORTNUMBER (was buggy anyway)
*rewrite GET-SOCKET-HOST-STRING
This commit is contained in:
parent
8974332da1
commit
9d3ddd79b9
|
@ -5,23 +5,14 @@
|
|||
;;; For copyright information, see the file COPYING which comes with
|
||||
;;; the distribution.
|
||||
|
||||
;;; interpolate hostname/IP address and portnumber from our request's net connection.
|
||||
;;; return host as string and portnumber as integer.
|
||||
(define (get-socket-hostname-and-portnumber req)
|
||||
(let ((addr (socket-local-address (request-socket req))))
|
||||
(with-fatal-error-handler
|
||||
(lambda (c more)
|
||||
(call-with-values (lambda ()(socket-address->internet-address addr))
|
||||
(lambda (ipaddr portnum) (values (format-internet-host-address ipaddr) portnum))))
|
||||
(values (host-info:name (host-info addr)) (service-info:port (service-info addr))))))
|
||||
|
||||
;; interpolate host info from our request's net connection.
|
||||
;; return string "foo.bar.org:7777" or "134.2.12.72:7777"
|
||||
;; return string. Example: "134.2.12.72:7777"
|
||||
(define (get-socket-host-string req)
|
||||
(call-with-values
|
||||
(lambda () (get-socket-hostname-and-portnumber req))
|
||||
(lambda (host portnum) (string-append host ":" (number->string portnum)))))
|
||||
|
||||
(let ((addr (socket-local-address (request-socket req))))
|
||||
(call-with-values
|
||||
(lambda ()(socket-address->internet-address addr))
|
||||
(lambda (ipaddr portnum)
|
||||
(string-append (format-internet-host-address ipaddr) ":" (number->string portnum))))))
|
||||
|
||||
;;; interpolate hostname or IP address from socket local address. return a string
|
||||
(define (host-name-or-ip addr)
|
||||
|
|
|
@ -238,8 +238,7 @@
|
|||
format-port))
|
||||
|
||||
(define-interface sunet-utilities-interface
|
||||
(export get-socket-hostname-and-portnumber
|
||||
get-socket-host-string
|
||||
(export get-socket-host-string
|
||||
host-name-or-ip
|
||||
on-interrupt
|
||||
socket-address->string
|
||||
|
|
Loading…
Reference in New Issue