fukamachi / woo

A fast non-blocking HTTP server on top of libev
http://ultra.wikia.com/wiki/Woo_(kaiju)
MIT License
1.28k stars 98 forks source link

IPv6 support #55

Closed fukamachi closed 8 years ago

fukamachi commented 8 years ago

fixes #53

svetlyak40wt commented 8 years ago

No, it doesn't work.

I have these interfaces on my machine:

eth0      Link encap:Ethernet  HWaddr fa:16:3e:4b:45:2c
          inet6 addr: 2a02:6b8:b010:3016::38b/64 Scope:Global
          inet6 addr: fe80::f816:3eff:fe4b:452c/64 Scope:Link
          inet6 addr: 2a02:6b8:b010:3016:f816:3eff:fe4b:452c/64 Scope:Global
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:85879156 errors:0 dropped:0 overruns:0 frame:0
          TX packets:160372 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:12305458420 (12.3 GB)  TX bytes:41603499 (41.6 MB)

eth0:avahi Link encap:Ethernet  HWaddr fa:16:3e:4b:45:2c
          inet addr:169.254.4.100  Bcast:169.254.255.255  Mask:255.255.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:11396 errors:0 dropped:0 overruns:0 frame:0
          TX packets:11396 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:3326492 (3.3 MB)  TX bytes:3326492 (3.3 MB)

When I'm starting woo as:

