Compare commits
2 Commits
0e218cb57b
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bba00a9892 | ||
|
|
8e1297a230 |
@@ -23,7 +23,3 @@ Run:
|
||||
|
||||
You'll need TLS keys, you can use `certs/generate.sh`
|
||||
for quick generation.
|
||||
|
||||
## TODO
|
||||
- [ ] Make TLS keys path configurable
|
||||
- [ ] Fix slowloris (proper response timeouts)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package main
|
||||
|
||||
// Benchmarks a Gemini server.
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package main
|
||||
|
||||
// Simply does Gemini requests and prints output.
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"flag"
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
package main
|
||||
|
||||
// A Gemini server.
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
_ "net/http/pprof"
|
||||
"os"
|
||||
"os/signal"
|
||||
"sync"
|
||||
@@ -39,6 +43,16 @@ func runApp(ctx context.Context) error {
|
||||
|
||||
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)
|
||||
signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM)
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ type Config struct {
|
||||
TLSCert string // TLS certificate file
|
||||
TLSKey string // TLS key file
|
||||
MaxResponseSize int // Max response size in bytes
|
||||
PprofAddr string // Address for pprof HTTP endpoint (empty = disabled)
|
||||
}
|
||||
|
||||
var CONFIG Config //nolint:gochecknoglobals
|
||||
@@ -49,6 +50,7 @@ func GetConfig() *Config {
|
||||
tlsCert := flag.String("tls-cert", "certs/server.crt", "TLS certificate 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")
|
||||
pprofAddr := flag.String("pprof-addr", "", "Address for pprof HTTP endpoint (empty = disabled)")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
@@ -74,5 +76,6 @@ func GetConfig() *Config {
|
||||
TLSCert: *tlsCert,
|
||||
TLSKey: *tlsKey,
|
||||
MaxResponseSize: *maxResponseSize,
|
||||
PprofAddr: *pprofAddr,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user