registerToProxyKite dials the proxy kite and calls register method then returns the reverse-proxy URL.
(c *Client, kiteURL *url.URL)
| 465 | // registerToProxyKite dials the proxy kite and calls register method then |
| 466 | // returns the reverse-proxy URL. |
| 467 | func (k *Kite) registerToProxyKite(c *Client, kiteURL *url.URL) (*url.URL, error) { |
| 468 | err := c.Dial() |
| 469 | if err != nil { |
| 470 | k.Log.Error("Cannot connect to Proxy kite: %s", err.Error()) |
| 471 | return nil, err |
| 472 | } |
| 473 | |
| 474 | // Disconnect from Proxy Kite if error happens while registering. |
| 475 | defer func() { |
| 476 | if err != nil { |
| 477 | c.Close() |
| 478 | } |
| 479 | }() |
| 480 | |
| 481 | // do not panic if we call Tell method below |
| 482 | if kiteURL == nil { |
| 483 | kiteURL = &url.URL{} |
| 484 | } |
| 485 | |
| 486 | // this could be tunnelproxy or reverseproxy. Tunnelproxy doesn't need an |
| 487 | // URL however Reverseproxy needs one. |
| 488 | result, err := c.TellWithTimeout("register", k.Config.Timeout, kiteURL.String()) |
| 489 | if err != nil { |
| 490 | k.Log.Error("Proxy register error: %s", err.Error()) |
| 491 | return nil, err |
| 492 | } |
| 493 | |
| 494 | proxyURL, err := result.String() |
| 495 | if err != nil { |
| 496 | k.Log.Error("Proxy register result error: %s", err.Error()) |
| 497 | return nil, err |
| 498 | } |
| 499 | |
| 500 | parsed, err := url.Parse(proxyURL) |
| 501 | if err != nil { |
| 502 | k.Log.Error("Cannot parse Proxy URL: %s", err.Error()) |
| 503 | return nil, err |
| 504 | } |
| 505 | |
| 506 | return parsed, nil |
| 507 | } |
| 508 | |
| 509 | // TellKontrolWithTimeout is a lower level function for communicating directly with |
| 510 | // kontrol. Like GetKites and GetToken, this automatically sets up and connects to |
no test coverage detected