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

Function handleDomainSocketClient

pkg/wshutil/wshutil.go:327–357  ·  view source on GitHub ↗
(conn net.Conn, readCallback func())

Source from the content-addressed store, hash-verified

325}
326
327func handleDomainSocketClient(conn net.Conn, readCallback func()) {
328 var linkIdContainer atomic.Int32
329 proxy := MakeRpcProxy("domain")
330 go func() {
331 defer func() {
332 panichandler.PanicHandler("handleDomainSocketClient:AdaptOutputChToStream", recover())
333 }()
334 writeErr := AdaptOutputChToStream(proxy.ToRemoteCh, conn)
335 if writeErr != nil {
336 log.Printf("error writing to domain socket: %v\n", writeErr)
337 }
338 }()
339 go func() {
340 // when input is closed, close the connection
341 defer func() {
342 panichandler.PanicHandler("handleDomainSocketClient:AdaptStreamToMsgCh", recover())
343 }()
344 defer func() {
345 conn.Close()
346 close(proxy.FromRemoteCh)
347 close(proxy.ToRemoteCh)
348 linkId := linkIdContainer.Load()
349 if linkId != baseds.NoLinkId {
350 DefaultRouter.UnregisterLink(baseds.LinkId(linkId))
351 }
352 }()
353 AdaptStreamToMsgCh(conn, proxy.FromRemoteCh, readCallback)
354 }()
355 linkId := DefaultRouter.RegisterUntrustedLink(proxy)
356 linkIdContainer.Store(int32(linkId))
357}
358
359// only for use on client
360func ExtractUnverifiedRpcContext(tokenStr string) (*wshrpc.RpcContext, error) {

Callers 1

RunWshRpcOverListenerFunction · 0.85

Calls 8

PanicHandlerFunction · 0.92
LinkIdTypeAlias · 0.92
MakeRpcProxyFunction · 0.85
AdaptOutputChToStreamFunction · 0.85
AdaptStreamToMsgChFunction · 0.85
UnregisterLinkMethod · 0.80
RegisterUntrustedLinkMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected