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

Function handleTunnel

handlers.go:157–180  ·  view source on GitHub ↗

handleTunnel opens two websockets, one to proxy kite and one to itself, then it copies the message between them.

(r *Request)

Source from the content-addressed store, hash-verified

155// handleTunnel opens two websockets, one to proxy kite and one to itself,
156// then it copies the message between them.
157func handleTunnel(r *Request) (interface{}, error) {
158 var args struct {
159 URL string
160 }
161 r.Args.One().MustUnmarshal(&args)
162
163 parsed, err := url.Parse(args.URL)
164 if err != nil {
165 return nil, err
166 }
167
168 requestHeader := http.Header{}
169 requestHeader.Add("Origin", "http://"+parsed.Host)
170
171 remoteConn, _, err := websocket.DefaultDialer.Dial(parsed.String(), requestHeader)
172 if err != nil {
173 return nil, err
174 }
175
176 session := sockjsclient.NewWebsocketSession(remoteConn)
177
178 go r.LocalKite.sockjsHandler(session)
179 return nil, nil
180}

Callers

nothing calls this directly

Calls 6

MustUnmarshalMethod · 0.80
OneMethod · 0.80
DialMethod · 0.80
sockjsHandlerMethod · 0.80
AddMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected