fukamachi / clack

Web server abstraction layer for Common Lisp
MIT License
1.04k stars 86 forks source link

Using value "localhost" to clackup with wookie is invalid #165

Closed C-Entropy closed 3 years ago

C-Entropy commented 3 years ago

when do something like:

(ql:quickload :clack)
(defvar *handler*
  (clack:clackup
      (lambda (env)
        (declare (ignore env))
        '(200 (:content-type "text/plain") ("Hello, Clack!")))
      :address "localhost"
      :server :wookie
      :port 5001))

It gives:Invalid address passed (not IPv4 or IPV6): "localhost"

Although we can avoid this without using "localhost". I think it is not a bad idea to change the default value.

And as @svetlyak40wt mentioned here, it may be a good choice to use something like: (usocket:get-host-by-name "localhost")

fukamachi commented 3 years ago

Confirmed. "cl-async" seems to reject the address.

As usocket:vector-quad-to-dotted-quad can convert the vector into a string, it won't be a difficult change.

CL-USER> (usocket:vector-quad-to-dotted-quad (usocket:get-host-by-name "localhost"))
"127.0.0.1"
CL-USER> (usocket:vector-quad-to-dotted-quad (usocket:get-host-by-name "127.0.0.1"))
"127.0.0.1"
CL-USER> (usocket:vector-quad-to-dotted-quad (usocket:get-host-by-name "192.168.1.1"))
"192.168.1.1"
CL-USER> (usocket:vector-quad-to-dotted-quad (usocket:get-host-by-name "google.com"))
"172.217.161.46"

This adds usocket as a dependency of Clack, but I'm not sure if it's acceptable.

C-Entropy commented 3 years ago

Or maybe better to point out that? Since some one may just use "localhost".

fukamachi commented 3 years ago

usocket is a quite thin library so that it shouldn't be a problem. I opened a PR at #166. Please check if it works for you.

C-Entropy commented 3 years ago

It looks like you have not accept it yet. I'm sorry that I don't now how to test a PR that have not been merged yet. But the code look ok to me.

C-Entropy commented 3 years ago

Okay, it works for me. Close. Thank you @fukamachi !