Live data from Hacker News

Show HN: unsafehttp – tiny web server from scratch in C, running on an orange pi

unsafehttp.benren.au

11–20 of 54 posts

Re: Show HN: unsafehttp – tiny web server from scratch in C, running on an orange pi

#11
post #9
post #2

Doesn't seem to be up =\

Found the issue - a use after free in send_response() if I close the session early due to an error. Was continuing to the next bit. Put a temp fix in place, will push a proper one later.

Still seems to have an issue, but no output before the crash. Will have to do some more debugging. Thanks for the test HN!

Source is here btw: https://github.com/GSGBen/unsafehttp/blob/main/src/main.c

Re: Show HN: unsafehttp – tiny web server from scratch in C, running on an orange pi

#12
post #8

Earlier quoted context omitted.

What is it about HN that overwhelms small servers like this? It was a small static page so I wouldn't think it'd be that much load on the server itself, even for an OrangePi like this one. Too many simultaneous connections for his router maybe? Or too much bandwidth for his internet connection?

If they are behind a NAT/ stateful firewall there is just so much connections it will handle at once. I think OpenWRT has like 16K max by default, f.ex. So for less than 16K requests by different users/IPs… each is kept for about 1 minute I think… it quickly will go down, I guess. :) cat /proc/sys/net/netfilter/nf_conntrack_max Should give some details.

Do you know if using the DMZ feature on most routers instead of port forwarding would get around this limit, or if there's any other way?

Re: Show HN: unsafehttp – tiny web server from scratch in C, running on an orange pi

#15
post #9
post #2

Doesn't seem to be up =\

Found the issue - a use after free in send_response() if I close the session early due to an error. Was continuing to the next bit. Put a temp fix in place, will push a proper one later.

hotfixing httpd UAFs is peak HN spirit :)

Re: Show HN: unsafehttp – tiny web server from scratch in C, running on an orange pi

#16
Are you near Sydney? I noted a possible link to the Central Coast. I will contribute a smaller device if you're game to host it.

PS. You may be unaware that your shortened domain name 'benren' from your whois-available real name means "stupid person" in Mandarin. Only noted because there is a company registered with the same name since 1999. On the off chance it's yours, probably not the best marketing in a global world. Just throwing it out there.

Re: Show HN: unsafehttp – tiny web server from scratch in C, running on an orange pi

#18
post #17
post #14

You are lucky that all of your sample files have dots in their names. (-:

I don't understand this, could you explain?

around line 663. there's a call to strrchr, checking for a period in the filename. then immediately after that, there's a strlen that uses the results.

Which is fine, unless the first call returns NULL, because there was no period in the name, and then the program will crash.

Re: Show HN: unsafehttp – tiny web server from scratch in C, running on an orange pi

#20
Nice effort but this isn’t interesting at all. You skipped the most interesting part; parsing http. This is beejs networking tutorial with writing a file to a socket.

Harsh? Maybe, but you’re posting this to a site with some of the most talented developers on planet. Real talk, sorry.

Post reply on HN