github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/service/logsend.go (about) 1 // Copyright 2017 Keybase, Inc. All rights reserved. Use of 2 // this source code is governed by the included BSD license. 3 4 package service 5 6 import ( 7 "errors" 8 "time" 9 10 "github.com/keybase/client/go/libkb" 11 keybase1 "github.com/keybase/client/go/protocol/keybase1" 12 "github.com/keybase/go-framed-msgpack-rpc/rpc" 13 "golang.org/x/net/context" 14 ) 15 16 type LogsendHandler struct { 17 *BaseHandler 18 libkb.Contextified 19 } 20 21 func NewLogsendHandler(xp rpc.Transporter, g *libkb.GlobalContext) *LogsendHandler { 22 return &LogsendHandler{ 23 BaseHandler: NewBaseHandler(g, xp), 24 Contextified: libkb.NewContextified(g), 25 } 26 } 27 28 func (h *LogsendHandler) PrepareLogsend(ctx context.Context) error { 29 connMgr := h.G().ConnectionManager 30 if connMgr == nil { 31 return errors.New("no connection manager available") 32 } 33 xp := connMgr.LookupByClientType(keybase1.ClientType_GUI_MAIN) 34 if xp == nil { 35 return errors.New("GUI main process wasn't found") 36 } 37 38 cli := keybase1.LogsendClient{Cli: rpc.NewClient(xp, libkb.NewContextifiedErrorUnwrapper(h.G()), nil)} 39 var cancel func() 40 ctx, cancel = context.WithTimeout(ctx, 10*time.Second) 41 defer cancel() 42 return cli.PrepareLogsend(ctx) 43 }