(woo:run
   (lambda (env)
     (declare (ignore env)) '(200 (:content-type "text/plain") ("Hello, World"))))

then it starts on 0.0.0.0:5000 which is not accessable from outer world.

What I really want is to call it like:

(woo:run
   (lambda (env)
     (declare (ignore env)) '(200 (:content-type "text/plain") ("Hello, World")))

 :address "::")

or

(woo:run
   (lambda (env)
     (declare (ignore env)) '(200 (:content-type "text/plain") ("Hello, World")))

 :address "ip6-allnodes")

but in first case I receive this error:

getaddrinfo() failed (Code: -9)
   [Condition of type WOO.EV.CONDITION:OS-ERROR]

Restarts:
 0: [RETRY] Retry SLIME REPL evaluation request.
 1: [*ABORT] Return to SLIME's top level.
 2: [ABORT] abort thread (#<THREAD "repl-thread" RUNNING {1004CC8033}>)

Backtrace:
  0: (WOO.EV.TCP::LISTEN-ON "::" 5000 :BACKLOG 128 :SOCKOPT 2)
  1: (WOO.EV.TCP::MAKE-LISTENER "::" 5000 :BACKLOG 128 :FD NIL :SOCKOPT 2)
  2: (WOO.EV.TCP:TCP-SERVER ("::" . 5000) #<FUNCTION WOO::READ-CB> :CONNECT-CB #<FUNCTION (LABELS WOO::START-SOCKET :IN WOO:RU$
  3: (WOO:RUN #<FUNCTION (LAMBDA (ENV)) {10058C1D5B}> :DEBUG T :PORT 5000 :ADDRESS "::" :LISTEN NIL :BACKLOG NIL :FD NIL :WORK$
  4: (SB-INT:SIMPLE-EVAL-IN-LEXENV (WOO:RUN (LAMBDA (ENV) (DECLARE #) (QUOTE #)) :ADDRESS "::") #<NULL-LEXENV>)
  5: (EVAL (WOO:RUN (LAMBDA (ENV) (DECLARE #) (QUOTE #)) :ADDRESS "::"))

and in second this one:

getaddrinfo() failed (Code: -2)
   [Condition of type WOO.EV.CONDITION:OS-ERROR]

Restarts:
 0: [RETRY] Retry SLIME REPL evaluation request.
 1: [*ABORT] Return to SLIME's top level.
 2: [ABORT] abort thread (#<THREAD "repl-thread" RUNNING {1004CC8033}>)

Backtrace:
  0: (WOO.EV.TCP::LISTEN-ON "ip6-allnodes" 5000 :BACKLOG 128 :SOCKOPT 2)
  1: (WOO.EV.TCP::MAKE-LISTENER "ip6-allnodes" 5000 :BACKLOG 128 :FD NIL :SOCKOPT 2)
  2: (WOO.EV.TCP:TCP-SERVER ("ip6-allnodes" . 5000) #<FUNCTION WOO::READ-CB> :CONNECT-CB #<FUNCTION (LABELS WOO::START-SOCKET $
  3: (WOO:RUN #<FUNCTION (LAMBDA (ENV)) {10056F2D2B}> :DEBUG T :PORT 5000 :ADDRESS "ip6-allnodes" :LISTEN NIL :BACKLOG NIL :FD$
  4: (SB-INT:SIMPLE-EVAL-IN-LEXENV (WOO:RUN (LAMBDA (ENV) (DECLARE #) (QUOTE #)) :ADDRESS "ip6-allnodes") #<NULL-LEXENV>)
  5: (EVAL (WOO:RUN (LAMBDA (ENV) (DECLARE #) (QUOTE #)) :ADDRESS "ip6-allnodes"))

But if I pass ::1 as :address, then woo successfully binds on ipv6 loopback interface. And moreover, if I explicitly specify external IPv6 address like :address "2a02:6b8:b010:3016::38b", then it start listening on it.

It would be convenient to be able to specify just :: as external IPv6 address.

Another problem

Another problem is even when woo started on right iterface, it outputs this error, when accepting connection:

140737018612544 is not a Lisp string or pointer.
   [Condition of type SIMPLE-ERROR]

Restarts:
 0: [RETRY] Retry SLIME REPL evaluation request.
 1: [*ABORT] Return to SLIME's top level.
 2: [ABORT] abort thread (#<THREAD "repl-thread" RUNNING {1004CC8033}>)

Backtrace:
  0: ((:METHOD CFFI:TRANSLATE-TO-FOREIGN (T CFFI::FOREIGN-STRING-TYPE)) 140737018612544 #<unavailable argument>) [fast-method]
  1: (WOO.LLSOCKET:INET-NTOP 10 #.(SB-SYS:INT-SAP #X7FFFE4003FB8) 140737018612544 28)
  2: (WOO.EV.TCP::GET-REMOTE-ADDR-AND-PORT)
  3: (WOO.EV.TCP::TCP-ACCEPT-CB #<unavailable argument> #.(SB-SYS:INT-SAP #X7FFFE4011E20) #<unavailable argument>)
  4: ((LAMBDA (SB-ALIEN::ARGS-POINTER SB-ALIEN::RESULT-POINTER FUNCTION) :IN "/home/art/.cache/common-lisp/sbcl-1.3.8-linux-x6$
  5: ("foreign function: call_into_lisp")
  6: ("foreign function: funcall3")
  7: ("foreign function: callback_wrapper_trampoline")
  8: ("foreign function: #x20100E4C")
  9: (WOO:RUN #<FUNCTION (LAMBDA (ENV)) {1006709EDB}> :DEBUG T :PORT 5000 :ADDRESS "2a02:6b8:b010:3016::38b" :LISTEN NIL :BACK$
 10: (SB-INT:SIMPLE-EVAL-IN-LEXENV (WOO:RUN (LAMBDA (ENV) (DECLARE #) (QUOTE #)) :ADDRESS "2a02:6b8:b010:3016::38b") #<NULL-LE$
 11: (EVAL (WOO:RUN (LAMBDA (ENV) (DECLARE #) (QUOTE #)) :ADDRESS "2a02:6b8:b010:3016::38b"))
 12: (SWANK::EVAL-REGION "(woo:run ..)

Do you have ideas how to fix it?

fukamachi commented 8 years ago

Thank you for testing and reporting the detail.

"::" cannot be accepted as IPv6 because of a bug of QURI. It was fixed at https://github.com/fukamachi/quri/commit/b3873ac72fcc64becfaa6c2d553f993db6fe5134. Please use the latest QURI or specify "::0" instead.

I think the "Another problem" has been fixed at https://github.com/fukamachi/woo/pull/55/commits/3b21b22756b02841d49db810558daa8bab483ce8. Please try it again when you have time.

svetlyak40wt commented 8 years ago

Great, this works now! (I tried with "::0" and latest code from this branch).

fukamachi commented 8 years ago

Thanks! I'll merge this in a few days since there's no performance degradation.