id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
sequencelengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
sequencelengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
158,500
keybase/client
go/kbfs/libkbfs/conflict_renamer.go
ConflictRenameHelper
func (WriterDeviceDateConflictRenamer) ConflictRenameHelper(t time.Time, user, device, original string) string { if device == "" { device = "unknown" } base, ext := splitExtension(original) date := t.Format("2006-01-02") return fmt.Sprintf("%s.conflicted (%s's %s copy %s)%s", base, user, device, date, ext) }
go
func (WriterDeviceDateConflictRenamer) ConflictRenameHelper(t time.Time, user, device, original string) string { if device == "" { device = "unknown" } base, ext := splitExtension(original) date := t.Format("2006-01-02") return fmt.Sprintf("%s.conflicted (%s's %s copy %s)%s", base, user, device, date, ext) }
[ "func", "(", "WriterDeviceDateConflictRenamer", ")", "ConflictRenameHelper", "(", "t", "time", ".", "Time", ",", "user", ",", "device", ",", "original", "string", ")", "string", "{", "if", "device", "==", "\"", "\"", "{", "device", "=", "\"", "\"", "\n", "}", "\n", "base", ",", "ext", ":=", "splitExtension", "(", "original", ")", "\n", "date", ":=", "t", ".", "Format", "(", "\"", "\"", ")", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "base", ",", "user", ",", "device", ",", "date", ",", "ext", ")", "\n", "}" ]
// ConflictRenameHelper is a helper for ConflictRename especially useful from // tests.
[ "ConflictRenameHelper", "is", "a", "helper", "for", "ConflictRename", "especially", "useful", "from", "tests", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/conflict_renamer.go#L41-L49
158,501
keybase/client
go/kbfs/libkbfs/conflict_renamer.go
splitExtension
func splitExtension(path string) (string, string) { for i := len(path) - 1; i > 0; i-- { switch path[i] { case '.': // Handle some multipart extensions if i >= 4 && path[i-4:i] == ".tar" { i -= 4 } // A leading dot is not an extension if i == 0 || path[i-1] == '/' || path[i-1] == '\\' { return path, "" } return path[:i], path[i:] case '/', '\\', ' ': return path, "" } } return path, "" }
go
func splitExtension(path string) (string, string) { for i := len(path) - 1; i > 0; i-- { switch path[i] { case '.': // Handle some multipart extensions if i >= 4 && path[i-4:i] == ".tar" { i -= 4 } // A leading dot is not an extension if i == 0 || path[i-1] == '/' || path[i-1] == '\\' { return path, "" } return path[:i], path[i:] case '/', '\\', ' ': return path, "" } } return path, "" }
[ "func", "splitExtension", "(", "path", "string", ")", "(", "string", ",", "string", ")", "{", "for", "i", ":=", "len", "(", "path", ")", "-", "1", ";", "i", ">", "0", ";", "i", "--", "{", "switch", "path", "[", "i", "]", "{", "case", "'.'", ":", "// Handle some multipart extensions", "if", "i", ">=", "4", "&&", "path", "[", "i", "-", "4", ":", "i", "]", "==", "\"", "\"", "{", "i", "-=", "4", "\n", "}", "\n", "// A leading dot is not an extension", "if", "i", "==", "0", "||", "path", "[", "i", "-", "1", "]", "==", "'/'", "||", "path", "[", "i", "-", "1", "]", "==", "'\\\\'", "{", "return", "path", ",", "\"", "\"", "\n", "}", "\n", "return", "path", "[", ":", "i", "]", ",", "path", "[", "i", ":", "]", "\n", "case", "'/'", ",", "'\\\\'", ",", "' '", ":", "return", "path", ",", "\"", "\"", "\n", "}", "\n", "}", "\n", "return", "path", ",", "\"", "\"", "\n", "}" ]
// splitExtension splits filename into a base name and the extension.
[ "splitExtension", "splits", "filename", "into", "a", "base", "name", "and", "the", "extension", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/conflict_renamer.go#L52-L70
158,502
keybase/client
go/chat/attachments/preview.go
Preview
func Preview(ctx context.Context, log utils.DebugLabeler, src ReadResetter, contentType, basename string, nvh types.NativeVideoHelper) (*PreviewRes, error) { switch contentType { case "image/jpeg", "image/png", "image/vnd.microsoft.icon", "image/x-icon": return previewImage(ctx, log, src, basename, contentType) case "image/gif": return previewGIF(ctx, log, src, basename) } if strings.HasPrefix(contentType, "video") { pre, err := previewVideo(ctx, log, src, basename, nvh) if err == nil { log.Debug(ctx, "Preview: found video preview for filename: %s contentType: %s", basename, contentType) return pre, nil } log.Debug(ctx, "Preview: failed to get video preview for filename: %s contentType: %s err: %s", basename, contentType, err) return previewVideoBlank(ctx, log, src, basename) } return nil, nil }
go
func Preview(ctx context.Context, log utils.DebugLabeler, src ReadResetter, contentType, basename string, nvh types.NativeVideoHelper) (*PreviewRes, error) { switch contentType { case "image/jpeg", "image/png", "image/vnd.microsoft.icon", "image/x-icon": return previewImage(ctx, log, src, basename, contentType) case "image/gif": return previewGIF(ctx, log, src, basename) } if strings.HasPrefix(contentType, "video") { pre, err := previewVideo(ctx, log, src, basename, nvh) if err == nil { log.Debug(ctx, "Preview: found video preview for filename: %s contentType: %s", basename, contentType) return pre, nil } log.Debug(ctx, "Preview: failed to get video preview for filename: %s contentType: %s err: %s", basename, contentType, err) return previewVideoBlank(ctx, log, src, basename) } return nil, nil }
[ "func", "Preview", "(", "ctx", "context", ".", "Context", ",", "log", "utils", ".", "DebugLabeler", ",", "src", "ReadResetter", ",", "contentType", ",", "basename", "string", ",", "nvh", "types", ".", "NativeVideoHelper", ")", "(", "*", "PreviewRes", ",", "error", ")", "{", "switch", "contentType", "{", "case", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ":", "return", "previewImage", "(", "ctx", ",", "log", ",", "src", ",", "basename", ",", "contentType", ")", "\n", "case", "\"", "\"", ":", "return", "previewGIF", "(", "ctx", ",", "log", ",", "src", ",", "basename", ")", "\n", "}", "\n", "if", "strings", ".", "HasPrefix", "(", "contentType", ",", "\"", "\"", ")", "{", "pre", ",", "err", ":=", "previewVideo", "(", "ctx", ",", "log", ",", "src", ",", "basename", ",", "nvh", ")", "\n", "if", "err", "==", "nil", "{", "log", ".", "Debug", "(", "ctx", ",", "\"", "\"", ",", "basename", ",", "contentType", ")", "\n", "return", "pre", ",", "nil", "\n", "}", "\n", "log", ".", "Debug", "(", "ctx", ",", "\"", "\"", ",", "basename", ",", "contentType", ",", "err", ")", "\n", "return", "previewVideoBlank", "(", "ctx", ",", "log", ",", "src", ",", "basename", ")", "\n", "}", "\n", "return", "nil", ",", "nil", "\n", "}" ]
// Preview creates preview assets from src. It returns an in-memory BufferSource // and the content type of the preview asset.
[ "Preview", "creates", "preview", "assets", "from", "src", ".", "It", "returns", "an", "in", "-", "memory", "BufferSource", "and", "the", "content", "type", "of", "the", "preview", "asset", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/attachments/preview.go#L46-L66
158,503
keybase/client
go/chat/attachments/preview.go
previewVideoBlank
func previewVideoBlank(ctx context.Context, log utils.DebugLabeler, src io.Reader, basename string) (res *PreviewRes, err error) { const width, height = 300, 150 img := image.NewNRGBA(image.Rect(0, 0, width, height)) for y := 0; y < height; y++ { for x := 0; x < width; x++ { img.Set(x, y, color.NRGBA{ R: 0, G: 0, B: 0, A: 255, }) } } var out bytes.Buffer if err := png.Encode(&out, img); err != nil { return res, err } imagePreview, err := previewImage(ctx, log, &out, basename, "image/png") if err != nil { return res, err } return &PreviewRes{ Source: imagePreview.Source, ContentType: "image/png", BaseWidth: imagePreview.BaseWidth, BaseHeight: imagePreview.BaseHeight, BaseDurationMs: 1, PreviewHeight: imagePreview.PreviewHeight, PreviewWidth: imagePreview.PreviewWidth, }, nil }
go
func previewVideoBlank(ctx context.Context, log utils.DebugLabeler, src io.Reader, basename string) (res *PreviewRes, err error) { const width, height = 300, 150 img := image.NewNRGBA(image.Rect(0, 0, width, height)) for y := 0; y < height; y++ { for x := 0; x < width; x++ { img.Set(x, y, color.NRGBA{ R: 0, G: 0, B: 0, A: 255, }) } } var out bytes.Buffer if err := png.Encode(&out, img); err != nil { return res, err } imagePreview, err := previewImage(ctx, log, &out, basename, "image/png") if err != nil { return res, err } return &PreviewRes{ Source: imagePreview.Source, ContentType: "image/png", BaseWidth: imagePreview.BaseWidth, BaseHeight: imagePreview.BaseHeight, BaseDurationMs: 1, PreviewHeight: imagePreview.PreviewHeight, PreviewWidth: imagePreview.PreviewWidth, }, nil }
[ "func", "previewVideoBlank", "(", "ctx", "context", ".", "Context", ",", "log", "utils", ".", "DebugLabeler", ",", "src", "io", ".", "Reader", ",", "basename", "string", ")", "(", "res", "*", "PreviewRes", ",", "err", "error", ")", "{", "const", "width", ",", "height", "=", "300", ",", "150", "\n", "img", ":=", "image", ".", "NewNRGBA", "(", "image", ".", "Rect", "(", "0", ",", "0", ",", "width", ",", "height", ")", ")", "\n", "for", "y", ":=", "0", ";", "y", "<", "height", ";", "y", "++", "{", "for", "x", ":=", "0", ";", "x", "<", "width", ";", "x", "++", "{", "img", ".", "Set", "(", "x", ",", "y", ",", "color", ".", "NRGBA", "{", "R", ":", "0", ",", "G", ":", "0", ",", "B", ":", "0", ",", "A", ":", "255", ",", "}", ")", "\n", "}", "\n", "}", "\n", "var", "out", "bytes", ".", "Buffer", "\n", "if", "err", ":=", "png", ".", "Encode", "(", "&", "out", ",", "img", ")", ";", "err", "!=", "nil", "{", "return", "res", ",", "err", "\n", "}", "\n", "imagePreview", ",", "err", ":=", "previewImage", "(", "ctx", ",", "log", ",", "&", "out", ",", "basename", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "res", ",", "err", "\n", "}", "\n", "return", "&", "PreviewRes", "{", "Source", ":", "imagePreview", ".", "Source", ",", "ContentType", ":", "\"", "\"", ",", "BaseWidth", ":", "imagePreview", ".", "BaseWidth", ",", "BaseHeight", ":", "imagePreview", ".", "BaseHeight", ",", "BaseDurationMs", ":", "1", ",", "PreviewHeight", ":", "imagePreview", ".", "PreviewHeight", ",", "PreviewWidth", ":", "imagePreview", ".", "PreviewWidth", ",", "}", ",", "nil", "\n", "}" ]
// previewVideoBlank previews a video by inserting a black rectangle with a play button on it.
[ "previewVideoBlank", "previews", "a", "video", "by", "inserting", "a", "black", "rectangle", "with", "a", "play", "button", "on", "it", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/attachments/preview.go#L69-L100
158,504
keybase/client
go/chat/attachments/preview.go
previewImage
func previewImage(ctx context.Context, log utils.DebugLabeler, src io.Reader, basename, contentType string) (res *PreviewRes, err error) { defer log.Trace(ctx, func() error { return err }, "previewImage")() // images.Decode in camlistore correctly handles exif orientation information. log.Debug(ctx, "previewImage: decoding image") img, _, err := images.Decode(src, nil) if err != nil { return nil, err } width, height := previewDimensions(img.Bounds()) log.Debug(ctx, "previewImage: resizing image: bounds: %s", img.Bounds()) preview := resize.Resize(width, height, img, resize.Bicubic) var buf bytes.Buffer var encodeContentType string switch contentType { case "image/vnd.microsoft.icon", "image/x-icon", "image/png": encodeContentType = "image/png" if err := png.Encode(&buf, preview); err != nil { return nil, err } default: encodeContentType = "image/jpeg" if err := jpeg.Encode(&buf, preview, &jpeg.Options{Quality: 90}); err != nil { return nil, err } } return &PreviewRes{ Source: buf.Bytes(), ContentType: encodeContentType, BaseWidth: img.Bounds().Dx(), BaseHeight: img.Bounds().Dy(), PreviewWidth: int(width), PreviewHeight: int(height), }, nil }
go
func previewImage(ctx context.Context, log utils.DebugLabeler, src io.Reader, basename, contentType string) (res *PreviewRes, err error) { defer log.Trace(ctx, func() error { return err }, "previewImage")() // images.Decode in camlistore correctly handles exif orientation information. log.Debug(ctx, "previewImage: decoding image") img, _, err := images.Decode(src, nil) if err != nil { return nil, err } width, height := previewDimensions(img.Bounds()) log.Debug(ctx, "previewImage: resizing image: bounds: %s", img.Bounds()) preview := resize.Resize(width, height, img, resize.Bicubic) var buf bytes.Buffer var encodeContentType string switch contentType { case "image/vnd.microsoft.icon", "image/x-icon", "image/png": encodeContentType = "image/png" if err := png.Encode(&buf, preview); err != nil { return nil, err } default: encodeContentType = "image/jpeg" if err := jpeg.Encode(&buf, preview, &jpeg.Options{Quality: 90}); err != nil { return nil, err } } return &PreviewRes{ Source: buf.Bytes(), ContentType: encodeContentType, BaseWidth: img.Bounds().Dx(), BaseHeight: img.Bounds().Dy(), PreviewWidth: int(width), PreviewHeight: int(height), }, nil }
[ "func", "previewImage", "(", "ctx", "context", ".", "Context", ",", "log", "utils", ".", "DebugLabeler", ",", "src", "io", ".", "Reader", ",", "basename", ",", "contentType", "string", ")", "(", "res", "*", "PreviewRes", ",", "err", "error", ")", "{", "defer", "log", ".", "Trace", "(", "ctx", ",", "func", "(", ")", "error", "{", "return", "err", "}", ",", "\"", "\"", ")", "(", ")", "\n", "// images.Decode in camlistore correctly handles exif orientation information.", "log", ".", "Debug", "(", "ctx", ",", "\"", "\"", ")", "\n", "img", ",", "_", ",", "err", ":=", "images", ".", "Decode", "(", "src", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "width", ",", "height", ":=", "previewDimensions", "(", "img", ".", "Bounds", "(", ")", ")", "\n\n", "log", ".", "Debug", "(", "ctx", ",", "\"", "\"", ",", "img", ".", "Bounds", "(", ")", ")", "\n", "preview", ":=", "resize", ".", "Resize", "(", "width", ",", "height", ",", "img", ",", "resize", ".", "Bicubic", ")", "\n", "var", "buf", "bytes", ".", "Buffer", "\n\n", "var", "encodeContentType", "string", "\n", "switch", "contentType", "{", "case", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ":", "encodeContentType", "=", "\"", "\"", "\n", "if", "err", ":=", "png", ".", "Encode", "(", "&", "buf", ",", "preview", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "default", ":", "encodeContentType", "=", "\"", "\"", "\n", "if", "err", ":=", "jpeg", ".", "Encode", "(", "&", "buf", ",", "preview", ",", "&", "jpeg", ".", "Options", "{", "Quality", ":", "90", "}", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n\n", "return", "&", "PreviewRes", "{", "Source", ":", "buf", ".", "Bytes", "(", ")", ",", "ContentType", ":", "encodeContentType", ",", "BaseWidth", ":", "img", ".", "Bounds", "(", ")", ".", "Dx", "(", ")", ",", "BaseHeight", ":", "img", ".", "Bounds", "(", ")", ".", "Dy", "(", ")", ",", "PreviewWidth", ":", "int", "(", "width", ")", ",", "PreviewHeight", ":", "int", "(", "height", ")", ",", "}", ",", "nil", "\n", "}" ]
// previewImage will resize a single-frame image.
[ "previewImage", "will", "resize", "a", "single", "-", "frame", "image", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/attachments/preview.go#L103-L140
158,505
keybase/client
go/chat/attachments/preview.go
gifDuration
func gifDuration(g *gif.GIF) int { var total int for _, d := range g.Delay { total += d } // total is in 100ths of a second, multiply by 10 to get milliseconds return total * 10 }
go
func gifDuration(g *gif.GIF) int { var total int for _, d := range g.Delay { total += d } // total is in 100ths of a second, multiply by 10 to get milliseconds return total * 10 }
[ "func", "gifDuration", "(", "g", "*", "gif", ".", "GIF", ")", "int", "{", "var", "total", "int", "\n", "for", "_", ",", "d", ":=", "range", "g", ".", "Delay", "{", "total", "+=", "d", "\n", "}", "\n\n", "// total is in 100ths of a second, multiply by 10 to get milliseconds", "return", "total", "*", "10", "\n", "}" ]
// gifDuration returns the duration of one loop of an animated gif // in milliseconds.
[ "gifDuration", "returns", "the", "duration", "of", "one", "loop", "of", "an", "animated", "gif", "in", "milliseconds", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/attachments/preview.go#L271-L279
158,506
keybase/client
go/engine/pgp_keygen.go
NewPGPKeyGen
func NewPGPKeyGen(g *libkb.GlobalContext, arg keybase1.PGPKeyGenDefaultArg) *PGPKeyGen { return &PGPKeyGen{ Contextified: libkb.NewContextified(g), arg: arg, } }
go
func NewPGPKeyGen(g *libkb.GlobalContext, arg keybase1.PGPKeyGenDefaultArg) *PGPKeyGen { return &PGPKeyGen{ Contextified: libkb.NewContextified(g), arg: arg, } }
[ "func", "NewPGPKeyGen", "(", "g", "*", "libkb", ".", "GlobalContext", ",", "arg", "keybase1", ".", "PGPKeyGenDefaultArg", ")", "*", "PGPKeyGen", "{", "return", "&", "PGPKeyGen", "{", "Contextified", ":", "libkb", ".", "NewContextified", "(", "g", ")", ",", "arg", ":", "arg", ",", "}", "\n", "}" ]
// NewPGPKeyGen creates a PGPKeyGen engine.
[ "NewPGPKeyGen", "creates", "a", "PGPKeyGen", "engine", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/pgp_keygen.go#L19-L24
158,507
keybase/client
go/libkb/identify_dispatch.go
NotifyTrackingSuccess
func (d *IdentifyDispatch) NotifyTrackingSuccess(mctx MetaContext, target keybase1.UID) { mctx.Debug("IdentifyDispatch.NotifyTrackingSuccess(%v)", target) d.Lock() defer d.Unlock() for _, listener := range d.listeners { select { case listener <- IdentifyDispatchMsg{Target: target}: default: } } }
go
func (d *IdentifyDispatch) NotifyTrackingSuccess(mctx MetaContext, target keybase1.UID) { mctx.Debug("IdentifyDispatch.NotifyTrackingSuccess(%v)", target) d.Lock() defer d.Unlock() for _, listener := range d.listeners { select { case listener <- IdentifyDispatchMsg{Target: target}: default: } } }
[ "func", "(", "d", "*", "IdentifyDispatch", ")", "NotifyTrackingSuccess", "(", "mctx", "MetaContext", ",", "target", "keybase1", ".", "UID", ")", "{", "mctx", ".", "Debug", "(", "\"", "\"", ",", "target", ")", "\n", "d", ".", "Lock", "(", ")", "\n", "defer", "d", ".", "Unlock", "(", ")", "\n", "for", "_", ",", "listener", ":=", "range", "d", ".", "listeners", "{", "select", "{", "case", "listener", "<-", "IdentifyDispatchMsg", "{", "Target", ":", "target", "}", ":", "default", ":", "}", "\n", "}", "\n", "}" ]
// NotifyTrackingSuccess notifies listeners that a target user has been found to satisfy tracking. // This could be through // - An identify call that heeded the active user's tracking of the target. // - A user tracked or untracked the target. // When the active user is the target all bets are off.
[ "NotifyTrackingSuccess", "notifies", "listeners", "that", "a", "target", "user", "has", "been", "found", "to", "satisfy", "tracking", ".", "This", "could", "be", "through", "-", "An", "identify", "call", "that", "heeded", "the", "active", "user", "s", "tracking", "of", "the", "target", ".", "-", "A", "user", "tracked", "or", "untracked", "the", "target", ".", "When", "the", "active", "user", "is", "the", "target", "all", "bets", "are", "off", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/identify_dispatch.go#L25-L35
158,508
keybase/client
go/libkb/identify_dispatch.go
Subscribe
func (d *IdentifyDispatch) Subscribe(mctx MetaContext) (unsubscribe func(), recvCh <-chan IdentifyDispatchMsg) { mctx.Debug("IdentifyDispatch.Subscribe") ch := make(chan IdentifyDispatchMsg, 10) d.Lock() defer d.Unlock() d.listeners = append(d.listeners, ch) unsubscribe = func() { mctx.Debug("IdentifyDispatch.Unsubcribe") d.Lock() defer d.Unlock() var listeners []chan<- IdentifyDispatchMsg for _, ch2 := range d.listeners { if ch == ch2 { continue } listeners = append(listeners, ch2) } d.listeners = listeners } return unsubscribe, ch }
go
func (d *IdentifyDispatch) Subscribe(mctx MetaContext) (unsubscribe func(), recvCh <-chan IdentifyDispatchMsg) { mctx.Debug("IdentifyDispatch.Subscribe") ch := make(chan IdentifyDispatchMsg, 10) d.Lock() defer d.Unlock() d.listeners = append(d.listeners, ch) unsubscribe = func() { mctx.Debug("IdentifyDispatch.Unsubcribe") d.Lock() defer d.Unlock() var listeners []chan<- IdentifyDispatchMsg for _, ch2 := range d.listeners { if ch == ch2 { continue } listeners = append(listeners, ch2) } d.listeners = listeners } return unsubscribe, ch }
[ "func", "(", "d", "*", "IdentifyDispatch", ")", "Subscribe", "(", "mctx", "MetaContext", ")", "(", "unsubscribe", "func", "(", ")", ",", "recvCh", "<-", "chan", "IdentifyDispatchMsg", ")", "{", "mctx", ".", "Debug", "(", "\"", "\"", ")", "\n", "ch", ":=", "make", "(", "chan", "IdentifyDispatchMsg", ",", "10", ")", "\n", "d", ".", "Lock", "(", ")", "\n", "defer", "d", ".", "Unlock", "(", ")", "\n", "d", ".", "listeners", "=", "append", "(", "d", ".", "listeners", ",", "ch", ")", "\n", "unsubscribe", "=", "func", "(", ")", "{", "mctx", ".", "Debug", "(", "\"", "\"", ")", "\n", "d", ".", "Lock", "(", ")", "\n", "defer", "d", ".", "Unlock", "(", ")", "\n", "var", "listeners", "[", "]", "chan", "<-", "IdentifyDispatchMsg", "\n", "for", "_", ",", "ch2", ":=", "range", "d", ".", "listeners", "{", "if", "ch", "==", "ch2", "{", "continue", "\n", "}", "\n", "listeners", "=", "append", "(", "listeners", ",", "ch2", ")", "\n", "}", "\n", "d", ".", "listeners", "=", "listeners", "\n", "}", "\n", "return", "unsubscribe", ",", "ch", "\n", "}" ]
// Subscribe to notifications. // `unsubscribe` releases resources associated with the subscription and should be called asap.
[ "Subscribe", "to", "notifications", ".", "unsubscribe", "releases", "resources", "associated", "with", "the", "subscription", "and", "should", "be", "called", "asap", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/identify_dispatch.go#L39-L59
158,509
keybase/client
go/libkb/identify_dispatch.go
OnLogout
func (d *IdentifyDispatch) OnLogout() { d.Lock() defer d.Unlock() d.listeners = nil }
go
func (d *IdentifyDispatch) OnLogout() { d.Lock() defer d.Unlock() d.listeners = nil }
[ "func", "(", "d", "*", "IdentifyDispatch", ")", "OnLogout", "(", ")", "{", "d", ".", "Lock", "(", ")", "\n", "defer", "d", ".", "Unlock", "(", ")", "\n", "d", ".", "listeners", "=", "nil", "\n", "}" ]
// OnLogout drops all subscriptions.
[ "OnLogout", "drops", "all", "subscriptions", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/identify_dispatch.go#L62-L66
158,510
keybase/client
go/uidmap/hardcoded_uids.go
findHardcoded
func findHardcoded(uid keybase1.UID) libkb.NormalizedUsername { findInit() searchFor := uid.ToBytes() if len(searchFor) != keybase1.UID_LEN { // wrong uid size return libkb.NormalizedUsername("") } l := len(uids) / keybase1.UID_LEN uidAt := func(i int) []byte { start := i * keybase1.UID_LEN return uids[start : start+keybase1.UID_LEN] } doCmp := func(i int) int { return bytes.Compare(searchFor, uidAt(i)) } n := sort.Search(l, func(i int) bool { return doCmp(i) <= 0 }) if n == l || doCmp(n) != 0 { return libkb.NormalizedUsername("") } offset := offsets[n] s := string(usernames[offset : offset+uint32(lengths[n])]) return libkb.NewNormalizedUsername(s) }
go
func findHardcoded(uid keybase1.UID) libkb.NormalizedUsername { findInit() searchFor := uid.ToBytes() if len(searchFor) != keybase1.UID_LEN { // wrong uid size return libkb.NormalizedUsername("") } l := len(uids) / keybase1.UID_LEN uidAt := func(i int) []byte { start := i * keybase1.UID_LEN return uids[start : start+keybase1.UID_LEN] } doCmp := func(i int) int { return bytes.Compare(searchFor, uidAt(i)) } n := sort.Search(l, func(i int) bool { return doCmp(i) <= 0 }) if n == l || doCmp(n) != 0 { return libkb.NormalizedUsername("") } offset := offsets[n] s := string(usernames[offset : offset+uint32(lengths[n])]) return libkb.NewNormalizedUsername(s) }
[ "func", "findHardcoded", "(", "uid", "keybase1", ".", "UID", ")", "libkb", ".", "NormalizedUsername", "{", "findInit", "(", ")", "\n", "searchFor", ":=", "uid", ".", "ToBytes", "(", ")", "\n", "if", "len", "(", "searchFor", ")", "!=", "keybase1", ".", "UID_LEN", "{", "// wrong uid size", "return", "libkb", ".", "NormalizedUsername", "(", "\"", "\"", ")", "\n", "}", "\n", "l", ":=", "len", "(", "uids", ")", "/", "keybase1", ".", "UID_LEN", "\n", "uidAt", ":=", "func", "(", "i", "int", ")", "[", "]", "byte", "{", "start", ":=", "i", "*", "keybase1", ".", "UID_LEN", "\n", "return", "uids", "[", "start", ":", "start", "+", "keybase1", ".", "UID_LEN", "]", "\n", "}", "\n", "doCmp", ":=", "func", "(", "i", "int", ")", "int", "{", "return", "bytes", ".", "Compare", "(", "searchFor", ",", "uidAt", "(", "i", ")", ")", "\n", "}", "\n", "n", ":=", "sort", ".", "Search", "(", "l", ",", "func", "(", "i", "int", ")", "bool", "{", "return", "doCmp", "(", "i", ")", "<=", "0", "\n", "}", ")", "\n", "if", "n", "==", "l", "||", "doCmp", "(", "n", ")", "!=", "0", "{", "return", "libkb", ".", "NormalizedUsername", "(", "\"", "\"", ")", "\n", "}", "\n", "offset", ":=", "offsets", "[", "n", "]", "\n", "s", ":=", "string", "(", "usernames", "[", "offset", ":", "offset", "+", "uint32", "(", "lengths", "[", "n", "]", ")", "]", ")", "\n", "return", "libkb", ".", "NewNormalizedUsername", "(", "s", ")", "\n", "}" ]
// Returns empty name if not found
[ "Returns", "empty", "name", "if", "not", "found" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/uidmap/hardcoded_uids.go#L73-L97
158,511
keybase/client
go/service/main.go
writeServiceInfo
func (d *Service) writeServiceInfo() error { _, err := d.ensureRuntimeDir() if err != nil { return err } // Write runtime info file rtInfo := libkb.KeybaseServiceInfo(d.G()) return rtInfo.WriteFile(d.G().Env.GetServiceInfoPath(), d.G().Log) }
go
func (d *Service) writeServiceInfo() error { _, err := d.ensureRuntimeDir() if err != nil { return err } // Write runtime info file rtInfo := libkb.KeybaseServiceInfo(d.G()) return rtInfo.WriteFile(d.G().Env.GetServiceInfoPath(), d.G().Log) }
[ "func", "(", "d", "*", "Service", ")", "writeServiceInfo", "(", ")", "error", "{", "_", ",", "err", ":=", "d", ".", "ensureRuntimeDir", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Write runtime info file", "rtInfo", ":=", "libkb", ".", "KeybaseServiceInfo", "(", "d", ".", "G", "(", ")", ")", "\n", "return", "rtInfo", ".", "WriteFile", "(", "d", ".", "G", "(", ")", ".", "Env", ".", "GetServiceInfoPath", "(", ")", ",", "d", ".", "G", "(", ")", ".", "Log", ")", "\n", "}" ]
// If the daemon is already running, we need to be able to check what version // it is, in case the client has been updated.
[ "If", "the", "daemon", "is", "already", "running", "we", "need", "to", "be", "able", "to", "check", "what", "version", "it", "is", "in", "case", "the", "client", "has", "been", "updated", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/main.go#L661-L670
158,512
keybase/client
go/service/main.go
ReleaseLock
func (d *Service) ReleaseLock() error { d.G().Log.Debug("Releasing lock file") return d.lockPid.Close() }
go
func (d *Service) ReleaseLock() error { d.G().Log.Debug("Releasing lock file") return d.lockPid.Close() }
[ "func", "(", "d", "*", "Service", ")", "ReleaseLock", "(", ")", "error", "{", "d", ".", "G", "(", ")", ".", "Log", ".", "Debug", "(", "\"", "\"", ")", "\n", "return", "d", ".", "lockPid", ".", "Close", "(", ")", "\n", "}" ]
// ReleaseLock releases the locking pidfile by closing, unlocking and // deleting it.
[ "ReleaseLock", "releases", "the", "locking", "pidfile", "by", "closing", "unlocking", "and", "deleting", "it", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/main.go#L983-L986
158,513
keybase/client
go/service/main.go
GetExclusiveLock
func (d *Service) GetExclusiveLock() error { if err := d.GetExclusiveLockWithoutAutoUnlock(); err != nil { return err } d.G().PushShutdownHook(func() error { return d.ReleaseLock() }) return nil }
go
func (d *Service) GetExclusiveLock() error { if err := d.GetExclusiveLockWithoutAutoUnlock(); err != nil { return err } d.G().PushShutdownHook(func() error { return d.ReleaseLock() }) return nil }
[ "func", "(", "d", "*", "Service", ")", "GetExclusiveLock", "(", ")", "error", "{", "if", "err", ":=", "d", ".", "GetExclusiveLockWithoutAutoUnlock", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "d", ".", "G", "(", ")", ".", "PushShutdownHook", "(", "func", "(", ")", "error", "{", "return", "d", ".", "ReleaseLock", "(", ")", "\n", "}", ")", "\n", "return", "nil", "\n", "}" ]
// GetExclusiveLock grabs the exclusive lock over running keybase // and then installs a shutdown hook to release the lock automatically // on shutdown.
[ "GetExclusiveLock", "grabs", "the", "exclusive", "lock", "over", "running", "keybase", "and", "then", "installs", "a", "shutdown", "hook", "to", "release", "the", "lock", "automatically", "on", "shutdown", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/main.go#L1001-L1009
158,514
keybase/client
go/service/main.go
configurePath
func (d *Service) configurePath() { defer d.G().Trace("Service#configurePath", func() error { return nil })() var newDirs string switch runtime.GOOS { case "darwin": newDirs = "/usr/local/bin:/usr/local/MacGPG2/bin" default: } if newDirs != "" { mergeIntoPath(d.G(), newDirs) } }
go
func (d *Service) configurePath() { defer d.G().Trace("Service#configurePath", func() error { return nil })() var newDirs string switch runtime.GOOS { case "darwin": newDirs = "/usr/local/bin:/usr/local/MacGPG2/bin" default: } if newDirs != "" { mergeIntoPath(d.G(), newDirs) } }
[ "func", "(", "d", "*", "Service", ")", "configurePath", "(", ")", "{", "defer", "d", ".", "G", "(", ")", ".", "Trace", "(", "\"", "\"", ",", "func", "(", ")", "error", "{", "return", "nil", "}", ")", "(", ")", "\n\n", "var", "newDirs", "string", "\n", "switch", "runtime", ".", "GOOS", "{", "case", "\"", "\"", ":", "newDirs", "=", "\"", "\"", "\n", "default", ":", "}", "\n", "if", "newDirs", "!=", "\"", "\"", "{", "mergeIntoPath", "(", "d", ".", "G", "(", ")", ",", "newDirs", ")", "\n", "}", "\n", "}" ]
// configurePath is a somewhat unfortunate hack, but as it currently stands, // when the keybase service is run out of launchd, its path is minimal and // often can't find the GPG location. We have hacks around this for CLI operation, // in which the CLI forwards its path to the service, and the service enlarges // its path accordingly. In this way, the service can get access to path additions // inserted by the user's shell startup scripts. However the same mechanism doesn't // apply to a GUI-driven workload, since the Electron GUI, like the Go service, is // launched from launchd and therefore has the wrong path. This function currently // noops on all platforms aside from macOS, but we can expand it later as needs be.
[ "configurePath", "is", "a", "somewhat", "unfortunate", "hack", "but", "as", "it", "currently", "stands", "when", "the", "keybase", "service", "is", "run", "out", "of", "launchd", "its", "path", "is", "minimal", "and", "often", "can", "t", "find", "the", "GPG", "location", ".", "We", "have", "hacks", "around", "this", "for", "CLI", "operation", "in", "which", "the", "CLI", "forwards", "its", "path", "to", "the", "service", "and", "the", "service", "enlarges", "its", "path", "accordingly", ".", "In", "this", "way", "the", "service", "can", "get", "access", "to", "path", "additions", "inserted", "by", "the", "user", "s", "shell", "startup", "scripts", ".", "However", "the", "same", "mechanism", "doesn", "t", "apply", "to", "a", "GUI", "-", "driven", "workload", "since", "the", "Electron", "GUI", "like", "the", "Go", "service", "is", "launched", "from", "launchd", "and", "therefore", "has", "the", "wrong", "path", ".", "This", "function", "currently", "noops", "on", "all", "platforms", "aside", "from", "macOS", "but", "we", "can", "expand", "it", "later", "as", "needs", "be", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/main.go#L1212-L1224
158,515
keybase/client
go/service/main.go
tryLogin
func (d *Service) tryLogin(ctx context.Context) { tryLoginOnce.Do(func() { eng := engine.NewLoginOffline(d.G()) m := libkb.NewMetaContext(ctx, d.G()) if err := engine.RunEngine2(m, eng); err != nil { m.Debug("error running LoginOffline on service startup: %s", err) m.Debug("trying LoginProvisionedDevice") // Standalone mode quirk here. We call tryLogin when client is // launched in standalone to unlock the same keys that we would // have in service mode. But NewLoginProvisionedDevice engine // needs KbKeyrings and not every command sets it up. Ensure // Keyring is available. // TODO: We will be phasing out KbKeyrings usage flag, or even // usage flags entirely. Then this will not be needed because // Keyrings will always be loaded. if m.G().Keyrings == nil { m.Debug("tryLogin: Configuring Keyrings") m.G().ConfigureKeyring() } deng := engine.NewLoginProvisionedDevice(d.G(), "") deng.SecretStoreOnly = true if err := engine.RunEngine2(m, deng); err != nil { m.Debug("error running LoginProvisionedDevice on service startup: %s", err) } } else { m.Debug("success running LoginOffline on service startup") } }) }
go
func (d *Service) tryLogin(ctx context.Context) { tryLoginOnce.Do(func() { eng := engine.NewLoginOffline(d.G()) m := libkb.NewMetaContext(ctx, d.G()) if err := engine.RunEngine2(m, eng); err != nil { m.Debug("error running LoginOffline on service startup: %s", err) m.Debug("trying LoginProvisionedDevice") // Standalone mode quirk here. We call tryLogin when client is // launched in standalone to unlock the same keys that we would // have in service mode. But NewLoginProvisionedDevice engine // needs KbKeyrings and not every command sets it up. Ensure // Keyring is available. // TODO: We will be phasing out KbKeyrings usage flag, or even // usage flags entirely. Then this will not be needed because // Keyrings will always be loaded. if m.G().Keyrings == nil { m.Debug("tryLogin: Configuring Keyrings") m.G().ConfigureKeyring() } deng := engine.NewLoginProvisionedDevice(d.G(), "") deng.SecretStoreOnly = true if err := engine.RunEngine2(m, deng); err != nil { m.Debug("error running LoginProvisionedDevice on service startup: %s", err) } } else { m.Debug("success running LoginOffline on service startup") } }) }
[ "func", "(", "d", "*", "Service", ")", "tryLogin", "(", "ctx", "context", ".", "Context", ")", "{", "tryLoginOnce", ".", "Do", "(", "func", "(", ")", "{", "eng", ":=", "engine", ".", "NewLoginOffline", "(", "d", ".", "G", "(", ")", ")", "\n", "m", ":=", "libkb", ".", "NewMetaContext", "(", "ctx", ",", "d", ".", "G", "(", ")", ")", "\n", "if", "err", ":=", "engine", ".", "RunEngine2", "(", "m", ",", "eng", ")", ";", "err", "!=", "nil", "{", "m", ".", "Debug", "(", "\"", "\"", ",", "err", ")", "\n", "m", ".", "Debug", "(", "\"", "\"", ")", "\n\n", "// Standalone mode quirk here. We call tryLogin when client is", "// launched in standalone to unlock the same keys that we would", "// have in service mode. But NewLoginProvisionedDevice engine", "// needs KbKeyrings and not every command sets it up. Ensure", "// Keyring is available.", "// TODO: We will be phasing out KbKeyrings usage flag, or even", "// usage flags entirely. Then this will not be needed because", "// Keyrings will always be loaded.", "if", "m", ".", "G", "(", ")", ".", "Keyrings", "==", "nil", "{", "m", ".", "Debug", "(", "\"", "\"", ")", "\n", "m", ".", "G", "(", ")", ".", "ConfigureKeyring", "(", ")", "\n", "}", "\n\n", "deng", ":=", "engine", ".", "NewLoginProvisionedDevice", "(", "d", ".", "G", "(", ")", ",", "\"", "\"", ")", "\n", "deng", ".", "SecretStoreOnly", "=", "true", "\n", "if", "err", ":=", "engine", ".", "RunEngine2", "(", "m", ",", "deng", ")", ";", "err", "!=", "nil", "{", "m", ".", "Debug", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "}", "else", "{", "m", ".", "Debug", "(", "\"", "\"", ")", "\n", "}", "\n", "}", ")", "\n", "}" ]
// tryLogin runs LoginOffline which will load the local session file and unlock the // local device keys without making any network requests. // // If that fails for any reason, LoginProvisionedDevice is used, which should get // around any issue where the session.json file is out of date or missing since the // last time the service started.
[ "tryLogin", "runs", "LoginOffline", "which", "will", "load", "the", "local", "session", "file", "and", "unlock", "the", "local", "device", "keys", "without", "making", "any", "network", "requests", ".", "If", "that", "fails", "for", "any", "reason", "LoginProvisionedDevice", "is", "used", "which", "should", "get", "around", "any", "issue", "where", "the", "session", ".", "json", "file", "is", "out", "of", "date", "or", "missing", "since", "the", "last", "time", "the", "service", "started", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/main.go#L1235-L1267
158,516
keybase/client
go/kbfs/kbfscodec/codec_msgpack.go
WriteExt
func (e ext) WriteExt(v interface{}) (buf []byte) { buf, err := e.codec.Encode(v) if err != nil { panic(fmt.Sprintf("Couldn't encode data in %v", v)) } return buf }
go
func (e ext) WriteExt(v interface{}) (buf []byte) { buf, err := e.codec.Encode(v) if err != nil { panic(fmt.Sprintf("Couldn't encode data in %v", v)) } return buf }
[ "func", "(", "e", "ext", ")", "WriteExt", "(", "v", "interface", "{", "}", ")", "(", "buf", "[", "]", "byte", ")", "{", "buf", ",", "err", ":=", "e", ".", "codec", ".", "Encode", "(", "v", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "v", ")", ")", "\n", "}", "\n", "return", "buf", "\n", "}" ]
// WriteExt implements the codec.Ext interface for ext.
[ "WriteExt", "implements", "the", "codec", ".", "Ext", "interface", "for", "ext", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscodec/codec_msgpack.go#L34-L40
158,517
keybase/client
go/kbfs/kbfscodec/codec_msgpack.go
ReadExt
func (e ext) ReadExt(v interface{}, buf []byte) { err := e.codec.Decode(buf, v) if err != nil { panic(fmt.Sprintf("Couldn't decode data into %v", v)) } }
go
func (e ext) ReadExt(v interface{}, buf []byte) { err := e.codec.Decode(buf, v) if err != nil { panic(fmt.Sprintf("Couldn't decode data into %v", v)) } }
[ "func", "(", "e", "ext", ")", "ReadExt", "(", "v", "interface", "{", "}", ",", "buf", "[", "]", "byte", ")", "{", "err", ":=", "e", ".", "codec", ".", "Decode", "(", "buf", ",", "v", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "v", ")", ")", "\n", "}", "\n", "}" ]
// ReadExt implements the codec.Ext interface for ext.
[ "ReadExt", "implements", "the", "codec", ".", "Ext", "interface", "for", "ext", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscodec/codec_msgpack.go#L43-L48
158,518
keybase/client
go/kbfs/kbfscodec/codec_msgpack.go
WriteExt
func (es extSlice) WriteExt(v interface{}) (buf []byte) { val := reflect.ValueOf(v) if val.Kind() != reflect.Slice { panic(fmt.Sprintf("Non-slice passed to extSlice.WriteExt %v", val.Kind())) } ifaceArray := make([]interface{}, val.Len()) for i := 0; i < val.Len(); i++ { ifaceArray[i] = val.Index(i).Interface() } buf, err := es.codec.Encode(ifaceArray) if err != nil { panic(fmt.Sprintf("Couldn't encode data in %v", v)) } return buf }
go
func (es extSlice) WriteExt(v interface{}) (buf []byte) { val := reflect.ValueOf(v) if val.Kind() != reflect.Slice { panic(fmt.Sprintf("Non-slice passed to extSlice.WriteExt %v", val.Kind())) } ifaceArray := make([]interface{}, val.Len()) for i := 0; i < val.Len(); i++ { ifaceArray[i] = val.Index(i).Interface() } buf, err := es.codec.Encode(ifaceArray) if err != nil { panic(fmt.Sprintf("Couldn't encode data in %v", v)) } return buf }
[ "func", "(", "es", "extSlice", ")", "WriteExt", "(", "v", "interface", "{", "}", ")", "(", "buf", "[", "]", "byte", ")", "{", "val", ":=", "reflect", ".", "ValueOf", "(", "v", ")", "\n", "if", "val", ".", "Kind", "(", ")", "!=", "reflect", ".", "Slice", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "val", ".", "Kind", "(", ")", ")", ")", "\n", "}", "\n\n", "ifaceArray", ":=", "make", "(", "[", "]", "interface", "{", "}", ",", "val", ".", "Len", "(", ")", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "val", ".", "Len", "(", ")", ";", "i", "++", "{", "ifaceArray", "[", "i", "]", "=", "val", ".", "Index", "(", "i", ")", ".", "Interface", "(", ")", "\n", "}", "\n\n", "buf", ",", "err", ":=", "es", ".", "codec", ".", "Encode", "(", "ifaceArray", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "v", ")", ")", "\n", "}", "\n", "return", "buf", "\n", "}" ]
// WriteExt implements the codec.Ext interface for extSlice.
[ "WriteExt", "implements", "the", "codec", ".", "Ext", "interface", "for", "extSlice", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscodec/codec_msgpack.go#L70-L87
158,519
keybase/client
go/kbfs/kbfscodec/codec_msgpack.go
ReadExt
func (es extSlice) ReadExt(v interface{}, buf []byte) { // ReadExt actually receives a pointer to the list val := reflect.ValueOf(v) if val.Kind() != reflect.Ptr { panic(fmt.Sprintf("Non-pointer passed to extSlice.ReadExt: %v", val.Kind())) } val = val.Elem() if val.Kind() != reflect.Slice { panic(fmt.Sprintf("Non-slice passed to extSlice.ReadExt %v", val.Kind())) } var ifaceArray []interface{} err := es.codec.Decode(buf, &ifaceArray) if err != nil { panic(fmt.Sprintf("Couldn't decode data into %v", v)) } if len(ifaceArray) > 0 { val.Set(reflect.MakeSlice(val.Type(), len(ifaceArray), len(ifaceArray))) } for i, v := range ifaceArray { if es.typer != nil { val.Index(i).Set(es.typer(v)) } else { val.Index(i).Set(reflect.ValueOf(v)) } } }
go
func (es extSlice) ReadExt(v interface{}, buf []byte) { // ReadExt actually receives a pointer to the list val := reflect.ValueOf(v) if val.Kind() != reflect.Ptr { panic(fmt.Sprintf("Non-pointer passed to extSlice.ReadExt: %v", val.Kind())) } val = val.Elem() if val.Kind() != reflect.Slice { panic(fmt.Sprintf("Non-slice passed to extSlice.ReadExt %v", val.Kind())) } var ifaceArray []interface{} err := es.codec.Decode(buf, &ifaceArray) if err != nil { panic(fmt.Sprintf("Couldn't decode data into %v", v)) } if len(ifaceArray) > 0 { val.Set(reflect.MakeSlice(val.Type(), len(ifaceArray), len(ifaceArray))) } for i, v := range ifaceArray { if es.typer != nil { val.Index(i).Set(es.typer(v)) } else { val.Index(i).Set(reflect.ValueOf(v)) } } }
[ "func", "(", "es", "extSlice", ")", "ReadExt", "(", "v", "interface", "{", "}", ",", "buf", "[", "]", "byte", ")", "{", "// ReadExt actually receives a pointer to the list", "val", ":=", "reflect", ".", "ValueOf", "(", "v", ")", "\n", "if", "val", ".", "Kind", "(", ")", "!=", "reflect", ".", "Ptr", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "val", ".", "Kind", "(", ")", ")", ")", "\n", "}", "\n\n", "val", "=", "val", ".", "Elem", "(", ")", "\n", "if", "val", ".", "Kind", "(", ")", "!=", "reflect", ".", "Slice", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "val", ".", "Kind", "(", ")", ")", ")", "\n", "}", "\n\n", "var", "ifaceArray", "[", "]", "interface", "{", "}", "\n", "err", ":=", "es", ".", "codec", ".", "Decode", "(", "buf", ",", "&", "ifaceArray", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "v", ")", ")", "\n", "}", "\n\n", "if", "len", "(", "ifaceArray", ")", ">", "0", "{", "val", ".", "Set", "(", "reflect", ".", "MakeSlice", "(", "val", ".", "Type", "(", ")", ",", "len", "(", "ifaceArray", ")", ",", "len", "(", "ifaceArray", ")", ")", ")", "\n", "}", "\n\n", "for", "i", ",", "v", ":=", "range", "ifaceArray", "{", "if", "es", ".", "typer", "!=", "nil", "{", "val", ".", "Index", "(", "i", ")", ".", "Set", "(", "es", ".", "typer", "(", "v", ")", ")", "\n", "}", "else", "{", "val", ".", "Index", "(", "i", ")", ".", "Set", "(", "reflect", ".", "ValueOf", "(", "v", ")", ")", "\n", "}", "\n", "}", "\n", "}" ]
// ReadExt implements the codec.Ext interface for extSlice.
[ "ReadExt", "implements", "the", "codec", ".", "Ext", "interface", "for", "extSlice", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscodec/codec_msgpack.go#L90-L122
158,520
keybase/client
go/kbfs/kbfscodec/codec_msgpack.go
newCodecMsgpackHelper
func newCodecMsgpackHelper(handleUnknownFields bool) *CodecMsgpack { handle := codec.MsgpackHandle{} handle.Canonical = true handle.WriteExt = true handle.DecodeUnknownFields = handleUnknownFields handle.EncodeUnknownFields = handleUnknownFields // save a codec that doesn't write extensions, so that we can just // call Encode/Decode when we want to (de)serialize extension // types. handleNoExt := handle handleNoExt.WriteExt = false ExtCodec := &CodecMsgpack{&handleNoExt, nil} return &CodecMsgpack{&handle, ExtCodec} }
go
func newCodecMsgpackHelper(handleUnknownFields bool) *CodecMsgpack { handle := codec.MsgpackHandle{} handle.Canonical = true handle.WriteExt = true handle.DecodeUnknownFields = handleUnknownFields handle.EncodeUnknownFields = handleUnknownFields // save a codec that doesn't write extensions, so that we can just // call Encode/Decode when we want to (de)serialize extension // types. handleNoExt := handle handleNoExt.WriteExt = false ExtCodec := &CodecMsgpack{&handleNoExt, nil} return &CodecMsgpack{&handle, ExtCodec} }
[ "func", "newCodecMsgpackHelper", "(", "handleUnknownFields", "bool", ")", "*", "CodecMsgpack", "{", "handle", ":=", "codec", ".", "MsgpackHandle", "{", "}", "\n", "handle", ".", "Canonical", "=", "true", "\n", "handle", ".", "WriteExt", "=", "true", "\n", "handle", ".", "DecodeUnknownFields", "=", "handleUnknownFields", "\n", "handle", ".", "EncodeUnknownFields", "=", "handleUnknownFields", "\n\n", "// save a codec that doesn't write extensions, so that we can just", "// call Encode/Decode when we want to (de)serialize extension", "// types.", "handleNoExt", ":=", "handle", "\n", "handleNoExt", ".", "WriteExt", "=", "false", "\n", "ExtCodec", ":=", "&", "CodecMsgpack", "{", "&", "handleNoExt", ",", "nil", "}", "\n", "return", "&", "CodecMsgpack", "{", "&", "handle", ",", "ExtCodec", "}", "\n", "}" ]
// newCodecMsgpackHelper constructs a new CodecMsgpack that may or may // not handle unknown fields.
[ "newCodecMsgpackHelper", "constructs", "a", "new", "CodecMsgpack", "that", "may", "or", "may", "not", "handle", "unknown", "fields", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscodec/codec_msgpack.go#L133-L147
158,521
keybase/client
go/kbfs/kbfscodec/codec_msgpack.go
Decode
func (c *CodecMsgpack) Decode(buf []byte, obj interface{}) error { err := codec.NewDecoderBytes(buf, c.h).Decode(obj) if err != nil { return errors.Wrap(err, "failed to decode") } return nil }
go
func (c *CodecMsgpack) Decode(buf []byte, obj interface{}) error { err := codec.NewDecoderBytes(buf, c.h).Decode(obj) if err != nil { return errors.Wrap(err, "failed to decode") } return nil }
[ "func", "(", "c", "*", "CodecMsgpack", ")", "Decode", "(", "buf", "[", "]", "byte", ",", "obj", "interface", "{", "}", ")", "error", "{", "err", ":=", "codec", ".", "NewDecoderBytes", "(", "buf", ",", "c", ".", "h", ")", ".", "Decode", "(", "obj", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Decode implements the Codec interface for CodecMsgpack
[ "Decode", "implements", "the", "Codec", "interface", "for", "CodecMsgpack" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscodec/codec_msgpack.go#L161-L167
158,522
keybase/client
go/kbfs/kbfscodec/codec_msgpack.go
Encode
func (c *CodecMsgpack) Encode(obj interface{}) (buf []byte, err error) { err = codec.NewEncoderBytes(&buf, c.h).Encode(obj) if err != nil { return nil, errors.Wrap(err, "failed to encode") } return buf, nil }
go
func (c *CodecMsgpack) Encode(obj interface{}) (buf []byte, err error) { err = codec.NewEncoderBytes(&buf, c.h).Encode(obj) if err != nil { return nil, errors.Wrap(err, "failed to encode") } return buf, nil }
[ "func", "(", "c", "*", "CodecMsgpack", ")", "Encode", "(", "obj", "interface", "{", "}", ")", "(", "buf", "[", "]", "byte", ",", "err", "error", ")", "{", "err", "=", "codec", ".", "NewEncoderBytes", "(", "&", "buf", ",", "c", ".", "h", ")", ".", "Encode", "(", "obj", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "return", "buf", ",", "nil", "\n", "}" ]
// Encode implements the Codec interface for CodecMsgpack
[ "Encode", "implements", "the", "Codec", "interface", "for", "CodecMsgpack" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscodec/codec_msgpack.go#L170-L176
158,523
keybase/client
go/kbfs/kbfscodec/codec_msgpack.go
RegisterType
func (c *CodecMsgpack) RegisterType(rt reflect.Type, code ExtCode) { c.h.(*codec.MsgpackHandle).SetExt(rt, uint64(code), ext{c.ExtCodec}) }
go
func (c *CodecMsgpack) RegisterType(rt reflect.Type, code ExtCode) { c.h.(*codec.MsgpackHandle).SetExt(rt, uint64(code), ext{c.ExtCodec}) }
[ "func", "(", "c", "*", "CodecMsgpack", ")", "RegisterType", "(", "rt", "reflect", ".", "Type", ",", "code", "ExtCode", ")", "{", "c", ".", "h", ".", "(", "*", "codec", ".", "MsgpackHandle", ")", ".", "SetExt", "(", "rt", ",", "uint64", "(", "code", ")", ",", "ext", "{", "c", ".", "ExtCodec", "}", ")", "\n", "}" ]
// RegisterType implements the Codec interface for CodecMsgpack
[ "RegisterType", "implements", "the", "Codec", "interface", "for", "CodecMsgpack" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscodec/codec_msgpack.go#L179-L181
158,524
keybase/client
go/kbfs/kbfscodec/codec_msgpack.go
RegisterIfaceSliceType
func (c *CodecMsgpack) RegisterIfaceSliceType(rt reflect.Type, code ExtCode, typer func(interface{}) reflect.Value) { c.h.(*codec.MsgpackHandle).SetExt(rt, uint64(code), extSlice{c, typer}) }
go
func (c *CodecMsgpack) RegisterIfaceSliceType(rt reflect.Type, code ExtCode, typer func(interface{}) reflect.Value) { c.h.(*codec.MsgpackHandle).SetExt(rt, uint64(code), extSlice{c, typer}) }
[ "func", "(", "c", "*", "CodecMsgpack", ")", "RegisterIfaceSliceType", "(", "rt", "reflect", ".", "Type", ",", "code", "ExtCode", ",", "typer", "func", "(", "interface", "{", "}", ")", "reflect", ".", "Value", ")", "{", "c", ".", "h", ".", "(", "*", "codec", ".", "MsgpackHandle", ")", ".", "SetExt", "(", "rt", ",", "uint64", "(", "code", ")", ",", "extSlice", "{", "c", ",", "typer", "}", ")", "\n", "}" ]
// RegisterIfaceSliceType implements the Codec interface for CodecMsgpack
[ "RegisterIfaceSliceType", "implements", "the", "Codec", "interface", "for", "CodecMsgpack" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscodec/codec_msgpack.go#L184-L187
158,525
keybase/client
go/libkb/saferdllloading_windows.go
SaferDLLLoading
func SaferDLLLoading() error { kernel32, err := syscall.LoadDLL("kernel32.dll") if err != nil { return err } procSetDllDirectoryW, err := kernel32.FindProc("SetDllDirectoryW") if err != nil { return err } var zero uint16 r1, _, e1 := syscall.Syscall(procSetDllDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(&zero)), 0, 0) procSetDefaultDllDirectories, err := kernel32.FindProc("SetDefaultDllDirectories") if err == nil && procSetDefaultDllDirectories.Addr() != 0 { r1, _, e1 = syscall.Syscall(procSetDefaultDllDirectories.Addr(), 1, loadLibrarySearchSystem32, 0, 0) if r1 == 0 { return e1 } } else { return errors.New("SetDefaultDllDirectories not found - please install KB2533623 for safer DLL loading") } return nil }
go
func SaferDLLLoading() error { kernel32, err := syscall.LoadDLL("kernel32.dll") if err != nil { return err } procSetDllDirectoryW, err := kernel32.FindProc("SetDllDirectoryW") if err != nil { return err } var zero uint16 r1, _, e1 := syscall.Syscall(procSetDllDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(&zero)), 0, 0) procSetDefaultDllDirectories, err := kernel32.FindProc("SetDefaultDllDirectories") if err == nil && procSetDefaultDllDirectories.Addr() != 0 { r1, _, e1 = syscall.Syscall(procSetDefaultDllDirectories.Addr(), 1, loadLibrarySearchSystem32, 0, 0) if r1 == 0 { return e1 } } else { return errors.New("SetDefaultDllDirectories not found - please install KB2533623 for safer DLL loading") } return nil }
[ "func", "SaferDLLLoading", "(", ")", "error", "{", "kernel32", ",", "err", ":=", "syscall", ".", "LoadDLL", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "procSetDllDirectoryW", ",", "err", ":=", "kernel32", ".", "FindProc", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "var", "zero", "uint16", "\n", "r1", ",", "_", ",", "e1", ":=", "syscall", ".", "Syscall", "(", "procSetDllDirectoryW", ".", "Addr", "(", ")", ",", "1", ",", "uintptr", "(", "unsafe", ".", "Pointer", "(", "&", "zero", ")", ")", ",", "0", ",", "0", ")", "\n\n", "procSetDefaultDllDirectories", ",", "err", ":=", "kernel32", ".", "FindProc", "(", "\"", "\"", ")", "\n", "if", "err", "==", "nil", "&&", "procSetDefaultDllDirectories", ".", "Addr", "(", ")", "!=", "0", "{", "r1", ",", "_", ",", "e1", "=", "syscall", ".", "Syscall", "(", "procSetDefaultDllDirectories", ".", "Addr", "(", ")", ",", "1", ",", "loadLibrarySearchSystem32", ",", "0", ",", "0", ")", "\n", "if", "r1", "==", "0", "{", "return", "e1", "\n", "}", "\n", "}", "else", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// SaferDLLLoading sets DLL load path to be safer.
[ "SaferDLLLoading", "sets", "DLL", "load", "path", "to", "be", "safer", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/saferdllloading_windows.go#L15-L41
158,526
keybase/client
go/libkb/file.go
NewFile
func NewFile(filename string, data []byte, perm os.FileMode) File { return File{filename, data, perm} }
go
func NewFile(filename string, data []byte, perm os.FileMode) File { return File{filename, data, perm} }
[ "func", "NewFile", "(", "filename", "string", ",", "data", "[", "]", "byte", ",", "perm", "os", ".", "FileMode", ")", "File", "{", "return", "File", "{", "filename", ",", "data", ",", "perm", "}", "\n", "}" ]
// NewFile returns a File
[ "NewFile", "returns", "a", "File" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/file.go#L19-L21
158,527
keybase/client
go/kbfs/libkbfs/kbfs_service.go
NewKBFSService
func NewKBFSService(kbCtx Context, config kbfsServiceConfig) ( *KBFSService, error) { log := config.MakeLogger("FSS") // Check to see if we're receiving a socket from systemd. If not, create // one and bind to it. listener, err := systemd.GetListenerFromEnvironment() if err != nil { return nil, err } if listener != nil { log.Debug("Found listener in the environment. Listening on fd 3.") } else { log.Debug("No listener found in the environment. Binding a new socket.") listener, err = kbCtx.BindToKBFSSocket() if err != nil { return nil, err } } k := &KBFSService{ config: config, log: log, kbCtx: kbCtx, } k.Run(listener) return k, nil }
go
func NewKBFSService(kbCtx Context, config kbfsServiceConfig) ( *KBFSService, error) { log := config.MakeLogger("FSS") // Check to see if we're receiving a socket from systemd. If not, create // one and bind to it. listener, err := systemd.GetListenerFromEnvironment() if err != nil { return nil, err } if listener != nil { log.Debug("Found listener in the environment. Listening on fd 3.") } else { log.Debug("No listener found in the environment. Binding a new socket.") listener, err = kbCtx.BindToKBFSSocket() if err != nil { return nil, err } } k := &KBFSService{ config: config, log: log, kbCtx: kbCtx, } k.Run(listener) return k, nil }
[ "func", "NewKBFSService", "(", "kbCtx", "Context", ",", "config", "kbfsServiceConfig", ")", "(", "*", "KBFSService", ",", "error", ")", "{", "log", ":=", "config", ".", "MakeLogger", "(", "\"", "\"", ")", "\n", "// Check to see if we're receiving a socket from systemd. If not, create", "// one and bind to it.", "listener", ",", "err", ":=", "systemd", ".", "GetListenerFromEnvironment", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "listener", "!=", "nil", "{", "log", ".", "Debug", "(", "\"", "\"", ")", "\n", "}", "else", "{", "log", ".", "Debug", "(", "\"", "\"", ")", "\n", "listener", ",", "err", "=", "kbCtx", ".", "BindToKBFSSocket", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n", "k", ":=", "&", "KBFSService", "{", "config", ":", "config", ",", "log", ":", "log", ",", "kbCtx", ":", "kbCtx", ",", "}", "\n", "k", ".", "Run", "(", "listener", ")", "\n", "return", "k", ",", "nil", "\n", "}" ]
// NewKBFSService creates a new KBFSService.
[ "NewKBFSService", "creates", "a", "new", "KBFSService", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/kbfs_service.go#L76-L101
158,528
keybase/client
go/kbfs/libkbfs/kbfs_service.go
registerProtocols
func (k *KBFSService) registerProtocols( srv *rpc.Server, xp rpc.Transporter) error { // TODO: fill in with actual protocols. protocols := []rpc.Protocol{ kbgitkbfs.DiskBlockCacheProtocol(NewDiskBlockCacheService(k.config)), } for _, proto := range protocols { if err := srv.Register(proto); err != nil { return err } } return nil }
go
func (k *KBFSService) registerProtocols( srv *rpc.Server, xp rpc.Transporter) error { // TODO: fill in with actual protocols. protocols := []rpc.Protocol{ kbgitkbfs.DiskBlockCacheProtocol(NewDiskBlockCacheService(k.config)), } for _, proto := range protocols { if err := srv.Register(proto); err != nil { return err } } return nil }
[ "func", "(", "k", "*", "KBFSService", ")", "registerProtocols", "(", "srv", "*", "rpc", ".", "Server", ",", "xp", "rpc", ".", "Transporter", ")", "error", "{", "// TODO: fill in with actual protocols.", "protocols", ":=", "[", "]", "rpc", ".", "Protocol", "{", "kbgitkbfs", ".", "DiskBlockCacheProtocol", "(", "NewDiskBlockCacheService", "(", "k", ".", "config", ")", ")", ",", "}", "\n", "for", "_", ",", "proto", ":=", "range", "protocols", "{", "if", "err", ":=", "srv", ".", "Register", "(", "proto", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// registerProtocols registers protocols for this KBFSService.
[ "registerProtocols", "registers", "protocols", "for", "this", "KBFSService", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/kbfs_service.go#L109-L121
158,529
keybase/client
go/kbfs/libkbfs/kbfs_service.go
handle
func (k *KBFSService) handle(c net.Conn) { xp := rpc.NewTransport(c, k.kbCtx.NewRPCLogFactory(), libkb.WrapError, rpc.DefaultMaxFrameLength) server := rpc.NewServer(xp, libkb.WrapError) err := k.registerProtocols(server, xp) if err != nil { k.log.Warning("RegisterProtocols error: %s", err) return } // Run the server, then wait for it or this KBFSService to finish. serverCh := server.Run() go func() { select { case <-k.stopCh: case <-serverCh: } // Close is idempotent, so always close when we're done. c.Close() }() <-serverCh // err is always non-nil. err = server.Err() if err != io.EOF { k.log.Warning("Run error: %s", err) } k.log.Debug("handle() complete") }
go
func (k *KBFSService) handle(c net.Conn) { xp := rpc.NewTransport(c, k.kbCtx.NewRPCLogFactory(), libkb.WrapError, rpc.DefaultMaxFrameLength) server := rpc.NewServer(xp, libkb.WrapError) err := k.registerProtocols(server, xp) if err != nil { k.log.Warning("RegisterProtocols error: %s", err) return } // Run the server, then wait for it or this KBFSService to finish. serverCh := server.Run() go func() { select { case <-k.stopCh: case <-serverCh: } // Close is idempotent, so always close when we're done. c.Close() }() <-serverCh // err is always non-nil. err = server.Err() if err != io.EOF { k.log.Warning("Run error: %s", err) } k.log.Debug("handle() complete") }
[ "func", "(", "k", "*", "KBFSService", ")", "handle", "(", "c", "net", ".", "Conn", ")", "{", "xp", ":=", "rpc", ".", "NewTransport", "(", "c", ",", "k", ".", "kbCtx", ".", "NewRPCLogFactory", "(", ")", ",", "libkb", ".", "WrapError", ",", "rpc", ".", "DefaultMaxFrameLength", ")", "\n\n", "server", ":=", "rpc", ".", "NewServer", "(", "xp", ",", "libkb", ".", "WrapError", ")", "\n\n", "err", ":=", "k", ".", "registerProtocols", "(", "server", ",", "xp", ")", "\n\n", "if", "err", "!=", "nil", "{", "k", ".", "log", ".", "Warning", "(", "\"", "\"", ",", "err", ")", "\n", "return", "\n", "}", "\n\n", "// Run the server, then wait for it or this KBFSService to finish.", "serverCh", ":=", "server", ".", "Run", "(", ")", "\n", "go", "func", "(", ")", "{", "select", "{", "case", "<-", "k", ".", "stopCh", ":", "case", "<-", "serverCh", ":", "}", "\n", "// Close is idempotent, so always close when we're done.", "c", ".", "Close", "(", ")", "\n", "}", "(", ")", "\n", "<-", "serverCh", "\n\n", "// err is always non-nil.", "err", "=", "server", ".", "Err", "(", ")", "\n", "if", "err", "!=", "io", ".", "EOF", "{", "k", ".", "log", ".", "Warning", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "k", ".", "log", ".", "Debug", "(", "\"", "\"", ")", "\n", "}" ]
// handle creates a server on an established connection.
[ "handle", "creates", "a", "server", "on", "an", "established", "connection", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/kbfs_service.go#L124-L155
158,530
keybase/client
go/kbfs/libkbfs/kbfs_service.go
listenLoop
func (k *KBFSService) listenLoop(l net.Listener) error { go func() { <-k.stopCh l.Close() }() defer l.Close() for { c, err := l.Accept() if err != nil { if libkb.IsSocketClosedError(err) { err = nil } k.log.Debug("listenLoop() done, error: %+v", err) return err } go k.handle(c) } }
go
func (k *KBFSService) listenLoop(l net.Listener) error { go func() { <-k.stopCh l.Close() }() defer l.Close() for { c, err := l.Accept() if err != nil { if libkb.IsSocketClosedError(err) { err = nil } k.log.Debug("listenLoop() done, error: %+v", err) return err } go k.handle(c) } }
[ "func", "(", "k", "*", "KBFSService", ")", "listenLoop", "(", "l", "net", ".", "Listener", ")", "error", "{", "go", "func", "(", ")", "{", "<-", "k", ".", "stopCh", "\n", "l", ".", "Close", "(", ")", "\n", "}", "(", ")", "\n", "defer", "l", ".", "Close", "(", ")", "\n", "for", "{", "c", ",", "err", ":=", "l", ".", "Accept", "(", ")", "\n", "if", "err", "!=", "nil", "{", "if", "libkb", ".", "IsSocketClosedError", "(", "err", ")", "{", "err", "=", "nil", "\n", "}", "\n\n", "k", ".", "log", ".", "Debug", "(", "\"", "\"", ",", "err", ")", "\n", "return", "err", "\n", "}", "\n", "go", "k", ".", "handle", "(", "c", ")", "\n", "}", "\n", "}" ]
// listenLoop listens on a passed-in listener and calls `handle` for any // connection that is established on the listener.
[ "listenLoop", "listens", "on", "a", "passed", "-", "in", "listener", "and", "calls", "handle", "for", "any", "connection", "that", "is", "established", "on", "the", "listener", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/kbfs_service.go#L159-L177
158,531
keybase/client
go/kbfs/idutil/daemon_local.go
SetCurrentUID
func (dl *DaemonLocal) SetCurrentUID(uid keybase1.UID) { dl.lock.Lock() defer dl.lock.Unlock() // TODO: Send out notifications. dl.currentUID = uid }
go
func (dl *DaemonLocal) SetCurrentUID(uid keybase1.UID) { dl.lock.Lock() defer dl.lock.Unlock() // TODO: Send out notifications. dl.currentUID = uid }
[ "func", "(", "dl", "*", "DaemonLocal", ")", "SetCurrentUID", "(", "uid", "keybase1", ".", "UID", ")", "{", "dl", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "dl", ".", "lock", ".", "Unlock", "(", ")", "\n", "// TODO: Send out notifications.", "dl", ".", "currentUID", "=", "uid", "\n", "}" ]
// SetCurrentUID sets the current UID.
[ "SetCurrentUID", "sets", "the", "current", "UID", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/idutil/daemon_local.go#L85-L90
158,532
keybase/client
go/kbfs/idutil/daemon_local.go
Resolve
func (dl *DaemonLocal) Resolve( ctx context.Context, assertion string, _ keybase1.OfflineAvailability) ( kbname.NormalizedUsername, keybase1.UserOrTeamID, error) { if err := checkContext(ctx); err != nil { return kbname.NormalizedUsername(""), keybase1.UserOrTeamID(""), err } dl.lock.Lock() defer dl.lock.Unlock() id, err := dl.assertionToIDLocked(ctx, assertion) if err != nil { return kbname.NormalizedUsername(""), keybase1.UserOrTeamID(""), err } if id.IsUser() { u, err := dl.localUsers.getLocalUser(id.AsUserOrBust()) if err != nil { return kbname.NormalizedUsername(""), keybase1.UserOrTeamID(""), err } return u.Name, id, nil } // Otherwise it's a team ti, err := dl.localTeams.getLocalTeam(id.AsTeamOrBust()) if err != nil { return kbname.NormalizedUsername(""), keybase1.UserOrTeamID(""), err } _, ok := dl.localImplicitTeams[id.AsTeamOrBust()] if ok { // An implicit team exists, so Resolve shouldn't work. The // caller should use `ResolveImplicitTeamByID` instead. return kbname.NormalizedUsername(""), keybase1.UserOrTeamID(""), fmt.Errorf("Team ID %s is an implicit team", id) } return ti.Name, id, nil }
go
func (dl *DaemonLocal) Resolve( ctx context.Context, assertion string, _ keybase1.OfflineAvailability) ( kbname.NormalizedUsername, keybase1.UserOrTeamID, error) { if err := checkContext(ctx); err != nil { return kbname.NormalizedUsername(""), keybase1.UserOrTeamID(""), err } dl.lock.Lock() defer dl.lock.Unlock() id, err := dl.assertionToIDLocked(ctx, assertion) if err != nil { return kbname.NormalizedUsername(""), keybase1.UserOrTeamID(""), err } if id.IsUser() { u, err := dl.localUsers.getLocalUser(id.AsUserOrBust()) if err != nil { return kbname.NormalizedUsername(""), keybase1.UserOrTeamID(""), err } return u.Name, id, nil } // Otherwise it's a team ti, err := dl.localTeams.getLocalTeam(id.AsTeamOrBust()) if err != nil { return kbname.NormalizedUsername(""), keybase1.UserOrTeamID(""), err } _, ok := dl.localImplicitTeams[id.AsTeamOrBust()] if ok { // An implicit team exists, so Resolve shouldn't work. The // caller should use `ResolveImplicitTeamByID` instead. return kbname.NormalizedUsername(""), keybase1.UserOrTeamID(""), fmt.Errorf("Team ID %s is an implicit team", id) } return ti.Name, id, nil }
[ "func", "(", "dl", "*", "DaemonLocal", ")", "Resolve", "(", "ctx", "context", ".", "Context", ",", "assertion", "string", ",", "_", "keybase1", ".", "OfflineAvailability", ")", "(", "kbname", ".", "NormalizedUsername", ",", "keybase1", ".", "UserOrTeamID", ",", "error", ")", "{", "if", "err", ":=", "checkContext", "(", "ctx", ")", ";", "err", "!=", "nil", "{", "return", "kbname", ".", "NormalizedUsername", "(", "\"", "\"", ")", ",", "keybase1", ".", "UserOrTeamID", "(", "\"", "\"", ")", ",", "err", "\n", "}", "\n\n", "dl", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "dl", ".", "lock", ".", "Unlock", "(", ")", "\n", "id", ",", "err", ":=", "dl", ".", "assertionToIDLocked", "(", "ctx", ",", "assertion", ")", "\n", "if", "err", "!=", "nil", "{", "return", "kbname", ".", "NormalizedUsername", "(", "\"", "\"", ")", ",", "keybase1", ".", "UserOrTeamID", "(", "\"", "\"", ")", ",", "err", "\n", "}", "\n\n", "if", "id", ".", "IsUser", "(", ")", "{", "u", ",", "err", ":=", "dl", ".", "localUsers", ".", "getLocalUser", "(", "id", ".", "AsUserOrBust", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "kbname", ".", "NormalizedUsername", "(", "\"", "\"", ")", ",", "keybase1", ".", "UserOrTeamID", "(", "\"", "\"", ")", ",", "err", "\n", "}", "\n", "return", "u", ".", "Name", ",", "id", ",", "nil", "\n", "}", "\n\n", "// Otherwise it's a team", "ti", ",", "err", ":=", "dl", ".", "localTeams", ".", "getLocalTeam", "(", "id", ".", "AsTeamOrBust", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "kbname", ".", "NormalizedUsername", "(", "\"", "\"", ")", ",", "keybase1", ".", "UserOrTeamID", "(", "\"", "\"", ")", ",", "err", "\n", "}", "\n\n", "_", ",", "ok", ":=", "dl", ".", "localImplicitTeams", "[", "id", ".", "AsTeamOrBust", "(", ")", "]", "\n", "if", "ok", "{", "// An implicit team exists, so Resolve shouldn't work. The", "// caller should use `ResolveImplicitTeamByID` instead.", "return", "kbname", ".", "NormalizedUsername", "(", "\"", "\"", ")", ",", "keybase1", ".", "UserOrTeamID", "(", "\"", "\"", ")", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "id", ")", "\n", "}", "\n\n", "return", "ti", ".", "Name", ",", "id", ",", "nil", "\n", "}" ]
// Resolve implements the KeybaseService interface for DaemonLocal.
[ "Resolve", "implements", "the", "KeybaseService", "interface", "for", "DaemonLocal", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/idutil/daemon_local.go#L131-L168
158,533
keybase/client
go/kbfs/idutil/daemon_local.go
Identify
func (dl *DaemonLocal) Identify( ctx context.Context, assertion, _ string, offline keybase1.OfflineAvailability) ( kbname.NormalizedUsername, keybase1.UserOrTeamID, error) { // The local daemon doesn't need to distinguish resolves from // identifies. return dl.Resolve(ctx, assertion, offline) }
go
func (dl *DaemonLocal) Identify( ctx context.Context, assertion, _ string, offline keybase1.OfflineAvailability) ( kbname.NormalizedUsername, keybase1.UserOrTeamID, error) { // The local daemon doesn't need to distinguish resolves from // identifies. return dl.Resolve(ctx, assertion, offline) }
[ "func", "(", "dl", "*", "DaemonLocal", ")", "Identify", "(", "ctx", "context", ".", "Context", ",", "assertion", ",", "_", "string", ",", "offline", "keybase1", ".", "OfflineAvailability", ")", "(", "kbname", ".", "NormalizedUsername", ",", "keybase1", ".", "UserOrTeamID", ",", "error", ")", "{", "// The local daemon doesn't need to distinguish resolves from", "// identifies.", "return", "dl", ".", "Resolve", "(", "ctx", ",", "assertion", ",", "offline", ")", "\n", "}" ]
// Identify implements the KeybaseService interface for DaemonLocal.
[ "Identify", "implements", "the", "KeybaseService", "interface", "for", "DaemonLocal", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/idutil/daemon_local.go#L171-L178
158,534
keybase/client
go/kbfs/idutil/daemon_local.go
NormalizeSocialAssertion
func (dl *DaemonLocal) NormalizeSocialAssertion( ctx context.Context, assertion string) (keybase1.SocialAssertion, error) { socialAssertion, isSocialAssertion := externals.NormalizeSocialAssertionStatic(assertion) if !isSocialAssertion { return keybase1.SocialAssertion{}, fmt.Errorf("Invalid social assertion") } return socialAssertion, nil }
go
func (dl *DaemonLocal) NormalizeSocialAssertion( ctx context.Context, assertion string) (keybase1.SocialAssertion, error) { socialAssertion, isSocialAssertion := externals.NormalizeSocialAssertionStatic(assertion) if !isSocialAssertion { return keybase1.SocialAssertion{}, fmt.Errorf("Invalid social assertion") } return socialAssertion, nil }
[ "func", "(", "dl", "*", "DaemonLocal", ")", "NormalizeSocialAssertion", "(", "ctx", "context", ".", "Context", ",", "assertion", "string", ")", "(", "keybase1", ".", "SocialAssertion", ",", "error", ")", "{", "socialAssertion", ",", "isSocialAssertion", ":=", "externals", ".", "NormalizeSocialAssertionStatic", "(", "assertion", ")", "\n", "if", "!", "isSocialAssertion", "{", "return", "keybase1", ".", "SocialAssertion", "{", "}", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "socialAssertion", ",", "nil", "\n", "}" ]
// NormalizeSocialAssertion implements the KeybaseService interface // for DaemonLocal.
[ "NormalizeSocialAssertion", "implements", "the", "KeybaseService", "interface", "for", "DaemonLocal", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/idutil/daemon_local.go#L182-L189
158,535
keybase/client
go/kbfs/idutil/daemon_local.go
ResolveImplicitTeamByID
func (dl *DaemonLocal) ResolveImplicitTeamByID( ctx context.Context, teamID keybase1.TeamID) (name string, err error) { if err := checkContext(ctx); err != nil { return "", err } dl.lock.Lock() defer dl.lock.Unlock() info, ok := dl.localImplicitTeams[teamID] if !ok { return "", NoSuchTeamError{teamID.String()} } return info.Name.String(), nil }
go
func (dl *DaemonLocal) ResolveImplicitTeamByID( ctx context.Context, teamID keybase1.TeamID) (name string, err error) { if err := checkContext(ctx); err != nil { return "", err } dl.lock.Lock() defer dl.lock.Unlock() info, ok := dl.localImplicitTeams[teamID] if !ok { return "", NoSuchTeamError{teamID.String()} } return info.Name.String(), nil }
[ "func", "(", "dl", "*", "DaemonLocal", ")", "ResolveImplicitTeamByID", "(", "ctx", "context", ".", "Context", ",", "teamID", "keybase1", ".", "TeamID", ")", "(", "name", "string", ",", "err", "error", ")", "{", "if", "err", ":=", "checkContext", "(", "ctx", ")", ";", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "dl", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "dl", ".", "lock", ".", "Unlock", "(", ")", "\n\n", "info", ",", "ok", ":=", "dl", ".", "localImplicitTeams", "[", "teamID", "]", "\n", "if", "!", "ok", "{", "return", "\"", "\"", ",", "NoSuchTeamError", "{", "teamID", ".", "String", "(", ")", "}", "\n", "}", "\n", "return", "info", ".", "Name", ".", "String", "(", ")", ",", "nil", "\n", "}" ]
// ResolveImplicitTeamByID implements the KeybaseService interface // for DaemonLocal.
[ "ResolveImplicitTeamByID", "implements", "the", "KeybaseService", "interface", "for", "DaemonLocal", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/idutil/daemon_local.go#L322-L336
158,536
keybase/client
go/kbfs/idutil/daemon_local.go
LoadUserPlusKeys
func (dl *DaemonLocal) LoadUserPlusKeys( ctx context.Context, uid keybase1.UID, _ keybase1.KID, _ keybase1.OfflineAvailability) (UserInfo, error) { if err := checkContext(ctx); err != nil { return UserInfo{}, err } dl.lock.Lock() defer dl.lock.Unlock() u, err := dl.localUsers.getLocalUser(uid) if err != nil { return UserInfo{}, err } var infoCopy UserInfo if err := kbfscodec.Update(dl.codec, &infoCopy, u.UserInfo); err != nil { return UserInfo{}, err } return infoCopy, nil }
go
func (dl *DaemonLocal) LoadUserPlusKeys( ctx context.Context, uid keybase1.UID, _ keybase1.KID, _ keybase1.OfflineAvailability) (UserInfo, error) { if err := checkContext(ctx); err != nil { return UserInfo{}, err } dl.lock.Lock() defer dl.lock.Unlock() u, err := dl.localUsers.getLocalUser(uid) if err != nil { return UserInfo{}, err } var infoCopy UserInfo if err := kbfscodec.Update(dl.codec, &infoCopy, u.UserInfo); err != nil { return UserInfo{}, err } return infoCopy, nil }
[ "func", "(", "dl", "*", "DaemonLocal", ")", "LoadUserPlusKeys", "(", "ctx", "context", ".", "Context", ",", "uid", "keybase1", ".", "UID", ",", "_", "keybase1", ".", "KID", ",", "_", "keybase1", ".", "OfflineAvailability", ")", "(", "UserInfo", ",", "error", ")", "{", "if", "err", ":=", "checkContext", "(", "ctx", ")", ";", "err", "!=", "nil", "{", "return", "UserInfo", "{", "}", ",", "err", "\n", "}", "\n\n", "dl", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "dl", ".", "lock", ".", "Unlock", "(", ")", "\n", "u", ",", "err", ":=", "dl", ".", "localUsers", ".", "getLocalUser", "(", "uid", ")", "\n", "if", "err", "!=", "nil", "{", "return", "UserInfo", "{", "}", ",", "err", "\n", "}", "\n\n", "var", "infoCopy", "UserInfo", "\n", "if", "err", ":=", "kbfscodec", ".", "Update", "(", "dl", ".", "codec", ",", "&", "infoCopy", ",", "u", ".", "UserInfo", ")", ";", "err", "!=", "nil", "{", "return", "UserInfo", "{", "}", ",", "err", "\n", "}", "\n", "return", "infoCopy", ",", "nil", "\n", "}" ]
// LoadUserPlusKeys implements the KeybaseService interface for // DaemonLocal.
[ "LoadUserPlusKeys", "implements", "the", "KeybaseService", "interface", "for", "DaemonLocal", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/idutil/daemon_local.go#L340-L359
158,537
keybase/client
go/kbfs/idutil/daemon_local.go
LoadTeamPlusKeys
func (dl *DaemonLocal) LoadTeamPlusKeys( ctx context.Context, tid keybase1.TeamID, _ tlf.Type, _ kbfsmd.KeyGen, _ keybase1.UserVersion, _ kbfscrypto.VerifyingKey, _ keybase1.TeamRole, _ keybase1.OfflineAvailability) (TeamInfo, error) { if err := checkContext(ctx); err != nil { return TeamInfo{}, err } dl.lock.Lock() defer dl.lock.Unlock() t, err := dl.localTeams.getLocalTeam(tid) if err != nil { return TeamInfo{}, err } // Copy the info since it contains a map that might be mutated. var infoCopy TeamInfo if err := kbfscodec.Update(dl.codec, &infoCopy, t); err != nil { return TeamInfo{}, err } return infoCopy, nil }
go
func (dl *DaemonLocal) LoadTeamPlusKeys( ctx context.Context, tid keybase1.TeamID, _ tlf.Type, _ kbfsmd.KeyGen, _ keybase1.UserVersion, _ kbfscrypto.VerifyingKey, _ keybase1.TeamRole, _ keybase1.OfflineAvailability) (TeamInfo, error) { if err := checkContext(ctx); err != nil { return TeamInfo{}, err } dl.lock.Lock() defer dl.lock.Unlock() t, err := dl.localTeams.getLocalTeam(tid) if err != nil { return TeamInfo{}, err } // Copy the info since it contains a map that might be mutated. var infoCopy TeamInfo if err := kbfscodec.Update(dl.codec, &infoCopy, t); err != nil { return TeamInfo{}, err } return infoCopy, nil }
[ "func", "(", "dl", "*", "DaemonLocal", ")", "LoadTeamPlusKeys", "(", "ctx", "context", ".", "Context", ",", "tid", "keybase1", ".", "TeamID", ",", "_", "tlf", ".", "Type", ",", "_", "kbfsmd", ".", "KeyGen", ",", "_", "keybase1", ".", "UserVersion", ",", "_", "kbfscrypto", ".", "VerifyingKey", ",", "_", "keybase1", ".", "TeamRole", ",", "_", "keybase1", ".", "OfflineAvailability", ")", "(", "TeamInfo", ",", "error", ")", "{", "if", "err", ":=", "checkContext", "(", "ctx", ")", ";", "err", "!=", "nil", "{", "return", "TeamInfo", "{", "}", ",", "err", "\n", "}", "\n\n", "dl", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "dl", ".", "lock", ".", "Unlock", "(", ")", "\n", "t", ",", "err", ":=", "dl", ".", "localTeams", ".", "getLocalTeam", "(", "tid", ")", "\n", "if", "err", "!=", "nil", "{", "return", "TeamInfo", "{", "}", ",", "err", "\n", "}", "\n\n", "// Copy the info since it contains a map that might be mutated.", "var", "infoCopy", "TeamInfo", "\n", "if", "err", ":=", "kbfscodec", ".", "Update", "(", "dl", ".", "codec", ",", "&", "infoCopy", ",", "t", ")", ";", "err", "!=", "nil", "{", "return", "TeamInfo", "{", "}", ",", "err", "\n", "}", "\n", "return", "infoCopy", ",", "nil", "\n", "}" ]
// LoadTeamPlusKeys implements the KeybaseService interface for // DaemonLocal.
[ "LoadTeamPlusKeys", "implements", "the", "KeybaseService", "interface", "for", "DaemonLocal", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/idutil/daemon_local.go#L363-L384
158,538
keybase/client
go/kbfs/idutil/daemon_local.go
CreateTeamTLF
func (dl *DaemonLocal) CreateTeamTLF( ctx context.Context, teamID keybase1.TeamID, tlfID tlf.ID) (err error) { if err := checkContext(ctx); err != nil { return err } // TODO: add check to make sure the private/public suffix of the // team ID matches that of the tlf ID. dl.lock.Lock() defer dl.lock.Unlock() iteamInfo, isImplicit := dl.localImplicitTeams[teamID] if isImplicit { iteamInfo.TlfID = tlfID dl.localImplicitTeams[teamID] = iteamInfo } _, isRegularTeam := dl.localTeams[teamID] if !isImplicit && !isRegularTeam { return NoSuchTeamError{teamID.String()} } dl.localTeamSettings[teamID] = keybase1.KBFSTeamSettings{ TlfID: keybase1.TLFID(tlfID.String())} return nil }
go
func (dl *DaemonLocal) CreateTeamTLF( ctx context.Context, teamID keybase1.TeamID, tlfID tlf.ID) (err error) { if err := checkContext(ctx); err != nil { return err } // TODO: add check to make sure the private/public suffix of the // team ID matches that of the tlf ID. dl.lock.Lock() defer dl.lock.Unlock() iteamInfo, isImplicit := dl.localImplicitTeams[teamID] if isImplicit { iteamInfo.TlfID = tlfID dl.localImplicitTeams[teamID] = iteamInfo } _, isRegularTeam := dl.localTeams[teamID] if !isImplicit && !isRegularTeam { return NoSuchTeamError{teamID.String()} } dl.localTeamSettings[teamID] = keybase1.KBFSTeamSettings{ TlfID: keybase1.TLFID(tlfID.String())} return nil }
[ "func", "(", "dl", "*", "DaemonLocal", ")", "CreateTeamTLF", "(", "ctx", "context", ".", "Context", ",", "teamID", "keybase1", ".", "TeamID", ",", "tlfID", "tlf", ".", "ID", ")", "(", "err", "error", ")", "{", "if", "err", ":=", "checkContext", "(", "ctx", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// TODO: add check to make sure the private/public suffix of the", "// team ID matches that of the tlf ID.", "dl", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "dl", ".", "lock", ".", "Unlock", "(", ")", "\n", "iteamInfo", ",", "isImplicit", ":=", "dl", ".", "localImplicitTeams", "[", "teamID", "]", "\n", "if", "isImplicit", "{", "iteamInfo", ".", "TlfID", "=", "tlfID", "\n", "dl", ".", "localImplicitTeams", "[", "teamID", "]", "=", "iteamInfo", "\n", "}", "\n", "_", ",", "isRegularTeam", ":=", "dl", ".", "localTeams", "[", "teamID", "]", "\n", "if", "!", "isImplicit", "&&", "!", "isRegularTeam", "{", "return", "NoSuchTeamError", "{", "teamID", ".", "String", "(", ")", "}", "\n", "}", "\n", "dl", ".", "localTeamSettings", "[", "teamID", "]", "=", "keybase1", ".", "KBFSTeamSettings", "{", "TlfID", ":", "keybase1", ".", "TLFID", "(", "tlfID", ".", "String", "(", ")", ")", "}", "\n", "return", "nil", "\n", "}" ]
// CreateTeamTLF implements the KeybaseService interface for // DaemonLocal.
[ "CreateTeamTLF", "implements", "the", "KeybaseService", "interface", "for", "DaemonLocal", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/idutil/daemon_local.go#L388-L410
158,539
keybase/client
go/kbfs/idutil/daemon_local.go
GetTeamSettings
func (dl *DaemonLocal) GetTeamSettings( ctx context.Context, teamID keybase1.TeamID, _ keybase1.OfflineAvailability) ( settings keybase1.KBFSTeamSettings, err error) { if err := checkContext(ctx); err != nil { return keybase1.KBFSTeamSettings{}, err } dl.lock.Lock() defer dl.lock.Unlock() return dl.localTeamSettings[teamID], nil }
go
func (dl *DaemonLocal) GetTeamSettings( ctx context.Context, teamID keybase1.TeamID, _ keybase1.OfflineAvailability) ( settings keybase1.KBFSTeamSettings, err error) { if err := checkContext(ctx); err != nil { return keybase1.KBFSTeamSettings{}, err } dl.lock.Lock() defer dl.lock.Unlock() return dl.localTeamSettings[teamID], nil }
[ "func", "(", "dl", "*", "DaemonLocal", ")", "GetTeamSettings", "(", "ctx", "context", ".", "Context", ",", "teamID", "keybase1", ".", "TeamID", ",", "_", "keybase1", ".", "OfflineAvailability", ")", "(", "settings", "keybase1", ".", "KBFSTeamSettings", ",", "err", "error", ")", "{", "if", "err", ":=", "checkContext", "(", "ctx", ")", ";", "err", "!=", "nil", "{", "return", "keybase1", ".", "KBFSTeamSettings", "{", "}", ",", "err", "\n", "}", "\n\n", "dl", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "dl", ".", "lock", ".", "Unlock", "(", ")", "\n", "return", "dl", ".", "localTeamSettings", "[", "teamID", "]", ",", "nil", "\n", "}" ]
// GetTeamSettings implements the KeybaseService interface for // DaemonLocal.
[ "GetTeamSettings", "implements", "the", "KeybaseService", "interface", "for", "DaemonLocal", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/idutil/daemon_local.go#L414-L425
158,540
keybase/client
go/kbfs/idutil/daemon_local.go
GetCurrentMerkleRoot
func (dl *DaemonLocal) GetCurrentMerkleRoot(ctx context.Context) ( keybase1.MerkleRootV2, time.Time, error) { if err := checkContext(ctx); err != nil { return keybase1.MerkleRootV2{}, time.Time{}, err } dl.lock.Lock() defer dl.lock.Unlock() return dl.merkleRoot, dl.merkleTime, nil }
go
func (dl *DaemonLocal) GetCurrentMerkleRoot(ctx context.Context) ( keybase1.MerkleRootV2, time.Time, error) { if err := checkContext(ctx); err != nil { return keybase1.MerkleRootV2{}, time.Time{}, err } dl.lock.Lock() defer dl.lock.Unlock() return dl.merkleRoot, dl.merkleTime, nil }
[ "func", "(", "dl", "*", "DaemonLocal", ")", "GetCurrentMerkleRoot", "(", "ctx", "context", ".", "Context", ")", "(", "keybase1", ".", "MerkleRootV2", ",", "time", ".", "Time", ",", "error", ")", "{", "if", "err", ":=", "checkContext", "(", "ctx", ")", ";", "err", "!=", "nil", "{", "return", "keybase1", ".", "MerkleRootV2", "{", "}", ",", "time", ".", "Time", "{", "}", ",", "err", "\n", "}", "\n\n", "dl", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "dl", ".", "lock", ".", "Unlock", "(", ")", "\n", "return", "dl", ".", "merkleRoot", ",", "dl", ".", "merkleTime", ",", "nil", "\n", "}" ]
// GetCurrentMerkleRoot implements the MerkleRootGetter interface for // DaemonLocal.
[ "GetCurrentMerkleRoot", "implements", "the", "MerkleRootGetter", "interface", "for", "DaemonLocal", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/idutil/daemon_local.go#L429-L438
158,541
keybase/client
go/kbfs/idutil/daemon_local.go
VerifyMerkleRoot
func (dl *DaemonLocal) VerifyMerkleRoot( _ context.Context, _ keybase1.MerkleRootV2, _ keybase1.KBFSRoot) error { return nil }
go
func (dl *DaemonLocal) VerifyMerkleRoot( _ context.Context, _ keybase1.MerkleRootV2, _ keybase1.KBFSRoot) error { return nil }
[ "func", "(", "dl", "*", "DaemonLocal", ")", "VerifyMerkleRoot", "(", "_", "context", ".", "Context", ",", "_", "keybase1", ".", "MerkleRootV2", ",", "_", "keybase1", ".", "KBFSRoot", ")", "error", "{", "return", "nil", "\n", "}" ]
// VerifyMerkleRoot implements the MerkleRootGetter interface for // DaemonLocal.
[ "VerifyMerkleRoot", "implements", "the", "MerkleRootGetter", "interface", "for", "DaemonLocal", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/idutil/daemon_local.go#L442-L445
158,542
keybase/client
go/kbfs/idutil/daemon_local.go
SetCurrentMerkleRoot
func (dl *DaemonLocal) SetCurrentMerkleRoot( root keybase1.MerkleRootV2, rootTime time.Time) { dl.lock.Lock() defer dl.lock.Unlock() dl.merkleRoot = root dl.merkleTime = rootTime }
go
func (dl *DaemonLocal) SetCurrentMerkleRoot( root keybase1.MerkleRootV2, rootTime time.Time) { dl.lock.Lock() defer dl.lock.Unlock() dl.merkleRoot = root dl.merkleTime = rootTime }
[ "func", "(", "dl", "*", "DaemonLocal", ")", "SetCurrentMerkleRoot", "(", "root", "keybase1", ".", "MerkleRootV2", ",", "rootTime", "time", ".", "Time", ")", "{", "dl", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "dl", ".", "lock", ".", "Unlock", "(", ")", "\n", "dl", ".", "merkleRoot", "=", "root", "\n", "dl", ".", "merkleTime", "=", "rootTime", "\n", "}" ]
// SetCurrentMerkleRoot is a helper function, useful for tests, to set // the current Merkle root.
[ "SetCurrentMerkleRoot", "is", "a", "helper", "function", "useful", "for", "tests", "to", "set", "the", "current", "Merkle", "root", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/idutil/daemon_local.go#L449-L455
158,543
keybase/client
go/kbfs/idutil/daemon_local.go
CurrentSession
func (dl *DaemonLocal) CurrentSession(ctx context.Context, sessionID int) ( SessionInfo, error) { if err := checkContext(ctx); err != nil { return SessionInfo{}, err } dl.lock.Lock() defer dl.lock.Unlock() u, err := dl.localUsers.getLocalUser(dl.currentUID) if err != nil { return SessionInfo{}, err } return SessionInfo{ Name: u.Name, UID: u.UID, CryptPublicKey: u.GetCurrentCryptPublicKey(), VerifyingKey: u.GetCurrentVerifyingKey(), }, nil }
go
func (dl *DaemonLocal) CurrentSession(ctx context.Context, sessionID int) ( SessionInfo, error) { if err := checkContext(ctx); err != nil { return SessionInfo{}, err } dl.lock.Lock() defer dl.lock.Unlock() u, err := dl.localUsers.getLocalUser(dl.currentUID) if err != nil { return SessionInfo{}, err } return SessionInfo{ Name: u.Name, UID: u.UID, CryptPublicKey: u.GetCurrentCryptPublicKey(), VerifyingKey: u.GetCurrentVerifyingKey(), }, nil }
[ "func", "(", "dl", "*", "DaemonLocal", ")", "CurrentSession", "(", "ctx", "context", ".", "Context", ",", "sessionID", "int", ")", "(", "SessionInfo", ",", "error", ")", "{", "if", "err", ":=", "checkContext", "(", "ctx", ")", ";", "err", "!=", "nil", "{", "return", "SessionInfo", "{", "}", ",", "err", "\n", "}", "\n\n", "dl", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "dl", ".", "lock", ".", "Unlock", "(", ")", "\n", "u", ",", "err", ":=", "dl", ".", "localUsers", ".", "getLocalUser", "(", "dl", ".", "currentUID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "SessionInfo", "{", "}", ",", "err", "\n", "}", "\n", "return", "SessionInfo", "{", "Name", ":", "u", ".", "Name", ",", "UID", ":", "u", ".", "UID", ",", "CryptPublicKey", ":", "u", ".", "GetCurrentCryptPublicKey", "(", ")", ",", "VerifyingKey", ":", "u", ".", "GetCurrentVerifyingKey", "(", ")", ",", "}", ",", "nil", "\n", "}" ]
// CurrentSession implements the KeybaseService interface for // DaemonLocal.
[ "CurrentSession", "implements", "the", "KeybaseService", "interface", "for", "DaemonLocal", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/idutil/daemon_local.go#L459-L477
158,544
keybase/client
go/kbfs/idutil/daemon_local.go
GetLocalUser
func (dl *DaemonLocal) GetLocalUser(uid keybase1.UID) (LocalUser, error) { dl.lock.Lock() defer dl.lock.Unlock() return dl.localUsers.getLocalUser(uid) }
go
func (dl *DaemonLocal) GetLocalUser(uid keybase1.UID) (LocalUser, error) { dl.lock.Lock() defer dl.lock.Unlock() return dl.localUsers.getLocalUser(uid) }
[ "func", "(", "dl", "*", "DaemonLocal", ")", "GetLocalUser", "(", "uid", "keybase1", ".", "UID", ")", "(", "LocalUser", ",", "error", ")", "{", "dl", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "dl", ".", "lock", ".", "Unlock", "(", ")", "\n", "return", "dl", ".", "localUsers", ".", "getLocalUser", "(", "uid", ")", "\n", "}" ]
// GetLocalUser returns the `LocalUser` object for the given UID.
[ "GetLocalUser", "returns", "the", "LocalUser", "object", "for", "the", "given", "UID", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/idutil/daemon_local.go#L680-L684
158,545
keybase/client
go/kbfs/idutil/daemon_local.go
SetLocalUser
func (dl *DaemonLocal) SetLocalUser(uid keybase1.UID, user LocalUser) { dl.lock.Lock() defer dl.lock.Unlock() dl.localUsers[uid] = user }
go
func (dl *DaemonLocal) SetLocalUser(uid keybase1.UID, user LocalUser) { dl.lock.Lock() defer dl.lock.Unlock() dl.localUsers[uid] = user }
[ "func", "(", "dl", "*", "DaemonLocal", ")", "SetLocalUser", "(", "uid", "keybase1", ".", "UID", ",", "user", "LocalUser", ")", "{", "dl", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "dl", ".", "lock", ".", "Unlock", "(", ")", "\n", "dl", ".", "localUsers", "[", "uid", "]", "=", "user", "\n", "}" ]
// SetLocalUser sets the `LocalUser` object for the given UID.
[ "SetLocalUser", "sets", "the", "LocalUser", "object", "for", "the", "given", "UID", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/idutil/daemon_local.go#L687-L691
158,546
keybase/client
go/kbfs/idutil/daemon_local.go
GetIDForAssertion
func (dl *DaemonLocal) GetIDForAssertion(assertion string) ( keybase1.UserOrTeamID, bool) { dl.lock.Lock() defer dl.lock.Unlock() id, ok := dl.asserts[assertion] return id, ok }
go
func (dl *DaemonLocal) GetIDForAssertion(assertion string) ( keybase1.UserOrTeamID, bool) { dl.lock.Lock() defer dl.lock.Unlock() id, ok := dl.asserts[assertion] return id, ok }
[ "func", "(", "dl", "*", "DaemonLocal", ")", "GetIDForAssertion", "(", "assertion", "string", ")", "(", "keybase1", ".", "UserOrTeamID", ",", "bool", ")", "{", "dl", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "dl", ".", "lock", ".", "Unlock", "(", ")", "\n", "id", ",", "ok", ":=", "dl", ".", "asserts", "[", "assertion", "]", "\n", "return", "id", ",", "ok", "\n", "}" ]
// GetIDForAssertion returns the UID associated with the given // assertion.
[ "GetIDForAssertion", "returns", "the", "UID", "associated", "with", "the", "given", "assertion", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/idutil/daemon_local.go#L695-L701
158,547
keybase/client
go/kbfs/idutil/daemon_local.go
GetLocalUsers
func (dl *DaemonLocal) GetLocalUsers() (res []LocalUser) { dl.lock.Lock() defer dl.lock.Unlock() for _, u := range dl.localUsers { res = append(res, u) } return res }
go
func (dl *DaemonLocal) GetLocalUsers() (res []LocalUser) { dl.lock.Lock() defer dl.lock.Unlock() for _, u := range dl.localUsers { res = append(res, u) } return res }
[ "func", "(", "dl", "*", "DaemonLocal", ")", "GetLocalUsers", "(", ")", "(", "res", "[", "]", "LocalUser", ")", "{", "dl", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "dl", ".", "lock", ".", "Unlock", "(", ")", "\n", "for", "_", ",", "u", ":=", "range", "dl", ".", "localUsers", "{", "res", "=", "append", "(", "res", ",", "u", ")", "\n", "}", "\n", "return", "res", "\n", "}" ]
// GetLocalUsers returns all of the users tracked by this daemon.
[ "GetLocalUsers", "returns", "all", "of", "the", "users", "tracked", "by", "this", "daemon", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/idutil/daemon_local.go#L704-L711
158,548
keybase/client
go/kbfs/idutil/daemon_local.go
NewDaemonLocal
func NewDaemonLocal( currentUID keybase1.UID, users []LocalUser, teams []TeamInfo, codec kbfscodec.Codec) *DaemonLocal { localUserMap := make(localUserMap) asserts := make(map[string]keybase1.UserOrTeamID) for _, u := range users { localUserMap[u.UID] = u for _, a := range u.Asserts { asserts[a] = u.UID.AsUserOrTeam() } asserts[string(u.Name)] = u.UID.AsUserOrTeam() } dl := &DaemonLocal{ codec: codec, localUsers: localUserMap, localTeams: make(localTeamMap), localTeamSettings: make(localTeamSettingsMap), localImplicitTeams: make(localImplicitTeamMap), asserts: asserts, implicitAsserts: make(map[string]keybase1.TeamID), currentUID: currentUID, // TODO: let test fill in valid merkle root. } dl.AddTeamsForTest(teams) return dl }
go
func NewDaemonLocal( currentUID keybase1.UID, users []LocalUser, teams []TeamInfo, codec kbfscodec.Codec) *DaemonLocal { localUserMap := make(localUserMap) asserts := make(map[string]keybase1.UserOrTeamID) for _, u := range users { localUserMap[u.UID] = u for _, a := range u.Asserts { asserts[a] = u.UID.AsUserOrTeam() } asserts[string(u.Name)] = u.UID.AsUserOrTeam() } dl := &DaemonLocal{ codec: codec, localUsers: localUserMap, localTeams: make(localTeamMap), localTeamSettings: make(localTeamSettingsMap), localImplicitTeams: make(localImplicitTeamMap), asserts: asserts, implicitAsserts: make(map[string]keybase1.TeamID), currentUID: currentUID, // TODO: let test fill in valid merkle root. } dl.AddTeamsForTest(teams) return dl }
[ "func", "NewDaemonLocal", "(", "currentUID", "keybase1", ".", "UID", ",", "users", "[", "]", "LocalUser", ",", "teams", "[", "]", "TeamInfo", ",", "codec", "kbfscodec", ".", "Codec", ")", "*", "DaemonLocal", "{", "localUserMap", ":=", "make", "(", "localUserMap", ")", "\n", "asserts", ":=", "make", "(", "map", "[", "string", "]", "keybase1", ".", "UserOrTeamID", ")", "\n", "for", "_", ",", "u", ":=", "range", "users", "{", "localUserMap", "[", "u", ".", "UID", "]", "=", "u", "\n", "for", "_", ",", "a", ":=", "range", "u", ".", "Asserts", "{", "asserts", "[", "a", "]", "=", "u", ".", "UID", ".", "AsUserOrTeam", "(", ")", "\n", "}", "\n", "asserts", "[", "string", "(", "u", ".", "Name", ")", "]", "=", "u", ".", "UID", ".", "AsUserOrTeam", "(", ")", "\n", "}", "\n", "dl", ":=", "&", "DaemonLocal", "{", "codec", ":", "codec", ",", "localUsers", ":", "localUserMap", ",", "localTeams", ":", "make", "(", "localTeamMap", ")", ",", "localTeamSettings", ":", "make", "(", "localTeamSettingsMap", ")", ",", "localImplicitTeams", ":", "make", "(", "localImplicitTeamMap", ")", ",", "asserts", ":", "asserts", ",", "implicitAsserts", ":", "make", "(", "map", "[", "string", "]", "keybase1", ".", "TeamID", ")", ",", "currentUID", ":", "currentUID", ",", "// TODO: let test fill in valid merkle root.", "}", "\n", "dl", ".", "AddTeamsForTest", "(", "teams", ")", "\n", "return", "dl", "\n", "}" ]
// NewDaemonLocal constructs a new DaemonLocal, initialized to contain // the given users and teams.
[ "NewDaemonLocal", "constructs", "a", "new", "DaemonLocal", "initialized", "to", "contain", "the", "given", "users", "and", "teams", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/idutil/daemon_local.go#L715-L740
158,549
keybase/client
go/kbfs/tlfhandle/handle.go
NewHandle
func NewHandle( ty tlf.Type, resolvedWriters map[keybase1.UserOrTeamID]kbname.NormalizedUsername, unresolvedWriters, unresolvedReaders []keybase1.SocialAssertion, name tlf.CanonicalName, tlfID tlf.ID) *Handle { return &Handle{ tlfType: ty, resolvedWriters: resolvedWriters, unresolvedWriters: unresolvedWriters, unresolvedReaders: unresolvedReaders, name: name, tlfID: tlfID, } }
go
func NewHandle( ty tlf.Type, resolvedWriters map[keybase1.UserOrTeamID]kbname.NormalizedUsername, unresolvedWriters, unresolvedReaders []keybase1.SocialAssertion, name tlf.CanonicalName, tlfID tlf.ID) *Handle { return &Handle{ tlfType: ty, resolvedWriters: resolvedWriters, unresolvedWriters: unresolvedWriters, unresolvedReaders: unresolvedReaders, name: name, tlfID: tlfID, } }
[ "func", "NewHandle", "(", "ty", "tlf", ".", "Type", ",", "resolvedWriters", "map", "[", "keybase1", ".", "UserOrTeamID", "]", "kbname", ".", "NormalizedUsername", ",", "unresolvedWriters", ",", "unresolvedReaders", "[", "]", "keybase1", ".", "SocialAssertion", ",", "name", "tlf", ".", "CanonicalName", ",", "tlfID", "tlf", ".", "ID", ")", "*", "Handle", "{", "return", "&", "Handle", "{", "tlfType", ":", "ty", ",", "resolvedWriters", ":", "resolvedWriters", ",", "unresolvedWriters", ":", "unresolvedWriters", ",", "unresolvedReaders", ":", "unresolvedReaders", ",", "name", ":", "name", ",", "tlfID", ":", "tlfID", ",", "}", "\n", "}" ]
// NewHandle returns a simple new Handle based on the given fields. // This is probably most useful for testing.
[ "NewHandle", "returns", "a", "simple", "new", "Handle", "based", "on", "the", "given", "fields", ".", "This", "is", "probably", "most", "useful", "for", "testing", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/handle.go#L53-L66
158,550
keybase/client
go/kbfs/tlfhandle/handle.go
IsWriter
func (h Handle) IsWriter(user keybase1.UID) bool { // TODO(KBFS-2185) relax this? if h.TypeForKeying() == tlf.TeamKeying { panic("Can't check whether a user is a writer on a team TLF") } _, ok := h.resolvedWriters[user.AsUserOrTeam()] return ok }
go
func (h Handle) IsWriter(user keybase1.UID) bool { // TODO(KBFS-2185) relax this? if h.TypeForKeying() == tlf.TeamKeying { panic("Can't check whether a user is a writer on a team TLF") } _, ok := h.resolvedWriters[user.AsUserOrTeam()] return ok }
[ "func", "(", "h", "Handle", ")", "IsWriter", "(", "user", "keybase1", ".", "UID", ")", "bool", "{", "// TODO(KBFS-2185) relax this?", "if", "h", ".", "TypeForKeying", "(", ")", "==", "tlf", ".", "TeamKeying", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "_", ",", "ok", ":=", "h", ".", "resolvedWriters", "[", "user", ".", "AsUserOrTeam", "(", ")", "]", "\n", "return", "ok", "\n", "}" ]
// IsWriter returns whether or not the given user is a writer for the // top-level folder represented by this TlfHandle.
[ "IsWriter", "returns", "whether", "or", "not", "the", "given", "user", "is", "a", "writer", "for", "the", "top", "-", "level", "folder", "represented", "by", "this", "TlfHandle", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/handle.go#L103-L110
158,551
keybase/client
go/kbfs/tlfhandle/handle.go
IsReader
func (h Handle) IsReader(user keybase1.UID) bool { // TODO(KBFS-2185) relax this? if h.TypeForKeying() == tlf.TeamKeying { panic("Can't check whether a user is a reader on a team TLF") } if h.TypeForKeying() == tlf.PublicKeying || h.IsWriter(user) { return true } _, ok := h.resolvedReaders[user.AsUserOrTeam()] return ok }
go
func (h Handle) IsReader(user keybase1.UID) bool { // TODO(KBFS-2185) relax this? if h.TypeForKeying() == tlf.TeamKeying { panic("Can't check whether a user is a reader on a team TLF") } if h.TypeForKeying() == tlf.PublicKeying || h.IsWriter(user) { return true } _, ok := h.resolvedReaders[user.AsUserOrTeam()] return ok }
[ "func", "(", "h", "Handle", ")", "IsReader", "(", "user", "keybase1", ".", "UID", ")", "bool", "{", "// TODO(KBFS-2185) relax this?", "if", "h", ".", "TypeForKeying", "(", ")", "==", "tlf", ".", "TeamKeying", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "h", ".", "TypeForKeying", "(", ")", "==", "tlf", ".", "PublicKeying", "||", "h", ".", "IsWriter", "(", "user", ")", "{", "return", "true", "\n", "}", "\n", "_", ",", "ok", ":=", "h", ".", "resolvedReaders", "[", "user", ".", "AsUserOrTeam", "(", ")", "]", "\n", "return", "ok", "\n", "}" ]
// IsReader returns whether or not the given user is a reader for the // top-level folder represented by this TlfHandle.
[ "IsReader", "returns", "whether", "or", "not", "the", "given", "user", "is", "a", "reader", "for", "the", "top", "-", "level", "folder", "represented", "by", "this", "TlfHandle", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/handle.go#L114-L124
158,552
keybase/client
go/kbfs/tlfhandle/handle.go
ResolvedUsersMap
func (h Handle) ResolvedUsersMap() map[keybase1.UserOrTeamID]kbname.NormalizedUsername { m := make(map[keybase1.UserOrTeamID]kbname.NormalizedUsername, len(h.resolvedReaders)+len(h.resolvedWriters)) for k, v := range h.resolvedReaders { m[k] = v } for k, v := range h.resolvedWriters { m[k] = v } return m }
go
func (h Handle) ResolvedUsersMap() map[keybase1.UserOrTeamID]kbname.NormalizedUsername { m := make(map[keybase1.UserOrTeamID]kbname.NormalizedUsername, len(h.resolvedReaders)+len(h.resolvedWriters)) for k, v := range h.resolvedReaders { m[k] = v } for k, v := range h.resolvedWriters { m[k] = v } return m }
[ "func", "(", "h", "Handle", ")", "ResolvedUsersMap", "(", ")", "map", "[", "keybase1", ".", "UserOrTeamID", "]", "kbname", ".", "NormalizedUsername", "{", "m", ":=", "make", "(", "map", "[", "keybase1", ".", "UserOrTeamID", "]", "kbname", ".", "NormalizedUsername", ",", "len", "(", "h", ".", "resolvedReaders", ")", "+", "len", "(", "h", ".", "resolvedWriters", ")", ")", "\n", "for", "k", ",", "v", ":=", "range", "h", ".", "resolvedReaders", "{", "m", "[", "k", "]", "=", "v", "\n", "}", "\n", "for", "k", ",", "v", ":=", "range", "h", ".", "resolvedWriters", "{", "m", "[", "k", "]", "=", "v", "\n", "}", "\n", "return", "m", "\n", "}" ]
// ResolvedUsersMap returns a map of resolved users from uid to usernames.
[ "ResolvedUsersMap", "returns", "a", "map", "of", "resolved", "users", "from", "uid", "to", "usernames", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/handle.go#L127-L137
158,553
keybase/client
go/kbfs/tlfhandle/handle.go
ResolvedWriters
func (h Handle) ResolvedWriters() []keybase1.UserOrTeamID { writers := h.unsortedResolvedWriters() sort.Sort(tlf.UIDList(writers)) return writers }
go
func (h Handle) ResolvedWriters() []keybase1.UserOrTeamID { writers := h.unsortedResolvedWriters() sort.Sort(tlf.UIDList(writers)) return writers }
[ "func", "(", "h", "Handle", ")", "ResolvedWriters", "(", ")", "[", "]", "keybase1", ".", "UserOrTeamID", "{", "writers", ":=", "h", ".", "unsortedResolvedWriters", "(", ")", "\n", "sort", ".", "Sort", "(", "tlf", ".", "UIDList", "(", "writers", ")", ")", "\n", "return", "writers", "\n", "}" ]
// ResolvedWriters returns the handle's resolved writer IDs in sorted // order.
[ "ResolvedWriters", "returns", "the", "handle", "s", "resolved", "writer", "IDs", "in", "sorted", "order", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/handle.go#L152-L156
158,554
keybase/client
go/kbfs/tlfhandle/handle.go
ResolvedReaders
func (h Handle) ResolvedReaders() []keybase1.UserOrTeamID { readers := h.unsortedResolvedReaders() sort.Sort(tlf.UIDList(readers)) return readers }
go
func (h Handle) ResolvedReaders() []keybase1.UserOrTeamID { readers := h.unsortedResolvedReaders() sort.Sort(tlf.UIDList(readers)) return readers }
[ "func", "(", "h", "Handle", ")", "ResolvedReaders", "(", ")", "[", "]", "keybase1", ".", "UserOrTeamID", "{", "readers", ":=", "h", ".", "unsortedResolvedReaders", "(", ")", "\n", "sort", ".", "Sort", "(", "tlf", ".", "UIDList", "(", "readers", ")", ")", "\n", "return", "readers", "\n", "}" ]
// ResolvedReaders returns the handle's resolved reader IDs in sorted // order. If the handle is public, nil will be returned.
[ "ResolvedReaders", "returns", "the", "handle", "s", "resolved", "reader", "IDs", "in", "sorted", "order", ".", "If", "the", "handle", "is", "public", "nil", "will", "be", "returned", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/handle.go#L178-L182
158,555
keybase/client
go/kbfs/tlfhandle/handle.go
UnresolvedWriters
func (h Handle) UnresolvedWriters() []keybase1.SocialAssertion { if len(h.unresolvedWriters) == 0 { return nil } unresolvedWriters := make([]keybase1.SocialAssertion, len(h.unresolvedWriters)) copy(unresolvedWriters, h.unresolvedWriters) return unresolvedWriters }
go
func (h Handle) UnresolvedWriters() []keybase1.SocialAssertion { if len(h.unresolvedWriters) == 0 { return nil } unresolvedWriters := make([]keybase1.SocialAssertion, len(h.unresolvedWriters)) copy(unresolvedWriters, h.unresolvedWriters) return unresolvedWriters }
[ "func", "(", "h", "Handle", ")", "UnresolvedWriters", "(", ")", "[", "]", "keybase1", ".", "SocialAssertion", "{", "if", "len", "(", "h", ".", "unresolvedWriters", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n", "unresolvedWriters", ":=", "make", "(", "[", "]", "keybase1", ".", "SocialAssertion", ",", "len", "(", "h", ".", "unresolvedWriters", ")", ")", "\n", "copy", "(", "unresolvedWriters", ",", "h", ".", "unresolvedWriters", ")", "\n", "return", "unresolvedWriters", "\n", "}" ]
// UnresolvedWriters returns the handle's unresolved writers in sorted // order.
[ "UnresolvedWriters", "returns", "the", "handle", "s", "unresolved", "writers", "in", "sorted", "order", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/handle.go#L186-L193
158,556
keybase/client
go/kbfs/tlfhandle/handle.go
UnresolvedReaders
func (h Handle) UnresolvedReaders() []keybase1.SocialAssertion { if len(h.unresolvedReaders) == 0 { return nil } unresolvedReaders := make([]keybase1.SocialAssertion, len(h.unresolvedReaders)) copy(unresolvedReaders, h.unresolvedReaders) return unresolvedReaders }
go
func (h Handle) UnresolvedReaders() []keybase1.SocialAssertion { if len(h.unresolvedReaders) == 0 { return nil } unresolvedReaders := make([]keybase1.SocialAssertion, len(h.unresolvedReaders)) copy(unresolvedReaders, h.unresolvedReaders) return unresolvedReaders }
[ "func", "(", "h", "Handle", ")", "UnresolvedReaders", "(", ")", "[", "]", "keybase1", ".", "SocialAssertion", "{", "if", "len", "(", "h", ".", "unresolvedReaders", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n", "unresolvedReaders", ":=", "make", "(", "[", "]", "keybase1", ".", "SocialAssertion", ",", "len", "(", "h", ".", "unresolvedReaders", ")", ")", "\n", "copy", "(", "unresolvedReaders", ",", "h", ".", "unresolvedReaders", ")", "\n", "return", "unresolvedReaders", "\n", "}" ]
// UnresolvedReaders returns the handle's unresolved readers in sorted // order. If the handle is public, nil will be returned.
[ "UnresolvedReaders", "returns", "the", "handle", "s", "unresolved", "readers", "in", "sorted", "order", ".", "If", "the", "handle", "is", "public", "nil", "will", "be", "returned", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/handle.go#L197-L204
158,557
keybase/client
go/kbfs/tlfhandle/handle.go
ConflictInfo
func (h Handle) ConflictInfo() *tlf.HandleExtension { if h.conflictInfo == nil { return nil } conflictInfoCopy := *h.conflictInfo return &conflictInfoCopy }
go
func (h Handle) ConflictInfo() *tlf.HandleExtension { if h.conflictInfo == nil { return nil } conflictInfoCopy := *h.conflictInfo return &conflictInfoCopy }
[ "func", "(", "h", "Handle", ")", "ConflictInfo", "(", ")", "*", "tlf", ".", "HandleExtension", "{", "if", "h", ".", "conflictInfo", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "conflictInfoCopy", ":=", "*", "h", ".", "conflictInfo", "\n", "return", "&", "conflictInfoCopy", "\n", "}" ]
// ConflictInfo returns the handle's conflict info, if any.
[ "ConflictInfo", "returns", "the", "handle", "s", "conflict", "info", "if", "any", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/handle.go#L207-L213
158,558
keybase/client
go/kbfs/tlfhandle/handle.go
FinalizedInfo
func (h Handle) FinalizedInfo() *tlf.HandleExtension { if h.finalizedInfo == nil { return nil } finalizedInfoCopy := *h.finalizedInfo return &finalizedInfoCopy }
go
func (h Handle) FinalizedInfo() *tlf.HandleExtension { if h.finalizedInfo == nil { return nil } finalizedInfoCopy := *h.finalizedInfo return &finalizedInfoCopy }
[ "func", "(", "h", "Handle", ")", "FinalizedInfo", "(", ")", "*", "tlf", ".", "HandleExtension", "{", "if", "h", ".", "finalizedInfo", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "finalizedInfoCopy", ":=", "*", "h", ".", "finalizedInfo", "\n", "return", "&", "finalizedInfoCopy", "\n", "}" ]
// FinalizedInfo returns the handle's finalized info, if any.
[ "FinalizedInfo", "returns", "the", "handle", "s", "finalized", "info", "if", "any", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/handle.go#L261-L267
158,559
keybase/client
go/kbfs/tlfhandle/handle.go
SetResolvedWriter
func (h *Handle) SetResolvedWriter( id keybase1.UserOrTeamID, name kbname.NormalizedUsername) { h.resolvedWriters[id] = name }
go
func (h *Handle) SetResolvedWriter( id keybase1.UserOrTeamID, name kbname.NormalizedUsername) { h.resolvedWriters[id] = name }
[ "func", "(", "h", "*", "Handle", ")", "SetResolvedWriter", "(", "id", "keybase1", ".", "UserOrTeamID", ",", "name", "kbname", ".", "NormalizedUsername", ")", "{", "h", ".", "resolvedWriters", "[", "id", "]", "=", "name", "\n", "}" ]
// SetResolvedWriter resolves the given `id` to the given `name`. // Useful for testing.
[ "SetResolvedWriter", "resolves", "the", "given", "id", "to", "the", "given", "name", ".", "Useful", "for", "testing", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/handle.go#L290-L293
158,560
keybase/client
go/kbfs/tlfhandle/handle.go
EqualsIgnoreName
func (h Handle) EqualsIgnoreName( codec kbfscodec.Codec, other Handle) (bool, error) { if h.tlfType != other.tlfType { return false, nil } if h.tlfID != other.tlfID { return false, nil } if !reflect.DeepEqual(h.resolvedWriters, other.resolvedWriters) { return false, nil } if !reflect.DeepEqual(h.resolvedReaders, other.resolvedReaders) { return false, nil } if !reflect.DeepEqual(h.unresolvedWriters, other.unresolvedWriters) { return false, nil } if !reflect.DeepEqual(h.unresolvedReaders, other.unresolvedReaders) { return false, nil } eq, err := kbfscodec.Equal(codec, h.conflictInfo, other.conflictInfo) if err != nil { return false, err } if !eq { return false, nil } eq, err = kbfscodec.Equal(codec, h.finalizedInfo, other.finalizedInfo) if err != nil { return false, err } return eq, nil }
go
func (h Handle) EqualsIgnoreName( codec kbfscodec.Codec, other Handle) (bool, error) { if h.tlfType != other.tlfType { return false, nil } if h.tlfID != other.tlfID { return false, nil } if !reflect.DeepEqual(h.resolvedWriters, other.resolvedWriters) { return false, nil } if !reflect.DeepEqual(h.resolvedReaders, other.resolvedReaders) { return false, nil } if !reflect.DeepEqual(h.unresolvedWriters, other.unresolvedWriters) { return false, nil } if !reflect.DeepEqual(h.unresolvedReaders, other.unresolvedReaders) { return false, nil } eq, err := kbfscodec.Equal(codec, h.conflictInfo, other.conflictInfo) if err != nil { return false, err } if !eq { return false, nil } eq, err = kbfscodec.Equal(codec, h.finalizedInfo, other.finalizedInfo) if err != nil { return false, err } return eq, nil }
[ "func", "(", "h", "Handle", ")", "EqualsIgnoreName", "(", "codec", "kbfscodec", ".", "Codec", ",", "other", "Handle", ")", "(", "bool", ",", "error", ")", "{", "if", "h", ".", "tlfType", "!=", "other", ".", "tlfType", "{", "return", "false", ",", "nil", "\n", "}", "\n", "if", "h", ".", "tlfID", "!=", "other", ".", "tlfID", "{", "return", "false", ",", "nil", "\n", "}", "\n\n", "if", "!", "reflect", ".", "DeepEqual", "(", "h", ".", "resolvedWriters", ",", "other", ".", "resolvedWriters", ")", "{", "return", "false", ",", "nil", "\n", "}", "\n\n", "if", "!", "reflect", ".", "DeepEqual", "(", "h", ".", "resolvedReaders", ",", "other", ".", "resolvedReaders", ")", "{", "return", "false", ",", "nil", "\n", "}", "\n\n", "if", "!", "reflect", ".", "DeepEqual", "(", "h", ".", "unresolvedWriters", ",", "other", ".", "unresolvedWriters", ")", "{", "return", "false", ",", "nil", "\n", "}", "\n\n", "if", "!", "reflect", ".", "DeepEqual", "(", "h", ".", "unresolvedReaders", ",", "other", ".", "unresolvedReaders", ")", "{", "return", "false", ",", "nil", "\n", "}", "\n\n", "eq", ",", "err", ":=", "kbfscodec", ".", "Equal", "(", "codec", ",", "h", ".", "conflictInfo", ",", "other", ".", "conflictInfo", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n", "if", "!", "eq", "{", "return", "false", ",", "nil", "\n", "}", "\n\n", "eq", ",", "err", "=", "kbfscodec", ".", "Equal", "(", "codec", ",", "h", ".", "finalizedInfo", ",", "other", ".", "finalizedInfo", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n", "return", "eq", ",", "nil", "\n", "}" ]
// EqualsIgnoreName returns whether h and other contain the same info ignoring the name.
[ "EqualsIgnoreName", "returns", "whether", "h", "and", "other", "contain", "the", "same", "info", "ignoring", "the", "name", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/handle.go#L327-L365
158,561
keybase/client
go/kbfs/tlfhandle/handle.go
Equals
func (h Handle) Equals( codec kbfscodec.Codec, other Handle) (bool, error) { eq, err := h.EqualsIgnoreName(codec, other) if err != nil { return false, err } if eq && h.name != other.name { return false, nil } return eq, nil }
go
func (h Handle) Equals( codec kbfscodec.Codec, other Handle) (bool, error) { eq, err := h.EqualsIgnoreName(codec, other) if err != nil { return false, err } if eq && h.name != other.name { return false, nil } return eq, nil }
[ "func", "(", "h", "Handle", ")", "Equals", "(", "codec", "kbfscodec", ".", "Codec", ",", "other", "Handle", ")", "(", "bool", ",", "error", ")", "{", "eq", ",", "err", ":=", "h", ".", "EqualsIgnoreName", "(", "codec", ",", "other", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n\n", "if", "eq", "&&", "h", ".", "name", "!=", "other", ".", "name", "{", "return", "false", ",", "nil", "\n", "}", "\n\n", "return", "eq", ",", "nil", "\n", "}" ]
// Equals returns whether h and other contain the same info.
[ "Equals", "returns", "whether", "h", "and", "other", "contain", "the", "same", "info", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/handle.go#L368-L380
158,562
keybase/client
go/kbfs/tlfhandle/handle.go
ToBareHandle
func (h Handle) ToBareHandle() (tlf.Handle, error) { var readers []keybase1.UserOrTeamID switch h.TypeForKeying() { case tlf.PublicKeying: readers = []keybase1.UserOrTeamID{ keybase1.UserOrTeamID(keybase1.PUBLIC_UID)} case tlf.TeamKeying: // Leave readers blank. default: readers = h.unsortedResolvedReaders() } return tlf.MakeHandle( h.unsortedResolvedWriters(), readers, h.unresolvedWriters, h.unresolvedReaders, h.Extensions()) }
go
func (h Handle) ToBareHandle() (tlf.Handle, error) { var readers []keybase1.UserOrTeamID switch h.TypeForKeying() { case tlf.PublicKeying: readers = []keybase1.UserOrTeamID{ keybase1.UserOrTeamID(keybase1.PUBLIC_UID)} case tlf.TeamKeying: // Leave readers blank. default: readers = h.unsortedResolvedReaders() } return tlf.MakeHandle( h.unsortedResolvedWriters(), readers, h.unresolvedWriters, h.unresolvedReaders, h.Extensions()) }
[ "func", "(", "h", "Handle", ")", "ToBareHandle", "(", ")", "(", "tlf", ".", "Handle", ",", "error", ")", "{", "var", "readers", "[", "]", "keybase1", ".", "UserOrTeamID", "\n", "switch", "h", ".", "TypeForKeying", "(", ")", "{", "case", "tlf", ".", "PublicKeying", ":", "readers", "=", "[", "]", "keybase1", ".", "UserOrTeamID", "{", "keybase1", ".", "UserOrTeamID", "(", "keybase1", ".", "PUBLIC_UID", ")", "}", "\n", "case", "tlf", ".", "TeamKeying", ":", "// Leave readers blank.", "default", ":", "readers", "=", "h", ".", "unsortedResolvedReaders", "(", ")", "\n", "}", "\n", "return", "tlf", ".", "MakeHandle", "(", "h", ".", "unsortedResolvedWriters", "(", ")", ",", "readers", ",", "h", ".", "unresolvedWriters", ",", "h", ".", "unresolvedReaders", ",", "h", ".", "Extensions", "(", ")", ")", "\n", "}" ]
// ToBareHandle returns a tlf.Handle corresponding to this handle.
[ "ToBareHandle", "returns", "a", "tlf", ".", "Handle", "corresponding", "to", "this", "handle", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/handle.go#L383-L398
158,563
keybase/client
go/kbfs/tlfhandle/handle.go
ToBareHandleOrBust
func (h Handle) ToBareHandleOrBust() tlf.Handle { bh, err := h.ToBareHandle() if err != nil { panic(err) } return bh }
go
func (h Handle) ToBareHandleOrBust() tlf.Handle { bh, err := h.ToBareHandle() if err != nil { panic(err) } return bh }
[ "func", "(", "h", "Handle", ")", "ToBareHandleOrBust", "(", ")", "tlf", ".", "Handle", "{", "bh", ",", "err", ":=", "h", ".", "ToBareHandle", "(", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "return", "bh", "\n", "}" ]
// ToBareHandleOrBust returns a tlf.Handle corresponding to this // handle, and panics if there's an error. Used by tests.
[ "ToBareHandleOrBust", "returns", "a", "tlf", ".", "Handle", "corresponding", "to", "this", "handle", "and", "panics", "if", "there", "s", "an", "error", ".", "Used", "by", "tests", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/handle.go#L402-L408
158,564
keybase/client
go/kbfs/tlfhandle/handle.go
DeepCopy
func (h Handle) DeepCopy() *Handle { hCopy := Handle{ tlfType: h.tlfType, name: h.name, unresolvedWriters: h.UnresolvedWriters(), unresolvedReaders: h.UnresolvedReaders(), conflictInfo: h.ConflictInfo(), finalizedInfo: h.FinalizedInfo(), tlfID: h.tlfID, } hCopy.resolvedWriters = make(map[keybase1.UserOrTeamID]kbname.NormalizedUsername, len(h.resolvedWriters)) for k, v := range h.resolvedWriters { hCopy.resolvedWriters[k] = v } hCopy.resolvedReaders = make(map[keybase1.UserOrTeamID]kbname.NormalizedUsername, len(h.resolvedReaders)) for k, v := range h.resolvedReaders { hCopy.resolvedReaders[k] = v } return &hCopy }
go
func (h Handle) DeepCopy() *Handle { hCopy := Handle{ tlfType: h.tlfType, name: h.name, unresolvedWriters: h.UnresolvedWriters(), unresolvedReaders: h.UnresolvedReaders(), conflictInfo: h.ConflictInfo(), finalizedInfo: h.FinalizedInfo(), tlfID: h.tlfID, } hCopy.resolvedWriters = make(map[keybase1.UserOrTeamID]kbname.NormalizedUsername, len(h.resolvedWriters)) for k, v := range h.resolvedWriters { hCopy.resolvedWriters[k] = v } hCopy.resolvedReaders = make(map[keybase1.UserOrTeamID]kbname.NormalizedUsername, len(h.resolvedReaders)) for k, v := range h.resolvedReaders { hCopy.resolvedReaders[k] = v } return &hCopy }
[ "func", "(", "h", "Handle", ")", "DeepCopy", "(", ")", "*", "Handle", "{", "hCopy", ":=", "Handle", "{", "tlfType", ":", "h", ".", "tlfType", ",", "name", ":", "h", ".", "name", ",", "unresolvedWriters", ":", "h", ".", "UnresolvedWriters", "(", ")", ",", "unresolvedReaders", ":", "h", ".", "UnresolvedReaders", "(", ")", ",", "conflictInfo", ":", "h", ".", "ConflictInfo", "(", ")", ",", "finalizedInfo", ":", "h", ".", "FinalizedInfo", "(", ")", ",", "tlfID", ":", "h", ".", "tlfID", ",", "}", "\n\n", "hCopy", ".", "resolvedWriters", "=", "make", "(", "map", "[", "keybase1", ".", "UserOrTeamID", "]", "kbname", ".", "NormalizedUsername", ",", "len", "(", "h", ".", "resolvedWriters", ")", ")", "\n", "for", "k", ",", "v", ":=", "range", "h", ".", "resolvedWriters", "{", "hCopy", ".", "resolvedWriters", "[", "k", "]", "=", "v", "\n", "}", "\n\n", "hCopy", ".", "resolvedReaders", "=", "make", "(", "map", "[", "keybase1", ".", "UserOrTeamID", "]", "kbname", ".", "NormalizedUsername", ",", "len", "(", "h", ".", "resolvedReaders", ")", ")", "\n", "for", "k", ",", "v", ":=", "range", "h", ".", "resolvedReaders", "{", "hCopy", ".", "resolvedReaders", "[", "k", "]", "=", "v", "\n", "}", "\n\n", "return", "&", "hCopy", "\n", "}" ]
// DeepCopy makes a deep copy of this `Handle`.
[ "DeepCopy", "makes", "a", "deep", "copy", "of", "this", "Handle", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/handle.go#L411-L433
158,565
keybase/client
go/kbfs/tlfhandle/handle.go
GetCanonicalName
func (h *Handle) GetCanonicalName() tlf.CanonicalName { if h.name == "" { panic(fmt.Sprintf("TlfHandle %v with no name", h)) } return h.name }
go
func (h *Handle) GetCanonicalName() tlf.CanonicalName { if h.name == "" { panic(fmt.Sprintf("TlfHandle %v with no name", h)) } return h.name }
[ "func", "(", "h", "*", "Handle", ")", "GetCanonicalName", "(", ")", "tlf", ".", "CanonicalName", "{", "if", "h", ".", "name", "==", "\"", "\"", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "h", ")", ")", "\n", "}", "\n\n", "return", "h", ".", "name", "\n", "}" ]
// GetCanonicalName returns the canonical name of this TLF.
[ "GetCanonicalName", "returns", "the", "canonical", "name", "of", "this", "TLF", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/handle.go#L436-L442
158,566
keybase/client
go/kbfs/tlfhandle/handle.go
ToFavorite
func (h *Handle) ToFavorite() favorites.Folder { return favorites.Folder{ Name: string(h.GetCanonicalName()), Type: h.Type(), } }
go
func (h *Handle) ToFavorite() favorites.Folder { return favorites.Folder{ Name: string(h.GetCanonicalName()), Type: h.Type(), } }
[ "func", "(", "h", "*", "Handle", ")", "ToFavorite", "(", ")", "favorites", ".", "Folder", "{", "return", "favorites", ".", "Folder", "{", "Name", ":", "string", "(", "h", ".", "GetCanonicalName", "(", ")", ")", ",", "Type", ":", "h", ".", "Type", "(", ")", ",", "}", "\n", "}" ]
// ToFavorite converts a TlfHandle into a Favorite, suitable for // Favorites calls.
[ "ToFavorite", "converts", "a", "TlfHandle", "into", "a", "Favorite", "suitable", "for", "Favorites", "calls", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/handle.go#L451-L456
158,567
keybase/client
go/kbfs/tlfhandle/handle.go
FavoriteData
func (h *Handle) FavoriteData() favorites.Data { fd := favorites.Data{ Name: string(h.GetCanonicalName()), FolderType: h.Type().FolderType(), Private: h.Type() != tlf.Public, ResetMembers: []keybase1.User{}, } if h.IsBackedByTeam() { teamID := h.FirstResolvedWriter().AsTeamOrBust() fd.TeamID = &teamID } return fd }
go
func (h *Handle) FavoriteData() favorites.Data { fd := favorites.Data{ Name: string(h.GetCanonicalName()), FolderType: h.Type().FolderType(), Private: h.Type() != tlf.Public, ResetMembers: []keybase1.User{}, } if h.IsBackedByTeam() { teamID := h.FirstResolvedWriter().AsTeamOrBust() fd.TeamID = &teamID } return fd }
[ "func", "(", "h", "*", "Handle", ")", "FavoriteData", "(", ")", "favorites", ".", "Data", "{", "fd", ":=", "favorites", ".", "Data", "{", "Name", ":", "string", "(", "h", ".", "GetCanonicalName", "(", ")", ")", ",", "FolderType", ":", "h", ".", "Type", "(", ")", ".", "FolderType", "(", ")", ",", "Private", ":", "h", ".", "Type", "(", ")", "!=", "tlf", ".", "Public", ",", "ResetMembers", ":", "[", "]", "keybase1", ".", "User", "{", "}", ",", "}", "\n", "if", "h", ".", "IsBackedByTeam", "(", ")", "{", "teamID", ":=", "h", ".", "FirstResolvedWriter", "(", ")", ".", "AsTeamOrBust", "(", ")", "\n", "fd", ".", "TeamID", "=", "&", "teamID", "\n", "}", "\n", "return", "fd", "\n", "}" ]
// FavoriteData converts a TlfHandle into FavoriteData, suitable for // Favorites calls.
[ "FavoriteData", "converts", "a", "TlfHandle", "into", "FavoriteData", "suitable", "for", "Favorites", "calls", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/handle.go#L460-L472
158,568
keybase/client
go/kbfs/tlfhandle/handle.go
ToFavToAdd
func (h *Handle) ToFavToAdd(created bool) favorites.ToAdd { return favorites.ToAdd{ Folder: h.ToFavorite(), Data: h.FavoriteData(), Created: created, } }
go
func (h *Handle) ToFavToAdd(created bool) favorites.ToAdd { return favorites.ToAdd{ Folder: h.ToFavorite(), Data: h.FavoriteData(), Created: created, } }
[ "func", "(", "h", "*", "Handle", ")", "ToFavToAdd", "(", "created", "bool", ")", "favorites", ".", "ToAdd", "{", "return", "favorites", ".", "ToAdd", "{", "Folder", ":", "h", ".", "ToFavorite", "(", ")", ",", "Data", ":", "h", ".", "FavoriteData", "(", ")", ",", "Created", ":", "created", ",", "}", "\n", "}" ]
// ToFavToAdd converts a TlfHandle into a Favorite to be added, and // sets internal state about whether the corresponding folder was just // created or not.
[ "ToFavToAdd", "converts", "a", "TlfHandle", "into", "a", "Favorite", "to", "be", "added", "and", "sets", "internal", "state", "about", "whether", "the", "corresponding", "folder", "was", "just", "created", "or", "not", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/handle.go#L477-L483
158,569
keybase/client
go/kbfs/tlfhandle/handle.go
CheckHandleOffline
func CheckHandleOffline( ctx context.Context, name string, t tlf.Type) error { _, _, _, err := idutil.SplitAndNormalizeTLFName(name, t) return err }
go
func CheckHandleOffline( ctx context.Context, name string, t tlf.Type) error { _, _, _, err := idutil.SplitAndNormalizeTLFName(name, t) return err }
[ "func", "CheckHandleOffline", "(", "ctx", "context", ".", "Context", ",", "name", "string", ",", "t", "tlf", ".", "Type", ")", "error", "{", "_", ",", "_", ",", "_", ",", "err", ":=", "idutil", ".", "SplitAndNormalizeTLFName", "(", "name", ",", "t", ")", "\n", "return", "err", "\n", "}" ]
// CheckHandleOffline does light checks whether a TLF handle looks ok, // it avoids all network calls.
[ "CheckHandleOffline", "does", "light", "checks", "whether", "a", "TLF", "handle", "looks", "ok", "it", "avoids", "all", "network", "calls", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/handle.go#L496-L500
158,570
keybase/client
go/kbfs/tlfhandle/handle.go
GetPreferredFormat
func (h Handle) GetPreferredFormat( username kbname.NormalizedUsername) tlf.PreferredName { s, err := tlf.CanonicalToPreferredName(username, h.GetCanonicalName()) if err != nil { panic("TlfHandle.GetPreferredFormat: Parsing canonical username failed!") } return s }
go
func (h Handle) GetPreferredFormat( username kbname.NormalizedUsername) tlf.PreferredName { s, err := tlf.CanonicalToPreferredName(username, h.GetCanonicalName()) if err != nil { panic("TlfHandle.GetPreferredFormat: Parsing canonical username failed!") } return s }
[ "func", "(", "h", "Handle", ")", "GetPreferredFormat", "(", "username", "kbname", ".", "NormalizedUsername", ")", "tlf", ".", "PreferredName", "{", "s", ",", "err", ":=", "tlf", ".", "CanonicalToPreferredName", "(", "username", ",", "h", ".", "GetCanonicalName", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "s", "\n", "}" ]
// GetPreferredFormat returns a TLF name formatted with the username given // as the parameter first. // This calls tlf.CanonicalToPreferredName with the canonical // tlf name which will be reordered into the preferred format. // An empty username is allowed here and results in the canonical ordering.
[ "GetPreferredFormat", "returns", "a", "TLF", "name", "formatted", "with", "the", "username", "given", "as", "the", "parameter", "first", ".", "This", "calls", "tlf", ".", "CanonicalToPreferredName", "with", "the", "canonical", "tlf", "name", "which", "will", "be", "reordered", "into", "the", "preferred", "format", ".", "An", "empty", "username", "is", "allowed", "here", "and", "results", "in", "the", "canonical", "ordering", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/handle.go#L519-L526
158,571
keybase/client
go/teams/seitan_v2.go
IsSeitany
func IsSeitany(s string) bool { return len(s) > seitanEncodedIKeyV2PlusOffset && strings.IndexByte(s, '+') > 1 }
go
func IsSeitany(s string) bool { return len(s) > seitanEncodedIKeyV2PlusOffset && strings.IndexByte(s, '+') > 1 }
[ "func", "IsSeitany", "(", "s", "string", ")", "bool", "{", "return", "len", "(", "s", ")", ">", "seitanEncodedIKeyV2PlusOffset", "&&", "strings", ".", "IndexByte", "(", "s", ",", "'+'", ")", ">", "1", "\n", "}" ]
// IsSeitany is a very conservative check of whether a given string looks // like a Seitan token. We want to err on the side of considering strings // Seitan tokens, since we don't mistakenly want to send botched Seitan // tokens to the server.
[ "IsSeitany", "is", "a", "very", "conservative", "check", "of", "whether", "a", "given", "string", "looks", "like", "a", "Seitan", "token", ".", "We", "want", "to", "err", "on", "the", "side", "of", "considering", "strings", "Seitan", "tokens", "since", "we", "don", "t", "mistakenly", "want", "to", "send", "botched", "Seitan", "tokens", "to", "the", "server", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/seitan_v2.go#L33-L35
158,572
keybase/client
go/teams/seitan_v2.go
ParseIKeyV2FromString
func ParseIKeyV2FromString(token string) (ikey SeitanIKeyV2, err error) { if len(token) != SeitanEncodedIKeyLength { return ikey, fmt.Errorf("invalid token length: expected %d characters, got %d", SeitanEncodedIKeyLength, len(token)) } if token[seitanEncodedIKeyV2PlusOffset] != '+' { return ikey, fmt.Errorf("invalid token format: expected %dth character to be '+'", seitanEncodedIKeyV2PlusOffset+1) } return SeitanIKeyV2(strings.ToLower(token)), nil }
go
func ParseIKeyV2FromString(token string) (ikey SeitanIKeyV2, err error) { if len(token) != SeitanEncodedIKeyLength { return ikey, fmt.Errorf("invalid token length: expected %d characters, got %d", SeitanEncodedIKeyLength, len(token)) } if token[seitanEncodedIKeyV2PlusOffset] != '+' { return ikey, fmt.Errorf("invalid token format: expected %dth character to be '+'", seitanEncodedIKeyV2PlusOffset+1) } return SeitanIKeyV2(strings.ToLower(token)), nil }
[ "func", "ParseIKeyV2FromString", "(", "token", "string", ")", "(", "ikey", "SeitanIKeyV2", ",", "err", "error", ")", "{", "if", "len", "(", "token", ")", "!=", "SeitanEncodedIKeyLength", "{", "return", "ikey", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "SeitanEncodedIKeyLength", ",", "len", "(", "token", ")", ")", "\n", "}", "\n", "if", "token", "[", "seitanEncodedIKeyV2PlusOffset", "]", "!=", "'+'", "{", "return", "ikey", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "seitanEncodedIKeyV2PlusOffset", "+", "1", ")", "\n", "}", "\n\n", "return", "SeitanIKeyV2", "(", "strings", ".", "ToLower", "(", "token", ")", ")", ",", "nil", "\n", "}" ]
// ParseIKeyV2FromString safely creates SeitanIKey value from // plaintext string. Only format is checked - any 18-character token // with '+' character at position 6 can be "Invite Key". Alphabet is // not checked, as it is only a hint for token generation and it can // change over time, but we assume that token length stays the same.
[ "ParseIKeyV2FromString", "safely", "creates", "SeitanIKey", "value", "from", "plaintext", "string", ".", "Only", "format", "is", "checked", "-", "any", "18", "-", "character", "token", "with", "+", "character", "at", "position", "6", "can", "be", "Invite", "Key", ".", "Alphabet", "is", "not", "checked", "as", "it", "is", "only", "a", "hint", "for", "token", "generation", "and", "it", "can", "change", "over", "time", "but", "we", "assume", "that", "token", "length", "stays", "the", "same", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/seitan_v2.go#L61-L70
158,573
keybase/client
go/kbnm/findbin.go
findKeybaseBinary
func findKeybaseBinary(name string) (string, error) { // Is it near the kbnm binary? binPath, err := utils.BinPath() if err == nil { path := filepath.Join(filepath.Dir(binPath), name) if _, err := os.Stat(path); !os.IsNotExist(err) { return path, nil } } // Is it in our PATH? path, err := exec.LookPath(name) if err == nil { return path, nil } // Last ditch effort! path = guessKeybasePath(name) if _, err := os.Stat(path); !os.IsNotExist(err) { return path, nil } return "", errKeybaseNotFound }
go
func findKeybaseBinary(name string) (string, error) { // Is it near the kbnm binary? binPath, err := utils.BinPath() if err == nil { path := filepath.Join(filepath.Dir(binPath), name) if _, err := os.Stat(path); !os.IsNotExist(err) { return path, nil } } // Is it in our PATH? path, err := exec.LookPath(name) if err == nil { return path, nil } // Last ditch effort! path = guessKeybasePath(name) if _, err := os.Stat(path); !os.IsNotExist(err) { return path, nil } return "", errKeybaseNotFound }
[ "func", "findKeybaseBinary", "(", "name", "string", ")", "(", "string", ",", "error", ")", "{", "// Is it near the kbnm binary?", "binPath", ",", "err", ":=", "utils", ".", "BinPath", "(", ")", "\n", "if", "err", "==", "nil", "{", "path", ":=", "filepath", ".", "Join", "(", "filepath", ".", "Dir", "(", "binPath", ")", ",", "name", ")", "\n", "if", "_", ",", "err", ":=", "os", ".", "Stat", "(", "path", ")", ";", "!", "os", ".", "IsNotExist", "(", "err", ")", "{", "return", "path", ",", "nil", "\n", "}", "\n", "}", "\n\n", "// Is it in our PATH?", "path", ",", "err", ":=", "exec", ".", "LookPath", "(", "name", ")", "\n", "if", "err", "==", "nil", "{", "return", "path", ",", "nil", "\n", "}", "\n\n", "// Last ditch effort!", "path", "=", "guessKeybasePath", "(", "name", ")", "\n", "if", "_", ",", "err", ":=", "os", ".", "Stat", "(", "path", ")", ";", "!", "os", ".", "IsNotExist", "(", "err", ")", "{", "return", "path", ",", "nil", "\n", "}", "\n\n", "return", "\"", "\"", ",", "errKeybaseNotFound", "\n", "}" ]
// findKeybaseBinary returns the path to a Keybase binary, if it finds it.
[ "findKeybaseBinary", "returns", "the", "path", "to", "a", "Keybase", "binary", "if", "it", "finds", "it", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbnm/findbin.go#L15-L38
158,574
keybase/client
go/libkb/pgp_key.go
StripRevocations
func (k *PGPKeyBundle) StripRevocations() (strippedKey *PGPKeyBundle) { strippedKey = nil if k.ArmoredPublicKey != "" { // Re-read the key because we want to return a copy, that does // not reference PGPKeyBundle `k` anywhere. strippedKey, _, _ = ReadOneKeyFromString(k.ArmoredPublicKey) } if strippedKey == nil { // Either Armored key was not saved or ReadOneKeyFromString // failed. Do old behavior here - we won't have a proper copy // of the key (there is a lot of pointers in the key structs), // but at least we won't have to bail out completely. entityCopy := *k.Entity strippedKey = &PGPKeyBundle{Entity: &entityCopy} } strippedKey.Revocations = nil oldSubkeys := strippedKey.Subkeys strippedKey.Subkeys = nil for _, subkey := range oldSubkeys { // Skip revoked subkeys if subkey.Sig.SigType == packet.SigTypeSubkeyBinding && subkey.Revocation == nil { strippedKey.Subkeys = append(strippedKey.Subkeys, subkey) } } return }
go
func (k *PGPKeyBundle) StripRevocations() (strippedKey *PGPKeyBundle) { strippedKey = nil if k.ArmoredPublicKey != "" { // Re-read the key because we want to return a copy, that does // not reference PGPKeyBundle `k` anywhere. strippedKey, _, _ = ReadOneKeyFromString(k.ArmoredPublicKey) } if strippedKey == nil { // Either Armored key was not saved or ReadOneKeyFromString // failed. Do old behavior here - we won't have a proper copy // of the key (there is a lot of pointers in the key structs), // but at least we won't have to bail out completely. entityCopy := *k.Entity strippedKey = &PGPKeyBundle{Entity: &entityCopy} } strippedKey.Revocations = nil oldSubkeys := strippedKey.Subkeys strippedKey.Subkeys = nil for _, subkey := range oldSubkeys { // Skip revoked subkeys if subkey.Sig.SigType == packet.SigTypeSubkeyBinding && subkey.Revocation == nil { strippedKey.Subkeys = append(strippedKey.Subkeys, subkey) } } return }
[ "func", "(", "k", "*", "PGPKeyBundle", ")", "StripRevocations", "(", ")", "(", "strippedKey", "*", "PGPKeyBundle", ")", "{", "strippedKey", "=", "nil", "\n", "if", "k", ".", "ArmoredPublicKey", "!=", "\"", "\"", "{", "// Re-read the key because we want to return a copy, that does", "// not reference PGPKeyBundle `k` anywhere.", "strippedKey", ",", "_", ",", "_", "=", "ReadOneKeyFromString", "(", "k", ".", "ArmoredPublicKey", ")", "\n", "}", "\n\n", "if", "strippedKey", "==", "nil", "{", "// Either Armored key was not saved or ReadOneKeyFromString", "// failed. Do old behavior here - we won't have a proper copy", "// of the key (there is a lot of pointers in the key structs),", "// but at least we won't have to bail out completely.", "entityCopy", ":=", "*", "k", ".", "Entity", "\n", "strippedKey", "=", "&", "PGPKeyBundle", "{", "Entity", ":", "&", "entityCopy", "}", "\n", "}", "\n\n", "strippedKey", ".", "Revocations", "=", "nil", "\n\n", "oldSubkeys", ":=", "strippedKey", ".", "Subkeys", "\n", "strippedKey", ".", "Subkeys", "=", "nil", "\n", "for", "_", ",", "subkey", ":=", "range", "oldSubkeys", "{", "// Skip revoked subkeys", "if", "subkey", ".", "Sig", ".", "SigType", "==", "packet", ".", "SigTypeSubkeyBinding", "&&", "subkey", ".", "Revocation", "==", "nil", "{", "strippedKey", ".", "Subkeys", "=", "append", "(", "strippedKey", ".", "Subkeys", ",", "subkey", ")", "\n", "}", "\n", "}", "\n", "return", "\n", "}" ]
// StripRevocations returns a copy of the key with revocations removed
[ "StripRevocations", "returns", "a", "copy", "of", "the", "key", "with", "revocations", "removed" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/pgp_key.go#L158-L186
158,575
keybase/client
go/libkb/pgp_key.go
firstPrivateKey
func firstPrivateKey(s string) (string, error) { scanner := bufio.NewScanner(strings.NewReader(s)) var lines []string looking := true complete := false for scanner.Scan() { line := scanner.Text() if looking && strings.HasPrefix(line, "-----BEGIN PGP PRIVATE KEY BLOCK-----") { looking = false } if looking { continue } lines = append(lines, line) if strings.HasPrefix(line, "-----END PGP PRIVATE KEY BLOCK-----") { complete = true break } } if err := scanner.Err(); err != nil { return "", err } if looking { // never found a private key block return "", NoSecretKeyError{} } if !complete { // string ended without the end tag return "", errors.New("never found end block line") } return strings.Join(lines, "\n"), nil }
go
func firstPrivateKey(s string) (string, error) { scanner := bufio.NewScanner(strings.NewReader(s)) var lines []string looking := true complete := false for scanner.Scan() { line := scanner.Text() if looking && strings.HasPrefix(line, "-----BEGIN PGP PRIVATE KEY BLOCK-----") { looking = false } if looking { continue } lines = append(lines, line) if strings.HasPrefix(line, "-----END PGP PRIVATE KEY BLOCK-----") { complete = true break } } if err := scanner.Err(); err != nil { return "", err } if looking { // never found a private key block return "", NoSecretKeyError{} } if !complete { // string ended without the end tag return "", errors.New("never found end block line") } return strings.Join(lines, "\n"), nil }
[ "func", "firstPrivateKey", "(", "s", "string", ")", "(", "string", ",", "error", ")", "{", "scanner", ":=", "bufio", ".", "NewScanner", "(", "strings", ".", "NewReader", "(", "s", ")", ")", "\n", "var", "lines", "[", "]", "string", "\n", "looking", ":=", "true", "\n", "complete", ":=", "false", "\n", "for", "scanner", ".", "Scan", "(", ")", "{", "line", ":=", "scanner", ".", "Text", "(", ")", "\n", "if", "looking", "&&", "strings", ".", "HasPrefix", "(", "line", ",", "\"", "\"", ")", "{", "looking", "=", "false", "\n\n", "}", "\n", "if", "looking", "{", "continue", "\n", "}", "\n", "lines", "=", "append", "(", "lines", ",", "line", ")", "\n", "if", "strings", ".", "HasPrefix", "(", "line", ",", "\"", "\"", ")", "{", "complete", "=", "true", "\n", "break", "\n", "}", "\n", "}", "\n", "if", "err", ":=", "scanner", ".", "Err", "(", ")", ";", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "if", "looking", "{", "// never found a private key block", "return", "\"", "\"", ",", "NoSecretKeyError", "{", "}", "\n", "}", "\n", "if", "!", "complete", "{", "// string ended without the end tag", "return", "\"", "\"", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "strings", ".", "Join", "(", "lines", ",", "\"", "\\n", "\"", ")", ",", "nil", "\n", "}" ]
// firstPrivateKey scans s for a private key block.
[ "firstPrivateKey", "scans", "s", "for", "a", "private", "key", "block", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/pgp_key.go#L400-L432
158,576
keybase/client
go/libkb/pgp_key.go
ReadPrivateKeyFromString
func ReadPrivateKeyFromString(s string) (*PGPKeyBundle, *Warnings, error) { priv, err := firstPrivateKey(s) if err != nil { return nil, &Warnings{}, err } return ReadOneKeyFromString(priv) }
go
func ReadPrivateKeyFromString(s string) (*PGPKeyBundle, *Warnings, error) { priv, err := firstPrivateKey(s) if err != nil { return nil, &Warnings{}, err } return ReadOneKeyFromString(priv) }
[ "func", "ReadPrivateKeyFromString", "(", "s", "string", ")", "(", "*", "PGPKeyBundle", ",", "*", "Warnings", ",", "error", ")", "{", "priv", ",", "err", ":=", "firstPrivateKey", "(", "s", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "&", "Warnings", "{", "}", ",", "err", "\n", "}", "\n", "return", "ReadOneKeyFromString", "(", "priv", ")", "\n", "}" ]
// ReadPrivateKeyFromString finds the first private key block in s // and decodes it into a PGPKeyBundle. It is useful in the case // where s contains multiple key blocks and you want the private // key block. For example, the result of gpg export.
[ "ReadPrivateKeyFromString", "finds", "the", "first", "private", "key", "block", "in", "s", "and", "decodes", "it", "into", "a", "PGPKeyBundle", ".", "It", "is", "useful", "in", "the", "case", "where", "s", "contains", "multiple", "key", "blocks", "and", "you", "want", "the", "private", "key", "block", ".", "For", "example", "the", "result", "of", "gpg", "export", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/pgp_key.go#L438-L444
158,577
keybase/client
go/libkb/pgp_key.go
FindKeybaseUsername
func (k *PGPKeyBundle) FindKeybaseUsername(un string) bool { rxx := regexp.MustCompile("(?i)< " + un + "@keybase.io>$") for _, id := range k.Identities { if rxx.MatchString(id.Name) { return true } } return false }
go
func (k *PGPKeyBundle) FindKeybaseUsername(un string) bool { rxx := regexp.MustCompile("(?i)< " + un + "@keybase.io>$") for _, id := range k.Identities { if rxx.MatchString(id.Name) { return true } } return false }
[ "func", "(", "k", "*", "PGPKeyBundle", ")", "FindKeybaseUsername", "(", "un", "string", ")", "bool", "{", "rxx", ":=", "regexp", ".", "MustCompile", "(", "\"", "\"", "+", "un", "+", "\"", "\"", ")", "\n\n", "for", "_", ",", "id", ":=", "range", "k", ".", "Identities", "{", "if", "rxx", ".", "MatchString", "(", "id", ".", "Name", ")", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}" ]
// XXX for now this is OK but probably we need a PGP uid parser // as in pgp-utils
[ "XXX", "for", "now", "this", "is", "OK", "but", "probably", "we", "need", "a", "PGP", "uid", "parser", "as", "in", "pgp", "-", "utils" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/pgp_key.go#L505-L515
158,578
keybase/client
go/libkb/pgp_key.go
FindPGPPrivateKey
func FindPGPPrivateKey(k *PGPKeyBundle) bool { if k.PrivateKey.PrivateKey != nil { return true } for _, subKey := range k.Subkeys { if subKey.PrivateKey != nil && subKey.PrivateKey.PrivateKey != nil { return true } } return false }
go
func FindPGPPrivateKey(k *PGPKeyBundle) bool { if k.PrivateKey.PrivateKey != nil { return true } for _, subKey := range k.Subkeys { if subKey.PrivateKey != nil && subKey.PrivateKey.PrivateKey != nil { return true } } return false }
[ "func", "FindPGPPrivateKey", "(", "k", "*", "PGPKeyBundle", ")", "bool", "{", "if", "k", ".", "PrivateKey", ".", "PrivateKey", "!=", "nil", "{", "return", "true", "\n", "}", "\n\n", "for", "_", ",", "subKey", ":=", "range", "k", ".", "Subkeys", "{", "if", "subKey", ".", "PrivateKey", "!=", "nil", "&&", "subKey", ".", "PrivateKey", ".", "PrivateKey", "!=", "nil", "{", "return", "true", "\n", "}", "\n", "}", "\n\n", "return", "false", "\n", "}" ]
// FindPGPPrivateKey checks if supposed secret key PGPKeyBundle // contains any valid PrivateKey entities. Sometimes primary private // key is stoopped out but there are subkeys with secret keys.
[ "FindPGPPrivateKey", "checks", "if", "supposed", "secret", "key", "PGPKeyBundle", "contains", "any", "valid", "PrivateKey", "entities", ".", "Sometimes", "primary", "private", "key", "is", "stoopped", "out", "but", "there", "are", "subkeys", "with", "secret", "keys", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/pgp_key.go#L577-L589
158,579
keybase/client
go/libkb/pgp_key.go
CheckIdentity
func (k *PGPKeyBundle) CheckIdentity(kbid Identity) (match bool, ctime int64, etime int64) { ctime, etime = -1, -1 for _, pgpIdentity := range k.Identities { if Cicmp(pgpIdentity.UserId.Email, kbid.Email) { match = true ctime = pgpIdentity.SelfSignature.CreationTime.Unix() // This is a special case in OpenPGP, so we used KeyLifetimeSecs lifeSeconds := pgpIdentity.SelfSignature.KeyLifetimeSecs if lifeSeconds == nil { // No expiration time is OK, it just means it never expires. etime = 0 } else { etime = ctime + int64(*lifeSeconds) } break } } return }
go
func (k *PGPKeyBundle) CheckIdentity(kbid Identity) (match bool, ctime int64, etime int64) { ctime, etime = -1, -1 for _, pgpIdentity := range k.Identities { if Cicmp(pgpIdentity.UserId.Email, kbid.Email) { match = true ctime = pgpIdentity.SelfSignature.CreationTime.Unix() // This is a special case in OpenPGP, so we used KeyLifetimeSecs lifeSeconds := pgpIdentity.SelfSignature.KeyLifetimeSecs if lifeSeconds == nil { // No expiration time is OK, it just means it never expires. etime = 0 } else { etime = ctime + int64(*lifeSeconds) } break } } return }
[ "func", "(", "k", "*", "PGPKeyBundle", ")", "CheckIdentity", "(", "kbid", "Identity", ")", "(", "match", "bool", ",", "ctime", "int64", ",", "etime", "int64", ")", "{", "ctime", ",", "etime", "=", "-", "1", ",", "-", "1", "\n", "for", "_", ",", "pgpIdentity", ":=", "range", "k", ".", "Identities", "{", "if", "Cicmp", "(", "pgpIdentity", ".", "UserId", ".", "Email", ",", "kbid", ".", "Email", ")", "{", "match", "=", "true", "\n", "ctime", "=", "pgpIdentity", ".", "SelfSignature", ".", "CreationTime", ".", "Unix", "(", ")", "\n", "// This is a special case in OpenPGP, so we used KeyLifetimeSecs", "lifeSeconds", ":=", "pgpIdentity", ".", "SelfSignature", ".", "KeyLifetimeSecs", "\n", "if", "lifeSeconds", "==", "nil", "{", "// No expiration time is OK, it just means it never expires.", "etime", "=", "0", "\n", "}", "else", "{", "etime", "=", "ctime", "+", "int64", "(", "*", "lifeSeconds", ")", "\n", "}", "\n", "break", "\n", "}", "\n", "}", "\n", "return", "\n", "}" ]
// CheckIdentity finds the [email protected] PGP identity and figures out when it // was created and when it's slated to expire. We plan to start phasing out use of // PGP-specified Expiration times as far as sigchain walking is concerned. But for now, // there are a few places where it's still used (see ComputedKeyInfos#InsertServerEldestKey).
[ "CheckIdentity", "finds", "the", "foo_user" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/pgp_key.go#L818-L836
158,580
keybase/client
go/libkb/pgp_key.go
DecryptFromString
func (k *PGPKeyBundle) DecryptFromString(ciphertext string) (msg []byte, sender keybase1.KID, err error) { err = KeyCannotDecryptError{} return }
go
func (k *PGPKeyBundle) DecryptFromString(ciphertext string) (msg []byte, sender keybase1.KID, err error) { err = KeyCannotDecryptError{} return }
[ "func", "(", "k", "*", "PGPKeyBundle", ")", "DecryptFromString", "(", "ciphertext", "string", ")", "(", "msg", "[", "]", "byte", ",", "sender", "keybase1", ".", "KID", ",", "err", "error", ")", "{", "err", "=", "KeyCannotDecryptError", "{", "}", "\n", "return", "\n", "}" ]
// DecryptFromString fails for this type of key, since we haven't implemented it yet
[ "DecryptFromString", "fails", "for", "this", "type", "of", "key", "since", "we", "haven", "t", "implemented", "it", "yet" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/pgp_key.go#L845-L848
158,581
keybase/client
go/service/track.go
NewTrackHandler
func NewTrackHandler(xp rpc.Transporter, g *libkb.GlobalContext) *TrackHandler { return &TrackHandler{ BaseHandler: NewBaseHandler(g, xp), Contextified: libkb.NewContextified(g), } }
go
func NewTrackHandler(xp rpc.Transporter, g *libkb.GlobalContext) *TrackHandler { return &TrackHandler{ BaseHandler: NewBaseHandler(g, xp), Contextified: libkb.NewContextified(g), } }
[ "func", "NewTrackHandler", "(", "xp", "rpc", ".", "Transporter", ",", "g", "*", "libkb", ".", "GlobalContext", ")", "*", "TrackHandler", "{", "return", "&", "TrackHandler", "{", "BaseHandler", ":", "NewBaseHandler", "(", "g", ",", "xp", ")", ",", "Contextified", ":", "libkb", ".", "NewContextified", "(", "g", ")", ",", "}", "\n", "}" ]
// NewTrackHandler creates a TrackHandler for the xp transport.
[ "NewTrackHandler", "creates", "a", "TrackHandler", "for", "the", "xp", "transport", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/track.go#L27-L32
158,582
keybase/client
go/service/track.go
Track
func (h *TrackHandler) Track(ctx context.Context, arg keybase1.TrackArg) (keybase1.ConfirmResult, error) { earg := engine.TrackEngineArg{ UserAssertion: arg.UserAssertion, Options: arg.Options, ForceRemoteCheck: arg.ForceRemoteCheck, } uis := libkb.UIs{ IdentifyUI: h.NewRemoteIdentifyUI(arg.SessionID, h.G()), SecretUI: h.getSecretUI(arg.SessionID, h.G()), SessionID: arg.SessionID, } eng := engine.NewTrackEngine(h.G(), &earg) m := libkb.NewMetaContext(ctx, h.G()).WithUIs(uis) err := engine.RunEngine2(m, eng) res := eng.ConfirmResult() return res, err }
go
func (h *TrackHandler) Track(ctx context.Context, arg keybase1.TrackArg) (keybase1.ConfirmResult, error) { earg := engine.TrackEngineArg{ UserAssertion: arg.UserAssertion, Options: arg.Options, ForceRemoteCheck: arg.ForceRemoteCheck, } uis := libkb.UIs{ IdentifyUI: h.NewRemoteIdentifyUI(arg.SessionID, h.G()), SecretUI: h.getSecretUI(arg.SessionID, h.G()), SessionID: arg.SessionID, } eng := engine.NewTrackEngine(h.G(), &earg) m := libkb.NewMetaContext(ctx, h.G()).WithUIs(uis) err := engine.RunEngine2(m, eng) res := eng.ConfirmResult() return res, err }
[ "func", "(", "h", "*", "TrackHandler", ")", "Track", "(", "ctx", "context", ".", "Context", ",", "arg", "keybase1", ".", "TrackArg", ")", "(", "keybase1", ".", "ConfirmResult", ",", "error", ")", "{", "earg", ":=", "engine", ".", "TrackEngineArg", "{", "UserAssertion", ":", "arg", ".", "UserAssertion", ",", "Options", ":", "arg", ".", "Options", ",", "ForceRemoteCheck", ":", "arg", ".", "ForceRemoteCheck", ",", "}", "\n", "uis", ":=", "libkb", ".", "UIs", "{", "IdentifyUI", ":", "h", ".", "NewRemoteIdentifyUI", "(", "arg", ".", "SessionID", ",", "h", ".", "G", "(", ")", ")", ",", "SecretUI", ":", "h", ".", "getSecretUI", "(", "arg", ".", "SessionID", ",", "h", ".", "G", "(", ")", ")", ",", "SessionID", ":", "arg", ".", "SessionID", ",", "}", "\n", "eng", ":=", "engine", ".", "NewTrackEngine", "(", "h", ".", "G", "(", ")", ",", "&", "earg", ")", "\n", "m", ":=", "libkb", ".", "NewMetaContext", "(", "ctx", ",", "h", ".", "G", "(", ")", ")", ".", "WithUIs", "(", "uis", ")", "\n", "err", ":=", "engine", ".", "RunEngine2", "(", "m", ",", "eng", ")", "\n", "res", ":=", "eng", ".", "ConfirmResult", "(", ")", "\n", "return", "res", ",", "err", "\n", "}" ]
// Track creates a TrackEngine and runs it.
[ "Track", "creates", "a", "TrackEngine", "and", "runs", "it", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/track.go#L35-L51
158,583
keybase/client
go/service/track.go
Untrack
func (h *TrackHandler) Untrack(ctx context.Context, arg keybase1.UntrackArg) error { earg := engine.UntrackEngineArg{ Username: libkb.NewNormalizedUsername(arg.Username), } uis := libkb.UIs{ SecretUI: h.getSecretUI(arg.SessionID, h.G()), SessionID: arg.SessionID, } eng := engine.NewUntrackEngine(h.G(), &earg) m := libkb.NewMetaContext(ctx, h.G()).WithUIs(uis) return engine.RunEngine2(m, eng) }
go
func (h *TrackHandler) Untrack(ctx context.Context, arg keybase1.UntrackArg) error { earg := engine.UntrackEngineArg{ Username: libkb.NewNormalizedUsername(arg.Username), } uis := libkb.UIs{ SecretUI: h.getSecretUI(arg.SessionID, h.G()), SessionID: arg.SessionID, } eng := engine.NewUntrackEngine(h.G(), &earg) m := libkb.NewMetaContext(ctx, h.G()).WithUIs(uis) return engine.RunEngine2(m, eng) }
[ "func", "(", "h", "*", "TrackHandler", ")", "Untrack", "(", "ctx", "context", ".", "Context", ",", "arg", "keybase1", ".", "UntrackArg", ")", "error", "{", "earg", ":=", "engine", ".", "UntrackEngineArg", "{", "Username", ":", "libkb", ".", "NewNormalizedUsername", "(", "arg", ".", "Username", ")", ",", "}", "\n", "uis", ":=", "libkb", ".", "UIs", "{", "SecretUI", ":", "h", ".", "getSecretUI", "(", "arg", ".", "SessionID", ",", "h", ".", "G", "(", ")", ")", ",", "SessionID", ":", "arg", ".", "SessionID", ",", "}", "\n", "eng", ":=", "engine", ".", "NewUntrackEngine", "(", "h", ".", "G", "(", ")", ",", "&", "earg", ")", "\n", "m", ":=", "libkb", ".", "NewMetaContext", "(", "ctx", ",", "h", ".", "G", "(", ")", ")", ".", "WithUIs", "(", "uis", ")", "\n", "return", "engine", ".", "RunEngine2", "(", "m", ",", "eng", ")", "\n", "}" ]
// Untrack creates an UntrackEngine and runs it.
[ "Untrack", "creates", "an", "UntrackEngine", "and", "runs", "it", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/track.go#L83-L94
158,584
keybase/client
go/engine/saltpack_sign.go
NewSaltpackSign
func NewSaltpackSign(g *libkb.GlobalContext, arg *SaltpackSignArg) *SaltpackSign { return &SaltpackSign{ arg: arg, Contextified: libkb.NewContextified(g), } }
go
func NewSaltpackSign(g *libkb.GlobalContext, arg *SaltpackSignArg) *SaltpackSign { return &SaltpackSign{ arg: arg, Contextified: libkb.NewContextified(g), } }
[ "func", "NewSaltpackSign", "(", "g", "*", "libkb", ".", "GlobalContext", ",", "arg", "*", "SaltpackSignArg", ")", "*", "SaltpackSign", "{", "return", "&", "SaltpackSign", "{", "arg", ":", "arg", ",", "Contextified", ":", "libkb", ".", "NewContextified", "(", "g", ")", ",", "}", "\n", "}" ]
// NewSaltpackSign creates a SaltpackSign engine.
[ "NewSaltpackSign", "creates", "a", "SaltpackSign", "engine", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/saltpack_sign.go#L27-L32
158,585
keybase/client
go/protocol/gregor1/remind.go
GetReminders
func (c RemindClient) GetReminders(ctx context.Context, maxReminders int) (res ReminderSet, err error) { __arg := GetRemindersArg{MaxReminders: maxReminders} err = c.Cli.Call(ctx, "gregor.1.remind.getReminders", []interface{}{__arg}, &res) return }
go
func (c RemindClient) GetReminders(ctx context.Context, maxReminders int) (res ReminderSet, err error) { __arg := GetRemindersArg{MaxReminders: maxReminders} err = c.Cli.Call(ctx, "gregor.1.remind.getReminders", []interface{}{__arg}, &res) return }
[ "func", "(", "c", "RemindClient", ")", "GetReminders", "(", "ctx", "context", ".", "Context", ",", "maxReminders", "int", ")", "(", "res", "ReminderSet", ",", "err", "error", ")", "{", "__arg", ":=", "GetRemindersArg", "{", "MaxReminders", ":", "maxReminders", "}", "\n", "err", "=", "c", ".", "Cli", ".", "Call", "(", "ctx", ",", "\"", "\"", ",", "[", "]", "interface", "{", "}", "{", "__arg", "}", ",", "&", "res", ")", "\n", "return", "\n", "}" ]
// getReminders gets the reminders waiting to be sent out as a batch. Get at most // maxReminders back.
[ "getReminders", "gets", "the", "reminders", "waiting", "to", "be", "sent", "out", "as", "a", "batch", ".", "Get", "at", "most", "maxReminders", "back", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/gregor1/remind.go#L71-L75
158,586
keybase/client
go/protocol/gregor1/remind.go
DeleteReminders
func (c RemindClient) DeleteReminders(ctx context.Context, reminderIDs []ReminderID) (err error) { __arg := DeleteRemindersArg{ReminderIDs: reminderIDs} err = c.Cli.Call(ctx, "gregor.1.remind.deleteReminders", []interface{}{__arg}, nil) return }
go
func (c RemindClient) DeleteReminders(ctx context.Context, reminderIDs []ReminderID) (err error) { __arg := DeleteRemindersArg{ReminderIDs: reminderIDs} err = c.Cli.Call(ctx, "gregor.1.remind.deleteReminders", []interface{}{__arg}, nil) return }
[ "func", "(", "c", "RemindClient", ")", "DeleteReminders", "(", "ctx", "context", ".", "Context", ",", "reminderIDs", "[", "]", "ReminderID", ")", "(", "err", "error", ")", "{", "__arg", ":=", "DeleteRemindersArg", "{", "ReminderIDs", ":", "reminderIDs", "}", "\n", "err", "=", "c", ".", "Cli", ".", "Call", "(", "ctx", ",", "\"", "\"", ",", "[", "]", "interface", "{", "}", "{", "__arg", "}", ",", "nil", ")", "\n", "return", "\n", "}" ]
// deleteReminders deletes all of the reminders by ReminderID
[ "deleteReminders", "deletes", "all", "of", "the", "reminders", "by", "ReminderID" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/gregor1/remind.go#L78-L82
158,587
keybase/client
go/service/rekey_master.go
sendRekeyEvent
func (r *rekeyMaster) sendRekeyEvent(e keybase1.RekeyEvent) (err error) { defer r.G().Trace(fmt.Sprintf("rekeyMaster#sendRekeyEvent(%v)", e), func() error { return err })() if e.InterruptType == int(RekeyInterruptSync) { r.G().Log.Debug("| No need to send a rekey event on a Sync() RPC") return nil } var ui *RekeyUI ui, err = r.getUI() if err != nil { return err } if ui == nil { r.G().Log.Debug("| no UI; not sending event information") return nil } err = ui.RekeySendEvent(context.Background(), keybase1.RekeySendEventArg{Event: e}) return err }
go
func (r *rekeyMaster) sendRekeyEvent(e keybase1.RekeyEvent) (err error) { defer r.G().Trace(fmt.Sprintf("rekeyMaster#sendRekeyEvent(%v)", e), func() error { return err })() if e.InterruptType == int(RekeyInterruptSync) { r.G().Log.Debug("| No need to send a rekey event on a Sync() RPC") return nil } var ui *RekeyUI ui, err = r.getUI() if err != nil { return err } if ui == nil { r.G().Log.Debug("| no UI; not sending event information") return nil } err = ui.RekeySendEvent(context.Background(), keybase1.RekeySendEventArg{Event: e}) return err }
[ "func", "(", "r", "*", "rekeyMaster", ")", "sendRekeyEvent", "(", "e", "keybase1", ".", "RekeyEvent", ")", "(", "err", "error", ")", "{", "defer", "r", ".", "G", "(", ")", ".", "Trace", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "e", ")", ",", "func", "(", ")", "error", "{", "return", "err", "}", ")", "(", ")", "\n\n", "if", "e", ".", "InterruptType", "==", "int", "(", "RekeyInterruptSync", ")", "{", "r", ".", "G", "(", ")", ".", "Log", ".", "Debug", "(", "\"", "\"", ")", "\n", "return", "nil", "\n", "}", "\n\n", "var", "ui", "*", "RekeyUI", "\n", "ui", ",", "err", "=", "r", ".", "getUI", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "ui", "==", "nil", "{", "r", ".", "G", "(", ")", ".", "Log", ".", "Debug", "(", "\"", "\"", ")", "\n", "return", "nil", "\n", "}", "\n", "err", "=", "ui", ".", "RekeySendEvent", "(", "context", ".", "Background", "(", ")", ",", "keybase1", ".", "RekeySendEventArg", "{", "Event", ":", "e", "}", ")", "\n", "return", "err", "\n", "}" ]
// sendRekeyEvent sends notification of a rekey event to the UI. It's largely // used for testing.
[ "sendRekeyEvent", "sends", "notification", "of", "a", "rekey", "event", "to", "the", "UI", ".", "It", "s", "largely", "used", "for", "testing", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/rekey_master.go#L310-L329
158,588
keybase/client
go/service/rekey_master.go
currentDeviceSolvesProblemSet
func (r *rekeyMaster) currentDeviceSolvesProblemSet(me *libkb.User, ps keybase1.ProblemSet) (ret bool) { r.G().Log.Debug("+ currentDeviceSolvesProblemSet") defer func() { r.G().Log.Debug("- currentDeviceSolvesProblemSet -> %v\n", ret) }() var paperKey libkb.GenericKey deviceKey, err := me.GetDeviceSubkey() if err != nil { r.G().Log.Info("| Problem getting device subkey: %s\n", err) return ret } m := libkb.NewMetaContextBackground(r.G()) if d := m.ActiveDevice().ProvisioningKey(m); d != nil { paperKey = d.EncryptionKey() } // We can continue though, so no need to error out if paperKey == nil { m.Debug("| No cached paper key") } if deviceKey != nil { r.G().Log.Debug("| currentDeviceSolvesProblemSet: checking device key: %s", deviceKey.GetKID()) } if paperKey != nil { r.G().Log.Debug("| currentDeviceSolvesProblemSet: checking paper key: %s", paperKey.GetKID()) } for _, tlf := range ps.Tlfs { if !keysSolveProblemTLF([]libkb.GenericKey{deviceKey, paperKey}, tlf) { r.G().Log.Debug("| Doesn't solve problem TLF: %s (%s)\n", tlf.Tlf.Name, tlf.Tlf.Id) return ret } } ret = true return ret }
go
func (r *rekeyMaster) currentDeviceSolvesProblemSet(me *libkb.User, ps keybase1.ProblemSet) (ret bool) { r.G().Log.Debug("+ currentDeviceSolvesProblemSet") defer func() { r.G().Log.Debug("- currentDeviceSolvesProblemSet -> %v\n", ret) }() var paperKey libkb.GenericKey deviceKey, err := me.GetDeviceSubkey() if err != nil { r.G().Log.Info("| Problem getting device subkey: %s\n", err) return ret } m := libkb.NewMetaContextBackground(r.G()) if d := m.ActiveDevice().ProvisioningKey(m); d != nil { paperKey = d.EncryptionKey() } // We can continue though, so no need to error out if paperKey == nil { m.Debug("| No cached paper key") } if deviceKey != nil { r.G().Log.Debug("| currentDeviceSolvesProblemSet: checking device key: %s", deviceKey.GetKID()) } if paperKey != nil { r.G().Log.Debug("| currentDeviceSolvesProblemSet: checking paper key: %s", paperKey.GetKID()) } for _, tlf := range ps.Tlfs { if !keysSolveProblemTLF([]libkb.GenericKey{deviceKey, paperKey}, tlf) { r.G().Log.Debug("| Doesn't solve problem TLF: %s (%s)\n", tlf.Tlf.Name, tlf.Tlf.Id) return ret } } ret = true return ret }
[ "func", "(", "r", "*", "rekeyMaster", ")", "currentDeviceSolvesProblemSet", "(", "me", "*", "libkb", ".", "User", ",", "ps", "keybase1", ".", "ProblemSet", ")", "(", "ret", "bool", ")", "{", "r", ".", "G", "(", ")", ".", "Log", ".", "Debug", "(", "\"", "\"", ")", "\n", "defer", "func", "(", ")", "{", "r", ".", "G", "(", ")", ".", "Log", ".", "Debug", "(", "\"", "\\n", "\"", ",", "ret", ")", "\n", "}", "(", ")", "\n\n", "var", "paperKey", "libkb", ".", "GenericKey", "\n", "deviceKey", ",", "err", ":=", "me", ".", "GetDeviceSubkey", "(", ")", "\n", "if", "err", "!=", "nil", "{", "r", ".", "G", "(", ")", ".", "Log", ".", "Info", "(", "\"", "\\n", "\"", ",", "err", ")", "\n", "return", "ret", "\n", "}", "\n\n", "m", ":=", "libkb", ".", "NewMetaContextBackground", "(", "r", ".", "G", "(", ")", ")", "\n", "if", "d", ":=", "m", ".", "ActiveDevice", "(", ")", ".", "ProvisioningKey", "(", "m", ")", ";", "d", "!=", "nil", "{", "paperKey", "=", "d", ".", "EncryptionKey", "(", ")", "\n", "}", "\n\n", "// We can continue though, so no need to error out", "if", "paperKey", "==", "nil", "{", "m", ".", "Debug", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "deviceKey", "!=", "nil", "{", "r", ".", "G", "(", ")", ".", "Log", ".", "Debug", "(", "\"", "\"", ",", "deviceKey", ".", "GetKID", "(", ")", ")", "\n", "}", "\n", "if", "paperKey", "!=", "nil", "{", "r", ".", "G", "(", ")", ".", "Log", ".", "Debug", "(", "\"", "\"", ",", "paperKey", ".", "GetKID", "(", ")", ")", "\n", "}", "\n\n", "for", "_", ",", "tlf", ":=", "range", "ps", ".", "Tlfs", "{", "if", "!", "keysSolveProblemTLF", "(", "[", "]", "libkb", ".", "GenericKey", "{", "deviceKey", ",", "paperKey", "}", ",", "tlf", ")", "{", "r", ".", "G", "(", ")", ".", "Log", ".", "Debug", "(", "\"", "\\n", "\"", ",", "tlf", ".", "Tlf", ".", "Name", ",", "tlf", ".", "Tlf", ".", "Id", ")", "\n", "return", "ret", "\n", "}", "\n", "}", "\n", "ret", "=", "true", "\n", "return", "ret", "\n", "}" ]
// currentDeviceSolvesProblemSet returns true if the current device can fix all // of the folders in the ProblemSet.
[ "currentDeviceSolvesProblemSet", "returns", "true", "if", "the", "current", "device", "can", "fix", "all", "of", "the", "folders", "in", "the", "ProblemSet", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/rekey_master.go#L437-L474
158,589
keybase/client
go/libkb/delegatekey.go
Run
func (d *Delegator) Run(m MetaContext) (err error) { var jw *jsonw.Wrapper defer m.Trace("Delegator#Run", func() error { return err })() if err = d.CheckArgs(m); err != nil { return err } d.MerkleRoot = m.G().MerkleClient.LastRoot() // We'll need to generate two proofs, so set the Ctime // so that we get the same time both times d.Ctime = m.G().Clock().Now().Unix() // For a sibkey signature, we first sign the blob with the // sibkey, and then embed that signature for the delegating key if d.DelegationType == DelegationTypeSibkey { if jw, err = KeyProof(m, *d); err != nil { m.Debug("| Failure in intermediate KeyProof()") return err } if d.RevSig, _, _, err = SignJSON(jw, d.NewKey); err != nil { m.Debug("| Failure in intermediate SignJson()") return err } } if m.G().LocalDb == nil { panic("should have a local DB") } proof, err := KeyProof2(m, *d) if err != nil { m.Debug("| Failure in KeyProof2()") return err } return d.SignAndPost(m, proof) }
go
func (d *Delegator) Run(m MetaContext) (err error) { var jw *jsonw.Wrapper defer m.Trace("Delegator#Run", func() error { return err })() if err = d.CheckArgs(m); err != nil { return err } d.MerkleRoot = m.G().MerkleClient.LastRoot() // We'll need to generate two proofs, so set the Ctime // so that we get the same time both times d.Ctime = m.G().Clock().Now().Unix() // For a sibkey signature, we first sign the blob with the // sibkey, and then embed that signature for the delegating key if d.DelegationType == DelegationTypeSibkey { if jw, err = KeyProof(m, *d); err != nil { m.Debug("| Failure in intermediate KeyProof()") return err } if d.RevSig, _, _, err = SignJSON(jw, d.NewKey); err != nil { m.Debug("| Failure in intermediate SignJson()") return err } } if m.G().LocalDb == nil { panic("should have a local DB") } proof, err := KeyProof2(m, *d) if err != nil { m.Debug("| Failure in KeyProof2()") return err } return d.SignAndPost(m, proof) }
[ "func", "(", "d", "*", "Delegator", ")", "Run", "(", "m", "MetaContext", ")", "(", "err", "error", ")", "{", "var", "jw", "*", "jsonw", ".", "Wrapper", "\n", "defer", "m", ".", "Trace", "(", "\"", "\"", ",", "func", "(", ")", "error", "{", "return", "err", "}", ")", "(", ")", "\n\n", "if", "err", "=", "d", ".", "CheckArgs", "(", "m", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "d", ".", "MerkleRoot", "=", "m", ".", "G", "(", ")", ".", "MerkleClient", ".", "LastRoot", "(", ")", "\n\n", "// We'll need to generate two proofs, so set the Ctime", "// so that we get the same time both times", "d", ".", "Ctime", "=", "m", ".", "G", "(", ")", ".", "Clock", "(", ")", ".", "Now", "(", ")", ".", "Unix", "(", ")", "\n\n", "// For a sibkey signature, we first sign the blob with the", "// sibkey, and then embed that signature for the delegating key", "if", "d", ".", "DelegationType", "==", "DelegationTypeSibkey", "{", "if", "jw", ",", "err", "=", "KeyProof", "(", "m", ",", "*", "d", ")", ";", "err", "!=", "nil", "{", "m", ".", "Debug", "(", "\"", "\"", ")", "\n", "return", "err", "\n", "}", "\n\n", "if", "d", ".", "RevSig", ",", "_", ",", "_", ",", "err", "=", "SignJSON", "(", "jw", ",", "d", ".", "NewKey", ")", ";", "err", "!=", "nil", "{", "m", ".", "Debug", "(", "\"", "\"", ")", "\n", "return", "err", "\n", "}", "\n", "}", "\n\n", "if", "m", ".", "G", "(", ")", ".", "LocalDb", "==", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "proof", ",", "err", ":=", "KeyProof2", "(", "m", ",", "*", "d", ")", "\n", "if", "err", "!=", "nil", "{", "m", ".", "Debug", "(", "\"", "\"", ")", "\n", "return", "err", "\n", "}", "\n\n", "return", "d", ".", "SignAndPost", "(", "m", ",", "proof", ")", "\n", "}" ]
// Run the Delegator, performing all necessary internal operations. Return err // on failure and nil on success.
[ "Run", "the", "Delegator", "performing", "all", "necessary", "internal", "operations", ".", "Return", "err", "on", "failure", "and", "nil", "on", "success", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/delegatekey.go#L162-L201
158,590
keybase/client
go/kbfs/libgit/id.go
MarshalText
func (id ID) MarshalText() ([]byte, error) { bytes, err := id.MarshalBinary() if err != nil { return nil, err } return []byte(hex.EncodeToString(bytes)), nil }
go
func (id ID) MarshalText() ([]byte, error) { bytes, err := id.MarshalBinary() if err != nil { return nil, err } return []byte(hex.EncodeToString(bytes)), nil }
[ "func", "(", "id", "ID", ")", "MarshalText", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "bytes", ",", "err", ":=", "id", ".", "MarshalBinary", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "[", "]", "byte", "(", "hex", ".", "EncodeToString", "(", "bytes", ")", ")", ",", "nil", "\n", "}" ]
// MarshalText implements the encoding.TextMarshaler interface for ID.
[ "MarshalText", "implements", "the", "encoding", ".", "TextMarshaler", "interface", "for", "ID", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libgit/id.go#L84-L90
158,591
keybase/client
go/kbfs/libkbfs/keybase_daemon_rpc.go
NewKeybaseDaemonRPC
func NewKeybaseDaemonRPC(config Config, kbCtx Context, log logger.Logger, debug bool, additionalProtocols []rpc.Protocol) *KeybaseDaemonRPC { k := newKeybaseDaemonRPC(config, kbCtx, log) k.config = config k.daemonLog = logger.New("daemon") if debug { k.daemonLog.Configure("", true, "") } conn := NewSharedKeybaseConnection(kbCtx, config, k) k.fillClients(conn.GetClient()) k.shutdownFn = conn.Shutdown if config.Mode().ServiceKeepaliveEnabled() { ctx, cancel := context.WithCancel(context.Background()) k.keepAliveCancel = cancel go k.keepAliveLoop(ctx) } k.notifyService = newNotifyServiceHandler(config, log) k.addKBFSProtocols() k.AddProtocols(additionalProtocols) return k }
go
func NewKeybaseDaemonRPC(config Config, kbCtx Context, log logger.Logger, debug bool, additionalProtocols []rpc.Protocol) *KeybaseDaemonRPC { k := newKeybaseDaemonRPC(config, kbCtx, log) k.config = config k.daemonLog = logger.New("daemon") if debug { k.daemonLog.Configure("", true, "") } conn := NewSharedKeybaseConnection(kbCtx, config, k) k.fillClients(conn.GetClient()) k.shutdownFn = conn.Shutdown if config.Mode().ServiceKeepaliveEnabled() { ctx, cancel := context.WithCancel(context.Background()) k.keepAliveCancel = cancel go k.keepAliveLoop(ctx) } k.notifyService = newNotifyServiceHandler(config, log) k.addKBFSProtocols() k.AddProtocols(additionalProtocols) return k }
[ "func", "NewKeybaseDaemonRPC", "(", "config", "Config", ",", "kbCtx", "Context", ",", "log", "logger", ".", "Logger", ",", "debug", "bool", ",", "additionalProtocols", "[", "]", "rpc", ".", "Protocol", ")", "*", "KeybaseDaemonRPC", "{", "k", ":=", "newKeybaseDaemonRPC", "(", "config", ",", "kbCtx", ",", "log", ")", "\n", "k", ".", "config", "=", "config", "\n", "k", ".", "daemonLog", "=", "logger", ".", "New", "(", "\"", "\"", ")", "\n", "if", "debug", "{", "k", ".", "daemonLog", ".", "Configure", "(", "\"", "\"", ",", "true", ",", "\"", "\"", ")", "\n", "}", "\n", "conn", ":=", "NewSharedKeybaseConnection", "(", "kbCtx", ",", "config", ",", "k", ")", "\n", "k", ".", "fillClients", "(", "conn", ".", "GetClient", "(", ")", ")", "\n", "k", ".", "shutdownFn", "=", "conn", ".", "Shutdown", "\n\n", "if", "config", ".", "Mode", "(", ")", ".", "ServiceKeepaliveEnabled", "(", ")", "{", "ctx", ",", "cancel", ":=", "context", ".", "WithCancel", "(", "context", ".", "Background", "(", ")", ")", "\n", "k", ".", "keepAliveCancel", "=", "cancel", "\n", "go", "k", ".", "keepAliveLoop", "(", "ctx", ")", "\n", "}", "\n", "k", ".", "notifyService", "=", "newNotifyServiceHandler", "(", "config", ",", "log", ")", "\n\n", "k", ".", "addKBFSProtocols", "(", ")", "\n", "k", ".", "AddProtocols", "(", "additionalProtocols", ")", "\n\n", "return", "k", "\n", "}" ]
// NewKeybaseDaemonRPC makes a new KeybaseDaemonRPC that makes RPC // calls using the socket of the given Keybase context.
[ "NewKeybaseDaemonRPC", "makes", "a", "new", "KeybaseDaemonRPC", "that", "makes", "RPC", "calls", "using", "the", "socket", "of", "the", "given", "Keybase", "context", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_daemon_rpc.go#L90-L113
158,592
keybase/client
go/kbfs/libkbfs/keybase_daemon_rpc.go
AddProtocols
func (k *KeybaseDaemonRPC) AddProtocols(protocols []rpc.Protocol) { if protocols == nil { return } k.lock.Lock() defer k.lock.Unlock() if k.protocols != nil { k.protocols = append(k.protocols, protocols...) } else { k.protocols = protocols } // If we are already connected, register these protocols. if k.server != nil { for _, p := range protocols { k.registerProtocol(k.server, p) } } }
go
func (k *KeybaseDaemonRPC) AddProtocols(protocols []rpc.Protocol) { if protocols == nil { return } k.lock.Lock() defer k.lock.Unlock() if k.protocols != nil { k.protocols = append(k.protocols, protocols...) } else { k.protocols = protocols } // If we are already connected, register these protocols. if k.server != nil { for _, p := range protocols { k.registerProtocol(k.server, p) } } }
[ "func", "(", "k", "*", "KeybaseDaemonRPC", ")", "AddProtocols", "(", "protocols", "[", "]", "rpc", ".", "Protocol", ")", "{", "if", "protocols", "==", "nil", "{", "return", "\n", "}", "\n\n", "k", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "k", ".", "lock", ".", "Unlock", "(", ")", "\n\n", "if", "k", ".", "protocols", "!=", "nil", "{", "k", ".", "protocols", "=", "append", "(", "k", ".", "protocols", ",", "protocols", "...", ")", "\n", "}", "else", "{", "k", ".", "protocols", "=", "protocols", "\n", "}", "\n\n", "// If we are already connected, register these protocols.", "if", "k", ".", "server", "!=", "nil", "{", "for", "_", ",", "p", ":=", "range", "protocols", "{", "k", ".", "registerProtocol", "(", "k", ".", "server", ",", "p", ")", "\n", "}", "\n", "}", "\n", "}" ]
// AddProtocols adds protocols that are registered on server connect
[ "AddProtocols", "adds", "protocols", "that", "are", "registered", "on", "server", "connect" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_daemon_rpc.go#L289-L309
158,593
keybase/client
go/kbfs/libkbfs/keybase_daemon_rpc.go
Shutdown
func (k *KeybaseDaemonRPC) Shutdown() { if k.shutdownFn != nil { k.shutdownFn() } if k.keepAliveCancel != nil { k.keepAliveCancel() } k.log.Warning("Keybase service shutdown") }
go
func (k *KeybaseDaemonRPC) Shutdown() { if k.shutdownFn != nil { k.shutdownFn() } if k.keepAliveCancel != nil { k.keepAliveCancel() } k.log.Warning("Keybase service shutdown") }
[ "func", "(", "k", "*", "KeybaseDaemonRPC", ")", "Shutdown", "(", ")", "{", "if", "k", ".", "shutdownFn", "!=", "nil", "{", "k", ".", "shutdownFn", "(", ")", "\n", "}", "\n", "if", "k", ".", "keepAliveCancel", "!=", "nil", "{", "k", ".", "keepAliveCancel", "(", ")", "\n", "}", "\n", "k", ".", "log", ".", "Warning", "(", "\"", "\"", ")", "\n\n", "}" ]
// Shutdown implements the KeybaseService interface for KeybaseDaemonRPC.
[ "Shutdown", "implements", "the", "KeybaseService", "interface", "for", "KeybaseDaemonRPC", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_daemon_rpc.go#L433-L442
158,594
keybase/client
go/kbfs/libkbfs/keybase_daemon_rpc.go
newNotifyServiceHandler
func newNotifyServiceHandler(config Config, log logger.Logger) keybase1.NotifyServiceInterface { s := &notifyServiceHandler{config: config, log: log} return s }
go
func newNotifyServiceHandler(config Config, log logger.Logger) keybase1.NotifyServiceInterface { s := &notifyServiceHandler{config: config, log: log} return s }
[ "func", "newNotifyServiceHandler", "(", "config", "Config", ",", "log", "logger", ".", "Logger", ")", "keybase1", ".", "NotifyServiceInterface", "{", "s", ":=", "&", "notifyServiceHandler", "{", "config", ":", "config", ",", "log", ":", "log", "}", "\n", "return", "s", "\n", "}" ]
// newNotifyServiceHandler makes a new NotifyServiceHandler
[ "newNotifyServiceHandler", "makes", "a", "new", "NotifyServiceHandler" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_daemon_rpc.go#L459-L462
158,595
keybase/client
go/kbfs/libkbfs/keybase_daemon_rpc.go
FavoritesChanged
func (k *KeybaseDaemonRPC) FavoritesChanged(ctx context.Context, uid keybase1.UID) error { k.log.Debug("Received FavoritesChanged RPC.") k.config.KBFSOps().RefreshCachedFavorites(ctx) return nil }
go
func (k *KeybaseDaemonRPC) FavoritesChanged(ctx context.Context, uid keybase1.UID) error { k.log.Debug("Received FavoritesChanged RPC.") k.config.KBFSOps().RefreshCachedFavorites(ctx) return nil }
[ "func", "(", "k", "*", "KeybaseDaemonRPC", ")", "FavoritesChanged", "(", "ctx", "context", ".", "Context", ",", "uid", "keybase1", ".", "UID", ")", "error", "{", "k", ".", "log", ".", "Debug", "(", "\"", "\"", ")", "\n", "k", ".", "config", ".", "KBFSOps", "(", ")", ".", "RefreshCachedFavorites", "(", "ctx", ")", "\n", "return", "nil", "\n", "}" ]
// FavoritesChanged implements keybase1.NotifyFavoritesClient
[ "FavoritesChanged", "implements", "keybase1", ".", "NotifyFavoritesClient" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keybase_daemon_rpc.go#L465-L470
158,596
keybase/client
go/kbfs/libkbfs/backpressure_disk_limiter.go
updateSemaphoreMax
func (bt *backpressureTracker) updateSemaphoreMax() { newMax := int64(bt.currLimit()) delta := newMax - bt.semaphoreMax // These operations are adjusting the *maximum* value of // bt.semaphore. if delta > 0 { bt.semaphore.Release(delta) } else if delta < 0 { bt.semaphore.ForceAcquire(-delta) } bt.semaphoreMax = newMax }
go
func (bt *backpressureTracker) updateSemaphoreMax() { newMax := int64(bt.currLimit()) delta := newMax - bt.semaphoreMax // These operations are adjusting the *maximum* value of // bt.semaphore. if delta > 0 { bt.semaphore.Release(delta) } else if delta < 0 { bt.semaphore.ForceAcquire(-delta) } bt.semaphoreMax = newMax }
[ "func", "(", "bt", "*", "backpressureTracker", ")", "updateSemaphoreMax", "(", ")", "{", "newMax", ":=", "int64", "(", "bt", ".", "currLimit", "(", ")", ")", "\n", "delta", ":=", "newMax", "-", "bt", ".", "semaphoreMax", "\n", "// These operations are adjusting the *maximum* value of", "// bt.semaphore.", "if", "delta", ">", "0", "{", "bt", ".", "semaphore", ".", "Release", "(", "delta", ")", "\n", "}", "else", "if", "delta", "<", "0", "{", "bt", ".", "semaphore", ".", "ForceAcquire", "(", "-", "delta", ")", "\n", "}", "\n", "bt", ".", "semaphoreMax", "=", "newMax", "\n", "}" ]
// updateSemaphoreMax must be called whenever bt.used or bt.free // changes.
[ "updateSemaphoreMax", "must", "be", "called", "whenever", "bt", ".", "used", "or", "bt", ".", "free", "changes", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/backpressure_disk_limiter.go#L143-L154
158,597
keybase/client
go/kbfs/libkbfs/backpressure_disk_limiter.go
newBackpressureDiskLimiter
func newBackpressureDiskLimiter( log logger.Logger, params backpressureDiskLimiterParams) ( *backpressureDiskLimiter, error) { freeBytes, freeFiles, err := params.freeBytesAndFilesFn() if err != nil { return nil, err } journalTracker, err := newJournalTracker( params.minThreshold, params.maxThreshold, params.quotaMinThreshold, params.quotaMaxThreshold, params.journalFrac, params.byteLimit, params.fileLimit, freeBytes, freeFiles) if err != nil { return nil, err } // byteLimit must be scaled by the proportion of the limit // that the disk cache should consume. Add 0.5 for rounding. diskCacheByteLimit := int64( (float64(params.byteLimit) * params.diskCacheFrac) + 0.5) syncCacheByteLimit := int64( (float64(params.byteLimit) * params.syncCacheFrac) + 0.5) overallByteTracker, err := newBackpressureTracker( 1.0, 1.0, 1.0, params.byteLimit, freeBytes) if err != nil { return nil, err } diskCacheByteTracker, err := newBackpressureTracker( 1.0, 1.0, params.diskCacheFrac, diskCacheByteLimit, freeBytes) if err != nil { return nil, err } syncCacheByteTracker, err := newBackpressureTracker( 1.0, 1.0, params.diskCacheFrac, syncCacheByteLimit, freeBytes) if err != nil { return nil, err } bdl := &backpressureDiskLimiter{ log: log, maxDelay: params.maxDelay, delayFn: params.delayFn, freeBytesAndFilesFn: params.freeBytesAndFilesFn, quotaFn: params.quotaFn, lock: sync.RWMutex{}, overallByteTracker: overallByteTracker, journalTracker: journalTracker, diskCacheByteTracker: diskCacheByteTracker, syncCacheByteTracker: syncCacheByteTracker, } return bdl, nil }
go
func newBackpressureDiskLimiter( log logger.Logger, params backpressureDiskLimiterParams) ( *backpressureDiskLimiter, error) { freeBytes, freeFiles, err := params.freeBytesAndFilesFn() if err != nil { return nil, err } journalTracker, err := newJournalTracker( params.minThreshold, params.maxThreshold, params.quotaMinThreshold, params.quotaMaxThreshold, params.journalFrac, params.byteLimit, params.fileLimit, freeBytes, freeFiles) if err != nil { return nil, err } // byteLimit must be scaled by the proportion of the limit // that the disk cache should consume. Add 0.5 for rounding. diskCacheByteLimit := int64( (float64(params.byteLimit) * params.diskCacheFrac) + 0.5) syncCacheByteLimit := int64( (float64(params.byteLimit) * params.syncCacheFrac) + 0.5) overallByteTracker, err := newBackpressureTracker( 1.0, 1.0, 1.0, params.byteLimit, freeBytes) if err != nil { return nil, err } diskCacheByteTracker, err := newBackpressureTracker( 1.0, 1.0, params.diskCacheFrac, diskCacheByteLimit, freeBytes) if err != nil { return nil, err } syncCacheByteTracker, err := newBackpressureTracker( 1.0, 1.0, params.diskCacheFrac, syncCacheByteLimit, freeBytes) if err != nil { return nil, err } bdl := &backpressureDiskLimiter{ log: log, maxDelay: params.maxDelay, delayFn: params.delayFn, freeBytesAndFilesFn: params.freeBytesAndFilesFn, quotaFn: params.quotaFn, lock: sync.RWMutex{}, overallByteTracker: overallByteTracker, journalTracker: journalTracker, diskCacheByteTracker: diskCacheByteTracker, syncCacheByteTracker: syncCacheByteTracker, } return bdl, nil }
[ "func", "newBackpressureDiskLimiter", "(", "log", "logger", ".", "Logger", ",", "params", "backpressureDiskLimiterParams", ")", "(", "*", "backpressureDiskLimiter", ",", "error", ")", "{", "freeBytes", ",", "freeFiles", ",", "err", ":=", "params", ".", "freeBytesAndFilesFn", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "journalTracker", ",", "err", ":=", "newJournalTracker", "(", "params", ".", "minThreshold", ",", "params", ".", "maxThreshold", ",", "params", ".", "quotaMinThreshold", ",", "params", ".", "quotaMaxThreshold", ",", "params", ".", "journalFrac", ",", "params", ".", "byteLimit", ",", "params", ".", "fileLimit", ",", "freeBytes", ",", "freeFiles", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// byteLimit must be scaled by the proportion of the limit", "// that the disk cache should consume. Add 0.5 for rounding.", "diskCacheByteLimit", ":=", "int64", "(", "(", "float64", "(", "params", ".", "byteLimit", ")", "*", "params", ".", "diskCacheFrac", ")", "+", "0.5", ")", "\n", "syncCacheByteLimit", ":=", "int64", "(", "(", "float64", "(", "params", ".", "byteLimit", ")", "*", "params", ".", "syncCacheFrac", ")", "+", "0.5", ")", "\n", "overallByteTracker", ",", "err", ":=", "newBackpressureTracker", "(", "1.0", ",", "1.0", ",", "1.0", ",", "params", ".", "byteLimit", ",", "freeBytes", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "diskCacheByteTracker", ",", "err", ":=", "newBackpressureTracker", "(", "1.0", ",", "1.0", ",", "params", ".", "diskCacheFrac", ",", "diskCacheByteLimit", ",", "freeBytes", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "syncCacheByteTracker", ",", "err", ":=", "newBackpressureTracker", "(", "1.0", ",", "1.0", ",", "params", ".", "diskCacheFrac", ",", "syncCacheByteLimit", ",", "freeBytes", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "bdl", ":=", "&", "backpressureDiskLimiter", "{", "log", ":", "log", ",", "maxDelay", ":", "params", ".", "maxDelay", ",", "delayFn", ":", "params", ".", "delayFn", ",", "freeBytesAndFilesFn", ":", "params", ".", "freeBytesAndFilesFn", ",", "quotaFn", ":", "params", ".", "quotaFn", ",", "lock", ":", "sync", ".", "RWMutex", "{", "}", ",", "overallByteTracker", ":", "overallByteTracker", ",", "journalTracker", ":", "journalTracker", ",", "diskCacheByteTracker", ":", "diskCacheByteTracker", ",", "syncCacheByteTracker", ":", "syncCacheByteTracker", ",", "}", "\n", "return", "bdl", ",", "nil", "\n", "}" ]
// newBackpressureDiskLimiter constructs a new backpressureDiskLimiter // with the given params.
[ "newBackpressureDiskLimiter", "constructs", "a", "new", "backpressureDiskLimiter", "with", "the", "given", "params", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/backpressure_disk_limiter.go#L739-L792
158,598
keybase/client
go/kbfs/libkbfs/backpressure_disk_limiter.go
defaultDoDelay
func defaultDoDelay(ctx context.Context, delay time.Duration) error { if delay == 0 { return nil } timer := time.NewTimer(delay) select { case <-timer.C: return nil case <-ctx.Done(): timer.Stop() return errors.WithStack(ctx.Err()) } }
go
func defaultDoDelay(ctx context.Context, delay time.Duration) error { if delay == 0 { return nil } timer := time.NewTimer(delay) select { case <-timer.C: return nil case <-ctx.Done(): timer.Stop() return errors.WithStack(ctx.Err()) } }
[ "func", "defaultDoDelay", "(", "ctx", "context", ".", "Context", ",", "delay", "time", ".", "Duration", ")", "error", "{", "if", "delay", "==", "0", "{", "return", "nil", "\n", "}", "\n\n", "timer", ":=", "time", ".", "NewTimer", "(", "delay", ")", "\n", "select", "{", "case", "<-", "timer", ".", "C", ":", "return", "nil", "\n", "case", "<-", "ctx", ".", "Done", "(", ")", ":", "timer", ".", "Stop", "(", ")", "\n", "return", "errors", ".", "WithStack", "(", "ctx", ".", "Err", "(", ")", ")", "\n", "}", "\n", "}" ]
// defaultDoDelay uses a timer to delay by the given duration.
[ "defaultDoDelay", "uses", "a", "timer", "to", "delay", "by", "the", "given", "duration", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/backpressure_disk_limiter.go#L795-L808
158,599
keybase/client
go/stellar/stellar.go
CreateWalletGated
func CreateWalletGated(mctx libkb.MetaContext) (res CreateWalletGatedResult, err error) { defer mctx.TraceTimed("Stellar.CreateWalletGated", func() error { return err })() defer func() { mctx.Debug("CreateWalletGated: (res:%+v, err:%v)", res, err != nil) }() res, err = createWalletGatedHelper(mctx) if err == nil && res.ErrorCreating != nil { // An error was encountered while creating the wallet. // This could have been the result of losing a race against other threads. // When multiple threads create a wallet only one will succeed. // In that case we _do_ have a wallet now even though this thread failed, // so run again for an accurate reply. return createWalletGatedHelper(mctx) } return res, err }
go
func CreateWalletGated(mctx libkb.MetaContext) (res CreateWalletGatedResult, err error) { defer mctx.TraceTimed("Stellar.CreateWalletGated", func() error { return err })() defer func() { mctx.Debug("CreateWalletGated: (res:%+v, err:%v)", res, err != nil) }() res, err = createWalletGatedHelper(mctx) if err == nil && res.ErrorCreating != nil { // An error was encountered while creating the wallet. // This could have been the result of losing a race against other threads. // When multiple threads create a wallet only one will succeed. // In that case we _do_ have a wallet now even though this thread failed, // so run again for an accurate reply. return createWalletGatedHelper(mctx) } return res, err }
[ "func", "CreateWalletGated", "(", "mctx", "libkb", ".", "MetaContext", ")", "(", "res", "CreateWalletGatedResult", ",", "err", "error", ")", "{", "defer", "mctx", ".", "TraceTimed", "(", "\"", "\"", ",", "func", "(", ")", "error", "{", "return", "err", "}", ")", "(", ")", "\n", "defer", "func", "(", ")", "{", "mctx", ".", "Debug", "(", "\"", "\"", ",", "res", ",", "err", "!=", "nil", ")", "\n", "}", "(", ")", "\n", "res", ",", "err", "=", "createWalletGatedHelper", "(", "mctx", ")", "\n", "if", "err", "==", "nil", "&&", "res", ".", "ErrorCreating", "!=", "nil", "{", "// An error was encountered while creating the wallet.", "// This could have been the result of losing a race against other threads.", "// When multiple threads create a wallet only one will succeed.", "// In that case we _do_ have a wallet now even though this thread failed,", "// so run again for an accurate reply.", "return", "createWalletGatedHelper", "(", "mctx", ")", "\n", "}", "\n", "return", "res", ",", "err", "\n", "}" ]
// CreateWalletGated may create a wallet for the user. // Taking into account settings from the server. // It should be speedy to call repeatedly _if_ the user gets a wallet.
[ "CreateWalletGated", "may", "create", "a", "wallet", "for", "the", "user", ".", "Taking", "into", "account", "settings", "from", "the", "server", ".", "It", "should", "be", "speedy", "to", "call", "repeatedly", "_if_", "the", "user", "gets", "a", "wallet", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/stellar.go#L79-L94