handleTunnel opens two websockets, one to proxy kite and one to itself, then it copies the message between them.
(r *Request)
| 155 | // handleTunnel opens two websockets, one to proxy kite and one to itself, |
| 156 | // then it copies the message between them. |
| 157 | func 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 | } |
nothing calls this directly
no test coverage detected