{"action":"created","issue":{"url":"https://api.github.com/repos/radare/radare2/issues/5458","repository_url":"https://api.github.com/repos/radare/radare2","labels_url":"https://api.github.com/repos/radare/radare2/issues/5458/labels{/name}","comments_url":"https://api.github.com/repos/radare/radare2/issues/5458/comments","events_url":"https://api.github.com/repos/radare/radare2/issues/5458/events","html_url":"https://github.com/radare/radare2/issues/5458","id":169782934,"number":5458,"title":"The http server doesn't work if hosted on Docker machine","user":{"login":"ljani","id":1334470,"avatar_url":"https://avatars.githubusercontent.com/u/1334470?v=3","gravatar_id":"","url":"https://api.github.com/users/ljani","html_url":"https://github.com/ljani","followers_url":"https://api.github.com/users/ljani/followers","following_url":"https://api.github.com/users/ljani/following{/other_user}","gists_url":"https://api.github.com/users/ljani/gists{/gist_id}","starred_url":"https://api.github.com/users/ljani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ljani/subscriptions","organizations_url":"https://api.github.com/users/ljani/orgs","repos_url":"https://api.github.com/users/ljani/repos","events_url":"https://api.github.com/users/ljani/events{/privacy}","received_events_url":"https://api.github.com/users/ljani/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-08-07T06:38:32Z","updated_at":"2016-08-07T11:20:21Z","closed_at":null,"body":"Steps to reproduce:\r\n- Install [Docker Machine](https://docs.docker.com/machine/) 0.12 on Windows 10 14393.10 x64\r\n- Create a docker machine using the VirtualBox driver\r\n- Start [`debian:latest`](https://hub.docker.com/_/debian/) with the port exposed (`9090`)\r\n- Install the git version of radare2\r\n- Start the web server: `r2 -c=h -e http.bind=0.0.0.0 --`\r\n- From your own machine, curl the open port\r\n\r\nActual output:\r\n```\r\ndocker-radare2 ❯❯❯ curl -v 192.168.99.100:32775\r\n* STATE: INIT => CONNECT handle 0x600057750; line 1396 (connection #-5000)\r\n* Rebuilt URL to: 192.168.99.100:32775/\r\n* Added connection 0. The cache now contains 1 members\r\n*   Trying 192.168.99.100...\r\n* STATE: CONNECT => WAITCONNECT handle 0x600057750; line 1449 (connection #0)\r\n* Connected to 192.168.99.100 (192.168.99.100) port 32775 (#0)\r\n* STATE: WAITCONNECT => SENDPROTOCONNECT handle 0x600057750; line 1556 (connection #0)\r\n* STATE: SENDPROTOCONNECT => DO handle 0x600057750; line 1574 (connection #0)\r\n> GET / HTTP/1.1\r\n> Host: 192.168.99.100:32775\r\n> User-Agent: curl/7.50.1\r\n> Accept: */*\r\n>\r\n* STATE: DO => DO_DONE handle 0x600057750; line 1653 (connection #0)\r\n* STATE: DO_DONE => WAITPERFORM handle 0x600057750; line 1780 (connection #0)\r\n* STATE: WAITPERFORM => PERFORM handle 0x600057750; line 1790 (connection #0)\r\n* HTTP 1.0, assume close after body\r\n< HTTP/1.0 200 ok\r\n< Content-Type: text/html\r\n< Access-Control-Allow-Origin: *\r\n< Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept\r\n< Connection: close\r\n< Content-Length: 6004\r\n<\r\n* Recv failure: Connection reset by peer\r\n* multi_done\r\n* Closing connection 0\r\n* The cache now contains 0 members\r\n* Expire cleared\r\ncurl: (56) Recv failure: Connection reset by peer\r\ndocker-radare2 ❯❯❯\r\n```\r\n\r\nExpected output:\r\n- The web page\r\n- Here's curl output from the docker machine:\r\n```\r\ndocker@Default:~$ curl -v localhost:32775\r\n* Rebuilt URL to: localhost:32775/\r\n*   Trying 127.0.0.1...\r\n* Connected to localhost (127.0.0.1) port 32775 (#0)\r\n> GET / HTTP/1.1\r\n> Host: localhost:32775\r\n> User-Agent: curl/7.49.1\r\n> Accept: */*\r\n>\r\n* HTTP 1.0, assume close after body\r\n< HTTP/1.0 200 ok\r\n< Content-Type: text/html\r\n< Access-Control-Allow-Origin: *\r\n< Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept\r\n< Connection: close\r\n< Content-Length: 6004\r\n<\r\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\r\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n<head>\r\n    SNIP\r\n</html>\r\n* Closing connection 0\r\ndocker@Default:~$\r\n```\r\n\r\nOther notes:\r\n- curl'ing localhost and the port on the docker machine (boot2docker) works fine. This probably means that if you're running Docker natively, you won't see the problem and Docker Machine is required to reproduce\r\n- The headers seem to go through, but the payload does not. It's like something happens [between `r_socket_printf` and `r_socket_write`](https://github.com/radare/radare2/blob/d07b7887865007519f019925972bc46c25238c1b/libr/socket/http_server.c#L86-L89) or [`r_socket_write`](https://github.com/radare/radare2/blob/d07b7887865007519f019925972bc46c25238c1b/libr/socket/socket.c#L516) is broken\r\n- Running a different web server in the container works fine (`python3 -m http.server 9090`), thus I think this is a problem with radare. Let me know if you think I should report this to the Docker team or the VirtualBox team instead.\r\n\r\nEDIT: also, the web server sees the connection:\r\n```\r\nStarting http server...\r\nopen http://127.0.0.1:9090/\r\nr2 -C http://127.0.0.1:9090/cmd/\r\n[HTTP] 192.168.99.1:2469 /\r\n```\r\n\r\nThe client IP differs if the request originates from the docker machine:\r\n```\r\nStarting http server...\r\nopen http://127.0.0.1:9090/\r\nr2 -C http://127.0.0.1:9090/cmd/\r\n[HTTP] 172.17.0.1:39024 /\r\n```"},"comment":{"url":"https://api.github.com/repos/radare/radare2/issues/comments/238076874","html_url":"https://github.com/radare/radare2/issues/5458#issuecomment-238076874","issue_url":"https://api.github.com/repos/radare/radare2/issues/5458","id":238076874,"user":{"login":"ljani","id":1334470,"avatar_url":"https://avatars.githubusercontent.com/u/1334470?v=3","gravatar_id":"","url":"https://api.github.com/users/ljani","html_url":"https://github.com/ljani","followers_url":"https://api.github.com/users/ljani/followers","following_url":"https://api.github.com/users/ljani/following{/other_user}","gists_url":"https://api.github.com/users/ljani/gists{/gist_id}","starred_url":"https://api.github.com/users/ljani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ljani/subscriptions","organizations_url":"https://api.github.com/users/ljani/orgs","repos_url":"https://api.github.com/users/ljani/repos","events_url":"https://api.github.com/users/ljani/events{/privacy}","received_events_url":"https://api.github.com/users/ljani/received_events","type":"User","site_admin":false},"created_at":"2016-08-07T11:20:21Z","updated_at":"2016-08-07T11:20:21Z","body":"Also, looking at the traffic with Wireshark, I see some packets `RST` flag send.\r\n\r\nThis is probably related to #3400?"}}
{"actor":{"display_login":"ljani"}}