()
| 200 | } |
| 201 | |
| 202 | func serverRunRouter() error { |
| 203 | log.Printf("starting connserver router") |
| 204 | router := wshutil.NewWshRouter() |
| 205 | ConnServerWshRouter = router |
| 206 | termProxy := wshutil.MakeRpcProxy("connserver-term") |
| 207 | rawCh := make(chan []byte, wshutil.DefaultOutputChSize) |
| 208 | go func() { |
| 209 | defer func() { |
| 210 | panichandler.PanicHandler("serverRunRouter:Parse", recover()) |
| 211 | }() |
| 212 | packetparser.Parse(os.Stdin, termProxy.FromRemoteCh, rawCh) |
| 213 | }() |
| 214 | go func() { |
| 215 | defer func() { |
| 216 | panichandler.PanicHandler("serverRunRouter:WritePackets", recover()) |
| 217 | }() |
| 218 | for msg := range termProxy.ToRemoteCh { |
| 219 | packetparser.WritePacket(os.Stdout, msg) |
| 220 | } |
| 221 | }() |
| 222 | go func() { |
| 223 | defer func() { |
| 224 | panichandler.PanicHandler("serverRunRouter:drainRawCh", recover()) |
| 225 | }() |
| 226 | defer func() { |
| 227 | log.Printf("stdin closed, shutting down") |
| 228 | wshutil.DoShutdown("", 0, true) |
| 229 | }() |
| 230 | for range rawCh { |
| 231 | // ignore |
| 232 | } |
| 233 | }() |
| 234 | router.RegisterUpstream(termProxy) |
| 235 | |
| 236 | sockName := getRemoteDomainSocketName() |
| 237 | |
| 238 | // setup the connserver rpc client first |
| 239 | client, bareRouteId, err := setupConnServerRpcClientWithRouter(router, sockName) |
| 240 | if err != nil { |
| 241 | return fmt.Errorf("error setting up connserver rpc client: %v", err) |
| 242 | } |
| 243 | wshfs.RpcClient = client |
| 244 | wshfs.RpcClientRouteId = bareRouteId |
| 245 | |
| 246 | log.Printf("trying to get JWT public key") |
| 247 | |
| 248 | // fetch and set JWT public key |
| 249 | jwtPublicKeyB64, err := wshclient.GetJwtPublicKeyCommand(client, nil) |
| 250 | if err != nil { |
| 251 | return fmt.Errorf("error getting jwt public key: %v", err) |
| 252 | } |
| 253 | jwtPublicKeyBytes, err := base64.StdEncoding.DecodeString(jwtPublicKeyB64) |
| 254 | if err != nil { |
| 255 | return fmt.Errorf("error decoding jwt public key: %v", err) |
| 256 | } |
| 257 | err = wavejwt.SetPublicKey(jwtPublicKeyBytes) |
| 258 | if err != nil { |
| 259 | return fmt.Errorf("error setting jwt public key: %v", err) |
no test coverage detected