| 296 | } |
| 297 | |
| 298 | func (rs *relayServer) ForwardPort(ctx context.Context, port uint16) error { |
| 299 | pfr := messages.NewPortForwardRequest("127.0.0.1", uint32(port)) |
| 300 | b, err := pfr.Marshal() |
| 301 | if err != nil { |
| 302 | return fmt.Errorf("error marshaling port forward request: %w", err) |
| 303 | } |
| 304 | |
| 305 | replied, data, err := rs.serverConn.SendRequest(messages.PortForwardRequestType, true, b) |
| 306 | if err != nil { |
| 307 | return fmt.Errorf("error sending port forward request: %w", err) |
| 308 | } |
| 309 | |
| 310 | if !replied { |
| 311 | return fmt.Errorf("port forward request not replied") |
| 312 | } |
| 313 | |
| 314 | if data == nil { |
| 315 | return fmt.Errorf("no data returned") |
| 316 | } |
| 317 | |
| 318 | return nil |
| 319 | } |
| 320 | |
| 321 | func makeConnection(server *relayServer) http.HandlerFunc { |
| 322 | return func(w http.ResponseWriter, r *http.Request) { |