returns the wrapped stdin and a new rpc client (that wraps the stdin input and stdout output)
(serverImpl wshutil.ServerImpl, jwtToken string)
| 151 | |
| 152 | // returns the wrapped stdin and a new rpc client (that wraps the stdin input and stdout output) |
| 153 | func setupRpcClient(serverImpl wshutil.ServerImpl, jwtToken string) error { |
| 154 | rpcCtx, err := wshutil.ExtractUnverifiedRpcContext(jwtToken) |
| 155 | if err != nil { |
| 156 | return fmt.Errorf("error extracting rpc context from %s: %v", wshutil.WaveJwtTokenVarName, err) |
| 157 | } |
| 158 | RpcContext = *rpcCtx |
| 159 | sockName, err := wshutil.ExtractUnverifiedSocketName(jwtToken) |
| 160 | if err != nil { |
| 161 | return fmt.Errorf("error extracting socket name from %s: %v", wshutil.WaveJwtTokenVarName, err) |
| 162 | } |
| 163 | RpcClient, err = wshutil.SetupDomainSocketRpcClient(sockName, serverImpl, "wshcmd") |
| 164 | if err != nil { |
| 165 | return fmt.Errorf("error setting up domain socket rpc client: %v", err) |
| 166 | } |
| 167 | authRtn, err := wshclient.AuthenticateCommand(RpcClient, jwtToken, &wshrpc.RpcOpts{Route: wshutil.ControlRoute}) |
| 168 | if err != nil { |
| 169 | return fmt.Errorf("error authenticating: %v", err) |
| 170 | } |
| 171 | RpcClientRouteId = authRtn.RouteId |
| 172 | blockId := os.Getenv("WAVETERM_BLOCKID") |
| 173 | if blockId != "" { |
| 174 | peerInfo := fmt.Sprintf("domain:block:%s", blockId) |
| 175 | wshclient.SetPeerInfoCommand(RpcClient, peerInfo, &wshrpc.RpcOpts{Route: wshutil.ControlRoute}) |
| 176 | } |
| 177 | // note we don't modify WrappedStdin here (just use os.Stdin) |
| 178 | return nil |
| 179 | } |
| 180 | |
| 181 | func isFullORef(orefStr string) bool { |
| 182 | _, err := waveobj.ParseORef(orefStr) |
no test coverage detected