Compare commits

..

1 Commits

Author SHA1 Message Date
antanst
0e218cb57b . 2025-10-14 16:58:38 +03:00
5 changed files with 4 additions and 21 deletions

View File

@@ -23,3 +23,7 @@ Run:
You'll need TLS keys, you can use `certs/generate.sh` You'll need TLS keys, you can use `certs/generate.sh`
for quick generation. for quick generation.
## TODO
- [ ] Make TLS keys path configurable
- [ ] Fix slowloris (proper response timeouts)

View File

@@ -1,7 +1,5 @@
package main package main
// Benchmarks a Gemini server.
import ( import (
"context" "context"
"crypto/tls" "crypto/tls"

View File

@@ -1,7 +1,5 @@
package main package main
// Simply does Gemini requests and prints output.
import ( import (
"crypto/tls" "crypto/tls"
"flag" "flag"

View File

@@ -1,14 +1,10 @@
package main package main
// A Gemini server.
import ( import (
"context" "context"
"crypto/tls" "crypto/tls"
"fmt" "fmt"
"net" "net"
"net/http"
_ "net/http/pprof"
"os" "os"
"os/signal" "os/signal"
"sync" "sync"
@@ -43,16 +39,6 @@ func runApp(ctx context.Context) error {
listenAddr := config.CONFIG.ListenAddr listenAddr := config.CONFIG.ListenAddr
// Start pprof HTTP server if enabled
if config.CONFIG.PprofAddr != "" {
go func() {
logger.Info("Starting pprof HTTP server", "address", config.CONFIG.PprofAddr)
if err := http.ListenAndServe(config.CONFIG.PprofAddr, nil); err != nil {
panic(fmt.Sprintf("pprof HTTP server failed: %v", err))
}
}()
}
signals := make(chan os.Signal, 1) signals := make(chan os.Signal, 1)
signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM) signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM)

View File

@@ -18,7 +18,6 @@ type Config struct {
TLSCert string // TLS certificate file TLSCert string // TLS certificate file
TLSKey string // TLS key file TLSKey string // TLS key file
MaxResponseSize int // Max response size in bytes MaxResponseSize int // Max response size in bytes
PprofAddr string // Address for pprof HTTP endpoint (empty = disabled)
} }
var CONFIG Config //nolint:gochecknoglobals var CONFIG Config //nolint:gochecknoglobals
@@ -50,7 +49,6 @@ func GetConfig() *Config {
tlsCert := flag.String("tls-cert", "certs/server.crt", "TLS certificate file") tlsCert := flag.String("tls-cert", "certs/server.crt", "TLS certificate file")
tlsKey := flag.String("tls-key", "certs/server.key", "TLS key file") tlsKey := flag.String("tls-key", "certs/server.key", "TLS key file")
maxResponseSize := flag.Int("max-response-size", 5_242_880, "Max response size in bytes") maxResponseSize := flag.Int("max-response-size", 5_242_880, "Max response size in bytes")
pprofAddr := flag.String("pprof-addr", "", "Address for pprof HTTP endpoint (empty = disabled)")
flag.Parse() flag.Parse()
@@ -76,6 +74,5 @@ func GetConfig() *Config {
TLSCert: *tlsCert, TLSCert: *tlsCert,
TLSKey: *tlsKey, TLSKey: *tlsKey,
MaxResponseSize: *maxResponseSize, MaxResponseSize: *maxResponseSize,
PprofAddr: *pprofAddr,
} }
} }