feat: add e2e tests, fix server shutdown and map race, update docs
- Add end-to-end test suite covering HTTP tunnel round-trip, POST forwarding, unknown tunnel 404, duplicate name rejection, unauthorized access, info endpoint, multi-tunnel routing, and graceful shutdown - Fix server graceful shutdown by closing TCP listener on context cancel - Fix data race in pkg/maps Entries() iterator by holding RLock - Rewrite README with architecture, configuration, and usage docs - Add AGENTS.md with project conventions and architecture guide - Update flake.nix (add gopls) and flake.lock
This commit is contained in:
@@ -70,11 +70,23 @@ func (s *Server) Start() error {
|
||||
}
|
||||
defer listener.Close()
|
||||
|
||||
// Context Cancellation - Close the listener when the context is cancelled
|
||||
// so that Accept() unblocks and the loop exits cleanly.
|
||||
go func() {
|
||||
<-s.ctx.Done()
|
||||
listener.Close()
|
||||
}()
|
||||
|
||||
// Start Listening
|
||||
log.Infof("conduit server listening on %s", s.cfg.BindAddress)
|
||||
for {
|
||||
conn, err := listener.Accept()
|
||||
if err != nil {
|
||||
// Expected Error on Shutdown
|
||||
if s.ctx.Err() != nil {
|
||||
log.Info("conduit server shutting down")
|
||||
return nil
|
||||
}
|
||||
log.WithError(err).Error("error accepting connection")
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user