MCPcopy Index your code
hub / github.com/koding/kite / registerToProxyKite

Method registerToProxyKite

kontrolclient.go:467–507  ·  view source on GitHub ↗

registerToProxyKite dials the proxy kite and calls register method then returns the reverse-proxy URL.

(c *Client, kiteURL *url.URL)

Source from the content-addressed store, hash-verified

465// registerToProxyKite dials the proxy kite and calls register method then
466// returns the reverse-proxy URL.
467func (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

Callers 1

RegisterToProxyMethod · 0.95

Calls 5

DialMethod · 0.80
TellWithTimeoutMethod · 0.80
ErrorMethod · 0.65
CloseMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected