Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

---

## [v2.5.3] - 2026-10-09 (Current Stable Milestone)
## [v2.5.4] - 2026-10-09 (Current Stable Milestone)

> **Milestone Focus:** Deep Stream Diagnostics, Forwarding Lifecycle Telemetry, Pump Error Tracing, and AcceptStream Error Propagation.

### ⚡ Hawal Core v2.5.4: Diagnostic Tracing
- **Egress & Ingress Stream Telemetry:** Added real-time structured logging for `OpenStream`, `AcceptStream`, `TypeOpen`, and local dial attempts in `relay.go` and `session.go`.
- **True Error Propagation in AcceptStream:** Aligned `AcceptStream` on closed sessions to return underlying `s.closeErr` instead of masked `ErrSessionClosed`, surfacing exact underlying connection failure causes.
- **Keepalive & Pump Monitoring:** Added logging on deadlink detection, outbound write failures, and inbound read errors to expose link drops immediately in logs.

---

## [v2.5.3] - 2026-10-09

> **Milestone Focus:** Immediate Keepalive/Handshake Delivery, Idle Reconnect Elimination, Synchronized DeadLink Timeout, Default MTU Hardening (1150), and GitOps Process Cycling.

Expand Down
2 changes: 1 addition & 1 deletion core/v2/cmd/hawal-core/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

var (
Version = "2.5.3"
Version = "2.5.4"
)

type ConfigFile struct {
Expand Down
5 changes: 4 additions & 1 deletion core/v2/engine/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ func (fl *ForwardListener) serve(getSession func() *Session) {
defer c.Close()
sess := getSession()
if sess == nil {
log.Printf("[Hawal-v2] ⚠️ Dropping client connection on %s: session is not ready", fl.rule.ListenPort)
return
}

Expand Down Expand Up @@ -138,13 +139,15 @@ func ServeEgress(ctx context.Context, session *Session, portMap map[string]strin
target = "127.0.0.1:" + target
}

log.Printf("[Hawal-v2] 🔌 Serving egress stream #%d -> dialing %s", s.ID(), target)
outConn, err := net.DialTimeout("tcp", target, 10*time.Second)
if err != nil {
log.Printf("[Hawal-v2] Egress dial to %s failed: %v", target, err)
log.Printf("[Hawal-v2] ❌ Egress dial to %s failed: %v", target, err)
_ = s.Reset()
return
}
defer outConn.Close()
log.Printf("[Hawal-v2] 🟢 Egress connected to %s for stream #%d", target, s.ID())

if tcpConn, ok := outConn.(*net.TCPConn); ok && noDelay {
_ = tcpConn.SetNoDelay(true)
Expand Down
14 changes: 13 additions & 1 deletion core/v2/engine/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,17 +169,24 @@ func (s *Session) OpenStream(target string) (*Stream, error) {
return nil, fmt.Errorf("engine: send open frame: %w", err)
}

log.Printf("[Hawal-v2] ➡️ OpenStream #%d for %s", id, target)
return st, nil
}

func (s *Session) AcceptStream(ctx context.Context) (*Stream, error) {
select {
case <-s.closed:
if s.closeErr != nil {
return nil, s.closeErr
}
return nil, ErrSessionClosed
case <-ctx.Done():
return nil, ctx.Err()
case st, ok := <-s.incoming:
if !ok {
if s.closeErr != nil {
return nil, s.closeErr
}
return nil, ErrSessionClosed
}
return st, nil
Expand Down Expand Up @@ -289,6 +296,7 @@ func (s *Session) outboundPump() {

_ = s.link.SetWriteDeadline(time.Now().Add(10 * time.Second))
if err := s.codec.Write(s.link, rec); err != nil {
log.Printf("[Hawal-v2] ❌ Outbound write failed for record type %d: %v", rec.Type, err)
_ = s.CloseWithError(fmt.Errorf("engine: write record: %w", err))
return
}
Expand All @@ -299,6 +307,7 @@ func (s *Session) inboundPump() {
for {
rec, err := s.codec.Read(s.link)
if err != nil {
log.Printf("[Hawal-v2] ❌ Inbound read failed: %v", err)
_ = s.CloseWithError(fmt.Errorf("engine: read record: %w", err))
return
}
Expand All @@ -308,6 +317,7 @@ func (s *Session) inboundPump() {
switch rec.Type {
case record.TypeOpen:
target := string(rec.Payload)
log.Printf("[Hawal-v2] ⬅️ Received TypeOpen stream #%d target %s", rec.StreamID, target)
st := newStream(rec.StreamID, target, s)

s.streamsMu.Lock()
Expand Down Expand Up @@ -350,6 +360,7 @@ func (s *Session) inboundPump() {

case record.TypePing:
// Peer is probing liveness; respond immediately with Pong
log.Printf("[Hawal-v2] 💓 Received Ping from peer, responding Pong")
pongPayload := []byte{byte(record.TypePong)}
_ = s.enqueueControl(mux.Frame{
StreamID: 0,
Expand All @@ -358,7 +369,7 @@ func (s *Session) inboundPump() {
})

case record.TypePong:
// Pong received; peer confirmed liveness (lastInboundActivity was updated)
log.Printf("[Hawal-v2] 💓 Received Pong from peer (RTT check OK)")
}
}
}
Expand Down Expand Up @@ -394,6 +405,7 @@ func (s *Session) pingLoop() {
// 2. Dead-link autodetection: if no response/activity for > timeout, tear down session
last := time.Unix(0, atomic.LoadInt64(&s.lastInboundActivity))
if time.Since(last) > timeout {
log.Printf("[Hawal-v2] 💀 Dead link detected: no inbound activity for %v (threshold: %v)", time.Since(last).Round(time.Second), timeout)
_ = s.CloseWithError(fmt.Errorf("engine: dead link detected (no activity for %v)", time.Since(last).Round(time.Second)))
return
}
Expand Down
Loading