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

Method RegisterURL

registerurl.go:22–48  ·  view source on GitHub ↗

RegisterURL returns a URL that is either local or public. It's an helper method to get a Registration URL that can be passed to Kontrol (via the methods Register(), RegisterToProxy(), etc.) It needs to be called after all configurations are done (like TLS, Port,etc.). If local is true a local IP is

(local bool)

Source from the content-addressed store, hash-verified

20// configurations are done (like TLS, Port,etc.). If local is true a local IP
21// is used, otherwise a public IP is being used.
22func (k *Kite) RegisterURL(local bool) *url.URL {
23 var ip net.IP
24 var err error
25
26 if local {
27 ip, err = localIP()
28 if err != nil {
29 return nil
30 }
31 } else {
32 ip, err = publicIP()
33 if err != nil {
34 return nil
35 }
36 }
37
38 scheme := "http"
39 if k.TLSConfig != nil {
40 scheme = "https"
41 }
42
43 return &url.URL{
44 Scheme: scheme,
45 Host: ip.String() + ":" + strconv.Itoa(k.Config.Port),
46 Path: "/" + k.name + "-" + k.version + "/kite",
47 }
48}
49
50// localIp returns a local IP from one of the local interfaces.
51func localIP() (net.IP, error) {

Callers

nothing calls this directly

Calls 3

localIPFunction · 0.85
publicIPFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected