A Issue in HTTP::%LOCAL-HOST-PARSED-IP-NUMBER when start CL-HTTP on specific x.x.x.x address and port

"Chun Tian (binghe)" <[email protected]> Wed, 23 Mar 2011 16:10:07 +0800
Newsgroups gmane.lisp.cl-http
Message-ID <[email protected]>
Hi, CL-HTTP developers

I'm trying to start a CL-HTTP server on specific x.x.x.x IPv4 address and port. I have to do this, because:

1) I don't have a resolvable hostname on my laptop and some other servers;
2) I have many interface addresses on single machine, need to choose a specific one to be the default virtual host.

Currently I have following initialize code when a empty CL-HTTP image without examples start up:

(defun warm-start ()
  (let ((host (get-from-command-line "-host"))
	(port (or (parse-integer (get-from-command-line "-port")) #+linux 443 #-linux 80)))

    #+linux
    (http:define-https-service
      :address host
      :port port
      :certificate #p"SYS:SSL;SERVER.CRT"
      :private-key #p"SYS:SSL;SERVER.KEY"
      :password :none
      :certificate-authorities #p"SYS:SSL;CA.CRT"
      :parameters #p"SYS:SSL;DH"
      :ciphers :all
      :ssl-version :ssl-default)

    (setq www-utils:*primary-network-host* host
	  http:*standard-http-port* port
	  http:*standard-protocol* #+linux :https #-linux :http
	  http:*resolve-ip-addresses* nil
	  http:*connection-backlog* 128.
	  http::*standard-log-directory* #p"SYS:LOG;")

    (http:set-maximum-number-of-connections 32.)
    (http:log-file-stream-stays-open t)

    (http:run-server-initializations t)
    ;; (http::run-server-launch-initializations t)
    (http:enable-http-service)))

Please let me know if my way to start CL-HTTP has something wrong.

And my problem is, when www-utils:*primary-network-host* was set to a string like "192.168.150.12", (WWW-UTILS:LOCAL-HOST) cannot work, because www-utils:%local-host-parsed-ip-number will call IPC:INTERNET-ADDRESS on *primary-network-host*, and due to its definition, only hostname can be accepted:

(defun local-machine-instance ()
  "Returns the primary domain name (or IP number) for the local host."
  (or *primary-network-host* (machine-instance)))

(defun %local-host-parsed-ip-number ()
  (ipc:internet-address (local-machine-instance)))

;; LispWorks version
(defun internet-address (name)
  (or (comm:get-host-entry name :fields '(:address))
      (error 'www-utils:unknown-host-name :hostname name)))

To make things work, I have to change the definition of %local-host-parsed-ip-number into this:

(in-package :www-utils)

(defun %local-host-parsed-ip-number ()
  (or (ipc:string-ip-address (local-machine-instance))
      (ipc:internet-address (local-machine-instance))))

Is this reasonable, or is there any other solution?

Regards,

Chun Tian (binghe)


_______________________________________________
WWW-CL mailing list
[email protected]
https://lists.csail.mit.edu/mailman/listinfo/www-cl