| 101 | } |
| 102 | |
| 103 | func (t *Tunnel) requestLoop() { |
| 104 | defer close(t.requestLoopDone) |
| 105 | for req := range t.speaker.requests { |
| 106 | if req.msg.Rpc != nil && req.msg.Rpc.MsgId != 0 { |
| 107 | t.handleRPC(req) |
| 108 | if _, ok := req.msg.GetMsg().(*ManagerMessage_Stop); ok { |
| 109 | close(t.sendCh) |
| 110 | return |
| 111 | } |
| 112 | continue |
| 113 | } |
| 114 | // Not a unary RPC. We don't know of any message types that are neither a response nor a |
| 115 | // unary RPC from the Manager. This shouldn't ever happen because we checked the protocol |
| 116 | // version during the handshake. |
| 117 | t.logger.Critical(t.ctx, "unknown request", slog.F("msg", req.msg)) |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | // handleRPC handles unary RPCs from the manager, sending a reply back to the manager. |
| 122 | func (t *Tunnel) handleRPC(req *request[*TunnelMessage, *ManagerMessage]) { |