💾 Archived View for gemi.dev › gemini-mailing-list › 000236.gmi captured on 2024-08-18 at 23:55:05. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-12-28)
-=-=-=-=-=-=-
I put up a tiny experiment of an ad-hoc server over on gemini://tomasino.org. The code for the server is on that gemini page for you to inspect and play with. Credit to xq for the concept. It's trivial to implement and may open the door for some folks who don't have a plan of running a big server. It may even be able to work with solderpunk's micro-instance ideas. I'm not sure if there's a way to validate client certs by building on to it, but that would make for easy micro-services. - tomasino
wow... that is awesome, i can't believe it is done in so few lines of code! vidak -eof
Hello! I don't understand how the infinite while works in this case... Is it consuming cpu all the time? I play once with ncat and the program was rather in two parts: 1: the-worker #!/bin/sh printf "20 text/gemini; charset=utf-8\r\n" printf "Page generated: %s\n\n" "$(date)" cat file-to-serve 2: the-listener #!/bin/sh port="1965" cert="cert.pem" key="key.pem" printf "Starting gemini server on port %s...\n" "$port" ncat --ssl --ssl-cert "$cert" --ssl-key "$key" --listen "$port" -k -c ./the-worker freD. ??????? Original Message ??????? On Friday 19 June 2020 19:28, James Tomasino <tomasino at lavabit.com> wrote: > I put up a tiny experiment of an ad-hoc server over on gemini://tomasino.org. The code for the server is on that gemini page for you to inspect and play with. Credit to xq for the concept. It's trivial to implement and may open the door for some folks who don't have a plan of running a big server. It may even be able to work with solderpunk's micro-instance ideas. I'm not sure if there's a way to validate client certs by building on to it, but that would make for easy micro-services. > > - tomasino </tomasino at lavabit.com>
On 6/25/20 11:34 AM, defdefred wrote: > I don't understand how the infinite while works in this case... > Is it consuming cpu all the time? ncat waits only for a single connection, then terminates. I tried using the switch to keep the connection alive and reuse it, but that means the connection is never closed on any single request and most clients display nothing. By wrapping it in an infinite while I just tell ncat to start a new listener when the previous one is used. There's only ever one running at a time, and it's a single thread, but traffic is low and it seems to work just fine.
Ok I'm dumb... don't saw the braces :-) Bash process substitution will do too #!/bin/sh port="1965" cert="cert.pem" key="key.pem" printf "Starting gemini server on port %s...\n" "$port" while true; do ncat --ssl --ssl-cert "$cert" --ssl-key "$key" --listen "$port" <( \ printf "20 text/gemini; charset=utf-8\r\n" ; \ printf "Page generated: %s\n\n" "$(date)" ; \ cat "$1" ) done freD. ??????? Original Message ??????? On Thursday 25 June 2020 14:09, James Tomasino <tomasino at lavabit.com> wrote: > On 6/25/20 11:34 AM, defdefred wrote: > > > I don't understand how the infinite while works in this case... > > Is it consuming cpu all the time? > > ncat waits only for a single connection, then terminates. I tried using the switch to keep the connection alive and reuse it, but that means the connection is never closed on any single request and most clients display nothing. By wrapping it in an infinite while I just tell ncat to start a new listener when the previous one is used. There's only ever one running at a time, and it's a single thread, but traffic is low and it seems to work just fine.
I think you can get rid of the loop here and use ncat -k , it's been working pretty well for me in testing. Jun 25, 2020 6:30:42 AM defdefred <defdefred at protonmail.com>: > Ok I'm dumb... don't saw the braces :-) > > Bash process substitution will do too > > #!/bin/sh > > port="1965" > cert="cert.pem" > key="key.pem" > > printf "Starting gemini server on port %s...\n" "$port" > while true; do > ncat --ssl --ssl-cert "$cert" --ssl-key "$key" --listen "$port" <( \ > printf "20 text/gemini; charset=utf-8\r\n" ; \ > printf "Page generated: %s\n\n" "$(date)" ; \ > cat "$1" ) > done > > freD. > > ??????? Original Message ??????? > On Thursday 25 June 2020 14:09, James Tomasino <tomasino at lavabit.com> wrote: > >> On 6/25/20 11:34 AM, defdefred wrote: >> >>> I don't understand how the infinite while works in this case... >>> Is it consuming cpu all the time? >> >> ncat waits only for a single connection, then terminates. I tried using the switch to keep the connection alive and reuse it, but that means the connection is never closed on any single request and most clients display nothing. By wrapping it in an infinite while I just tell ncat to start a new listener when the previous one is used. There's only ever one running at a time, and it's a single thread, but traffic is low and it seems to work just fine. >
---
Previous Thread: Great web site to port to gemini
Next Thread: Some new tests in the Gemini Client Torture Test