MCPcopy
hub / github.com/wavetermdev/waveterm / SetupDomainSocketRpcClient

Function SetupDomainSocketRpcClient

pkg/wshutil/wshutil.go:188–217  ·  view source on GitHub ↗
(sockName string, serverImpl ServerImpl, debugName string)

Source from the content-addressed store, hash-verified

186}
187
188func SetupDomainSocketRpcClient(sockName string, serverImpl ServerImpl, debugName string) (*WshRpc, error) {
189 sockName = wavebase.ExpandHomeDirSafe(sockName)
190 resolvedPath, err := filepath.EvalSymlinks(sockName)
191 if err == nil {
192 sockName = resolvedPath
193 }
194 if !filepath.IsAbs(sockName) {
195 return nil, fmt.Errorf("socket path must be absolute: %s", sockName)
196 }
197 conn, tcpErr := tryTcpSocket(sockName)
198 var unixErr error
199 if tcpErr != nil {
200 conn, unixErr = net.Dial("unix", sockName)
201 }
202 if tcpErr != nil && unixErr != nil {
203 return nil, fmt.Errorf("failed to connect to tcp or unix domain socket: tcp err:%w: unix socket err: %w", tcpErr, unixErr)
204 }
205 rtn, errCh, err := SetupConnRpcClient(conn, serverImpl, debugName)
206 go func() {
207 defer func() {
208 panichandler.PanicHandler("SetupDomainSocketRpcClient:closeConn", recover())
209 }()
210 defer conn.Close()
211 err := <-errCh
212 if err != nil && err != io.EOF {
213 log.Printf("error in domain socket connection: %v\n", err)
214 }
215 }()
216 return rtn, err
217}
218
219func MakeClientJWTToken(rpcCtx wshrpc.RpcContext) (string, error) {
220 if wavebase.IsDevMode() {

Callers 3

ConnectMethod · 0.92
setupRpcClientWithTokenFunction · 0.92
setupRpcClientFunction · 0.92

Calls 5

ExpandHomeDirSafeFunction · 0.92
PanicHandlerFunction · 0.92
tryTcpSocketFunction · 0.85
SetupConnRpcClientFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected