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
159,100
keybase/client
go/kbfs/data/dirty_file.go
AssimilateDeferredNewBytes
func (df *DirtyFile) AssimilateDeferredNewBytes() { df.lock.Lock() defer df.lock.Unlock() if df.deferredNewBytes == 0 { return } df.dirtyBcache.UpdateUnsyncedBytes(df.Path.Tlf, df.deferredNewBytes, false) df.deferredNewBytes = 0 }
go
func (df *DirtyFile) AssimilateDeferredNewBytes() { df.lock.Lock() defer df.lock.Unlock() if df.deferredNewBytes == 0 { return } df.dirtyBcache.UpdateUnsyncedBytes(df.Path.Tlf, df.deferredNewBytes, false) df.deferredNewBytes = 0 }
[ "func", "(", "df", "*", "DirtyFile", ")", "AssimilateDeferredNewBytes", "(", ")", "{", "df", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "df", ".", "lock", ".", "Unlock", "(", ")", "\n", "if", "df", ".", "deferredNewBytes", "==", "0", "{", "return", "\n", "}", "\n", "df", ".", "dirtyBcache", ".", "UpdateUnsyncedBytes", "(", "df", ".", "Path", ".", "Tlf", ",", "df", ".", "deferredNewBytes", ",", "false", ")", "\n", "df", ".", "deferredNewBytes", "=", "0", "\n", "}" ]
// AssimilateDeferredNewBytes is called to indicate that any deferred // bytes should be included in the count of the next sync.
[ "AssimilateDeferredNewBytes", "is", "called", "to", "indicate", "that", "any", "deferred", "bytes", "should", "be", "included", "in", "the", "count", "of", "the", "next", "sync", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/data/dirty_file.go#L366-L374
159,101
keybase/client
go/libkb/globals.go
simulateServiceRestart
func (g *GlobalContext) simulateServiceRestart() { defer g.switchUserMu.Acquire(NewMetaContext(context.TODO(), g), "simulateServiceRestart")() g.ActiveDevice.Clear() }
go
func (g *GlobalContext) simulateServiceRestart() { defer g.switchUserMu.Acquire(NewMetaContext(context.TODO(), g), "simulateServiceRestart")() g.ActiveDevice.Clear() }
[ "func", "(", "g", "*", "GlobalContext", ")", "simulateServiceRestart", "(", ")", "{", "defer", "g", ".", "switchUserMu", ".", "Acquire", "(", "NewMetaContext", "(", "context", ".", "TODO", "(", ")", ",", "g", ")", ",", "\"", "\"", ")", "(", ")", "\n", "g", ".", "ActiveDevice", ".", "Clear", "(", ")", "\n", "}" ]
// simulateServiceRestart simulates what happens when a service restarts for the // purposes of testing.
[ "simulateServiceRestart", "simulates", "what", "happens", "when", "a", "service", "restarts", "for", "the", "purposes", "of", "testing", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/globals.go#L269-L272
159,102
keybase/client
go/libkb/globals.go
Shutdown
func (g *GlobalContext) Shutdown() error { var err error didShutdown := false // Wrap in a Once.Do so that we don't inadvertedly // run this code twice. g.shutdownOnce.Do(func() { g.Log.Debug("GlobalContext#Shutdown(%p)\n", g) didShutdown = true epick := FirstErrorPicker{} if g.NotifyRouter != nil { g.NotifyRouter.Shutdown() } if g.UIRouter != nil { g.UIRouter.Shutdown() } if g.ConnectionManager != nil { g.ConnectionManager.Shutdown() } if g.UI != nil { epick.Push(g.UI.Shutdown()) } if g.LocalDb != nil { epick.Push(g.LocalDb.Close()) } if g.LocalChatDb != nil { epick.Push(g.LocalChatDb.Close()) } // Shutdown can still race with Logout, so make sure that we hold onto // the cacheMu before shutting down the caches. See comments in // shutdownCachesLocked g.cacheMu.Lock() g.shutdownCachesLocked() g.cacheMu.Unlock() if g.Resolver != nil { g.Resolver.Shutdown(NewMetaContextBackground(g)) } for _, hook := range g.ShutdownHooks { epick.Push(hook()) } g.Identify3State.Shutdown() err = epick.Error() g.Log.Debug("exiting shutdown code=%d; err=%v", g.ExitCode, err) }) // Make a little bit of a statement if we wind up here a second time // (which is a bug). if !didShutdown { g.Log.Debug("Skipped shutdown on second call") } return err }
go
func (g *GlobalContext) Shutdown() error { var err error didShutdown := false // Wrap in a Once.Do so that we don't inadvertedly // run this code twice. g.shutdownOnce.Do(func() { g.Log.Debug("GlobalContext#Shutdown(%p)\n", g) didShutdown = true epick := FirstErrorPicker{} if g.NotifyRouter != nil { g.NotifyRouter.Shutdown() } if g.UIRouter != nil { g.UIRouter.Shutdown() } if g.ConnectionManager != nil { g.ConnectionManager.Shutdown() } if g.UI != nil { epick.Push(g.UI.Shutdown()) } if g.LocalDb != nil { epick.Push(g.LocalDb.Close()) } if g.LocalChatDb != nil { epick.Push(g.LocalChatDb.Close()) } // Shutdown can still race with Logout, so make sure that we hold onto // the cacheMu before shutting down the caches. See comments in // shutdownCachesLocked g.cacheMu.Lock() g.shutdownCachesLocked() g.cacheMu.Unlock() if g.Resolver != nil { g.Resolver.Shutdown(NewMetaContextBackground(g)) } for _, hook := range g.ShutdownHooks { epick.Push(hook()) } g.Identify3State.Shutdown() err = epick.Error() g.Log.Debug("exiting shutdown code=%d; err=%v", g.ExitCode, err) }) // Make a little bit of a statement if we wind up here a second time // (which is a bug). if !didShutdown { g.Log.Debug("Skipped shutdown on second call") } return err }
[ "func", "(", "g", "*", "GlobalContext", ")", "Shutdown", "(", ")", "error", "{", "var", "err", "error", "\n", "didShutdown", ":=", "false", "\n\n", "// Wrap in a Once.Do so that we don't inadvertedly", "// run this code twice.", "g", ".", "shutdownOnce", ".", "Do", "(", "func", "(", ")", "{", "g", ".", "Log", ".", "Debug", "(", "\"", "\\n", "\"", ",", "g", ")", "\n", "didShutdown", "=", "true", "\n\n", "epick", ":=", "FirstErrorPicker", "{", "}", "\n\n", "if", "g", ".", "NotifyRouter", "!=", "nil", "{", "g", ".", "NotifyRouter", ".", "Shutdown", "(", ")", "\n", "}", "\n\n", "if", "g", ".", "UIRouter", "!=", "nil", "{", "g", ".", "UIRouter", ".", "Shutdown", "(", ")", "\n", "}", "\n\n", "if", "g", ".", "ConnectionManager", "!=", "nil", "{", "g", ".", "ConnectionManager", ".", "Shutdown", "(", ")", "\n", "}", "\n\n", "if", "g", ".", "UI", "!=", "nil", "{", "epick", ".", "Push", "(", "g", ".", "UI", ".", "Shutdown", "(", ")", ")", "\n", "}", "\n", "if", "g", ".", "LocalDb", "!=", "nil", "{", "epick", ".", "Push", "(", "g", ".", "LocalDb", ".", "Close", "(", ")", ")", "\n", "}", "\n", "if", "g", ".", "LocalChatDb", "!=", "nil", "{", "epick", ".", "Push", "(", "g", ".", "LocalChatDb", ".", "Close", "(", ")", ")", "\n", "}", "\n\n", "// Shutdown can still race with Logout, so make sure that we hold onto", "// the cacheMu before shutting down the caches. See comments in", "// shutdownCachesLocked", "g", ".", "cacheMu", ".", "Lock", "(", ")", "\n", "g", ".", "shutdownCachesLocked", "(", ")", "\n", "g", ".", "cacheMu", ".", "Unlock", "(", ")", "\n\n", "if", "g", ".", "Resolver", "!=", "nil", "{", "g", ".", "Resolver", ".", "Shutdown", "(", "NewMetaContextBackground", "(", "g", ")", ")", "\n", "}", "\n\n", "for", "_", ",", "hook", ":=", "range", "g", ".", "ShutdownHooks", "{", "epick", ".", "Push", "(", "hook", "(", ")", ")", "\n", "}", "\n\n", "g", ".", "Identify3State", ".", "Shutdown", "(", ")", "\n\n", "err", "=", "epick", ".", "Error", "(", ")", "\n\n", "g", ".", "Log", ".", "Debug", "(", "\"", "\"", ",", "g", ".", "ExitCode", ",", "err", ")", "\n", "}", ")", "\n\n", "// Make a little bit of a statement if we wind up here a second time", "// (which is a bug).", "if", "!", "didShutdown", "{", "g", ".", "Log", ".", "Debug", "(", "\"", "\"", ")", "\n", "}", "\n\n", "return", "err", "\n", "}" ]
// Shutdown is called exactly once per-process and does whatever // cleanup is necessary to shut down the server.
[ "Shutdown", "is", "called", "exactly", "once", "per", "-", "process", "and", "does", "whatever", "cleanup", "is", "necessary", "to", "shut", "down", "the", "server", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/globals.go#L655-L718
159,103
keybase/client
go/libkb/globals.go
LogoutSelfCheck
func (g *GlobalContext) LogoutSelfCheck(ctx context.Context) error { mctx := NewMetaContext(ctx, g) uid := g.ActiveDevice.UID() if uid.IsNil() { mctx.Debug("LogoutSelfCheck: no uid") return nil } deviceID := g.ActiveDevice.DeviceID() if deviceID.IsNil() { mctx.Debug("LogoutSelfCheck: no device id") return nil } arg := APIArg{ Endpoint: "selfcheck", Args: HTTPArgs{ "uid": S{Val: uid.String()}, "device_id": S{Val: deviceID.String()}, }, SessionType: APISessionTypeREQUIRED, } res, err := g.API.Post(mctx, arg) if err != nil { return err } logout, err := res.Body.AtKey("logout").GetBool() if err != nil { return err } mctx.Debug("LogoutSelfCheck: should log out? %v", logout) if logout { mctx.Debug("LogoutSelfCheck: logging out...") return g.Logout(mctx.Ctx()) } return nil }
go
func (g *GlobalContext) LogoutSelfCheck(ctx context.Context) error { mctx := NewMetaContext(ctx, g) uid := g.ActiveDevice.UID() if uid.IsNil() { mctx.Debug("LogoutSelfCheck: no uid") return nil } deviceID := g.ActiveDevice.DeviceID() if deviceID.IsNil() { mctx.Debug("LogoutSelfCheck: no device id") return nil } arg := APIArg{ Endpoint: "selfcheck", Args: HTTPArgs{ "uid": S{Val: uid.String()}, "device_id": S{Val: deviceID.String()}, }, SessionType: APISessionTypeREQUIRED, } res, err := g.API.Post(mctx, arg) if err != nil { return err } logout, err := res.Body.AtKey("logout").GetBool() if err != nil { return err } mctx.Debug("LogoutSelfCheck: should log out? %v", logout) if logout { mctx.Debug("LogoutSelfCheck: logging out...") return g.Logout(mctx.Ctx()) } return nil }
[ "func", "(", "g", "*", "GlobalContext", ")", "LogoutSelfCheck", "(", "ctx", "context", ".", "Context", ")", "error", "{", "mctx", ":=", "NewMetaContext", "(", "ctx", ",", "g", ")", "\n", "uid", ":=", "g", ".", "ActiveDevice", ".", "UID", "(", ")", "\n", "if", "uid", ".", "IsNil", "(", ")", "{", "mctx", ".", "Debug", "(", "\"", "\"", ")", "\n", "return", "nil", "\n", "}", "\n", "deviceID", ":=", "g", ".", "ActiveDevice", ".", "DeviceID", "(", ")", "\n", "if", "deviceID", ".", "IsNil", "(", ")", "{", "mctx", ".", "Debug", "(", "\"", "\"", ")", "\n", "return", "nil", "\n", "}", "\n\n", "arg", ":=", "APIArg", "{", "Endpoint", ":", "\"", "\"", ",", "Args", ":", "HTTPArgs", "{", "\"", "\"", ":", "S", "{", "Val", ":", "uid", ".", "String", "(", ")", "}", ",", "\"", "\"", ":", "S", "{", "Val", ":", "deviceID", ".", "String", "(", ")", "}", ",", "}", ",", "SessionType", ":", "APISessionTypeREQUIRED", ",", "}", "\n", "res", ",", "err", ":=", "g", ".", "API", ".", "Post", "(", "mctx", ",", "arg", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "logout", ",", "err", ":=", "res", ".", "Body", ".", "AtKey", "(", "\"", "\"", ")", ".", "GetBool", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "mctx", ".", "Debug", "(", "\"", "\"", ",", "logout", ")", "\n", "if", "logout", "{", "mctx", ".", "Debug", "(", "\"", "\"", ")", "\n", "return", "g", ".", "Logout", "(", "mctx", ".", "Ctx", "(", ")", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// LogoutSelfCheck checks with the API server to see if this uid+device pair should // logout.
[ "LogoutSelfCheck", "checks", "with", "the", "API", "server", "to", "see", "if", "this", "uid", "+", "device", "pair", "should", "logout", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/globals.go#L1069-L1107
159,104
keybase/client
go/libkb/globals.go
GetPerUserKeyring
func (g *GlobalContext) GetPerUserKeyring(ctx context.Context) (ret *PerUserKeyring, err error) { defer g.Trace("G#GetPerUserKeyring", func() error { return err })() myUID := g.ActiveDevice.UID() if myUID.IsNil() { return nil, errors.New("PerUserKeyring unavailable with no UID") } // Don't do any operations under these locks that could come back and hit them again. // That's why GetMyUID up above is not under this lock. g.perUserKeyringMu.Lock() defer g.perUserKeyringMu.Unlock() makeNew := func() (*PerUserKeyring, error) { pukring, err := NewPerUserKeyring(g, myUID) if err != nil { g.Log.CWarningf(ctx, "G#GetPerUserKeyring -> failed: %s", err) g.perUserKeyring = nil return nil, err } g.Log.CDebugf(ctx, "G#GetPerUserKeyring -> new") g.perUserKeyring = pukring return g.perUserKeyring, nil } if g.perUserKeyring == nil { return makeNew() } pukUID := g.perUserKeyring.GetUID() if pukUID.Equal(myUID) { return g.perUserKeyring, nil } return makeNew() }
go
func (g *GlobalContext) GetPerUserKeyring(ctx context.Context) (ret *PerUserKeyring, err error) { defer g.Trace("G#GetPerUserKeyring", func() error { return err })() myUID := g.ActiveDevice.UID() if myUID.IsNil() { return nil, errors.New("PerUserKeyring unavailable with no UID") } // Don't do any operations under these locks that could come back and hit them again. // That's why GetMyUID up above is not under this lock. g.perUserKeyringMu.Lock() defer g.perUserKeyringMu.Unlock() makeNew := func() (*PerUserKeyring, error) { pukring, err := NewPerUserKeyring(g, myUID) if err != nil { g.Log.CWarningf(ctx, "G#GetPerUserKeyring -> failed: %s", err) g.perUserKeyring = nil return nil, err } g.Log.CDebugf(ctx, "G#GetPerUserKeyring -> new") g.perUserKeyring = pukring return g.perUserKeyring, nil } if g.perUserKeyring == nil { return makeNew() } pukUID := g.perUserKeyring.GetUID() if pukUID.Equal(myUID) { return g.perUserKeyring, nil } return makeNew() }
[ "func", "(", "g", "*", "GlobalContext", ")", "GetPerUserKeyring", "(", "ctx", "context", ".", "Context", ")", "(", "ret", "*", "PerUserKeyring", ",", "err", "error", ")", "{", "defer", "g", ".", "Trace", "(", "\"", "\"", ",", "func", "(", ")", "error", "{", "return", "err", "}", ")", "(", ")", "\n\n", "myUID", ":=", "g", ".", "ActiveDevice", ".", "UID", "(", ")", "\n", "if", "myUID", ".", "IsNil", "(", ")", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// Don't do any operations under these locks that could come back and hit them again.", "// That's why GetMyUID up above is not under this lock.", "g", ".", "perUserKeyringMu", ".", "Lock", "(", ")", "\n", "defer", "g", ".", "perUserKeyringMu", ".", "Unlock", "(", ")", "\n\n", "makeNew", ":=", "func", "(", ")", "(", "*", "PerUserKeyring", ",", "error", ")", "{", "pukring", ",", "err", ":=", "NewPerUserKeyring", "(", "g", ",", "myUID", ")", "\n", "if", "err", "!=", "nil", "{", "g", ".", "Log", ".", "CWarningf", "(", "ctx", ",", "\"", "\"", ",", "err", ")", "\n", "g", ".", "perUserKeyring", "=", "nil", "\n", "return", "nil", ",", "err", "\n", "}", "\n", "g", ".", "Log", ".", "CDebugf", "(", "ctx", ",", "\"", "\"", ")", "\n", "g", ".", "perUserKeyring", "=", "pukring", "\n", "return", "g", ".", "perUserKeyring", ",", "nil", "\n", "}", "\n\n", "if", "g", ".", "perUserKeyring", "==", "nil", "{", "return", "makeNew", "(", ")", "\n", "}", "\n", "pukUID", ":=", "g", ".", "perUserKeyring", ".", "GetUID", "(", ")", "\n", "if", "pukUID", ".", "Equal", "(", "myUID", ")", "{", "return", "g", ".", "perUserKeyring", ",", "nil", "\n", "}", "\n", "return", "makeNew", "(", ")", "\n", "}" ]
// GetPerUserKeyring recreates PerUserKeyring if the uid changes or this is none installed.
[ "GetPerUserKeyring", "recreates", "PerUserKeyring", "if", "the", "uid", "changes", "or", "this", "is", "none", "installed", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/globals.go#L1249-L1282
159,105
keybase/client
go/kbfs/libfs/node_wrappers.go
ShouldCreateMissedLookup
func (sfn *specialFileNode) ShouldCreateMissedLookup( ctx context.Context, name string) ( bool, context.Context, data.EntryType, os.FileInfo, string) { if !perTlfWrappedNodeNames[name] { return sfn.Node.ShouldCreateMissedLookup(ctx, name) } switch name { case StatusFileName: sfn := &statusFileNode{ Node: nil, fb: sfn.GetFolderBranch(), config: sfn.config, log: sfn.log, } f := sfn.GetFile(ctx) return true, ctx, data.FakeFile, f.(*wrappedReadFile).GetInfo(), "" default: panic(fmt.Sprintf("Name %s was in map, but not in switch", name)) } }
go
func (sfn *specialFileNode) ShouldCreateMissedLookup( ctx context.Context, name string) ( bool, context.Context, data.EntryType, os.FileInfo, string) { if !perTlfWrappedNodeNames[name] { return sfn.Node.ShouldCreateMissedLookup(ctx, name) } switch name { case StatusFileName: sfn := &statusFileNode{ Node: nil, fb: sfn.GetFolderBranch(), config: sfn.config, log: sfn.log, } f := sfn.GetFile(ctx) return true, ctx, data.FakeFile, f.(*wrappedReadFile).GetInfo(), "" default: panic(fmt.Sprintf("Name %s was in map, but not in switch", name)) } }
[ "func", "(", "sfn", "*", "specialFileNode", ")", "ShouldCreateMissedLookup", "(", "ctx", "context", ".", "Context", ",", "name", "string", ")", "(", "bool", ",", "context", ".", "Context", ",", "data", ".", "EntryType", ",", "os", ".", "FileInfo", ",", "string", ")", "{", "if", "!", "perTlfWrappedNodeNames", "[", "name", "]", "{", "return", "sfn", ".", "Node", ".", "ShouldCreateMissedLookup", "(", "ctx", ",", "name", ")", "\n", "}", "\n\n", "switch", "name", "{", "case", "StatusFileName", ":", "sfn", ":=", "&", "statusFileNode", "{", "Node", ":", "nil", ",", "fb", ":", "sfn", ".", "GetFolderBranch", "(", ")", ",", "config", ":", "sfn", ".", "config", ",", "log", ":", "sfn", ".", "log", ",", "}", "\n", "f", ":=", "sfn", ".", "GetFile", "(", "ctx", ")", "\n", "return", "true", ",", "ctx", ",", "data", ".", "FakeFile", ",", "f", ".", "(", "*", "wrappedReadFile", ")", ".", "GetInfo", "(", ")", ",", "\"", "\"", "\n", "default", ":", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "name", ")", ")", "\n", "}", "\n\n", "}" ]
// ShouldCreateMissedLookup implements the Node interface for // specialFileNode.
[ "ShouldCreateMissedLookup", "implements", "the", "Node", "interface", "for", "specialFileNode", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/node_wrappers.go#L62-L83
159,106
keybase/client
go/kbfs/libfs/node_wrappers.go
WrapChild
func (sfn *specialFileNode) WrapChild(child libkbfs.Node) libkbfs.Node { child = sfn.Node.WrapChild(child) name := child.GetBasename() if !perTlfWrappedNodeNames[name] { if child.EntryType() == data.Dir { // Wrap this child too, so we can look up special files in // subdirectories of this node as well. return &specialFileNode{ Node: child, config: sfn.config, log: sfn.log, } } return child } switch name { case StatusFileName: return &statusFileNode{ Node: &libkbfs.ReadonlyNode{Node: child}, fb: sfn.GetFolderBranch(), config: sfn.config, log: sfn.log, } default: panic(fmt.Sprintf("Name %s was in map, but not in switch", name)) } }
go
func (sfn *specialFileNode) WrapChild(child libkbfs.Node) libkbfs.Node { child = sfn.Node.WrapChild(child) name := child.GetBasename() if !perTlfWrappedNodeNames[name] { if child.EntryType() == data.Dir { // Wrap this child too, so we can look up special files in // subdirectories of this node as well. return &specialFileNode{ Node: child, config: sfn.config, log: sfn.log, } } return child } switch name { case StatusFileName: return &statusFileNode{ Node: &libkbfs.ReadonlyNode{Node: child}, fb: sfn.GetFolderBranch(), config: sfn.config, log: sfn.log, } default: panic(fmt.Sprintf("Name %s was in map, but not in switch", name)) } }
[ "func", "(", "sfn", "*", "specialFileNode", ")", "WrapChild", "(", "child", "libkbfs", ".", "Node", ")", "libkbfs", ".", "Node", "{", "child", "=", "sfn", ".", "Node", ".", "WrapChild", "(", "child", ")", "\n", "name", ":=", "child", ".", "GetBasename", "(", ")", "\n", "if", "!", "perTlfWrappedNodeNames", "[", "name", "]", "{", "if", "child", ".", "EntryType", "(", ")", "==", "data", ".", "Dir", "{", "// Wrap this child too, so we can look up special files in", "// subdirectories of this node as well.", "return", "&", "specialFileNode", "{", "Node", ":", "child", ",", "config", ":", "sfn", ".", "config", ",", "log", ":", "sfn", ".", "log", ",", "}", "\n", "}", "\n", "return", "child", "\n", "}", "\n\n", "switch", "name", "{", "case", "StatusFileName", ":", "return", "&", "statusFileNode", "{", "Node", ":", "&", "libkbfs", ".", "ReadonlyNode", "{", "Node", ":", "child", "}", ",", "fb", ":", "sfn", ".", "GetFolderBranch", "(", ")", ",", "config", ":", "sfn", ".", "config", ",", "log", ":", "sfn", ".", "log", ",", "}", "\n", "default", ":", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "name", ")", ")", "\n", "}", "\n", "}" ]
// WrapChild implements the Node interface for specialFileNode.
[ "WrapChild", "implements", "the", "Node", "interface", "for", "specialFileNode", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/node_wrappers.go#L86-L113
159,107
keybase/client
go/kbfs/libfs/node_wrappers.go
AddRootWrapper
func AddRootWrapper(config libkbfs.Config) { rw := rootWrapper{config, config.MakeLogger("")} config.AddRootNodeWrapper(rw.wrap) }
go
func AddRootWrapper(config libkbfs.Config) { rw := rootWrapper{config, config.MakeLogger("")} config.AddRootNodeWrapper(rw.wrap) }
[ "func", "AddRootWrapper", "(", "config", "libkbfs", ".", "Config", ")", "{", "rw", ":=", "rootWrapper", "{", "config", ",", "config", ".", "MakeLogger", "(", "\"", "\"", ")", "}", "\n", "config", ".", "AddRootNodeWrapper", "(", "rw", ".", "wrap", ")", "\n", "}" ]
// AddRootWrapper should be called on startup by any KBFS interface // that wants to handle special files.
[ "AddRootWrapper", "should", "be", "called", "on", "startup", "by", "any", "KBFS", "interface", "that", "wants", "to", "handle", "special", "files", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/node_wrappers.go#L132-L135
159,108
keybase/client
go/service/delegate_ui.go
NewDelegateUICtlHandler
func NewDelegateUICtlHandler(xp rpc.Transporter, id libkb.ConnectionID, g *libkb.GlobalContext, rekeyMaster *rekeyMaster) *DelegateUICtlHandler { return &DelegateUICtlHandler{ Contextified: libkb.NewContextified(g), BaseHandler: NewBaseHandler(g, xp), id: id, rekeyMaster: rekeyMaster, } }
go
func NewDelegateUICtlHandler(xp rpc.Transporter, id libkb.ConnectionID, g *libkb.GlobalContext, rekeyMaster *rekeyMaster) *DelegateUICtlHandler { return &DelegateUICtlHandler{ Contextified: libkb.NewContextified(g), BaseHandler: NewBaseHandler(g, xp), id: id, rekeyMaster: rekeyMaster, } }
[ "func", "NewDelegateUICtlHandler", "(", "xp", "rpc", ".", "Transporter", ",", "id", "libkb", ".", "ConnectionID", ",", "g", "*", "libkb", ".", "GlobalContext", ",", "rekeyMaster", "*", "rekeyMaster", ")", "*", "DelegateUICtlHandler", "{", "return", "&", "DelegateUICtlHandler", "{", "Contextified", ":", "libkb", ".", "NewContextified", "(", "g", ")", ",", "BaseHandler", ":", "NewBaseHandler", "(", "g", ",", "xp", ")", ",", "id", ":", "id", ",", "rekeyMaster", ":", "rekeyMaster", ",", "}", "\n", "}" ]
// NewDelegateUICtlHandler creates a new handler for setting up notification // channels
[ "NewDelegateUICtlHandler", "creates", "a", "new", "handler", "for", "setting", "up", "notification", "channels" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/delegate_ui.go#L22-L29
159,109
keybase/client
go/kbfs/kbfscrypto/encrypted_data.go
ToHashType
func (v EncryptionVer) ToHashType() kbfshash.HashType { switch v { case EncryptionSecretbox: return kbfshash.SHA256Hash case EncryptionSecretboxWithKeyNonce: return kbfshash.SHA256HashV2 default: return kbfshash.InvalidHash } }
go
func (v EncryptionVer) ToHashType() kbfshash.HashType { switch v { case EncryptionSecretbox: return kbfshash.SHA256Hash case EncryptionSecretboxWithKeyNonce: return kbfshash.SHA256HashV2 default: return kbfshash.InvalidHash } }
[ "func", "(", "v", "EncryptionVer", ")", "ToHashType", "(", ")", "kbfshash", ".", "HashType", "{", "switch", "v", "{", "case", "EncryptionSecretbox", ":", "return", "kbfshash", ".", "SHA256Hash", "\n", "case", "EncryptionSecretboxWithKeyNonce", ":", "return", "kbfshash", ".", "SHA256HashV2", "\n", "default", ":", "return", "kbfshash", ".", "InvalidHash", "\n", "}", "\n", "}" ]
// ToHashType returns the type of the hash that should be used for the // given encryption version.
[ "ToHashType", "returns", "the", "type", "of", "the", "hash", "that", "should", "be", "used", "for", "the", "given", "encryption", "version", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscrypto/encrypted_data.go#L48-L57
159,110
keybase/client
go/kbfs/kbfscrypto/encrypted_data.go
encryptDataWithNonce
func encryptDataWithNonce( data []byte, key [32]byte, nonce [24]byte, ver EncryptionVer) ( encryptedData, error) { sealedData := secretbox.Seal(nil, data, &nonce, &key) return encryptedData{ Version: ver, Nonce: nonce[:], EncryptedData: sealedData, }, nil }
go
func encryptDataWithNonce( data []byte, key [32]byte, nonce [24]byte, ver EncryptionVer) ( encryptedData, error) { sealedData := secretbox.Seal(nil, data, &nonce, &key) return encryptedData{ Version: ver, Nonce: nonce[:], EncryptedData: sealedData, }, nil }
[ "func", "encryptDataWithNonce", "(", "data", "[", "]", "byte", ",", "key", "[", "32", "]", "byte", ",", "nonce", "[", "24", "]", "byte", ",", "ver", "EncryptionVer", ")", "(", "encryptedData", ",", "error", ")", "{", "sealedData", ":=", "secretbox", ".", "Seal", "(", "nil", ",", "data", ",", "&", "nonce", ",", "&", "key", ")", "\n\n", "return", "encryptedData", "{", "Version", ":", "ver", ",", "Nonce", ":", "nonce", "[", ":", "]", ",", "EncryptedData", ":", "sealedData", ",", "}", ",", "nil", "\n", "}" ]
// encryptDataWithNonce encrypts the given data with the given // symmetric key and nonce.
[ "encryptDataWithNonce", "encrypts", "the", "given", "data", "with", "the", "given", "symmetric", "key", "and", "nonce", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscrypto/encrypted_data.go#L93-L103
159,111
keybase/client
go/kbfs/kbfscrypto/encrypted_data.go
encryptData
func encryptData(data []byte, key [32]byte) (encryptedData, error) { var nonce [24]byte err := RandRead(nonce[:]) if err != nil { return encryptedData{}, err } return encryptDataWithNonce(data, key, nonce, EncryptionSecretbox) }
go
func encryptData(data []byte, key [32]byte) (encryptedData, error) { var nonce [24]byte err := RandRead(nonce[:]) if err != nil { return encryptedData{}, err } return encryptDataWithNonce(data, key, nonce, EncryptionSecretbox) }
[ "func", "encryptData", "(", "data", "[", "]", "byte", ",", "key", "[", "32", "]", "byte", ")", "(", "encryptedData", ",", "error", ")", "{", "var", "nonce", "[", "24", "]", "byte", "\n", "err", ":=", "RandRead", "(", "nonce", "[", ":", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "encryptedData", "{", "}", ",", "err", "\n", "}", "\n\n", "return", "encryptDataWithNonce", "(", "data", ",", "key", ",", "nonce", ",", "EncryptionSecretbox", ")", "\n", "}" ]
// encryptData encrypts the given data with the given symmetric key.
[ "encryptData", "encrypts", "the", "given", "data", "with", "the", "given", "symmetric", "key", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscrypto/encrypted_data.go#L106-L114
159,112
keybase/client
go/kbfs/kbfscrypto/encrypted_data.go
decryptData
func decryptData( encryptedData encryptedData, key [32]byte, nonce [24]byte) ([]byte, error) { switch encryptedData.Version { case EncryptionSecretbox: // We're good, no nonce check needed. case EncryptionSecretboxWithKeyNonce: if !bytes.Equal(nonce[:], encryptedData.Nonce) { return nil, errors.WithStack(InvalidNonceError{encryptedData.Nonce}) } default: return nil, errors.WithStack( UnknownEncryptionVer{encryptedData.Version}) } decryptedData, ok := secretbox.Open( nil, encryptedData.EncryptedData, &nonce, &key) if !ok { return nil, errors.WithStack( libkb.DecryptionError{Cause: errors.New("Cannot open secret box")}) } return decryptedData, nil }
go
func decryptData( encryptedData encryptedData, key [32]byte, nonce [24]byte) ([]byte, error) { switch encryptedData.Version { case EncryptionSecretbox: // We're good, no nonce check needed. case EncryptionSecretboxWithKeyNonce: if !bytes.Equal(nonce[:], encryptedData.Nonce) { return nil, errors.WithStack(InvalidNonceError{encryptedData.Nonce}) } default: return nil, errors.WithStack( UnknownEncryptionVer{encryptedData.Version}) } decryptedData, ok := secretbox.Open( nil, encryptedData.EncryptedData, &nonce, &key) if !ok { return nil, errors.WithStack( libkb.DecryptionError{Cause: errors.New("Cannot open secret box")}) } return decryptedData, nil }
[ "func", "decryptData", "(", "encryptedData", "encryptedData", ",", "key", "[", "32", "]", "byte", ",", "nonce", "[", "24", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "switch", "encryptedData", ".", "Version", "{", "case", "EncryptionSecretbox", ":", "// We're good, no nonce check needed.", "case", "EncryptionSecretboxWithKeyNonce", ":", "if", "!", "bytes", ".", "Equal", "(", "nonce", "[", ":", "]", ",", "encryptedData", ".", "Nonce", ")", "{", "return", "nil", ",", "errors", ".", "WithStack", "(", "InvalidNonceError", "{", "encryptedData", ".", "Nonce", "}", ")", "\n", "}", "\n", "default", ":", "return", "nil", ",", "errors", ".", "WithStack", "(", "UnknownEncryptionVer", "{", "encryptedData", ".", "Version", "}", ")", "\n", "}", "\n\n", "decryptedData", ",", "ok", ":=", "secretbox", ".", "Open", "(", "nil", ",", "encryptedData", ".", "EncryptedData", ",", "&", "nonce", ",", "&", "key", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "errors", ".", "WithStack", "(", "libkb", ".", "DecryptionError", "{", "Cause", ":", "errors", ".", "New", "(", "\"", "\"", ")", "}", ")", "\n", "}", "\n\n", "return", "decryptedData", ",", "nil", "\n", "}" ]
// decryptData decrypts the given encrypted data with the given // symmetric key and nonce.
[ "decryptData", "decrypts", "the", "given", "encrypted", "data", "with", "the", "given", "symmetric", "key", "and", "nonce", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscrypto/encrypted_data.go#L118-L140
159,113
keybase/client
go/kbfs/kbfscrypto/encrypted_data.go
EncryptTLFCryptKeyClientHalf
func EncryptTLFCryptKeyClientHalf( privateKey TLFEphemeralPrivateKey, publicKey CryptPublicKey, clientHalf TLFCryptKeyClientHalf) ( encryptedClientHalf EncryptedTLFCryptKeyClientHalf, err error) { var nonce [24]byte err = RandRead(nonce[:]) if err != nil { return EncryptedTLFCryptKeyClientHalf{}, err } keypair, err := libkb.ImportKeypairFromKID(publicKey.KID()) if err != nil { return EncryptedTLFCryptKeyClientHalf{}, errors.WithStack(err) } dhKeyPair, ok := keypair.(libkb.NaclDHKeyPair) if !ok { return EncryptedTLFCryptKeyClientHalf{}, errors.WithStack( libkb.KeyCannotEncryptError{}) } clientHalfData := clientHalf.Data() privateKeyData := privateKey.Data() encryptedBytes := box.Seal(nil, clientHalfData[:], &nonce, (*[32]byte)(&dhKeyPair.Public), &privateKeyData) return EncryptedTLFCryptKeyClientHalf{ encryptedData{ Version: EncryptionSecretbox, EncryptedData: encryptedBytes, Nonce: nonce[:], }, }, nil }
go
func EncryptTLFCryptKeyClientHalf( privateKey TLFEphemeralPrivateKey, publicKey CryptPublicKey, clientHalf TLFCryptKeyClientHalf) ( encryptedClientHalf EncryptedTLFCryptKeyClientHalf, err error) { var nonce [24]byte err = RandRead(nonce[:]) if err != nil { return EncryptedTLFCryptKeyClientHalf{}, err } keypair, err := libkb.ImportKeypairFromKID(publicKey.KID()) if err != nil { return EncryptedTLFCryptKeyClientHalf{}, errors.WithStack(err) } dhKeyPair, ok := keypair.(libkb.NaclDHKeyPair) if !ok { return EncryptedTLFCryptKeyClientHalf{}, errors.WithStack( libkb.KeyCannotEncryptError{}) } clientHalfData := clientHalf.Data() privateKeyData := privateKey.Data() encryptedBytes := box.Seal(nil, clientHalfData[:], &nonce, (*[32]byte)(&dhKeyPair.Public), &privateKeyData) return EncryptedTLFCryptKeyClientHalf{ encryptedData{ Version: EncryptionSecretbox, EncryptedData: encryptedBytes, Nonce: nonce[:], }, }, nil }
[ "func", "EncryptTLFCryptKeyClientHalf", "(", "privateKey", "TLFEphemeralPrivateKey", ",", "publicKey", "CryptPublicKey", ",", "clientHalf", "TLFCryptKeyClientHalf", ")", "(", "encryptedClientHalf", "EncryptedTLFCryptKeyClientHalf", ",", "err", "error", ")", "{", "var", "nonce", "[", "24", "]", "byte", "\n", "err", "=", "RandRead", "(", "nonce", "[", ":", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "EncryptedTLFCryptKeyClientHalf", "{", "}", ",", "err", "\n", "}", "\n\n", "keypair", ",", "err", ":=", "libkb", ".", "ImportKeypairFromKID", "(", "publicKey", ".", "KID", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "EncryptedTLFCryptKeyClientHalf", "{", "}", ",", "errors", ".", "WithStack", "(", "err", ")", "\n", "}", "\n\n", "dhKeyPair", ",", "ok", ":=", "keypair", ".", "(", "libkb", ".", "NaclDHKeyPair", ")", "\n", "if", "!", "ok", "{", "return", "EncryptedTLFCryptKeyClientHalf", "{", "}", ",", "errors", ".", "WithStack", "(", "libkb", ".", "KeyCannotEncryptError", "{", "}", ")", "\n", "}", "\n\n", "clientHalfData", ":=", "clientHalf", ".", "Data", "(", ")", "\n", "privateKeyData", ":=", "privateKey", ".", "Data", "(", ")", "\n", "encryptedBytes", ":=", "box", ".", "Seal", "(", "nil", ",", "clientHalfData", "[", ":", "]", ",", "&", "nonce", ",", "(", "*", "[", "32", "]", "byte", ")", "(", "&", "dhKeyPair", ".", "Public", ")", ",", "&", "privateKeyData", ")", "\n\n", "return", "EncryptedTLFCryptKeyClientHalf", "{", "encryptedData", "{", "Version", ":", "EncryptionSecretbox", ",", "EncryptedData", ":", "encryptedBytes", ",", "Nonce", ":", "nonce", "[", ":", "]", ",", "}", ",", "}", ",", "nil", "\n", "}" ]
// EncryptTLFCryptKeyClientHalf encrypts a TLFCryptKeyClientHalf // using both a TLF's ephemeral private key and a device pubkey.
[ "EncryptTLFCryptKeyClientHalf", "encrypts", "a", "TLFCryptKeyClientHalf", "using", "both", "a", "TLF", "s", "ephemeral", "private", "key", "and", "a", "device", "pubkey", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscrypto/encrypted_data.go#L150-L182
159,114
keybase/client
go/kbfs/kbfscrypto/encrypted_data.go
EncryptEncodedPrivateMetadata
func EncryptEncodedPrivateMetadata(encodedPrivateMetadata []byte, key TLFCryptKey) ( encryptedPrivateMetadata EncryptedPrivateMetadata, err error) { encryptedData, err := encryptData(encodedPrivateMetadata, key.Data()) if err != nil { return EncryptedPrivateMetadata{}, err } return EncryptedPrivateMetadata{encryptedData}, nil }
go
func EncryptEncodedPrivateMetadata(encodedPrivateMetadata []byte, key TLFCryptKey) ( encryptedPrivateMetadata EncryptedPrivateMetadata, err error) { encryptedData, err := encryptData(encodedPrivateMetadata, key.Data()) if err != nil { return EncryptedPrivateMetadata{}, err } return EncryptedPrivateMetadata{encryptedData}, nil }
[ "func", "EncryptEncodedPrivateMetadata", "(", "encodedPrivateMetadata", "[", "]", "byte", ",", "key", "TLFCryptKey", ")", "(", "encryptedPrivateMetadata", "EncryptedPrivateMetadata", ",", "err", "error", ")", "{", "encryptedData", ",", "err", ":=", "encryptData", "(", "encodedPrivateMetadata", ",", "key", ".", "Data", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "EncryptedPrivateMetadata", "{", "}", ",", "err", "\n", "}", "\n\n", "return", "EncryptedPrivateMetadata", "{", "encryptedData", "}", ",", "nil", "\n", "}" ]
// EncryptEncodedPrivateMetadata encrypts an encoded PrivateMetadata // object.
[ "EncryptEncodedPrivateMetadata", "encrypts", "an", "encoded", "PrivateMetadata", "object", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscrypto/encrypted_data.go#L191-L199
159,115
keybase/client
go/kbfs/kbfscrypto/encrypted_data.go
DecryptPrivateMetadata
func DecryptPrivateMetadata( encryptedPrivateMetadata EncryptedPrivateMetadata, key TLFCryptKey) ( []byte, error) { if encryptedPrivateMetadata.encryptedData.Version == EncryptionSecretboxWithKeyNonce { // Only blocks should have v2 encryption. return nil, errors.WithStack(InvalidEncryptionVer{ encryptedPrivateMetadata.encryptedData.Version}) } nonce, err := encryptedPrivateMetadata.encryptedData.Nonce24() if err != nil { return nil, err } return decryptData( encryptedPrivateMetadata.encryptedData, key.Data(), nonce) }
go
func DecryptPrivateMetadata( encryptedPrivateMetadata EncryptedPrivateMetadata, key TLFCryptKey) ( []byte, error) { if encryptedPrivateMetadata.encryptedData.Version == EncryptionSecretboxWithKeyNonce { // Only blocks should have v2 encryption. return nil, errors.WithStack(InvalidEncryptionVer{ encryptedPrivateMetadata.encryptedData.Version}) } nonce, err := encryptedPrivateMetadata.encryptedData.Nonce24() if err != nil { return nil, err } return decryptData( encryptedPrivateMetadata.encryptedData, key.Data(), nonce) }
[ "func", "DecryptPrivateMetadata", "(", "encryptedPrivateMetadata", "EncryptedPrivateMetadata", ",", "key", "TLFCryptKey", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "encryptedPrivateMetadata", ".", "encryptedData", ".", "Version", "==", "EncryptionSecretboxWithKeyNonce", "{", "// Only blocks should have v2 encryption.", "return", "nil", ",", "errors", ".", "WithStack", "(", "InvalidEncryptionVer", "{", "encryptedPrivateMetadata", ".", "encryptedData", ".", "Version", "}", ")", "\n", "}", "\n\n", "nonce", ",", "err", ":=", "encryptedPrivateMetadata", ".", "encryptedData", ".", "Nonce24", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "decryptData", "(", "encryptedPrivateMetadata", ".", "encryptedData", ",", "key", ".", "Data", "(", ")", ",", "nonce", ")", "\n", "}" ]
// DecryptPrivateMetadata decrypts a PrivateMetadata object, but does // not decode it.
[ "DecryptPrivateMetadata", "decrypts", "a", "PrivateMetadata", "object", "but", "does", "not", "decode", "it", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscrypto/encrypted_data.go#L203-L220
159,116
keybase/client
go/kbfs/kbfscrypto/encrypted_data.go
EncryptPaddedEncodedBlock
func EncryptPaddedEncodedBlock( paddedEncodedBlock []byte, tlfCryptKey TLFCryptKey, blockServerHalf BlockCryptKeyServerHalf, ver EncryptionVer) ( encryptedBlock EncryptedBlock, err error) { var ed encryptedData switch ver { case EncryptionSecretbox: key := UnmaskBlockCryptKey(blockServerHalf, tlfCryptKey) ed, err = encryptData(paddedEncodedBlock, key.Data()) if err != nil { return EncryptedBlock{}, err } case EncryptionSecretboxWithKeyNonce: key := MakeBlockHashKey(blockServerHalf, tlfCryptKey) ed, err = encryptDataWithNonce( paddedEncodedBlock, key.cryptKey(), key.nonce(), EncryptionSecretboxWithKeyNonce) if err != nil { return EncryptedBlock{}, err } default: return EncryptedBlock{}, errors.WithStack(UnknownEncryptionVer{ver}) } return EncryptedBlock{ed}, nil }
go
func EncryptPaddedEncodedBlock( paddedEncodedBlock []byte, tlfCryptKey TLFCryptKey, blockServerHalf BlockCryptKeyServerHalf, ver EncryptionVer) ( encryptedBlock EncryptedBlock, err error) { var ed encryptedData switch ver { case EncryptionSecretbox: key := UnmaskBlockCryptKey(blockServerHalf, tlfCryptKey) ed, err = encryptData(paddedEncodedBlock, key.Data()) if err != nil { return EncryptedBlock{}, err } case EncryptionSecretboxWithKeyNonce: key := MakeBlockHashKey(blockServerHalf, tlfCryptKey) ed, err = encryptDataWithNonce( paddedEncodedBlock, key.cryptKey(), key.nonce(), EncryptionSecretboxWithKeyNonce) if err != nil { return EncryptedBlock{}, err } default: return EncryptedBlock{}, errors.WithStack(UnknownEncryptionVer{ver}) } return EncryptedBlock{ed}, nil }
[ "func", "EncryptPaddedEncodedBlock", "(", "paddedEncodedBlock", "[", "]", "byte", ",", "tlfCryptKey", "TLFCryptKey", ",", "blockServerHalf", "BlockCryptKeyServerHalf", ",", "ver", "EncryptionVer", ")", "(", "encryptedBlock", "EncryptedBlock", ",", "err", "error", ")", "{", "var", "ed", "encryptedData", "\n", "switch", "ver", "{", "case", "EncryptionSecretbox", ":", "key", ":=", "UnmaskBlockCryptKey", "(", "blockServerHalf", ",", "tlfCryptKey", ")", "\n", "ed", ",", "err", "=", "encryptData", "(", "paddedEncodedBlock", ",", "key", ".", "Data", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "EncryptedBlock", "{", "}", ",", "err", "\n", "}", "\n", "case", "EncryptionSecretboxWithKeyNonce", ":", "key", ":=", "MakeBlockHashKey", "(", "blockServerHalf", ",", "tlfCryptKey", ")", "\n", "ed", ",", "err", "=", "encryptDataWithNonce", "(", "paddedEncodedBlock", ",", "key", ".", "cryptKey", "(", ")", ",", "key", ".", "nonce", "(", ")", ",", "EncryptionSecretboxWithKeyNonce", ")", "\n", "if", "err", "!=", "nil", "{", "return", "EncryptedBlock", "{", "}", ",", "err", "\n", "}", "\n", "default", ":", "return", "EncryptedBlock", "{", "}", ",", "errors", ".", "WithStack", "(", "UnknownEncryptionVer", "{", "ver", "}", ")", "\n", "}", "\n\n", "return", "EncryptedBlock", "{", "ed", "}", ",", "nil", "\n", "}" ]
// EncryptPaddedEncodedBlock encrypts a padded, encoded block.
[ "EncryptPaddedEncodedBlock", "encrypts", "a", "padded", "encoded", "block", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscrypto/encrypted_data.go#L228-L253
159,117
keybase/client
go/kbfs/kbfscrypto/encrypted_data.go
DecryptBlock
func DecryptBlock( encryptedBlock EncryptedBlock, tlfCryptKey TLFCryptKey, blockServerHalf BlockCryptKeyServerHalf) ([]byte, error) { switch encryptedBlock.encryptedData.Version { case EncryptionSecretbox: nonce, err := encryptedBlock.encryptedData.Nonce24() if err != nil { return nil, err } key := UnmaskBlockCryptKey(blockServerHalf, tlfCryptKey) return decryptData(encryptedBlock.encryptedData, key.Data(), nonce) case EncryptionSecretboxWithKeyNonce: key := MakeBlockHashKey(blockServerHalf, tlfCryptKey) return decryptData( encryptedBlock.encryptedData, key.cryptKey(), key.nonce()) default: return nil, errors.WithStack( InvalidEncryptionVer{encryptedBlock.encryptedData.Version}) } }
go
func DecryptBlock( encryptedBlock EncryptedBlock, tlfCryptKey TLFCryptKey, blockServerHalf BlockCryptKeyServerHalf) ([]byte, error) { switch encryptedBlock.encryptedData.Version { case EncryptionSecretbox: nonce, err := encryptedBlock.encryptedData.Nonce24() if err != nil { return nil, err } key := UnmaskBlockCryptKey(blockServerHalf, tlfCryptKey) return decryptData(encryptedBlock.encryptedData, key.Data(), nonce) case EncryptionSecretboxWithKeyNonce: key := MakeBlockHashKey(blockServerHalf, tlfCryptKey) return decryptData( encryptedBlock.encryptedData, key.cryptKey(), key.nonce()) default: return nil, errors.WithStack( InvalidEncryptionVer{encryptedBlock.encryptedData.Version}) } }
[ "func", "DecryptBlock", "(", "encryptedBlock", "EncryptedBlock", ",", "tlfCryptKey", "TLFCryptKey", ",", "blockServerHalf", "BlockCryptKeyServerHalf", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "switch", "encryptedBlock", ".", "encryptedData", ".", "Version", "{", "case", "EncryptionSecretbox", ":", "nonce", ",", "err", ":=", "encryptedBlock", ".", "encryptedData", ".", "Nonce24", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "key", ":=", "UnmaskBlockCryptKey", "(", "blockServerHalf", ",", "tlfCryptKey", ")", "\n", "return", "decryptData", "(", "encryptedBlock", ".", "encryptedData", ",", "key", ".", "Data", "(", ")", ",", "nonce", ")", "\n", "case", "EncryptionSecretboxWithKeyNonce", ":", "key", ":=", "MakeBlockHashKey", "(", "blockServerHalf", ",", "tlfCryptKey", ")", "\n", "return", "decryptData", "(", "encryptedBlock", ".", "encryptedData", ",", "key", ".", "cryptKey", "(", ")", ",", "key", ".", "nonce", "(", ")", ")", "\n", "default", ":", "return", "nil", ",", "errors", ".", "WithStack", "(", "InvalidEncryptionVer", "{", "encryptedBlock", ".", "encryptedData", ".", "Version", "}", ")", "\n", "}", "\n", "}" ]
// DecryptBlock decrypts a block, but does not unpad or decode it.
[ "DecryptBlock", "decrypts", "a", "block", "but", "does", "not", "unpad", "or", "decode", "it", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscrypto/encrypted_data.go#L256-L276
159,118
keybase/client
go/kbfs/kbfscrypto/encrypted_data.go
EncryptTLFCryptKeys
func EncryptTLFCryptKeys(codec kbfscodec.Codec, oldKeys []TLFCryptKey, key TLFCryptKey) ( encryptedTLFCryptKeys EncryptedTLFCryptKeys, err error) { encodedKeys, err := codec.Encode(oldKeys) if err != nil { return EncryptedTLFCryptKeys{}, err } encryptedData, err := encryptData(encodedKeys, key.Data()) if err != nil { return EncryptedTLFCryptKeys{}, err } return EncryptedTLFCryptKeys{encryptedData}, nil }
go
func EncryptTLFCryptKeys(codec kbfscodec.Codec, oldKeys []TLFCryptKey, key TLFCryptKey) ( encryptedTLFCryptKeys EncryptedTLFCryptKeys, err error) { encodedKeys, err := codec.Encode(oldKeys) if err != nil { return EncryptedTLFCryptKeys{}, err } encryptedData, err := encryptData(encodedKeys, key.Data()) if err != nil { return EncryptedTLFCryptKeys{}, err } return EncryptedTLFCryptKeys{encryptedData}, nil }
[ "func", "EncryptTLFCryptKeys", "(", "codec", "kbfscodec", ".", "Codec", ",", "oldKeys", "[", "]", "TLFCryptKey", ",", "key", "TLFCryptKey", ")", "(", "encryptedTLFCryptKeys", "EncryptedTLFCryptKeys", ",", "err", "error", ")", "{", "encodedKeys", ",", "err", ":=", "codec", ".", "Encode", "(", "oldKeys", ")", "\n", "if", "err", "!=", "nil", "{", "return", "EncryptedTLFCryptKeys", "{", "}", ",", "err", "\n", "}", "\n\n", "encryptedData", ",", "err", ":=", "encryptData", "(", "encodedKeys", ",", "key", ".", "Data", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "EncryptedTLFCryptKeys", "{", "}", ",", "err", "\n", "}", "\n\n", "return", "EncryptedTLFCryptKeys", "{", "encryptedData", "}", ",", "nil", "\n", "}" ]
// EncryptTLFCryptKeys encrypts a TLFCryptKey array.
[ "EncryptTLFCryptKeys", "encrypts", "a", "TLFCryptKey", "array", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscrypto/encrypted_data.go#L284-L297
159,119
keybase/client
go/kbfs/kbfscrypto/encrypted_data.go
DecryptTLFCryptKeys
func DecryptTLFCryptKeys( codec kbfscodec.Codec, encryptedTLFCryptKeys EncryptedTLFCryptKeys, key TLFCryptKey) ( []TLFCryptKey, error) { if encryptedTLFCryptKeys.encryptedData.Version == EncryptionSecretboxWithKeyNonce { // Only blocks should have v2 encryption. return nil, errors.WithStack( InvalidEncryptionVer{encryptedTLFCryptKeys.encryptedData.Version}) } nonce, err := encryptedTLFCryptKeys.encryptedData.Nonce24() if err != nil { return nil, err } encodedKeys, err := decryptData( encryptedTLFCryptKeys.encryptedData, key.Data(), nonce) if err != nil { return nil, err } var oldKeys []TLFCryptKey err = codec.Decode(encodedKeys, &oldKeys) if err != nil { return nil, err } return oldKeys, nil }
go
func DecryptTLFCryptKeys( codec kbfscodec.Codec, encryptedTLFCryptKeys EncryptedTLFCryptKeys, key TLFCryptKey) ( []TLFCryptKey, error) { if encryptedTLFCryptKeys.encryptedData.Version == EncryptionSecretboxWithKeyNonce { // Only blocks should have v2 encryption. return nil, errors.WithStack( InvalidEncryptionVer{encryptedTLFCryptKeys.encryptedData.Version}) } nonce, err := encryptedTLFCryptKeys.encryptedData.Nonce24() if err != nil { return nil, err } encodedKeys, err := decryptData( encryptedTLFCryptKeys.encryptedData, key.Data(), nonce) if err != nil { return nil, err } var oldKeys []TLFCryptKey err = codec.Decode(encodedKeys, &oldKeys) if err != nil { return nil, err } return oldKeys, nil }
[ "func", "DecryptTLFCryptKeys", "(", "codec", "kbfscodec", ".", "Codec", ",", "encryptedTLFCryptKeys", "EncryptedTLFCryptKeys", ",", "key", "TLFCryptKey", ")", "(", "[", "]", "TLFCryptKey", ",", "error", ")", "{", "if", "encryptedTLFCryptKeys", ".", "encryptedData", ".", "Version", "==", "EncryptionSecretboxWithKeyNonce", "{", "// Only blocks should have v2 encryption.", "return", "nil", ",", "errors", ".", "WithStack", "(", "InvalidEncryptionVer", "{", "encryptedTLFCryptKeys", ".", "encryptedData", ".", "Version", "}", ")", "\n", "}", "\n\n", "nonce", ",", "err", ":=", "encryptedTLFCryptKeys", ".", "encryptedData", ".", "Nonce24", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "encodedKeys", ",", "err", ":=", "decryptData", "(", "encryptedTLFCryptKeys", ".", "encryptedData", ",", "key", ".", "Data", "(", ")", ",", "nonce", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "oldKeys", "[", "]", "TLFCryptKey", "\n", "err", "=", "codec", ".", "Decode", "(", "encodedKeys", ",", "&", "oldKeys", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "oldKeys", ",", "nil", "\n", "}" ]
// DecryptTLFCryptKeys decrypts a TLFCryptKey array, but does not // decode it.
[ "DecryptTLFCryptKeys", "decrypts", "a", "TLFCryptKey", "array", "but", "does", "not", "decode", "it", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscrypto/encrypted_data.go#L301-L329
159,120
keybase/client
go/kbfs/kbfscrypto/encrypted_data.go
MakeEncryptedMerkleLeaf
func MakeEncryptedMerkleLeaf( version EncryptionVer, data []byte, nonce *[24]byte) EncryptedMerkleLeaf { return EncryptedMerkleLeaf{ encryptedData{ Version: version, EncryptedData: data, Nonce: nonce[:], }, } }
go
func MakeEncryptedMerkleLeaf( version EncryptionVer, data []byte, nonce *[24]byte) EncryptedMerkleLeaf { return EncryptedMerkleLeaf{ encryptedData{ Version: version, EncryptedData: data, Nonce: nonce[:], }, } }
[ "func", "MakeEncryptedMerkleLeaf", "(", "version", "EncryptionVer", ",", "data", "[", "]", "byte", ",", "nonce", "*", "[", "24", "]", "byte", ")", "EncryptedMerkleLeaf", "{", "return", "EncryptedMerkleLeaf", "{", "encryptedData", "{", "Version", ":", "version", ",", "EncryptedData", ":", "data", ",", "Nonce", ":", "nonce", "[", ":", "]", ",", "}", ",", "}", "\n", "}" ]
// MakeEncryptedMerkleLeaf constructs an EncryptedMerkleLeaf.
[ "MakeEncryptedMerkleLeaf", "constructs", "an", "EncryptedMerkleLeaf", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscrypto/encrypted_data.go#L337-L346
159,121
keybase/client
go/kbfs/kbfscrypto/encrypted_data.go
PrepareMerkleLeaf
func PrepareMerkleLeaf(encryptedMerkleLeaf EncryptedMerkleLeaf) ( nonce [24]byte, err error) { if encryptedMerkleLeaf.Version != EncryptionSecretbox { return nonce, errors.WithStack(UnknownEncryptionVer{ Ver: encryptedMerkleLeaf.Version}) } if len(encryptedMerkleLeaf.Nonce) != len(nonce) { return nonce, errors.WithStack(InvalidNonceError{ Nonce: encryptedMerkleLeaf.Nonce}) } copy(nonce[:], encryptedMerkleLeaf.Nonce) return nonce, nil }
go
func PrepareMerkleLeaf(encryptedMerkleLeaf EncryptedMerkleLeaf) ( nonce [24]byte, err error) { if encryptedMerkleLeaf.Version != EncryptionSecretbox { return nonce, errors.WithStack(UnknownEncryptionVer{ Ver: encryptedMerkleLeaf.Version}) } if len(encryptedMerkleLeaf.Nonce) != len(nonce) { return nonce, errors.WithStack(InvalidNonceError{ Nonce: encryptedMerkleLeaf.Nonce}) } copy(nonce[:], encryptedMerkleLeaf.Nonce) return nonce, nil }
[ "func", "PrepareMerkleLeaf", "(", "encryptedMerkleLeaf", "EncryptedMerkleLeaf", ")", "(", "nonce", "[", "24", "]", "byte", ",", "err", "error", ")", "{", "if", "encryptedMerkleLeaf", ".", "Version", "!=", "EncryptionSecretbox", "{", "return", "nonce", ",", "errors", ".", "WithStack", "(", "UnknownEncryptionVer", "{", "Ver", ":", "encryptedMerkleLeaf", ".", "Version", "}", ")", "\n", "}", "\n\n", "if", "len", "(", "encryptedMerkleLeaf", ".", "Nonce", ")", "!=", "len", "(", "nonce", ")", "{", "return", "nonce", ",", "errors", ".", "WithStack", "(", "InvalidNonceError", "{", "Nonce", ":", "encryptedMerkleLeaf", ".", "Nonce", "}", ")", "\n", "}", "\n", "copy", "(", "nonce", "[", ":", "]", ",", "encryptedMerkleLeaf", ".", "Nonce", ")", "\n", "return", "nonce", ",", "nil", "\n", "}" ]
// PrepareMerkleLeaf verifies the correctness of the given leaf, and // returns its nonce.
[ "PrepareMerkleLeaf", "verifies", "the", "correctness", "of", "the", "given", "leaf", "and", "returns", "its", "nonce", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscrypto/encrypted_data.go#L350-L365
159,122
keybase/client
go/kbfs/kbfscrypto/encrypted_data.go
DecryptMerkleLeaf
func DecryptMerkleLeaf( privateKey TLFPrivateKey, publicKey TLFEphemeralPublicKey, encryptedMerkleLeaf EncryptedMerkleLeaf) ([]byte, error) { nonce, err := PrepareMerkleLeaf(encryptedMerkleLeaf) if err != nil { return nil, err } publicKeyData := publicKey.Data() privateKeyData := privateKey.Data() decryptedData, ok := box.Open(nil, encryptedMerkleLeaf.EncryptedData, &nonce, &publicKeyData, &privateKeyData) if !ok { return nil, errors.WithStack( libkb.DecryptionError{Cause: errors.New("Cannot open box")}) } return decryptedData, nil }
go
func DecryptMerkleLeaf( privateKey TLFPrivateKey, publicKey TLFEphemeralPublicKey, encryptedMerkleLeaf EncryptedMerkleLeaf) ([]byte, error) { nonce, err := PrepareMerkleLeaf(encryptedMerkleLeaf) if err != nil { return nil, err } publicKeyData := publicKey.Data() privateKeyData := privateKey.Data() decryptedData, ok := box.Open(nil, encryptedMerkleLeaf.EncryptedData, &nonce, &publicKeyData, &privateKeyData) if !ok { return nil, errors.WithStack( libkb.DecryptionError{Cause: errors.New("Cannot open box")}) } return decryptedData, nil }
[ "func", "DecryptMerkleLeaf", "(", "privateKey", "TLFPrivateKey", ",", "publicKey", "TLFEphemeralPublicKey", ",", "encryptedMerkleLeaf", "EncryptedMerkleLeaf", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "nonce", ",", "err", ":=", "PrepareMerkleLeaf", "(", "encryptedMerkleLeaf", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "publicKeyData", ":=", "publicKey", ".", "Data", "(", ")", "\n", "privateKeyData", ":=", "privateKey", ".", "Data", "(", ")", "\n", "decryptedData", ",", "ok", ":=", "box", ".", "Open", "(", "nil", ",", "encryptedMerkleLeaf", ".", "EncryptedData", ",", "&", "nonce", ",", "&", "publicKeyData", ",", "&", "privateKeyData", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "errors", ".", "WithStack", "(", "libkb", ".", "DecryptionError", "{", "Cause", ":", "errors", ".", "New", "(", "\"", "\"", ")", "}", ")", "\n", "}", "\n", "return", "decryptedData", ",", "nil", "\n", "}" ]
// DecryptMerkleLeaf decrypts an EncryptedMerkleLeaf using the given // private TLF key and ephemeral public key.
[ "DecryptMerkleLeaf", "decrypts", "an", "EncryptedMerkleLeaf", "using", "the", "given", "private", "TLF", "key", "and", "ephemeral", "public", "key", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfscrypto/encrypted_data.go#L369-L386
159,123
keybase/client
go/engine/puk_upkeep.go
NewPerUserKeyUpkeep
func NewPerUserKeyUpkeep(g *libkb.GlobalContext, args *PerUserKeyUpkeepArgs) *PerUserKeyUpkeep { return &PerUserKeyUpkeep{ args: args, Contextified: libkb.NewContextified(g), } }
go
func NewPerUserKeyUpkeep(g *libkb.GlobalContext, args *PerUserKeyUpkeepArgs) *PerUserKeyUpkeep { return &PerUserKeyUpkeep{ args: args, Contextified: libkb.NewContextified(g), } }
[ "func", "NewPerUserKeyUpkeep", "(", "g", "*", "libkb", ".", "GlobalContext", ",", "args", "*", "PerUserKeyUpkeepArgs", ")", "*", "PerUserKeyUpkeep", "{", "return", "&", "PerUserKeyUpkeep", "{", "args", ":", "args", ",", "Contextified", ":", "libkb", ".", "NewContextified", "(", "g", ")", ",", "}", "\n", "}" ]
// NewPerUserKeyUpkeep creates a PerUserKeyUpkeep engine.
[ "NewPerUserKeyUpkeep", "creates", "a", "PerUserKeyUpkeep", "engine", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/puk_upkeep.go#L31-L36
159,124
keybase/client
go/engine/puk_upkeep.go
shouldRollKey
func (e *PerUserKeyUpkeep) shouldRollKey(m libkb.MetaContext, uid keybase1.UID, upak *keybase1.UserPlusKeysV2) (bool, error) { if len(upak.PerUserKeys) == 0 { m.Debug("PerUserKeyUpkeep has no per-user-key") return false, nil } m.Debug("PerUserKeyUpkeep has %v per-user-keys", len(upak.PerUserKeys)) lastPuk := upak.PerUserKeys[len(upak.PerUserKeys)-1] if !lastPuk.SignedByKID.IsValid() { return false, errors.New("latest per-user-key had invalid signed-by KID") } m.Debug("PerUserKeyUpkeep last key signed by KID: %v", lastPuk.SignedByKID.String()) return !e.keyIsActiveSibkey(m, lastPuk.SignedByKID, upak), nil }
go
func (e *PerUserKeyUpkeep) shouldRollKey(m libkb.MetaContext, uid keybase1.UID, upak *keybase1.UserPlusKeysV2) (bool, error) { if len(upak.PerUserKeys) == 0 { m.Debug("PerUserKeyUpkeep has no per-user-key") return false, nil } m.Debug("PerUserKeyUpkeep has %v per-user-keys", len(upak.PerUserKeys)) lastPuk := upak.PerUserKeys[len(upak.PerUserKeys)-1] if !lastPuk.SignedByKID.IsValid() { return false, errors.New("latest per-user-key had invalid signed-by KID") } m.Debug("PerUserKeyUpkeep last key signed by KID: %v", lastPuk.SignedByKID.String()) return !e.keyIsActiveSibkey(m, lastPuk.SignedByKID, upak), nil }
[ "func", "(", "e", "*", "PerUserKeyUpkeep", ")", "shouldRollKey", "(", "m", "libkb", ".", "MetaContext", ",", "uid", "keybase1", ".", "UID", ",", "upak", "*", "keybase1", ".", "UserPlusKeysV2", ")", "(", "bool", ",", "error", ")", "{", "if", "len", "(", "upak", ".", "PerUserKeys", ")", "==", "0", "{", "m", ".", "Debug", "(", "\"", "\"", ")", "\n", "return", "false", ",", "nil", "\n", "}", "\n", "m", ".", "Debug", "(", "\"", "\"", ",", "len", "(", "upak", ".", "PerUserKeys", ")", ")", "\n\n", "lastPuk", ":=", "upak", ".", "PerUserKeys", "[", "len", "(", "upak", ".", "PerUserKeys", ")", "-", "1", "]", "\n", "if", "!", "lastPuk", ".", "SignedByKID", ".", "IsValid", "(", ")", "{", "return", "false", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "m", ".", "Debug", "(", "\"", "\"", ",", "lastPuk", ".", "SignedByKID", ".", "String", "(", ")", ")", "\n", "return", "!", "e", ".", "keyIsActiveSibkey", "(", "m", ",", "lastPuk", ".", "SignedByKID", ",", "upak", ")", ",", "nil", "\n", "}" ]
// Whether we should roll the per-user-key.
[ "Whether", "we", "should", "roll", "the", "per", "-", "user", "-", "key", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/puk_upkeep.go#L106-L120
159,125
keybase/client
go/install/fuse_status_windows.go
findDokanUninstall
func findDokanUninstall(log Log, wow64 bool) (result string) { dokanRegexp := regexp.MustCompile("^Dokan Library.*Bundle") var access uint32 = registry.ENUMERATE_SUB_KEYS | registry.QUERY_VALUE // Assume this is build 64 bit, so we need this flag to see 32 bit WOW registry // https://msdn.microsoft.com/en-us/library/windows/desktop/aa384129(v=vs.110).aspx if wow64 { access = access | registry.WOW64_32KEY } k, err := registry.OpenKey(registry.LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall", access) if err != nil { log.Info("Error %s opening uninstall subkeys\n", err.Error()) return } defer k.Close() names, err := k.ReadSubKeyNames(-1) if err != nil { log.Info("Error %s reading subkeys\n", err.Error()) return } for _, name := range names { subKey, err := registry.OpenKey(k, name, registry.QUERY_VALUE) if err != nil { log.Info("Error %s opening subkey %s\n", err.Error(), name) } displayName, _, err := subKey.GetStringValue("DisplayName") if err != nil { // this error is not interesting to log continue } if !dokanRegexp.MatchString(displayName) { continue } result, _, err := subKey.GetStringValue("UninstallString") if err != nil { result, _, err = subKey.GetStringValue("QuietUninstallString") } if err != nil { log.Info("Error %s opening subkey UninstallString", err.Error()) } else { return result } } return }
go
func findDokanUninstall(log Log, wow64 bool) (result string) { dokanRegexp := regexp.MustCompile("^Dokan Library.*Bundle") var access uint32 = registry.ENUMERATE_SUB_KEYS | registry.QUERY_VALUE // Assume this is build 64 bit, so we need this flag to see 32 bit WOW registry // https://msdn.microsoft.com/en-us/library/windows/desktop/aa384129(v=vs.110).aspx if wow64 { access = access | registry.WOW64_32KEY } k, err := registry.OpenKey(registry.LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall", access) if err != nil { log.Info("Error %s opening uninstall subkeys\n", err.Error()) return } defer k.Close() names, err := k.ReadSubKeyNames(-1) if err != nil { log.Info("Error %s reading subkeys\n", err.Error()) return } for _, name := range names { subKey, err := registry.OpenKey(k, name, registry.QUERY_VALUE) if err != nil { log.Info("Error %s opening subkey %s\n", err.Error(), name) } displayName, _, err := subKey.GetStringValue("DisplayName") if err != nil { // this error is not interesting to log continue } if !dokanRegexp.MatchString(displayName) { continue } result, _, err := subKey.GetStringValue("UninstallString") if err != nil { result, _, err = subKey.GetStringValue("QuietUninstallString") } if err != nil { log.Info("Error %s opening subkey UninstallString", err.Error()) } else { return result } } return }
[ "func", "findDokanUninstall", "(", "log", "Log", ",", "wow64", "bool", ")", "(", "result", "string", ")", "{", "dokanRegexp", ":=", "regexp", ".", "MustCompile", "(", "\"", "\"", ")", "\n", "var", "access", "uint32", "=", "registry", ".", "ENUMERATE_SUB_KEYS", "|", "registry", ".", "QUERY_VALUE", "\n", "// Assume this is build 64 bit, so we need this flag to see 32 bit WOW registry", "// https://msdn.microsoft.com/en-us/library/windows/desktop/aa384129(v=vs.110).aspx", "if", "wow64", "{", "access", "=", "access", "|", "registry", ".", "WOW64_32KEY", "\n", "}", "\n\n", "k", ",", "err", ":=", "registry", ".", "OpenKey", "(", "registry", ".", "LOCAL_MACHINE", ",", "\"", "\\\\", "\\\\", "\\\\", "\\\\", "\"", ",", "access", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Info", "(", "\"", "\\n", "\"", ",", "err", ".", "Error", "(", ")", ")", "\n", "return", "\n", "}", "\n", "defer", "k", ".", "Close", "(", ")", "\n\n", "names", ",", "err", ":=", "k", ".", "ReadSubKeyNames", "(", "-", "1", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Info", "(", "\"", "\\n", "\"", ",", "err", ".", "Error", "(", ")", ")", "\n", "return", "\n", "}", "\n", "for", "_", ",", "name", ":=", "range", "names", "{", "subKey", ",", "err", ":=", "registry", ".", "OpenKey", "(", "k", ",", "name", ",", "registry", ".", "QUERY_VALUE", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Info", "(", "\"", "\\n", "\"", ",", "err", ".", "Error", "(", ")", ",", "name", ")", "\n", "}", "\n\n", "displayName", ",", "_", ",", "err", ":=", "subKey", ".", "GetStringValue", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "// this error is not interesting to log", "continue", "\n", "}", "\n", "if", "!", "dokanRegexp", ".", "MatchString", "(", "displayName", ")", "{", "continue", "\n", "}", "\n\n", "result", ",", "_", ",", "err", ":=", "subKey", ".", "GetStringValue", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "result", ",", "_", ",", "err", "=", "subKey", ".", "GetStringValue", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Info", "(", "\"", "\"", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "else", "{", "return", "result", "\n", "}", "\n\n", "}", "\n", "return", "\n", "}" ]
// Read all the uninstall subkeys and find the ones with DisplayName starting with "Dokan Library" // and containing "Bundle"
[ "Read", "all", "the", "uninstall", "subkeys", "and", "find", "the", "ones", "with", "DisplayName", "starting", "with", "Dokan", "Library", "and", "containing", "Bundle" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/install/fuse_status_windows.go#L40-L88
159,126
keybase/client
go/kbfs/libkbfs/disk_block_cache_service.go
GetBlock
func (cache *DiskBlockCacheService) GetBlock(ctx context.Context, arg kbgitkbfs.GetBlockArg) (kbgitkbfs.GetBlockRes, error) { // TODO: make sure this isn't remote. dbc := cache.config.DiskBlockCache() if dbc == nil { return kbgitkbfs.GetBlockRes{}, DiskBlockCacheError{"Disk cache is nil"} } tlfID := tlf.ID{} err := tlfID.UnmarshalBinary(arg.TlfID) if err != nil { return kbgitkbfs.GetBlockRes{}, newDiskBlockCacheError(err) } blockID := kbfsblock.ID{} err = blockID.UnmarshalBinary(arg.BlockID) if err != nil { return kbgitkbfs.GetBlockRes{}, newDiskBlockCacheError(err) } buf, serverHalf, prefetchStatus, err := dbc.Get( ctx, tlfID, blockID, DiskBlockAnyCache) if err != nil { return kbgitkbfs.GetBlockRes{}, newDiskBlockCacheError(err) } protocolPrefetchStatus := prefetchStatus.ToProtocol() return kbgitkbfs.GetBlockRes{ Buf: buf, ServerHalf: serverHalf.Bytes(), PrefetchStatus: protocolPrefetchStatus, }, nil }
go
func (cache *DiskBlockCacheService) GetBlock(ctx context.Context, arg kbgitkbfs.GetBlockArg) (kbgitkbfs.GetBlockRes, error) { // TODO: make sure this isn't remote. dbc := cache.config.DiskBlockCache() if dbc == nil { return kbgitkbfs.GetBlockRes{}, DiskBlockCacheError{"Disk cache is nil"} } tlfID := tlf.ID{} err := tlfID.UnmarshalBinary(arg.TlfID) if err != nil { return kbgitkbfs.GetBlockRes{}, newDiskBlockCacheError(err) } blockID := kbfsblock.ID{} err = blockID.UnmarshalBinary(arg.BlockID) if err != nil { return kbgitkbfs.GetBlockRes{}, newDiskBlockCacheError(err) } buf, serverHalf, prefetchStatus, err := dbc.Get( ctx, tlfID, blockID, DiskBlockAnyCache) if err != nil { return kbgitkbfs.GetBlockRes{}, newDiskBlockCacheError(err) } protocolPrefetchStatus := prefetchStatus.ToProtocol() return kbgitkbfs.GetBlockRes{ Buf: buf, ServerHalf: serverHalf.Bytes(), PrefetchStatus: protocolPrefetchStatus, }, nil }
[ "func", "(", "cache", "*", "DiskBlockCacheService", ")", "GetBlock", "(", "ctx", "context", ".", "Context", ",", "arg", "kbgitkbfs", ".", "GetBlockArg", ")", "(", "kbgitkbfs", ".", "GetBlockRes", ",", "error", ")", "{", "// TODO: make sure this isn't remote.", "dbc", ":=", "cache", ".", "config", ".", "DiskBlockCache", "(", ")", "\n", "if", "dbc", "==", "nil", "{", "return", "kbgitkbfs", ".", "GetBlockRes", "{", "}", ",", "DiskBlockCacheError", "{", "\"", "\"", "}", "\n", "}", "\n", "tlfID", ":=", "tlf", ".", "ID", "{", "}", "\n", "err", ":=", "tlfID", ".", "UnmarshalBinary", "(", "arg", ".", "TlfID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "kbgitkbfs", ".", "GetBlockRes", "{", "}", ",", "newDiskBlockCacheError", "(", "err", ")", "\n", "}", "\n", "blockID", ":=", "kbfsblock", ".", "ID", "{", "}", "\n", "err", "=", "blockID", ".", "UnmarshalBinary", "(", "arg", ".", "BlockID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "kbgitkbfs", ".", "GetBlockRes", "{", "}", ",", "newDiskBlockCacheError", "(", "err", ")", "\n", "}", "\n", "buf", ",", "serverHalf", ",", "prefetchStatus", ",", "err", ":=", "dbc", ".", "Get", "(", "ctx", ",", "tlfID", ",", "blockID", ",", "DiskBlockAnyCache", ")", "\n", "if", "err", "!=", "nil", "{", "return", "kbgitkbfs", ".", "GetBlockRes", "{", "}", ",", "newDiskBlockCacheError", "(", "err", ")", "\n", "}", "\n", "protocolPrefetchStatus", ":=", "prefetchStatus", ".", "ToProtocol", "(", ")", "\n\n", "return", "kbgitkbfs", ".", "GetBlockRes", "{", "Buf", ":", "buf", ",", "ServerHalf", ":", "serverHalf", ".", "Bytes", "(", ")", ",", "PrefetchStatus", ":", "protocolPrefetchStatus", ",", "}", ",", "nil", "\n", "}" ]
// GetBlock implements the DiskBlockCacheInterface interface for // DiskBlockCacheService.
[ "GetBlock", "implements", "the", "DiskBlockCacheInterface", "interface", "for", "DiskBlockCacheService", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/disk_block_cache_service.go#L38-L68
159,127
keybase/client
go/kbfs/libkbfs/disk_block_cache_service.go
GetPrefetchStatus
func (cache *DiskBlockCacheService) GetPrefetchStatus( ctx context.Context, arg kbgitkbfs.GetPrefetchStatusArg) ( prefetchStatus kbgitkbfs.PrefetchStatus, err error) { dbc := cache.config.DiskBlockCache() if dbc == nil { return NoPrefetch.ToProtocol(), DiskBlockCacheError{"Disk cache is nil"} } tlfID := tlf.ID{} err = tlfID.UnmarshalBinary(arg.TlfID) if err != nil { return NoPrefetch.ToProtocol(), newDiskBlockCacheError(err) } blockID := kbfsblock.ID{} err = blockID.UnmarshalBinary(arg.BlockID) if err != nil { return NoPrefetch.ToProtocol(), newDiskBlockCacheError(err) } cacheType := DiskBlockAnyCache if cache.config.IsSyncedTlf(tlfID) { cacheType = DiskBlockSyncCache } dbStatus, err := dbc.GetPrefetchStatus(ctx, tlfID, blockID, cacheType) if err != nil { return NoPrefetch.ToProtocol(), newDiskBlockCacheError(err) } return dbStatus.ToProtocol(), nil }
go
func (cache *DiskBlockCacheService) GetPrefetchStatus( ctx context.Context, arg kbgitkbfs.GetPrefetchStatusArg) ( prefetchStatus kbgitkbfs.PrefetchStatus, err error) { dbc := cache.config.DiskBlockCache() if dbc == nil { return NoPrefetch.ToProtocol(), DiskBlockCacheError{"Disk cache is nil"} } tlfID := tlf.ID{} err = tlfID.UnmarshalBinary(arg.TlfID) if err != nil { return NoPrefetch.ToProtocol(), newDiskBlockCacheError(err) } blockID := kbfsblock.ID{} err = blockID.UnmarshalBinary(arg.BlockID) if err != nil { return NoPrefetch.ToProtocol(), newDiskBlockCacheError(err) } cacheType := DiskBlockAnyCache if cache.config.IsSyncedTlf(tlfID) { cacheType = DiskBlockSyncCache } dbStatus, err := dbc.GetPrefetchStatus(ctx, tlfID, blockID, cacheType) if err != nil { return NoPrefetch.ToProtocol(), newDiskBlockCacheError(err) } return dbStatus.ToProtocol(), nil }
[ "func", "(", "cache", "*", "DiskBlockCacheService", ")", "GetPrefetchStatus", "(", "ctx", "context", ".", "Context", ",", "arg", "kbgitkbfs", ".", "GetPrefetchStatusArg", ")", "(", "prefetchStatus", "kbgitkbfs", ".", "PrefetchStatus", ",", "err", "error", ")", "{", "dbc", ":=", "cache", ".", "config", ".", "DiskBlockCache", "(", ")", "\n", "if", "dbc", "==", "nil", "{", "return", "NoPrefetch", ".", "ToProtocol", "(", ")", ",", "DiskBlockCacheError", "{", "\"", "\"", "}", "\n", "}", "\n", "tlfID", ":=", "tlf", ".", "ID", "{", "}", "\n", "err", "=", "tlfID", ".", "UnmarshalBinary", "(", "arg", ".", "TlfID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "NoPrefetch", ".", "ToProtocol", "(", ")", ",", "newDiskBlockCacheError", "(", "err", ")", "\n", "}", "\n", "blockID", ":=", "kbfsblock", ".", "ID", "{", "}", "\n", "err", "=", "blockID", ".", "UnmarshalBinary", "(", "arg", ".", "BlockID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "NoPrefetch", ".", "ToProtocol", "(", ")", ",", "newDiskBlockCacheError", "(", "err", ")", "\n", "}", "\n\n", "cacheType", ":=", "DiskBlockAnyCache", "\n", "if", "cache", ".", "config", ".", "IsSyncedTlf", "(", "tlfID", ")", "{", "cacheType", "=", "DiskBlockSyncCache", "\n", "}", "\n\n", "dbStatus", ",", "err", ":=", "dbc", ".", "GetPrefetchStatus", "(", "ctx", ",", "tlfID", ",", "blockID", ",", "cacheType", ")", "\n", "if", "err", "!=", "nil", "{", "return", "NoPrefetch", ".", "ToProtocol", "(", ")", ",", "newDiskBlockCacheError", "(", "err", ")", "\n", "}", "\n", "return", "dbStatus", ".", "ToProtocol", "(", ")", ",", "nil", "\n", "}" ]
// GetPrefetchStatus implements the DiskBlockCacheInterface interface // for DiskBlockCacheService.
[ "GetPrefetchStatus", "implements", "the", "DiskBlockCacheInterface", "interface", "for", "DiskBlockCacheService", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/disk_block_cache_service.go#L72-L100
159,128
keybase/client
go/kbfs/libkbfs/disk_block_cache_service.go
PutBlock
func (cache *DiskBlockCacheService) PutBlock(ctx context.Context, arg kbgitkbfs.PutBlockArg) error { dbc := cache.config.DiskBlockCache() if dbc == nil { return DiskBlockCacheError{"Disk cache is nil"} } tlfID := tlf.ID{} err := tlfID.UnmarshalBinary(arg.TlfID) if err != nil { return newDiskBlockCacheError(err) } blockID := kbfsblock.ID{} err = blockID.UnmarshalBinary(arg.BlockID) if err != nil { return newDiskBlockCacheError(err) } serverHalf := kbfscrypto.BlockCryptKeyServerHalf{} err = serverHalf.UnmarshalBinary(arg.ServerHalf) if err != nil { return newDiskBlockCacheError(err) } cacheType := DiskBlockAnyCache if cache.config.IsSyncedTlf(tlfID) { cacheType = DiskBlockSyncCache } err = dbc.Put(ctx, tlfID, blockID, arg.Buf, serverHalf, cacheType) if err != nil { return newDiskBlockCacheError(err) } return nil }
go
func (cache *DiskBlockCacheService) PutBlock(ctx context.Context, arg kbgitkbfs.PutBlockArg) error { dbc := cache.config.DiskBlockCache() if dbc == nil { return DiskBlockCacheError{"Disk cache is nil"} } tlfID := tlf.ID{} err := tlfID.UnmarshalBinary(arg.TlfID) if err != nil { return newDiskBlockCacheError(err) } blockID := kbfsblock.ID{} err = blockID.UnmarshalBinary(arg.BlockID) if err != nil { return newDiskBlockCacheError(err) } serverHalf := kbfscrypto.BlockCryptKeyServerHalf{} err = serverHalf.UnmarshalBinary(arg.ServerHalf) if err != nil { return newDiskBlockCacheError(err) } cacheType := DiskBlockAnyCache if cache.config.IsSyncedTlf(tlfID) { cacheType = DiskBlockSyncCache } err = dbc.Put(ctx, tlfID, blockID, arg.Buf, serverHalf, cacheType) if err != nil { return newDiskBlockCacheError(err) } return nil }
[ "func", "(", "cache", "*", "DiskBlockCacheService", ")", "PutBlock", "(", "ctx", "context", ".", "Context", ",", "arg", "kbgitkbfs", ".", "PutBlockArg", ")", "error", "{", "dbc", ":=", "cache", ".", "config", ".", "DiskBlockCache", "(", ")", "\n", "if", "dbc", "==", "nil", "{", "return", "DiskBlockCacheError", "{", "\"", "\"", "}", "\n", "}", "\n", "tlfID", ":=", "tlf", ".", "ID", "{", "}", "\n", "err", ":=", "tlfID", ".", "UnmarshalBinary", "(", "arg", ".", "TlfID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "newDiskBlockCacheError", "(", "err", ")", "\n", "}", "\n", "blockID", ":=", "kbfsblock", ".", "ID", "{", "}", "\n", "err", "=", "blockID", ".", "UnmarshalBinary", "(", "arg", ".", "BlockID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "newDiskBlockCacheError", "(", "err", ")", "\n", "}", "\n", "serverHalf", ":=", "kbfscrypto", ".", "BlockCryptKeyServerHalf", "{", "}", "\n", "err", "=", "serverHalf", ".", "UnmarshalBinary", "(", "arg", ".", "ServerHalf", ")", "\n", "if", "err", "!=", "nil", "{", "return", "newDiskBlockCacheError", "(", "err", ")", "\n", "}", "\n", "cacheType", ":=", "DiskBlockAnyCache", "\n", "if", "cache", ".", "config", ".", "IsSyncedTlf", "(", "tlfID", ")", "{", "cacheType", "=", "DiskBlockSyncCache", "\n", "}", "\n", "err", "=", "dbc", ".", "Put", "(", "ctx", ",", "tlfID", ",", "blockID", ",", "arg", ".", "Buf", ",", "serverHalf", ",", "cacheType", ")", "\n", "if", "err", "!=", "nil", "{", "return", "newDiskBlockCacheError", "(", "err", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// PutBlock implements the DiskBlockCacheInterface interface for // DiskBlockCacheService.
[ "PutBlock", "implements", "the", "DiskBlockCacheInterface", "interface", "for", "DiskBlockCacheService", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/disk_block_cache_service.go#L104-L134
159,129
keybase/client
go/kbfs/libkbfs/disk_block_cache_service.go
DeleteBlocks
func (cache *DiskBlockCacheService) DeleteBlocks(ctx context.Context, blockIDs [][]byte) (kbgitkbfs.DeleteBlocksRes, error) { dbc := cache.config.DiskBlockCache() if dbc == nil { return kbgitkbfs.DeleteBlocksRes{}, DiskBlockCacheError{"Disk cache is nil"} } blocks := make([]kbfsblock.ID, 0, len(blockIDs)) for _, b := range blockIDs { blockID := kbfsblock.ID{} err := blockID.UnmarshalBinary(b) if err != nil { return kbgitkbfs.DeleteBlocksRes{}, newDiskBlockCacheError(err) } blocks = append(blocks, blockID) } numRemoved, sizeRemoved, err := dbc.Delete(ctx, blocks, DiskBlockAnyCache) if err != nil { return kbgitkbfs.DeleteBlocksRes{}, newDiskBlockCacheError(err) } return kbgitkbfs.DeleteBlocksRes{ NumRemoved: numRemoved, SizeRemoved: sizeRemoved, }, nil }
go
func (cache *DiskBlockCacheService) DeleteBlocks(ctx context.Context, blockIDs [][]byte) (kbgitkbfs.DeleteBlocksRes, error) { dbc := cache.config.DiskBlockCache() if dbc == nil { return kbgitkbfs.DeleteBlocksRes{}, DiskBlockCacheError{"Disk cache is nil"} } blocks := make([]kbfsblock.ID, 0, len(blockIDs)) for _, b := range blockIDs { blockID := kbfsblock.ID{} err := blockID.UnmarshalBinary(b) if err != nil { return kbgitkbfs.DeleteBlocksRes{}, newDiskBlockCacheError(err) } blocks = append(blocks, blockID) } numRemoved, sizeRemoved, err := dbc.Delete(ctx, blocks, DiskBlockAnyCache) if err != nil { return kbgitkbfs.DeleteBlocksRes{}, newDiskBlockCacheError(err) } return kbgitkbfs.DeleteBlocksRes{ NumRemoved: numRemoved, SizeRemoved: sizeRemoved, }, nil }
[ "func", "(", "cache", "*", "DiskBlockCacheService", ")", "DeleteBlocks", "(", "ctx", "context", ".", "Context", ",", "blockIDs", "[", "]", "[", "]", "byte", ")", "(", "kbgitkbfs", ".", "DeleteBlocksRes", ",", "error", ")", "{", "dbc", ":=", "cache", ".", "config", ".", "DiskBlockCache", "(", ")", "\n", "if", "dbc", "==", "nil", "{", "return", "kbgitkbfs", ".", "DeleteBlocksRes", "{", "}", ",", "DiskBlockCacheError", "{", "\"", "\"", "}", "\n", "}", "\n", "blocks", ":=", "make", "(", "[", "]", "kbfsblock", ".", "ID", ",", "0", ",", "len", "(", "blockIDs", ")", ")", "\n", "for", "_", ",", "b", ":=", "range", "blockIDs", "{", "blockID", ":=", "kbfsblock", ".", "ID", "{", "}", "\n", "err", ":=", "blockID", ".", "UnmarshalBinary", "(", "b", ")", "\n", "if", "err", "!=", "nil", "{", "return", "kbgitkbfs", ".", "DeleteBlocksRes", "{", "}", ",", "newDiskBlockCacheError", "(", "err", ")", "\n", "}", "\n", "blocks", "=", "append", "(", "blocks", ",", "blockID", ")", "\n", "}", "\n", "numRemoved", ",", "sizeRemoved", ",", "err", ":=", "dbc", ".", "Delete", "(", "ctx", ",", "blocks", ",", "DiskBlockAnyCache", ")", "\n", "if", "err", "!=", "nil", "{", "return", "kbgitkbfs", ".", "DeleteBlocksRes", "{", "}", ",", "newDiskBlockCacheError", "(", "err", ")", "\n", "}", "\n", "return", "kbgitkbfs", ".", "DeleteBlocksRes", "{", "NumRemoved", ":", "numRemoved", ",", "SizeRemoved", ":", "sizeRemoved", ",", "}", ",", "nil", "\n", "}" ]
// DeleteBlocks implements the DiskBlockCacheInterface interface for // DiskBlockCacheService.
[ "DeleteBlocks", "implements", "the", "DiskBlockCacheInterface", "interface", "for", "DiskBlockCacheService", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/disk_block_cache_service.go#L138-L162
159,130
keybase/client
go/kbfs/libkbfs/disk_block_cache_service.go
UpdateBlockMetadata
func (cache *DiskBlockCacheService) UpdateBlockMetadata(ctx context.Context, arg kbgitkbfs.UpdateBlockMetadataArg) error { dbc := cache.config.DiskBlockCache() if dbc == nil { return DiskBlockCacheError{"Disk cache is nil"} } tlfID := tlf.ID{} err := tlfID.UnmarshalBinary(arg.TlfID) if err != nil { return newDiskBlockCacheError(err) } blockID := kbfsblock.ID{} err = blockID.UnmarshalBinary(arg.BlockID) if err != nil { return newDiskBlockCacheError(err) } err = dbc.UpdateMetadata( ctx, tlfID, blockID, PrefetchStatus(arg.PrefetchStatus), DiskBlockAnyCache) if err != nil { return newDiskBlockCacheError(err) } return nil }
go
func (cache *DiskBlockCacheService) UpdateBlockMetadata(ctx context.Context, arg kbgitkbfs.UpdateBlockMetadataArg) error { dbc := cache.config.DiskBlockCache() if dbc == nil { return DiskBlockCacheError{"Disk cache is nil"} } tlfID := tlf.ID{} err := tlfID.UnmarshalBinary(arg.TlfID) if err != nil { return newDiskBlockCacheError(err) } blockID := kbfsblock.ID{} err = blockID.UnmarshalBinary(arg.BlockID) if err != nil { return newDiskBlockCacheError(err) } err = dbc.UpdateMetadata( ctx, tlfID, blockID, PrefetchStatus(arg.PrefetchStatus), DiskBlockAnyCache) if err != nil { return newDiskBlockCacheError(err) } return nil }
[ "func", "(", "cache", "*", "DiskBlockCacheService", ")", "UpdateBlockMetadata", "(", "ctx", "context", ".", "Context", ",", "arg", "kbgitkbfs", ".", "UpdateBlockMetadataArg", ")", "error", "{", "dbc", ":=", "cache", ".", "config", ".", "DiskBlockCache", "(", ")", "\n", "if", "dbc", "==", "nil", "{", "return", "DiskBlockCacheError", "{", "\"", "\"", "}", "\n", "}", "\n", "tlfID", ":=", "tlf", ".", "ID", "{", "}", "\n", "err", ":=", "tlfID", ".", "UnmarshalBinary", "(", "arg", ".", "TlfID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "newDiskBlockCacheError", "(", "err", ")", "\n", "}", "\n", "blockID", ":=", "kbfsblock", ".", "ID", "{", "}", "\n", "err", "=", "blockID", ".", "UnmarshalBinary", "(", "arg", ".", "BlockID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "newDiskBlockCacheError", "(", "err", ")", "\n", "}", "\n", "err", "=", "dbc", ".", "UpdateMetadata", "(", "ctx", ",", "tlfID", ",", "blockID", ",", "PrefetchStatus", "(", "arg", ".", "PrefetchStatus", ")", ",", "DiskBlockAnyCache", ")", "\n", "if", "err", "!=", "nil", "{", "return", "newDiskBlockCacheError", "(", "err", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// UpdateBlockMetadata implements the DiskBlockCacheInterface interface for // DiskBlockCacheService.
[ "UpdateBlockMetadata", "implements", "the", "DiskBlockCacheInterface", "interface", "for", "DiskBlockCacheService", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/disk_block_cache_service.go#L166-L189
159,131
keybase/client
go/stellar/bundle/boxer.go
BoxAndEncode
func BoxAndEncode(a *stellar1.Bundle, pukGen keybase1.PerUserKeyGeneration, puk libkb.PerUserKeySeed) (*BoxedEncoded, error) { err := a.CheckInvariants() if err != nil { return nil, err } accountsVisible, accountsSecret := visibilitySplit(a) // visible portion parent visibleV2 := newVisibleParent(a, accountsVisible) boxed := newBoxedEncoded() // encrypted account bundles for i, acctEntry := range visibleV2.Accounts { secret, ok := a.AccountBundles[acctEntry.AccountID] if !ok { continue } ab, err := accountBoxAndEncode(acctEntry.AccountID, secret, pukGen, puk) if err != nil { return nil, err } boxed.AcctBundles[acctEntry.AccountID] = *ab visibleV2.Accounts[i].EncAcctBundleHash = ab.EncHash } // have to do this after to get hashes of encrypted account bundles visiblePack, err := libkb.MsgpackEncode(visibleV2) if err != nil { return nil, err } visibleHash := sha256.Sum256(visiblePack) boxed.VisParentB64 = base64.StdEncoding.EncodeToString(visiblePack) // secret portion parent versionedSecret := stellar1.NewBundleSecretVersionedWithV2(stellar1.BundleSecretV2{ VisibleHash: visibleHash[:], Accounts: accountsSecret, }) boxed.EncParent, boxed.EncParentB64, err = parentBoxAndEncode(versionedSecret, pukGen, puk) if err != nil { return nil, err } return boxed, nil }
go
func BoxAndEncode(a *stellar1.Bundle, pukGen keybase1.PerUserKeyGeneration, puk libkb.PerUserKeySeed) (*BoxedEncoded, error) { err := a.CheckInvariants() if err != nil { return nil, err } accountsVisible, accountsSecret := visibilitySplit(a) // visible portion parent visibleV2 := newVisibleParent(a, accountsVisible) boxed := newBoxedEncoded() // encrypted account bundles for i, acctEntry := range visibleV2.Accounts { secret, ok := a.AccountBundles[acctEntry.AccountID] if !ok { continue } ab, err := accountBoxAndEncode(acctEntry.AccountID, secret, pukGen, puk) if err != nil { return nil, err } boxed.AcctBundles[acctEntry.AccountID] = *ab visibleV2.Accounts[i].EncAcctBundleHash = ab.EncHash } // have to do this after to get hashes of encrypted account bundles visiblePack, err := libkb.MsgpackEncode(visibleV2) if err != nil { return nil, err } visibleHash := sha256.Sum256(visiblePack) boxed.VisParentB64 = base64.StdEncoding.EncodeToString(visiblePack) // secret portion parent versionedSecret := stellar1.NewBundleSecretVersionedWithV2(stellar1.BundleSecretV2{ VisibleHash: visibleHash[:], Accounts: accountsSecret, }) boxed.EncParent, boxed.EncParentB64, err = parentBoxAndEncode(versionedSecret, pukGen, puk) if err != nil { return nil, err } return boxed, nil }
[ "func", "BoxAndEncode", "(", "a", "*", "stellar1", ".", "Bundle", ",", "pukGen", "keybase1", ".", "PerUserKeyGeneration", ",", "puk", "libkb", ".", "PerUserKeySeed", ")", "(", "*", "BoxedEncoded", ",", "error", ")", "{", "err", ":=", "a", ".", "CheckInvariants", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "accountsVisible", ",", "accountsSecret", ":=", "visibilitySplit", "(", "a", ")", "\n\n", "// visible portion parent", "visibleV2", ":=", "newVisibleParent", "(", "a", ",", "accountsVisible", ")", "\n\n", "boxed", ":=", "newBoxedEncoded", "(", ")", "\n\n", "// encrypted account bundles", "for", "i", ",", "acctEntry", ":=", "range", "visibleV2", ".", "Accounts", "{", "secret", ",", "ok", ":=", "a", ".", "AccountBundles", "[", "acctEntry", ".", "AccountID", "]", "\n", "if", "!", "ok", "{", "continue", "\n", "}", "\n", "ab", ",", "err", ":=", "accountBoxAndEncode", "(", "acctEntry", ".", "AccountID", ",", "secret", ",", "pukGen", ",", "puk", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "boxed", ".", "AcctBundles", "[", "acctEntry", ".", "AccountID", "]", "=", "*", "ab", "\n\n", "visibleV2", ".", "Accounts", "[", "i", "]", ".", "EncAcctBundleHash", "=", "ab", ".", "EncHash", "\n", "}", "\n\n", "// have to do this after to get hashes of encrypted account bundles", "visiblePack", ",", "err", ":=", "libkb", ".", "MsgpackEncode", "(", "visibleV2", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "visibleHash", ":=", "sha256", ".", "Sum256", "(", "visiblePack", ")", "\n", "boxed", ".", "VisParentB64", "=", "base64", ".", "StdEncoding", ".", "EncodeToString", "(", "visiblePack", ")", "\n\n", "// secret portion parent", "versionedSecret", ":=", "stellar1", ".", "NewBundleSecretVersionedWithV2", "(", "stellar1", ".", "BundleSecretV2", "{", "VisibleHash", ":", "visibleHash", "[", ":", "]", ",", "Accounts", ":", "accountsSecret", ",", "}", ")", "\n", "boxed", ".", "EncParent", ",", "boxed", ".", "EncParentB64", ",", "err", "=", "parentBoxAndEncode", "(", "versionedSecret", ",", "pukGen", ",", "puk", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "boxed", ",", "nil", "\n", "}" ]
// BoxAndEncode encrypts and encodes a Bundle object.
[ "BoxAndEncode", "encrypts", "and", "encodes", "a", "Bundle", "object", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/bundle/boxer.go#L64-L111
159,132
keybase/client
go/stellar/bundle/boxer.go
unboxParent
func unboxParent(encBundle stellar1.EncryptedBundle, hash stellar1.Hash, visB64 string, puk libkb.PerUserKeySeed) (*stellar1.Bundle, stellar1.BundleVersion, error) { versioned, err := decryptParent(encBundle, puk) if err != nil { return nil, 0, err } version, err := versioned.Version() if err != nil { return nil, 0, err } var bundleOut stellar1.Bundle switch version { case stellar1.BundleVersion_V2: bundleOut, err = unboxParentV2(versioned, visB64) if err != nil { return nil, 0, err } default: return nil, 0, fmt.Errorf("unsupported parent bundle version: %d", version) } bundleOut.OwnHash = hash if len(bundleOut.OwnHash) == 0 { return nil, 0, errors.New("stellar account bundle missing own hash") } return &bundleOut, version, nil }
go
func unboxParent(encBundle stellar1.EncryptedBundle, hash stellar1.Hash, visB64 string, puk libkb.PerUserKeySeed) (*stellar1.Bundle, stellar1.BundleVersion, error) { versioned, err := decryptParent(encBundle, puk) if err != nil { return nil, 0, err } version, err := versioned.Version() if err != nil { return nil, 0, err } var bundleOut stellar1.Bundle switch version { case stellar1.BundleVersion_V2: bundleOut, err = unboxParentV2(versioned, visB64) if err != nil { return nil, 0, err } default: return nil, 0, fmt.Errorf("unsupported parent bundle version: %d", version) } bundleOut.OwnHash = hash if len(bundleOut.OwnHash) == 0 { return nil, 0, errors.New("stellar account bundle missing own hash") } return &bundleOut, version, nil }
[ "func", "unboxParent", "(", "encBundle", "stellar1", ".", "EncryptedBundle", ",", "hash", "stellar1", ".", "Hash", ",", "visB64", "string", ",", "puk", "libkb", ".", "PerUserKeySeed", ")", "(", "*", "stellar1", ".", "Bundle", ",", "stellar1", ".", "BundleVersion", ",", "error", ")", "{", "versioned", ",", "err", ":=", "decryptParent", "(", "encBundle", ",", "puk", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "0", ",", "err", "\n", "}", "\n", "version", ",", "err", ":=", "versioned", ".", "Version", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "0", ",", "err", "\n", "}", "\n\n", "var", "bundleOut", "stellar1", ".", "Bundle", "\n", "switch", "version", "{", "case", "stellar1", ".", "BundleVersion_V2", ":", "bundleOut", ",", "err", "=", "unboxParentV2", "(", "versioned", ",", "visB64", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "0", ",", "err", "\n", "}", "\n", "default", ":", "return", "nil", ",", "0", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "version", ")", "\n", "}", "\n\n", "bundleOut", ".", "OwnHash", "=", "hash", "\n", "if", "len", "(", "bundleOut", ".", "OwnHash", ")", "==", "0", "{", "return", "nil", ",", "0", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "return", "&", "bundleOut", ",", "version", ",", "nil", "\n", "}" ]
// unboxParent unboxes an encrypted parent bundle and decodes the visual portion of the bundle. // It validates the visible hash in the secret portion.
[ "unboxParent", "unboxes", "an", "encrypted", "parent", "bundle", "and", "decodes", "the", "visual", "portion", "of", "the", "bundle", ".", "It", "validates", "the", "visible", "hash", "in", "the", "secret", "portion", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/bundle/boxer.go#L330-L357
159,133
keybase/client
go/stellar/bundle/boxer.go
decryptParent
func decryptParent(encBundle stellar1.EncryptedBundle, puk libkb.PerUserKeySeed) (res stellar1.BundleSecretVersioned, err error) { switch encBundle.V { case 1: // CORE-8135 return res, fmt.Errorf("stellar secret bundle encryption version 1 has been retired") case 2: default: return res, fmt.Errorf("unsupported stellar secret bundle encryption version: %v", encBundle.V) } // Derive key reason := libkb.DeriveReasonPUKStellarBundle symmetricKey, err := puk.DeriveSymmetricKey(reason) if err != nil { return res, err } // Secretbox clearpack, ok := secretbox.Open(nil, encBundle.E, (*[libkb.NaclDHNonceSize]byte)(&encBundle.N), (*[libkb.NaclSecretBoxKeySize]byte)(&symmetricKey)) if !ok { return res, errors.New("stellar bundle secret box open failed") } // Msgpack (inner) err = libkb.MsgpackDecode(&res, clearpack) return res, err }
go
func decryptParent(encBundle stellar1.EncryptedBundle, puk libkb.PerUserKeySeed) (res stellar1.BundleSecretVersioned, err error) { switch encBundle.V { case 1: // CORE-8135 return res, fmt.Errorf("stellar secret bundle encryption version 1 has been retired") case 2: default: return res, fmt.Errorf("unsupported stellar secret bundle encryption version: %v", encBundle.V) } // Derive key reason := libkb.DeriveReasonPUKStellarBundle symmetricKey, err := puk.DeriveSymmetricKey(reason) if err != nil { return res, err } // Secretbox clearpack, ok := secretbox.Open(nil, encBundle.E, (*[libkb.NaclDHNonceSize]byte)(&encBundle.N), (*[libkb.NaclSecretBoxKeySize]byte)(&symmetricKey)) if !ok { return res, errors.New("stellar bundle secret box open failed") } // Msgpack (inner) err = libkb.MsgpackDecode(&res, clearpack) return res, err }
[ "func", "decryptParent", "(", "encBundle", "stellar1", ".", "EncryptedBundle", ",", "puk", "libkb", ".", "PerUserKeySeed", ")", "(", "res", "stellar1", ".", "BundleSecretVersioned", ",", "err", "error", ")", "{", "switch", "encBundle", ".", "V", "{", "case", "1", ":", "// CORE-8135", "return", "res", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "case", "2", ":", "default", ":", "return", "res", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "encBundle", ".", "V", ")", "\n", "}", "\n\n", "// Derive key", "reason", ":=", "libkb", ".", "DeriveReasonPUKStellarBundle", "\n", "symmetricKey", ",", "err", ":=", "puk", ".", "DeriveSymmetricKey", "(", "reason", ")", "\n", "if", "err", "!=", "nil", "{", "return", "res", ",", "err", "\n", "}", "\n\n", "// Secretbox", "clearpack", ",", "ok", ":=", "secretbox", ".", "Open", "(", "nil", ",", "encBundle", ".", "E", ",", "(", "*", "[", "libkb", ".", "NaclDHNonceSize", "]", "byte", ")", "(", "&", "encBundle", ".", "N", ")", ",", "(", "*", "[", "libkb", ".", "NaclSecretBoxKeySize", "]", "byte", ")", "(", "&", "symmetricKey", ")", ")", "\n", "if", "!", "ok", "{", "return", "res", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// Msgpack (inner)", "err", "=", "libkb", ".", "MsgpackDecode", "(", "&", "res", ",", "clearpack", ")", "\n", "return", "res", ",", "err", "\n", "}" ]
// decryptParent decrypts an encrypted parent bundle with the provided puk.
[ "decryptParent", "decrypts", "an", "encrypted", "parent", "bundle", "with", "the", "provided", "puk", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/bundle/boxer.go#L379-L407
159,134
keybase/client
go/stellar/bundle/boxer.go
decode
func decode(encryptedB64 string) (stellar1.EncryptedAccountBundle, stellar1.Hash, error) { cipherpack, err := base64.StdEncoding.DecodeString(encryptedB64) if err != nil { return stellar1.EncryptedAccountBundle{}, stellar1.Hash{}, err } encHash := sha256.Sum256(cipherpack) var enc stellar1.EncryptedAccountBundle if err = libkb.MsgpackDecode(&enc, cipherpack); err != nil { return stellar1.EncryptedAccountBundle{}, stellar1.Hash{}, err } return enc, encHash[:], nil }
go
func decode(encryptedB64 string) (stellar1.EncryptedAccountBundle, stellar1.Hash, error) { cipherpack, err := base64.StdEncoding.DecodeString(encryptedB64) if err != nil { return stellar1.EncryptedAccountBundle{}, stellar1.Hash{}, err } encHash := sha256.Sum256(cipherpack) var enc stellar1.EncryptedAccountBundle if err = libkb.MsgpackDecode(&enc, cipherpack); err != nil { return stellar1.EncryptedAccountBundle{}, stellar1.Hash{}, err } return enc, encHash[:], nil }
[ "func", "decode", "(", "encryptedB64", "string", ")", "(", "stellar1", ".", "EncryptedAccountBundle", ",", "stellar1", ".", "Hash", ",", "error", ")", "{", "cipherpack", ",", "err", ":=", "base64", ".", "StdEncoding", ".", "DecodeString", "(", "encryptedB64", ")", "\n", "if", "err", "!=", "nil", "{", "return", "stellar1", ".", "EncryptedAccountBundle", "{", "}", ",", "stellar1", ".", "Hash", "{", "}", ",", "err", "\n", "}", "\n", "encHash", ":=", "sha256", ".", "Sum256", "(", "cipherpack", ")", "\n", "var", "enc", "stellar1", ".", "EncryptedAccountBundle", "\n", "if", "err", "=", "libkb", ".", "MsgpackDecode", "(", "&", "enc", ",", "cipherpack", ")", ";", "err", "!=", "nil", "{", "return", "stellar1", ".", "EncryptedAccountBundle", "{", "}", ",", "stellar1", ".", "Hash", "{", "}", ",", "err", "\n", "}", "\n", "return", "enc", ",", "encHash", "[", ":", "]", ",", "nil", "\n", "}" ]
// decode decodes a base64-encoded encrypted account bundle.
[ "decode", "decodes", "a", "base64", "-", "encoded", "encrypted", "account", "bundle", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/bundle/boxer.go#L410-L421
159,135
keybase/client
go/stellar/bundle/boxer.go
unbox
func unbox(encBundle stellar1.EncryptedAccountBundle, hash stellar1.Hash /* visB64 string, */, puk libkb.PerUserKeySeed) (*stellar1.AccountBundle, stellar1.AccountBundleVersion, error) { versioned, err := decrypt(encBundle, puk) if err != nil { return nil, 0, err } version, err := versioned.Version() if err != nil { return nil, 0, err } var bundleOut stellar1.AccountBundle switch version { case stellar1.AccountBundleVersion_V1: secretV1 := versioned.V1() bundleOut = stellar1.AccountBundle{ AccountID: secretV1.AccountID, Signers: secretV1.Signers, } case stellar1.AccountBundleVersion_V2, stellar1.AccountBundleVersion_V3, stellar1.AccountBundleVersion_V4, stellar1.AccountBundleVersion_V5, stellar1.AccountBundleVersion_V6, stellar1.AccountBundleVersion_V7, stellar1.AccountBundleVersion_V8, stellar1.AccountBundleVersion_V9, stellar1.AccountBundleVersion_V10: return nil, 0, errors.New("unsupported AccountBundleSecret version") default: return nil, 0, errors.New("invalid AccountBundle version") } bundleOut.OwnHash = hash if len(bundleOut.OwnHash) == 0 { return nil, 0, errors.New("stellar account bundle missing own hash") } return &bundleOut, version, nil }
go
func unbox(encBundle stellar1.EncryptedAccountBundle, hash stellar1.Hash /* visB64 string, */, puk libkb.PerUserKeySeed) (*stellar1.AccountBundle, stellar1.AccountBundleVersion, error) { versioned, err := decrypt(encBundle, puk) if err != nil { return nil, 0, err } version, err := versioned.Version() if err != nil { return nil, 0, err } var bundleOut stellar1.AccountBundle switch version { case stellar1.AccountBundleVersion_V1: secretV1 := versioned.V1() bundleOut = stellar1.AccountBundle{ AccountID: secretV1.AccountID, Signers: secretV1.Signers, } case stellar1.AccountBundleVersion_V2, stellar1.AccountBundleVersion_V3, stellar1.AccountBundleVersion_V4, stellar1.AccountBundleVersion_V5, stellar1.AccountBundleVersion_V6, stellar1.AccountBundleVersion_V7, stellar1.AccountBundleVersion_V8, stellar1.AccountBundleVersion_V9, stellar1.AccountBundleVersion_V10: return nil, 0, errors.New("unsupported AccountBundleSecret version") default: return nil, 0, errors.New("invalid AccountBundle version") } bundleOut.OwnHash = hash if len(bundleOut.OwnHash) == 0 { return nil, 0, errors.New("stellar account bundle missing own hash") } return &bundleOut, version, nil }
[ "func", "unbox", "(", "encBundle", "stellar1", ".", "EncryptedAccountBundle", ",", "hash", "stellar1", ".", "Hash", "/* visB64 string, */", ",", "puk", "libkb", ".", "PerUserKeySeed", ")", "(", "*", "stellar1", ".", "AccountBundle", ",", "stellar1", ".", "AccountBundleVersion", ",", "error", ")", "{", "versioned", ",", "err", ":=", "decrypt", "(", "encBundle", ",", "puk", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "0", ",", "err", "\n", "}", "\n", "version", ",", "err", ":=", "versioned", ".", "Version", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "0", ",", "err", "\n", "}", "\n\n", "var", "bundleOut", "stellar1", ".", "AccountBundle", "\n", "switch", "version", "{", "case", "stellar1", ".", "AccountBundleVersion_V1", ":", "secretV1", ":=", "versioned", ".", "V1", "(", ")", "\n", "bundleOut", "=", "stellar1", ".", "AccountBundle", "{", "AccountID", ":", "secretV1", ".", "AccountID", ",", "Signers", ":", "secretV1", ".", "Signers", ",", "}", "\n", "case", "stellar1", ".", "AccountBundleVersion_V2", ",", "stellar1", ".", "AccountBundleVersion_V3", ",", "stellar1", ".", "AccountBundleVersion_V4", ",", "stellar1", ".", "AccountBundleVersion_V5", ",", "stellar1", ".", "AccountBundleVersion_V6", ",", "stellar1", ".", "AccountBundleVersion_V7", ",", "stellar1", ".", "AccountBundleVersion_V8", ",", "stellar1", ".", "AccountBundleVersion_V9", ",", "stellar1", ".", "AccountBundleVersion_V10", ":", "return", "nil", ",", "0", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "default", ":", "return", "nil", ",", "0", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "bundleOut", ".", "OwnHash", "=", "hash", "\n", "if", "len", "(", "bundleOut", ".", "OwnHash", ")", "==", "0", "{", "return", "nil", ",", "0", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "return", "&", "bundleOut", ",", "version", ",", "nil", "\n", "}" ]
// unbox unboxes an encrypted account bundle and decodes the visual portion of the bundle. // It validates the visible hash in the secret portion.
[ "unbox", "unboxes", "an", "encrypted", "account", "bundle", "and", "decodes", "the", "visual", "portion", "of", "the", "bundle", ".", "It", "validates", "the", "visible", "hash", "in", "the", "secret", "portion", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/bundle/boxer.go#L425-L463
159,136
keybase/client
go/stellar/bundle/boxer.go
decrypt
func decrypt(encBundle stellar1.EncryptedAccountBundle, puk libkb.PerUserKeySeed) (stellar1.AccountBundleSecretVersioned, error) { var empty stellar1.AccountBundleSecretVersioned if encBundle.V != 1 { return empty, errors.New("invalid stellar secret account bundle encryption version") } // Derive key reason := libkb.DeriveReasonPUKStellarAcctBundle symmetricKey, err := puk.DeriveSymmetricKey(reason) if err != nil { return empty, err } // Secretbox clearpack, ok := secretbox.Open(nil, encBundle.E, (*[libkb.NaclDHNonceSize]byte)(&encBundle.N), (*[libkb.NaclSecretBoxKeySize]byte)(&symmetricKey)) if !ok { return empty, errors.New("stellar bundle secret box open failed") } // Msgpack (inner) var bver stellar1.AccountBundleSecretVersioned err = libkb.MsgpackDecode(&bver, clearpack) if err != nil { return empty, err } return bver, nil }
go
func decrypt(encBundle stellar1.EncryptedAccountBundle, puk libkb.PerUserKeySeed) (stellar1.AccountBundleSecretVersioned, error) { var empty stellar1.AccountBundleSecretVersioned if encBundle.V != 1 { return empty, errors.New("invalid stellar secret account bundle encryption version") } // Derive key reason := libkb.DeriveReasonPUKStellarAcctBundle symmetricKey, err := puk.DeriveSymmetricKey(reason) if err != nil { return empty, err } // Secretbox clearpack, ok := secretbox.Open(nil, encBundle.E, (*[libkb.NaclDHNonceSize]byte)(&encBundle.N), (*[libkb.NaclSecretBoxKeySize]byte)(&symmetricKey)) if !ok { return empty, errors.New("stellar bundle secret box open failed") } // Msgpack (inner) var bver stellar1.AccountBundleSecretVersioned err = libkb.MsgpackDecode(&bver, clearpack) if err != nil { return empty, err } return bver, nil }
[ "func", "decrypt", "(", "encBundle", "stellar1", ".", "EncryptedAccountBundle", ",", "puk", "libkb", ".", "PerUserKeySeed", ")", "(", "stellar1", ".", "AccountBundleSecretVersioned", ",", "error", ")", "{", "var", "empty", "stellar1", ".", "AccountBundleSecretVersioned", "\n", "if", "encBundle", ".", "V", "!=", "1", "{", "return", "empty", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// Derive key", "reason", ":=", "libkb", ".", "DeriveReasonPUKStellarAcctBundle", "\n", "symmetricKey", ",", "err", ":=", "puk", ".", "DeriveSymmetricKey", "(", "reason", ")", "\n", "if", "err", "!=", "nil", "{", "return", "empty", ",", "err", "\n", "}", "\n\n", "// Secretbox", "clearpack", ",", "ok", ":=", "secretbox", ".", "Open", "(", "nil", ",", "encBundle", ".", "E", ",", "(", "*", "[", "libkb", ".", "NaclDHNonceSize", "]", "byte", ")", "(", "&", "encBundle", ".", "N", ")", ",", "(", "*", "[", "libkb", ".", "NaclSecretBoxKeySize", "]", "byte", ")", "(", "&", "symmetricKey", ")", ")", "\n", "if", "!", "ok", "{", "return", "empty", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// Msgpack (inner)", "var", "bver", "stellar1", ".", "AccountBundleSecretVersioned", "\n", "err", "=", "libkb", ".", "MsgpackDecode", "(", "&", "bver", ",", "clearpack", ")", "\n", "if", "err", "!=", "nil", "{", "return", "empty", ",", "err", "\n", "}", "\n", "return", "bver", ",", "nil", "\n", "}" ]
// decrypt decrypts an encrypted account bundle with the provided puk.
[ "decrypt", "decrypts", "an", "encrypted", "account", "bundle", "with", "the", "provided", "puk", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/bundle/boxer.go#L466-L494
159,137
keybase/client
go/stellar/bundle/boxer.go
merge
func merge(secret stellar1.BundleSecretV2, visible stellar1.BundleVisibleV2) (stellar1.Bundle, error) { if len(secret.Accounts) != len(visible.Accounts) { return stellar1.Bundle{}, errors.New("invalid bundle, mismatched number of visible and secret accounts") } accounts := convertVisibleAccounts(visible.Accounts) // these should be in the same order for i, secretAccount := range secret.Accounts { if accounts[i].AccountID != secretAccount.AccountID { return stellar1.Bundle{}, errors.New("invalid bundle, mismatched order of visible and secret accounts") } accounts[i].Name = secretAccount.Name } return stellar1.Bundle{ Revision: visible.Revision, Prev: visible.Prev, Accounts: accounts, }, nil }
go
func merge(secret stellar1.BundleSecretV2, visible stellar1.BundleVisibleV2) (stellar1.Bundle, error) { if len(secret.Accounts) != len(visible.Accounts) { return stellar1.Bundle{}, errors.New("invalid bundle, mismatched number of visible and secret accounts") } accounts := convertVisibleAccounts(visible.Accounts) // these should be in the same order for i, secretAccount := range secret.Accounts { if accounts[i].AccountID != secretAccount.AccountID { return stellar1.Bundle{}, errors.New("invalid bundle, mismatched order of visible and secret accounts") } accounts[i].Name = secretAccount.Name } return stellar1.Bundle{ Revision: visible.Revision, Prev: visible.Prev, Accounts: accounts, }, nil }
[ "func", "merge", "(", "secret", "stellar1", ".", "BundleSecretV2", ",", "visible", "stellar1", ".", "BundleVisibleV2", ")", "(", "stellar1", ".", "Bundle", ",", "error", ")", "{", "if", "len", "(", "secret", ".", "Accounts", ")", "!=", "len", "(", "visible", ".", "Accounts", ")", "{", "return", "stellar1", ".", "Bundle", "{", "}", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "accounts", ":=", "convertVisibleAccounts", "(", "visible", ".", "Accounts", ")", "\n\n", "// these should be in the same order", "for", "i", ",", "secretAccount", ":=", "range", "secret", ".", "Accounts", "{", "if", "accounts", "[", "i", "]", ".", "AccountID", "!=", "secretAccount", ".", "AccountID", "{", "return", "stellar1", ".", "Bundle", "{", "}", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "accounts", "[", "i", "]", ".", "Name", "=", "secretAccount", ".", "Name", "\n", "}", "\n", "return", "stellar1", ".", "Bundle", "{", "Revision", ":", "visible", ".", "Revision", ",", "Prev", ":", "visible", ".", "Prev", ",", "Accounts", ":", "accounts", ",", "}", ",", "nil", "\n", "}" ]
// merge combines the versioned secret account bundle and the visible account bundle into // a stellar1.AccountBundle for local use.
[ "merge", "combines", "the", "versioned", "secret", "account", "bundle", "and", "the", "visible", "account", "bundle", "into", "a", "stellar1", ".", "AccountBundle", "for", "local", "use", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/bundle/boxer.go#L511-L529
159,138
keybase/client
go/engine/saltpack_verify.go
NewSaltpackVerify
func NewSaltpackVerify(g *libkb.GlobalContext, arg *SaltpackVerifyArg) *SaltpackVerify { return &SaltpackVerify{ arg: arg, Contextified: libkb.NewContextified(g), } }
go
func NewSaltpackVerify(g *libkb.GlobalContext, arg *SaltpackVerifyArg) *SaltpackVerify { return &SaltpackVerify{ arg: arg, Contextified: libkb.NewContextified(g), } }
[ "func", "NewSaltpackVerify", "(", "g", "*", "libkb", ".", "GlobalContext", ",", "arg", "*", "SaltpackVerifyArg", ")", "*", "SaltpackVerify", "{", "return", "&", "SaltpackVerify", "{", "arg", ":", "arg", ",", "Contextified", ":", "libkb", ".", "NewContextified", "(", "g", ")", ",", "}", "\n", "}" ]
// NewSaltpackVerify creates a SaltpackVerify engine.
[ "NewSaltpackVerify", "creates", "a", "SaltpackVerify", "engine", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/saltpack_verify.go#L28-L33
159,139
keybase/client
go/kbun/username.go
CheckUsername
func CheckUsername(s string) bool { return len(s) >= 2 && len(s) <= 16 && usernameRE.MatchString(s) }
go
func CheckUsername(s string) bool { return len(s) >= 2 && len(s) <= 16 && usernameRE.MatchString(s) }
[ "func", "CheckUsername", "(", "s", "string", ")", "bool", "{", "return", "len", "(", "s", ")", ">=", "2", "&&", "len", "(", "s", ")", "<=", "16", "&&", "usernameRE", ".", "MatchString", "(", "s", ")", "\n", "}" ]
// CheckUsername returns true if the given string can be a Keybase // username.
[ "CheckUsername", "returns", "true", "if", "the", "given", "string", "can", "be", "a", "Keybase", "username", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbun/username.go#L16-L18
159,140
keybase/client
go/kbun/username.go
Eq
func (n NormalizedUsername) Eq(n2 NormalizedUsername) bool { return string(n) == string(n2) }
go
func (n NormalizedUsername) Eq(n2 NormalizedUsername) bool { return string(n) == string(n2) }
[ "func", "(", "n", "NormalizedUsername", ")", "Eq", "(", "n2", "NormalizedUsername", ")", "bool", "{", "return", "string", "(", "n", ")", "==", "string", "(", "n2", ")", "\n", "}" ]
// Eq returns true if the given normalized usernames are equal
[ "Eq", "returns", "true", "if", "the", "given", "normalized", "usernames", "are", "equal" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbun/username.go#L32-L34
159,141
keybase/client
go/chat/search/storage.go
deleteOldVersions
func (s *store) deleteOldVersions(ctx context.Context, keyFn func(int) (libkb.DbKey, error), maxVersion int) { for version := 1; version < maxVersion; version++ { key, err := keyFn(version) if err != nil { s.Debug(ctx, "unable to get key for version %d, %v", version, err) continue } s.Debug(ctx, "cleaning old version %d: for key %v", version, key) if err := s.G().LocalChatDb.Delete(key); err != nil { s.Debug(ctx, "deleteOldVersions: failed to delete key: %s", err) } } }
go
func (s *store) deleteOldVersions(ctx context.Context, keyFn func(int) (libkb.DbKey, error), maxVersion int) { for version := 1; version < maxVersion; version++ { key, err := keyFn(version) if err != nil { s.Debug(ctx, "unable to get key for version %d, %v", version, err) continue } s.Debug(ctx, "cleaning old version %d: for key %v", version, key) if err := s.G().LocalChatDb.Delete(key); err != nil { s.Debug(ctx, "deleteOldVersions: failed to delete key: %s", err) } } }
[ "func", "(", "s", "*", "store", ")", "deleteOldVersions", "(", "ctx", "context", ".", "Context", ",", "keyFn", "func", "(", "int", ")", "(", "libkb", ".", "DbKey", ",", "error", ")", ",", "maxVersion", "int", ")", "{", "for", "version", ":=", "1", ";", "version", "<", "maxVersion", ";", "version", "++", "{", "key", ",", "err", ":=", "keyFn", "(", "version", ")", "\n", "if", "err", "!=", "nil", "{", "s", ".", "Debug", "(", "ctx", ",", "\"", "\"", ",", "version", ",", "err", ")", "\n", "continue", "\n", "}", "\n", "s", ".", "Debug", "(", "ctx", ",", "\"", "\"", ",", "version", ",", "key", ")", "\n", "if", "err", ":=", "s", ".", "G", "(", ")", ".", "LocalChatDb", ".", "Delete", "(", "key", ")", ";", "err", "!=", "nil", "{", "s", ".", "Debug", "(", "ctx", ",", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "}", "\n", "}" ]
// deleteOldVersions purges old disk structures so we don't error out on msg // pack decode or strand indexes with ephemeral content.
[ "deleteOldVersions", "purges", "old", "disk", "structures", "so", "we", "don", "t", "error", "out", "on", "msg", "pack", "decode", "or", "strand", "indexes", "with", "ephemeral", "content", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/search/storage.go#L169-L181
159,142
keybase/client
go/chat/search/storage.go
addTokens
func (s *store) addTokens(ctx context.Context, batch *addTokenBatch, uid gregor1.UID, convID chat1.ConversationID, tokens tokenMap, msgID chat1.MessageID) error { for token, aliases := range tokens { // Update the token entry with the msg ID hit te, err := s.getTokenEntryWithBatch(ctx, batch, uid, convID, token) if err != nil { return err } te.MsgIDs[msgID] = chat1.EmptyStruct{} // Update all the aliases to point at the token for alias := range aliases { aliasEntry, err := s.getAliasEntryWithBatch(ctx, batch, alias) if err != nil { return err } aliasEntry.Aliases[token] = chat1.EmptyStruct{} } } return nil }
go
func (s *store) addTokens(ctx context.Context, batch *addTokenBatch, uid gregor1.UID, convID chat1.ConversationID, tokens tokenMap, msgID chat1.MessageID) error { for token, aliases := range tokens { // Update the token entry with the msg ID hit te, err := s.getTokenEntryWithBatch(ctx, batch, uid, convID, token) if err != nil { return err } te.MsgIDs[msgID] = chat1.EmptyStruct{} // Update all the aliases to point at the token for alias := range aliases { aliasEntry, err := s.getAliasEntryWithBatch(ctx, batch, alias) if err != nil { return err } aliasEntry.Aliases[token] = chat1.EmptyStruct{} } } return nil }
[ "func", "(", "s", "*", "store", ")", "addTokens", "(", "ctx", "context", ".", "Context", ",", "batch", "*", "addTokenBatch", ",", "uid", "gregor1", ".", "UID", ",", "convID", "chat1", ".", "ConversationID", ",", "tokens", "tokenMap", ",", "msgID", "chat1", ".", "MessageID", ")", "error", "{", "for", "token", ",", "aliases", ":=", "range", "tokens", "{", "// Update the token entry with the msg ID hit", "te", ",", "err", ":=", "s", ".", "getTokenEntryWithBatch", "(", "ctx", ",", "batch", ",", "uid", ",", "convID", ",", "token", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "te", ".", "MsgIDs", "[", "msgID", "]", "=", "chat1", ".", "EmptyStruct", "{", "}", "\n\n", "// Update all the aliases to point at the token", "for", "alias", ":=", "range", "aliases", "{", "aliasEntry", ",", "err", ":=", "s", ".", "getAliasEntryWithBatch", "(", "ctx", ",", "batch", ",", "alias", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "aliasEntry", ".", "Aliases", "[", "token", "]", "=", "chat1", ".", "EmptyStruct", "{", "}", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// addTokens add the given tokens to the index under the given message // id, when ingesting EDIT messages the msgID is of the superseded msg but the // tokens are from the EDIT itself.
[ "addTokens", "add", "the", "given", "tokens", "to", "the", "index", "under", "the", "given", "message", "id", "when", "ingesting", "EDIT", "messages", "the", "msgID", "is", "of", "the", "superseded", "msg", "but", "the", "tokens", "are", "from", "the", "EDIT", "itself", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/search/storage.go#L406-L426
159,143
keybase/client
go/service/device.go
NewDeviceHandler
func NewDeviceHandler(xp rpc.Transporter, g *libkb.GlobalContext, gregor *gregorHandler) *DeviceHandler { return &DeviceHandler{ BaseHandler: NewBaseHandler(g, xp), Contextified: libkb.NewContextified(g), gregor: gregor, } }
go
func NewDeviceHandler(xp rpc.Transporter, g *libkb.GlobalContext, gregor *gregorHandler) *DeviceHandler { return &DeviceHandler{ BaseHandler: NewBaseHandler(g, xp), Contextified: libkb.NewContextified(g), gregor: gregor, } }
[ "func", "NewDeviceHandler", "(", "xp", "rpc", ".", "Transporter", ",", "g", "*", "libkb", ".", "GlobalContext", ",", "gregor", "*", "gregorHandler", ")", "*", "DeviceHandler", "{", "return", "&", "DeviceHandler", "{", "BaseHandler", ":", "NewBaseHandler", "(", "g", ",", "xp", ")", ",", "Contextified", ":", "libkb", ".", "NewContextified", "(", "g", ")", ",", "gregor", ":", "gregor", ",", "}", "\n", "}" ]
// NewDeviceHandler creates a DeviceHandler for the xp transport.
[ "NewDeviceHandler", "creates", "a", "DeviceHandler", "for", "the", "xp", "transport", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/device.go#L26-L32
159,144
keybase/client
go/service/device.go
DeviceList
func (h *DeviceHandler) DeviceList(ctx context.Context, sessionID int) ([]keybase1.Device, error) { uis := libkb.UIs{ LogUI: h.getLogUI(sessionID), SessionID: sessionID, } eng := engine.NewDevList(h.G()) m := libkb.NewMetaContext(ctx, h.G()).WithUIs(uis) if err := engine.RunEngine2(m, eng); err != nil { return nil, err } return eng.List(), nil }
go
func (h *DeviceHandler) DeviceList(ctx context.Context, sessionID int) ([]keybase1.Device, error) { uis := libkb.UIs{ LogUI: h.getLogUI(sessionID), SessionID: sessionID, } eng := engine.NewDevList(h.G()) m := libkb.NewMetaContext(ctx, h.G()).WithUIs(uis) if err := engine.RunEngine2(m, eng); err != nil { return nil, err } return eng.List(), nil }
[ "func", "(", "h", "*", "DeviceHandler", ")", "DeviceList", "(", "ctx", "context", ".", "Context", ",", "sessionID", "int", ")", "(", "[", "]", "keybase1", ".", "Device", ",", "error", ")", "{", "uis", ":=", "libkb", ".", "UIs", "{", "LogUI", ":", "h", ".", "getLogUI", "(", "sessionID", ")", ",", "SessionID", ":", "sessionID", ",", "}", "\n", "eng", ":=", "engine", ".", "NewDevList", "(", "h", ".", "G", "(", ")", ")", "\n", "m", ":=", "libkb", ".", "NewMetaContext", "(", "ctx", ",", "h", ".", "G", "(", ")", ")", ".", "WithUIs", "(", "uis", ")", "\n", "if", "err", ":=", "engine", ".", "RunEngine2", "(", "m", ",", "eng", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "eng", ".", "List", "(", ")", ",", "nil", "\n", "}" ]
// DeviceList returns a list of all the devices for a user.
[ "DeviceList", "returns", "a", "list", "of", "all", "the", "devices", "for", "a", "user", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/device.go#L35-L46
159,145
keybase/client
go/service/device.go
DeviceHistoryList
func (h *DeviceHandler) DeviceHistoryList(nctx context.Context, sessionID int) ([]keybase1.DeviceDetail, error) { uis := libkb.UIs{ LogUI: h.getLogUI(sessionID), SessionID: sessionID, } eng := engine.NewDeviceHistorySelf(h.G()) m := libkb.NewMetaContext(nctx, h.G()).WithUIs(uis) if err := engine.RunEngine2(m, eng); err != nil { return nil, err } return eng.Devices(), nil }
go
func (h *DeviceHandler) DeviceHistoryList(nctx context.Context, sessionID int) ([]keybase1.DeviceDetail, error) { uis := libkb.UIs{ LogUI: h.getLogUI(sessionID), SessionID: sessionID, } eng := engine.NewDeviceHistorySelf(h.G()) m := libkb.NewMetaContext(nctx, h.G()).WithUIs(uis) if err := engine.RunEngine2(m, eng); err != nil { return nil, err } return eng.Devices(), nil }
[ "func", "(", "h", "*", "DeviceHandler", ")", "DeviceHistoryList", "(", "nctx", "context", ".", "Context", ",", "sessionID", "int", ")", "(", "[", "]", "keybase1", ".", "DeviceDetail", ",", "error", ")", "{", "uis", ":=", "libkb", ".", "UIs", "{", "LogUI", ":", "h", ".", "getLogUI", "(", "sessionID", ")", ",", "SessionID", ":", "sessionID", ",", "}", "\n", "eng", ":=", "engine", ".", "NewDeviceHistorySelf", "(", "h", ".", "G", "(", ")", ")", "\n", "m", ":=", "libkb", ".", "NewMetaContext", "(", "nctx", ",", "h", ".", "G", "(", ")", ")", ".", "WithUIs", "(", "uis", ")", "\n", "if", "err", ":=", "engine", ".", "RunEngine2", "(", "m", ",", "eng", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "eng", ".", "Devices", "(", ")", ",", "nil", "\n", "}" ]
// DeviceHistoryList returns a list of all the devices for a user, // with detailed history and provisioner, revoker information.
[ "DeviceHistoryList", "returns", "a", "list", "of", "all", "the", "devices", "for", "a", "user", "with", "detailed", "history", "and", "provisioner", "revoker", "information", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/device.go#L50-L61
159,146
keybase/client
go/service/device.go
CheckDeviceNameFormat
func (h *DeviceHandler) CheckDeviceNameFormat(_ context.Context, arg keybase1.CheckDeviceNameFormatArg) (bool, error) { ok := libkb.CheckDeviceName.F(arg.Name) if ok { return ok, nil } return false, errors.New(libkb.CheckDeviceName.Hint) }
go
func (h *DeviceHandler) CheckDeviceNameFormat(_ context.Context, arg keybase1.CheckDeviceNameFormatArg) (bool, error) { ok := libkb.CheckDeviceName.F(arg.Name) if ok { return ok, nil } return false, errors.New(libkb.CheckDeviceName.Hint) }
[ "func", "(", "h", "*", "DeviceHandler", ")", "CheckDeviceNameFormat", "(", "_", "context", ".", "Context", ",", "arg", "keybase1", ".", "CheckDeviceNameFormatArg", ")", "(", "bool", ",", "error", ")", "{", "ok", ":=", "libkb", ".", "CheckDeviceName", ".", "F", "(", "arg", ".", "Name", ")", "\n", "if", "ok", "{", "return", "ok", ",", "nil", "\n", "}", "\n", "return", "false", ",", "errors", ".", "New", "(", "libkb", ".", "CheckDeviceName", ".", "Hint", ")", "\n", "}" ]
// CheckDeviceNameFormat verifies that the device name has a valid // format.
[ "CheckDeviceNameFormat", "verifies", "that", "the", "device", "name", "has", "a", "valid", "format", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/device.go#L78-L84
159,147
keybase/client
go/client/cmd_ctl_start_osx.go
NewCmdCtlStart
func NewCmdCtlStart(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command { return cli.Command{ Name: "start", Usage: "Start the app and services", Flags: []cli.Flag{ cli.StringFlag{ Name: "include", Usage: fmt.Sprintf("Stop only specified components, comma separated. Specify %v.", availableCtlComponents), }, cli.StringFlag{ Name: "exclude", Usage: fmt.Sprintf("Stop all except excluded components, comma separated. Specify %v.", availableCtlComponents), }, }, Action: func(c *cli.Context) { cl.ChooseCommand(newCmdCtlStart(g), "start", c) cl.SetForkCmd(libcmdline.NoFork) cl.SetLogForward(libcmdline.LogForwardNone) cl.SetNoStandalone() }, } }
go
func NewCmdCtlStart(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command { return cli.Command{ Name: "start", Usage: "Start the app and services", Flags: []cli.Flag{ cli.StringFlag{ Name: "include", Usage: fmt.Sprintf("Stop only specified components, comma separated. Specify %v.", availableCtlComponents), }, cli.StringFlag{ Name: "exclude", Usage: fmt.Sprintf("Stop all except excluded components, comma separated. Specify %v.", availableCtlComponents), }, }, Action: func(c *cli.Context) { cl.ChooseCommand(newCmdCtlStart(g), "start", c) cl.SetForkCmd(libcmdline.NoFork) cl.SetLogForward(libcmdline.LogForwardNone) cl.SetNoStandalone() }, } }
[ "func", "NewCmdCtlStart", "(", "cl", "*", "libcmdline", ".", "CommandLine", ",", "g", "*", "libkb", ".", "GlobalContext", ")", "cli", ".", "Command", "{", "return", "cli", ".", "Command", "{", "Name", ":", "\"", "\"", ",", "Usage", ":", "\"", "\"", ",", "Flags", ":", "[", "]", "cli", ".", "Flag", "{", "cli", ".", "StringFlag", "{", "Name", ":", "\"", "\"", ",", "Usage", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "availableCtlComponents", ")", ",", "}", ",", "cli", ".", "StringFlag", "{", "Name", ":", "\"", "\"", ",", "Usage", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "availableCtlComponents", ")", ",", "}", ",", "}", ",", "Action", ":", "func", "(", "c", "*", "cli", ".", "Context", ")", "{", "cl", ".", "ChooseCommand", "(", "newCmdCtlStart", "(", "g", ")", ",", "\"", "\"", ",", "c", ")", "\n", "cl", ".", "SetForkCmd", "(", "libcmdline", ".", "NoFork", ")", "\n", "cl", ".", "SetLogForward", "(", "libcmdline", ".", "LogForwardNone", ")", "\n", "cl", ".", "SetNoStandalone", "(", ")", "\n", "}", ",", "}", "\n", "}" ]
// NewCmdCtlStart constructs ctl start command
[ "NewCmdCtlStart", "constructs", "ctl", "start", "command" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/cmd_ctl_start_osx.go#L18-L39
159,148
keybase/client
go/kbfs/libkbfs/md_journal.go
MakeImmutableBareRootMetadata
func MakeImmutableBareRootMetadata( rmd kbfsmd.RootMetadata, extra kbfsmd.ExtraMetadata, mdID kbfsmd.ID, localTimestamp time.Time) ImmutableBareRootMetadata { if mdID == (kbfsmd.ID{}) { panic("zero mdID passed to MakeImmutableBareRootMetadata") } return ImmutableBareRootMetadata{rmd, extra, mdID, localTimestamp} }
go
func MakeImmutableBareRootMetadata( rmd kbfsmd.RootMetadata, extra kbfsmd.ExtraMetadata, mdID kbfsmd.ID, localTimestamp time.Time) ImmutableBareRootMetadata { if mdID == (kbfsmd.ID{}) { panic("zero mdID passed to MakeImmutableBareRootMetadata") } return ImmutableBareRootMetadata{rmd, extra, mdID, localTimestamp} }
[ "func", "MakeImmutableBareRootMetadata", "(", "rmd", "kbfsmd", ".", "RootMetadata", ",", "extra", "kbfsmd", ".", "ExtraMetadata", ",", "mdID", "kbfsmd", ".", "ID", ",", "localTimestamp", "time", ".", "Time", ")", "ImmutableBareRootMetadata", "{", "if", "mdID", "==", "(", "kbfsmd", ".", "ID", "{", "}", ")", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "ImmutableBareRootMetadata", "{", "rmd", ",", "extra", ",", "mdID", ",", "localTimestamp", "}", "\n", "}" ]
// MakeImmutableBareRootMetadata makes a new ImmutableBareRootMetadata // from the given BareRootMetadata and its corresponding MdID.
[ "MakeImmutableBareRootMetadata", "makes", "a", "new", "ImmutableBareRootMetadata", "from", "the", "given", "BareRootMetadata", "and", "its", "corresponding", "MdID", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/md_journal.go#L47-L54
159,149
keybase/client
go/kbfs/libkbfs/md_journal.go
MakeBareTlfHandleWithExtra
func (ibrmd ImmutableBareRootMetadata) MakeBareTlfHandleWithExtra() ( tlf.Handle, error) { return ibrmd.RootMetadata.MakeBareTlfHandle(ibrmd.extra) }
go
func (ibrmd ImmutableBareRootMetadata) MakeBareTlfHandleWithExtra() ( tlf.Handle, error) { return ibrmd.RootMetadata.MakeBareTlfHandle(ibrmd.extra) }
[ "func", "(", "ibrmd", "ImmutableBareRootMetadata", ")", "MakeBareTlfHandleWithExtra", "(", ")", "(", "tlf", ".", "Handle", ",", "error", ")", "{", "return", "ibrmd", ".", "RootMetadata", ".", "MakeBareTlfHandle", "(", "ibrmd", ".", "extra", ")", "\n", "}" ]
// MakeBareTlfHandleWithExtra makes a BareTlfHandle for this // ImmutableBareRootMetadata. Should be used only by servers and MDOps.
[ "MakeBareTlfHandleWithExtra", "makes", "a", "BareTlfHandle", "for", "this", "ImmutableBareRootMetadata", ".", "Should", "be", "used", "only", "by", "servers", "and", "MDOps", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/md_journal.go#L58-L61
159,150
keybase/client
go/kbfs/libkbfs/md_journal.go
getExtraMetadata
func (j mdJournal) getExtraMetadata( wkbID kbfsmd.TLFWriterKeyBundleID, rkbID kbfsmd.TLFReaderKeyBundleID, wkbNew, rkbNew bool) (kbfsmd.ExtraMetadata, error) { if (wkbID == kbfsmd.TLFWriterKeyBundleID{}) != (rkbID == kbfsmd.TLFReaderKeyBundleID{}) { return nil, errors.Errorf( "wkbID is empty (%t) != rkbID is empty (%t)", wkbID == kbfsmd.TLFWriterKeyBundleID{}, rkbID == kbfsmd.TLFReaderKeyBundleID{}) } if wkbID == (kbfsmd.TLFWriterKeyBundleID{}) { return nil, nil } wkb, err := kbfsmd.DeserializeTLFWriterKeyBundleV3( j.codec, j.writerKeyBundleV3Path(wkbID)) if err != nil { return nil, err } err = kbfsmd.CheckWKBID(j.codec, wkbID, wkb) if err != nil { return nil, err } rkb, err := kbfsmd.DeserializeTLFReaderKeyBundleV3( j.codec, j.readerKeyBundleV3Path(rkbID)) if err != nil { return nil, err } err = kbfsmd.CheckRKBID(j.codec, rkbID, rkb) if err != nil { return nil, err } return kbfsmd.NewExtraMetadataV3(wkb, rkb, wkbNew, rkbNew), nil }
go
func (j mdJournal) getExtraMetadata( wkbID kbfsmd.TLFWriterKeyBundleID, rkbID kbfsmd.TLFReaderKeyBundleID, wkbNew, rkbNew bool) (kbfsmd.ExtraMetadata, error) { if (wkbID == kbfsmd.TLFWriterKeyBundleID{}) != (rkbID == kbfsmd.TLFReaderKeyBundleID{}) { return nil, errors.Errorf( "wkbID is empty (%t) != rkbID is empty (%t)", wkbID == kbfsmd.TLFWriterKeyBundleID{}, rkbID == kbfsmd.TLFReaderKeyBundleID{}) } if wkbID == (kbfsmd.TLFWriterKeyBundleID{}) { return nil, nil } wkb, err := kbfsmd.DeserializeTLFWriterKeyBundleV3( j.codec, j.writerKeyBundleV3Path(wkbID)) if err != nil { return nil, err } err = kbfsmd.CheckWKBID(j.codec, wkbID, wkb) if err != nil { return nil, err } rkb, err := kbfsmd.DeserializeTLFReaderKeyBundleV3( j.codec, j.readerKeyBundleV3Path(rkbID)) if err != nil { return nil, err } err = kbfsmd.CheckRKBID(j.codec, rkbID, rkb) if err != nil { return nil, err } return kbfsmd.NewExtraMetadataV3(wkb, rkb, wkbNew, rkbNew), nil }
[ "func", "(", "j", "mdJournal", ")", "getExtraMetadata", "(", "wkbID", "kbfsmd", ".", "TLFWriterKeyBundleID", ",", "rkbID", "kbfsmd", ".", "TLFReaderKeyBundleID", ",", "wkbNew", ",", "rkbNew", "bool", ")", "(", "kbfsmd", ".", "ExtraMetadata", ",", "error", ")", "{", "if", "(", "wkbID", "==", "kbfsmd", ".", "TLFWriterKeyBundleID", "{", "}", ")", "!=", "(", "rkbID", "==", "kbfsmd", ".", "TLFReaderKeyBundleID", "{", "}", ")", "{", "return", "nil", ",", "errors", ".", "Errorf", "(", "\"", "\"", ",", "wkbID", "==", "kbfsmd", ".", "TLFWriterKeyBundleID", "{", "}", ",", "rkbID", "==", "kbfsmd", ".", "TLFReaderKeyBundleID", "{", "}", ")", "\n", "}", "\n\n", "if", "wkbID", "==", "(", "kbfsmd", ".", "TLFWriterKeyBundleID", "{", "}", ")", "{", "return", "nil", ",", "nil", "\n", "}", "\n\n", "wkb", ",", "err", ":=", "kbfsmd", ".", "DeserializeTLFWriterKeyBundleV3", "(", "j", ".", "codec", ",", "j", ".", "writerKeyBundleV3Path", "(", "wkbID", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "err", "=", "kbfsmd", ".", "CheckWKBID", "(", "j", ".", "codec", ",", "wkbID", ",", "wkb", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "rkb", ",", "err", ":=", "kbfsmd", ".", "DeserializeTLFReaderKeyBundleV3", "(", "j", ".", "codec", ",", "j", ".", "readerKeyBundleV3Path", "(", "rkbID", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "err", "=", "kbfsmd", ".", "CheckRKBID", "(", "j", ".", "codec", ",", "rkbID", ",", "rkb", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "kbfsmd", ".", "NewExtraMetadataV3", "(", "wkb", ",", "rkb", ",", "wkbNew", ",", "rkbNew", ")", ",", "nil", "\n", "}" ]
// getExtraMetadata gets the extra metadata corresponding to the given // IDs, if any, after checking them.
[ "getExtraMetadata", "gets", "the", "extra", "metadata", "corresponding", "to", "the", "given", "IDs", "if", "any", "after", "checking", "them", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/md_journal.go#L326-L364
159,151
keybase/client
go/kbfs/libkbfs/md_journal.go
getEarliestWithExtra
func (j mdJournal) getEarliestWithExtra( ctx context.Context, verifyBranchID bool) ( kbfsmd.ID, kbfsmd.MutableRootMetadata, kbfsmd.ExtraMetadata, time.Time, error) { entry, exists, err := j.j.getEarliestEntry() if err != nil { return kbfsmd.ID{}, nil, nil, time.Time{}, err } if !exists { return kbfsmd.ID{}, nil, nil, time.Time{}, nil } earliest, extra, timestamp, err := j.getMDAndExtra(ctx, entry, verifyBranchID) if err != nil { return kbfsmd.ID{}, nil, nil, time.Time{}, err } return entry.ID, earliest, extra, timestamp, nil }
go
func (j mdJournal) getEarliestWithExtra( ctx context.Context, verifyBranchID bool) ( kbfsmd.ID, kbfsmd.MutableRootMetadata, kbfsmd.ExtraMetadata, time.Time, error) { entry, exists, err := j.j.getEarliestEntry() if err != nil { return kbfsmd.ID{}, nil, nil, time.Time{}, err } if !exists { return kbfsmd.ID{}, nil, nil, time.Time{}, nil } earliest, extra, timestamp, err := j.getMDAndExtra(ctx, entry, verifyBranchID) if err != nil { return kbfsmd.ID{}, nil, nil, time.Time{}, err } return entry.ID, earliest, extra, timestamp, nil }
[ "func", "(", "j", "mdJournal", ")", "getEarliestWithExtra", "(", "ctx", "context", ".", "Context", ",", "verifyBranchID", "bool", ")", "(", "kbfsmd", ".", "ID", ",", "kbfsmd", ".", "MutableRootMetadata", ",", "kbfsmd", ".", "ExtraMetadata", ",", "time", ".", "Time", ",", "error", ")", "{", "entry", ",", "exists", ",", "err", ":=", "j", ".", "j", ".", "getEarliestEntry", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "kbfsmd", ".", "ID", "{", "}", ",", "nil", ",", "nil", ",", "time", ".", "Time", "{", "}", ",", "err", "\n", "}", "\n", "if", "!", "exists", "{", "return", "kbfsmd", ".", "ID", "{", "}", ",", "nil", ",", "nil", ",", "time", ".", "Time", "{", "}", ",", "nil", "\n", "}", "\n", "earliest", ",", "extra", ",", "timestamp", ",", "err", ":=", "j", ".", "getMDAndExtra", "(", "ctx", ",", "entry", ",", "verifyBranchID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "kbfsmd", ".", "ID", "{", "}", ",", "nil", ",", "nil", ",", "time", ".", "Time", "{", "}", ",", "err", "\n", "}", "\n", "return", "entry", ".", "ID", ",", "earliest", ",", "extra", ",", "timestamp", ",", "nil", "\n", "}" ]
// getEarliestWithExtra returns a kbfsmd.MutableRootMetadata so that it // can be put in a RootMetadataSigned object.
[ "getEarliestWithExtra", "returns", "a", "kbfsmd", ".", "MutableRootMetadata", "so", "that", "it", "can", "be", "put", "in", "a", "RootMetadataSigned", "object", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/md_journal.go#L557-L573
159,152
keybase/client
go/kbfs/libkbfs/md_journal.go
clearHelper
func (j *mdJournal) clearHelper(ctx context.Context, bid kbfsmd.BranchID, earliestBranchRevision kbfsmd.Revision) (err error) { j.log.CDebugf(ctx, "Clearing journal for branch %s", bid) defer func() { if err != nil { j.deferLog.CDebugf(ctx, "Clearing journal for branch %s failed with %+v", bid, err) } }() if bid == kbfsmd.NullBranchID { return errors.New("Cannot clear master branch") } if j.branchID != bid { // Nothing to do. j.log.CDebugf(ctx, "Ignoring clear for branch %s while on branch %s", bid, j.branchID) return nil } head, err := j.getHead(ctx, bid) if err != nil { return err } if head == (ImmutableBareRootMetadata{}) { // The journal has been flushed but not cleared yet. j.branchID = kbfsmd.NullBranchID return nil } if head.BID() != j.branchID { return errors.Errorf("Head branch ID %s doesn't match journal "+ "branch ID %s while clearing", head.BID(), j.branchID) } latestRevision, err := j.j.readLatestRevision() if err != nil { return err } _, allEntries, err := j.j.getEntryRange( earliestBranchRevision, latestRevision) if err != nil { return err } err = j.j.clearFrom(earliestBranchRevision) if err != nil { return err } j.branchID = kbfsmd.NullBranchID // No need to set lastMdID in this case. // Garbage-collect the old branch entries. TODO: we'll eventually // need a sweeper to clean up entries left behind if we crash // here. for _, entry := range allEntries { err := j.removeMD(entry.ID) if err != nil { return err } } return nil }
go
func (j *mdJournal) clearHelper(ctx context.Context, bid kbfsmd.BranchID, earliestBranchRevision kbfsmd.Revision) (err error) { j.log.CDebugf(ctx, "Clearing journal for branch %s", bid) defer func() { if err != nil { j.deferLog.CDebugf(ctx, "Clearing journal for branch %s failed with %+v", bid, err) } }() if bid == kbfsmd.NullBranchID { return errors.New("Cannot clear master branch") } if j.branchID != bid { // Nothing to do. j.log.CDebugf(ctx, "Ignoring clear for branch %s while on branch %s", bid, j.branchID) return nil } head, err := j.getHead(ctx, bid) if err != nil { return err } if head == (ImmutableBareRootMetadata{}) { // The journal has been flushed but not cleared yet. j.branchID = kbfsmd.NullBranchID return nil } if head.BID() != j.branchID { return errors.Errorf("Head branch ID %s doesn't match journal "+ "branch ID %s while clearing", head.BID(), j.branchID) } latestRevision, err := j.j.readLatestRevision() if err != nil { return err } _, allEntries, err := j.j.getEntryRange( earliestBranchRevision, latestRevision) if err != nil { return err } err = j.j.clearFrom(earliestBranchRevision) if err != nil { return err } j.branchID = kbfsmd.NullBranchID // No need to set lastMdID in this case. // Garbage-collect the old branch entries. TODO: we'll eventually // need a sweeper to clean up entries left behind if we crash // here. for _, entry := range allEntries { err := j.removeMD(entry.ID) if err != nil { return err } } return nil }
[ "func", "(", "j", "*", "mdJournal", ")", "clearHelper", "(", "ctx", "context", ".", "Context", ",", "bid", "kbfsmd", ".", "BranchID", ",", "earliestBranchRevision", "kbfsmd", ".", "Revision", ")", "(", "err", "error", ")", "{", "j", ".", "log", ".", "CDebugf", "(", "ctx", ",", "\"", "\"", ",", "bid", ")", "\n", "defer", "func", "(", ")", "{", "if", "err", "!=", "nil", "{", "j", ".", "deferLog", ".", "CDebugf", "(", "ctx", ",", "\"", "\"", ",", "bid", ",", "err", ")", "\n", "}", "\n", "}", "(", ")", "\n\n", "if", "bid", "==", "kbfsmd", ".", "NullBranchID", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "j", ".", "branchID", "!=", "bid", "{", "// Nothing to do.", "j", ".", "log", ".", "CDebugf", "(", "ctx", ",", "\"", "\"", ",", "bid", ",", "j", ".", "branchID", ")", "\n", "return", "nil", "\n", "}", "\n\n", "head", ",", "err", ":=", "j", ".", "getHead", "(", "ctx", ",", "bid", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "head", "==", "(", "ImmutableBareRootMetadata", "{", "}", ")", "{", "// The journal has been flushed but not cleared yet.", "j", ".", "branchID", "=", "kbfsmd", ".", "NullBranchID", "\n", "return", "nil", "\n", "}", "\n\n", "if", "head", ".", "BID", "(", ")", "!=", "j", ".", "branchID", "{", "return", "errors", ".", "Errorf", "(", "\"", "\"", "+", "\"", "\"", ",", "head", ".", "BID", "(", ")", ",", "j", ".", "branchID", ")", "\n", "}", "\n\n", "latestRevision", ",", "err", ":=", "j", ".", "j", ".", "readLatestRevision", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "_", ",", "allEntries", ",", "err", ":=", "j", ".", "j", ".", "getEntryRange", "(", "earliestBranchRevision", ",", "latestRevision", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "err", "=", "j", ".", "j", ".", "clearFrom", "(", "earliestBranchRevision", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "j", ".", "branchID", "=", "kbfsmd", ".", "NullBranchID", "\n\n", "// No need to set lastMdID in this case.", "// Garbage-collect the old branch entries. TODO: we'll eventually", "// need a sweeper to clean up entries left behind if we crash", "// here.", "for", "_", ",", "entry", ":=", "range", "allEntries", "{", "err", ":=", "j", ".", "removeMD", "(", "entry", ".", "ID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// clearHelper removes all the journal entries starting from // earliestBranchRevision and deletes the corresponding MD // updates. All MDs from earliestBranchRevision onwards must have // branch equal to the given one, which must not be kbfsmd.NullBranchID. This // means that, if bid != kbfsmd.PendingLocalSquashBranchID, // earliestBranchRevision must equal the earliest revision, and if bid // == kbfsmd.PendingLocalSquashBranchID, earliestBranchRevision must equal // one past the last local squash revision. If the branch is a pending // local squash, it preserves the MD updates corresponding to the // prefix of existing local squashes, so they can be re-used in the // newly-resolved journal.
[ "clearHelper", "removes", "all", "the", "journal", "entries", "starting", "from", "earliestBranchRevision", "and", "deletes", "the", "corresponding", "MD", "updates", ".", "All", "MDs", "from", "earliestBranchRevision", "onwards", "must", "have", "branch", "equal", "to", "the", "given", "one", "which", "must", "not", "be", "kbfsmd", ".", "NullBranchID", ".", "This", "means", "that", "if", "bid", "!", "=", "kbfsmd", ".", "PendingLocalSquashBranchID", "earliestBranchRevision", "must", "equal", "the", "earliest", "revision", "and", "if", "bid", "==", "kbfsmd", ".", "PendingLocalSquashBranchID", "earliestBranchRevision", "must", "equal", "one", "past", "the", "last", "local", "squash", "revision", ".", "If", "the", "branch", "is", "a", "pending", "local", "squash", "it", "preserves", "the", "MD", "updates", "corresponding", "to", "the", "prefix", "of", "existing", "local", "squashes", "so", "they", "can", "be", "re", "-", "used", "in", "the", "newly", "-", "resolved", "journal", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/md_journal.go#L944-L1012
159,153
keybase/client
go/kbfs/libkbfs/md_journal.go
clear
func (j *mdJournal) clear(ctx context.Context, bid kbfsmd.BranchID) error { earliestBranchRevision, err := j.j.readEarliestRevision() if err != nil { return err } if earliestBranchRevision != kbfsmd.RevisionUninitialized && bid == kbfsmd.PendingLocalSquashBranchID { latestRevision, err := j.j.readLatestRevision() if err != nil { return err } for ; earliestBranchRevision <= latestRevision; earliestBranchRevision++ { entry, err := j.j.readJournalEntry(earliestBranchRevision) if err != nil { return err } if !entry.IsLocalSquash { break } } } return j.clearHelper(ctx, bid, earliestBranchRevision) }
go
func (j *mdJournal) clear(ctx context.Context, bid kbfsmd.BranchID) error { earliestBranchRevision, err := j.j.readEarliestRevision() if err != nil { return err } if earliestBranchRevision != kbfsmd.RevisionUninitialized && bid == kbfsmd.PendingLocalSquashBranchID { latestRevision, err := j.j.readLatestRevision() if err != nil { return err } for ; earliestBranchRevision <= latestRevision; earliestBranchRevision++ { entry, err := j.j.readJournalEntry(earliestBranchRevision) if err != nil { return err } if !entry.IsLocalSquash { break } } } return j.clearHelper(ctx, bid, earliestBranchRevision) }
[ "func", "(", "j", "*", "mdJournal", ")", "clear", "(", "ctx", "context", ".", "Context", ",", "bid", "kbfsmd", ".", "BranchID", ")", "error", "{", "earliestBranchRevision", ",", "err", ":=", "j", ".", "j", ".", "readEarliestRevision", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "earliestBranchRevision", "!=", "kbfsmd", ".", "RevisionUninitialized", "&&", "bid", "==", "kbfsmd", ".", "PendingLocalSquashBranchID", "{", "latestRevision", ",", "err", ":=", "j", ".", "j", ".", "readLatestRevision", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "for", ";", "earliestBranchRevision", "<=", "latestRevision", ";", "earliestBranchRevision", "++", "{", "entry", ",", "err", ":=", "j", ".", "j", ".", "readJournalEntry", "(", "earliestBranchRevision", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "!", "entry", ".", "IsLocalSquash", "{", "break", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "j", ".", "clearHelper", "(", "ctx", ",", "bid", ",", "earliestBranchRevision", ")", "\n", "}" ]
// clear removes all the journal entries, and deletes the // corresponding MD updates. If the branch is a pending local squash, // it preserves the MD updates corresponding to the prefix of existing // local squashes, so they can be re-used in the newly-resolved // journal.
[ "clear", "removes", "all", "the", "journal", "entries", "and", "deletes", "the", "corresponding", "MD", "updates", ".", "If", "the", "branch", "is", "a", "pending", "local", "squash", "it", "preserves", "the", "MD", "updates", "corresponding", "to", "the", "prefix", "of", "existing", "local", "squashes", "so", "they", "can", "be", "re", "-", "used", "in", "the", "newly", "-", "resolved", "journal", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/md_journal.go#L1403-L1428
159,154
keybase/client
go/kbfs/kbfsmd/errors.go
Error
func (e MDRevisionMismatch) Error() string { return fmt.Sprintf("MD revision %d isn't next in line for our "+ "current revision %d", e.Rev, e.Curr) }
go
func (e MDRevisionMismatch) Error() string { return fmt.Sprintf("MD revision %d isn't next in line for our "+ "current revision %d", e.Rev, e.Curr) }
[ "func", "(", "e", "MDRevisionMismatch", ")", "Error", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", "+", "\"", "\"", ",", "e", ".", "Rev", ",", "e", ".", "Curr", ")", "\n", "}" ]
// Error implements the error interface for MDRevisionMismatch.
[ "Error", "implements", "the", "error", "interface", "for", "MDRevisionMismatch", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/errors.go#L65-L68
159,155
keybase/client
go/kbfs/kbfsmd/errors.go
Error
func (e InvalidNonPrivateTLFOperation) Error() string { return fmt.Sprintf( "Tried to do invalid operation %s on non-private TLF %v (ver=%v)", e.opName, e.id, e.ver) }
go
func (e InvalidNonPrivateTLFOperation) Error() string { return fmt.Sprintf( "Tried to do invalid operation %s on non-private TLF %v (ver=%v)", e.opName, e.id, e.ver) }
[ "func", "(", "e", "InvalidNonPrivateTLFOperation", ")", "Error", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "e", ".", "opName", ",", "e", ".", "id", ",", "e", ".", "ver", ")", "\n", "}" ]
// Error implements the error interface for InvalidNonPrivateTLFOperation.
[ "Error", "implements", "the", "error", "interface", "for", "InvalidNonPrivateTLFOperation", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/errors.go#L103-L107
159,156
keybase/client
go/kbfs/kbfsmd/errors.go
Error
func (e InvalidKeyGenerationError) Error() string { return fmt.Sprintf("Invalid key generation %d for %s", int(e.KeyGen), e.TlfID) }
go
func (e InvalidKeyGenerationError) Error() string { return fmt.Sprintf("Invalid key generation %d for %s", int(e.KeyGen), e.TlfID) }
[ "func", "(", "e", "InvalidKeyGenerationError", ")", "Error", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "int", "(", "e", ".", "KeyGen", ")", ",", "e", ".", "TlfID", ")", "\n", "}" ]
// Error implements the error interface for InvalidKeyGenerationError.
[ "Error", "implements", "the", "error", "interface", "for", "InvalidKeyGenerationError", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/errors.go#L117-L119
159,157
keybase/client
go/kbfs/kbfsmd/errors.go
Error
func (e NewKeyGenerationError) Error() string { return fmt.Sprintf( "The data for %v is keyed with a key generation (%d) that "+ "we don't know", e.TlfID, e.KeyGen) }
go
func (e NewKeyGenerationError) Error() string { return fmt.Sprintf( "The data for %v is keyed with a key generation (%d) that "+ "we don't know", e.TlfID, e.KeyGen) }
[ "func", "(", "e", "NewKeyGenerationError", ")", "Error", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", "+", "\"", "\"", ",", "e", ".", "TlfID", ",", "e", ".", "KeyGen", ")", "\n", "}" ]
// Error implements the error interface for NewKeyGenerationError.
[ "Error", "implements", "the", "error", "interface", "for", "NewKeyGenerationError", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/errors.go#L129-L133
159,158
keybase/client
go/kbfs/kbfsmd/errors.go
Error
func (e InvalidMetadataVersionError) Error() string { return fmt.Sprintf("Invalid metadata version %d for folder %s", int(e.MetadataVer), e.TlfID) }
go
func (e InvalidMetadataVersionError) Error() string { return fmt.Sprintf("Invalid metadata version %d for folder %s", int(e.MetadataVer), e.TlfID) }
[ "func", "(", "e", "InvalidMetadataVersionError", ")", "Error", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "int", "(", "e", ".", "MetadataVer", ")", ",", "e", ".", "TlfID", ")", "\n", "}" ]
// Error implements the error interface for InvalidMetadataVersionError.
[ "Error", "implements", "the", "error", "interface", "for", "InvalidMetadataVersionError", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/errors.go#L157-L160
159,159
keybase/client
go/kbfs/kbfsmd/errors.go
Error
func (e NewMetadataVersionError) Error() string { return fmt.Sprintf( "The metadata for folder %s is of a version (%d) that we can't read", e.Tlf, e.MetadataVer) }
go
func (e NewMetadataVersionError) Error() string { return fmt.Sprintf( "The metadata for folder %s is of a version (%d) that we can't read", e.Tlf, e.MetadataVer) }
[ "func", "(", "e", "NewMetadataVersionError", ")", "Error", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "e", ".", "Tlf", ",", "e", ".", "MetadataVer", ")", "\n", "}" ]
// Error implements the error interface for NewMetadataVersionError.
[ "Error", "implements", "the", "error", "interface", "for", "NewMetadataVersionError", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfsmd/errors.go#L171-L175
159,160
keybase/client
go/libkb/constants.go
ProofUserAgent
func ProofUserAgent() string { var os string if runtime.GOOS == "darwin" { // Either ios or mac if isIOS { os = "ios" } else { os = "mac" } } else { os = runtime.GOOS } return fmt.Sprintf("%s:%s", os, Version) }
go
func ProofUserAgent() string { var os string if runtime.GOOS == "darwin" { // Either ios or mac if isIOS { os = "ios" } else { os = "mac" } } else { os = runtime.GOOS } return fmt.Sprintf("%s:%s", os, Version) }
[ "func", "ProofUserAgent", "(", ")", "string", "{", "var", "os", "string", "\n", "if", "runtime", ".", "GOOS", "==", "\"", "\"", "{", "// Either ios or mac", "if", "isIOS", "{", "os", "=", "\"", "\"", "\n", "}", "else", "{", "os", "=", "\"", "\"", "\n", "}", "\n", "}", "else", "{", "os", "=", "runtime", ".", "GOOS", "\n", "}", "\n\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "os", ",", "Version", ")", "\n", "}" ]
// Returns a simplified UserAgent that's used as the kb_ua GET param.
[ "Returns", "a", "simplified", "UserAgent", "that", "s", "used", "as", "the", "kb_ua", "GET", "param", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/constants.go#L94-L108
159,161
keybase/client
go/gregor/storage/mem_sm.go
isDismissedAt
func (i item) isDismissedAt(t time.Time) bool { if i.dismissedImmediate { return true } if i.dtime != nil && isBeforeOrSame(*i.dtime, t) { return true } if dt := i.item.DTime(); dt != nil && isBeforeOrSame(toTime(i.ctime, dt), t) { return true } return false }
go
func (i item) isDismissedAt(t time.Time) bool { if i.dismissedImmediate { return true } if i.dtime != nil && isBeforeOrSame(*i.dtime, t) { return true } if dt := i.item.DTime(); dt != nil && isBeforeOrSame(toTime(i.ctime, dt), t) { return true } return false }
[ "func", "(", "i", "item", ")", "isDismissedAt", "(", "t", "time", ".", "Time", ")", "bool", "{", "if", "i", ".", "dismissedImmediate", "{", "return", "true", "\n", "}", "\n", "if", "i", ".", "dtime", "!=", "nil", "&&", "isBeforeOrSame", "(", "*", "i", ".", "dtime", ",", "t", ")", "{", "return", "true", "\n", "}", "\n", "if", "dt", ":=", "i", ".", "item", ".", "DTime", "(", ")", ";", "dt", "!=", "nil", "&&", "isBeforeOrSame", "(", "toTime", "(", "i", ".", "ctime", ",", "dt", ")", ",", "t", ")", "{", "return", "true", "\n", "}", "\n", "return", "false", "\n", "}" ]
// isDismissedAt returns true if item i is dismissed at time t. It will always return // true if the `dismissedImmediate` flag was turned out.
[ "isDismissedAt", "returns", "true", "if", "item", "i", "is", "dismissed", "at", "time", "t", ".", "It", "will", "always", "return", "true", "if", "the", "dismissedImmediate", "flag", "was", "turned", "out", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/gregor/storage/mem_sm.go#L87-L98
159,162
keybase/client
go/gregor/storage/mem_sm.go
isDismissedAt
func (m loggedMsg) isDismissedAt(t time.Time) bool { return m.i != nil && m.i.isDismissedAt(t) }
go
func (m loggedMsg) isDismissedAt(t time.Time) bool { return m.i != nil && m.i.isDismissedAt(t) }
[ "func", "(", "m", "loggedMsg", ")", "isDismissedAt", "(", "t", "time", ".", "Time", ")", "bool", "{", "return", "m", ".", "i", "!=", "nil", "&&", "m", ".", "i", ".", "isDismissedAt", "(", "t", ")", "\n", "}" ]
// isDismissedAt returns true if the log message has an associated item // and that item was dismissed at time t.
[ "isDismissedAt", "returns", "true", "if", "the", "log", "message", "has", "an", "associated", "item", "and", "that", "item", "was", "dismissed", "at", "time", "t", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/gregor/storage/mem_sm.go#L102-L104
159,163
keybase/client
go/gregor/storage/mem_sm.go
addItem
func (u *user) addItem(now time.Time, i gregor.Item) *item { msgID := i.Metadata().MsgID().Bytes() for _, it := range u.items { if bytes.Equal(msgID, it.item.Metadata().MsgID().Bytes()) { return it } } newItem := &item{item: i, ctime: nowIfZero(now, i.Metadata().CTime())} if i.DTime() != nil { newItem.dtime = i.DTime().Time() } u.items = append(u.items, newItem) return newItem }
go
func (u *user) addItem(now time.Time, i gregor.Item) *item { msgID := i.Metadata().MsgID().Bytes() for _, it := range u.items { if bytes.Equal(msgID, it.item.Metadata().MsgID().Bytes()) { return it } } newItem := &item{item: i, ctime: nowIfZero(now, i.Metadata().CTime())} if i.DTime() != nil { newItem.dtime = i.DTime().Time() } u.items = append(u.items, newItem) return newItem }
[ "func", "(", "u", "*", "user", ")", "addItem", "(", "now", "time", ".", "Time", ",", "i", "gregor", ".", "Item", ")", "*", "item", "{", "msgID", ":=", "i", ".", "Metadata", "(", ")", ".", "MsgID", "(", ")", ".", "Bytes", "(", ")", "\n", "for", "_", ",", "it", ":=", "range", "u", ".", "items", "{", "if", "bytes", ".", "Equal", "(", "msgID", ",", "it", ".", "item", ".", "Metadata", "(", ")", ".", "MsgID", "(", ")", ".", "Bytes", "(", ")", ")", "{", "return", "it", "\n", "}", "\n", "}", "\n", "newItem", ":=", "&", "item", "{", "item", ":", "i", ",", "ctime", ":", "nowIfZero", "(", "now", ",", "i", ".", "Metadata", "(", ")", ".", "CTime", "(", ")", ")", "}", "\n", "if", "i", ".", "DTime", "(", ")", "!=", "nil", "{", "newItem", ".", "dtime", "=", "i", ".", "DTime", "(", ")", ".", "Time", "(", ")", "\n", "}", "\n", "u", ".", "items", "=", "append", "(", "u", ".", "items", ",", "newItem", ")", "\n", "return", "newItem", "\n", "}" ]
// addItem adds an item for this user
[ "addItem", "adds", "an", "item", "for", "this", "user" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/gregor/storage/mem_sm.go#L115-L128
159,164
keybase/client
go/gregor/storage/mem_sm.go
logMessage
func (u *user) logMessage(t time.Time, m gregor.InBandMessage, i *item) { for _, l := range u.log { if bytes.Equal(l.m.Metadata().MsgID().Bytes(), m.Metadata().MsgID().Bytes()) { return } } u.log = append(u.log, loggedMsg{m, t, i}) }
go
func (u *user) logMessage(t time.Time, m gregor.InBandMessage, i *item) { for _, l := range u.log { if bytes.Equal(l.m.Metadata().MsgID().Bytes(), m.Metadata().MsgID().Bytes()) { return } } u.log = append(u.log, loggedMsg{m, t, i}) }
[ "func", "(", "u", "*", "user", ")", "logMessage", "(", "t", "time", ".", "Time", ",", "m", "gregor", ".", "InBandMessage", ",", "i", "*", "item", ")", "{", "for", "_", ",", "l", ":=", "range", "u", ".", "log", "{", "if", "bytes", ".", "Equal", "(", "l", ".", "m", ".", "Metadata", "(", ")", ".", "MsgID", "(", ")", ".", "Bytes", "(", ")", ",", "m", ".", "Metadata", "(", ")", ".", "MsgID", "(", ")", ".", "Bytes", "(", ")", ")", "{", "return", "\n", "}", "\n", "}", "\n", "u", ".", "log", "=", "append", "(", "u", ".", "log", ",", "loggedMsg", "{", "m", ",", "t", ",", "i", "}", ")", "\n", "}" ]
// logMessage logs a message for this user and potentially associates an item
[ "logMessage", "logs", "a", "message", "for", "this", "user", "and", "potentially", "associates", "an", "item" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/gregor/storage/mem_sm.go#L137-L144
159,165
keybase/client
go/gregor/storage/mem_sm.go
getUser
func (m *MemEngine) getUser(uid gregor.UID) *user { uidHex := uidToString(uid) if u, ok := m.users[uidHex]; ok { return u } u := newUser(m.log) m.users[uidHex] = u return u }
go
func (m *MemEngine) getUser(uid gregor.UID) *user { uidHex := uidToString(uid) if u, ok := m.users[uidHex]; ok { return u } u := newUser(m.log) m.users[uidHex] = u return u }
[ "func", "(", "m", "*", "MemEngine", ")", "getUser", "(", "uid", "gregor", ".", "UID", ")", "*", "user", "{", "uidHex", ":=", "uidToString", "(", "uid", ")", "\n", "if", "u", ",", "ok", ":=", "m", ".", "users", "[", "uidHex", "]", ";", "ok", "{", "return", "u", "\n", "}", "\n", "u", ":=", "newUser", "(", "m", ".", "log", ")", "\n", "m", ".", "users", "[", "uidHex", "]", "=", "u", "\n", "return", "u", "\n", "}" ]
// getUser gets or makes a new user object for the given UID.
[ "getUser", "gets", "or", "makes", "a", "new", "user", "object", "for", "the", "given", "UID", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/gregor/storage/mem_sm.go#L380-L388
159,166
keybase/client
go/libkb/json.go
Rollback
func (f *jsonFileTransaction) Rollback() error { f.f.G().Log.Debug("+ Rolling back %s to state from %s", f.f.which, f.f.filename) err := f.f.Load(false) if !f.f.exists { // Before transaction there was no file, so set in-memory // wrapper to clean state as well. f.f.jw = jsonw.NewDictionary() f.f.G().Log.Debug("+ Rolling back to clean state because f.exists is false") } f.f.G().Log.Debug("- Rollback -> %s", ErrToOk(err)) return err }
go
func (f *jsonFileTransaction) Rollback() error { f.f.G().Log.Debug("+ Rolling back %s to state from %s", f.f.which, f.f.filename) err := f.f.Load(false) if !f.f.exists { // Before transaction there was no file, so set in-memory // wrapper to clean state as well. f.f.jw = jsonw.NewDictionary() f.f.G().Log.Debug("+ Rolling back to clean state because f.exists is false") } f.f.G().Log.Debug("- Rollback -> %s", ErrToOk(err)) return err }
[ "func", "(", "f", "*", "jsonFileTransaction", ")", "Rollback", "(", ")", "error", "{", "f", ".", "f", ".", "G", "(", ")", ".", "Log", ".", "Debug", "(", "\"", "\"", ",", "f", ".", "f", ".", "which", ",", "f", ".", "f", ".", "filename", ")", "\n", "err", ":=", "f", ".", "f", ".", "Load", "(", "false", ")", "\n", "if", "!", "f", ".", "f", ".", "exists", "{", "// Before transaction there was no file, so set in-memory", "// wrapper to clean state as well.", "f", ".", "f", ".", "jw", "=", "jsonw", ".", "NewDictionary", "(", ")", "\n", "f", ".", "f", ".", "G", "(", ")", ".", "Log", ".", "Debug", "(", "\"", "\"", ")", "\n", "}", "\n", "f", ".", "f", ".", "G", "(", ")", ".", "Log", ".", "Debug", "(", "\"", "\"", ",", "ErrToOk", "(", "err", ")", ")", "\n", "return", "err", "\n", "}" ]
// Rollback reloads config from unchanged config file, bringing its // state back to from before the transaction changes. Note that it // only works for changes that do not affect UserConfig, which caches // values, and has to be reloaded manually.
[ "Rollback", "reloads", "config", "from", "unchanged", "config", "file", "bringing", "its", "state", "back", "to", "from", "before", "the", "transaction", "changes", ".", "Note", "that", "it", "only", "works", "for", "changes", "that", "do", "not", "affect", "UserConfig", "which", "caches", "values", "and", "has", "to", "be", "reloaded", "manually", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/json.go#L324-L335
159,167
keybase/client
go/client/cmd_device.go
NewCmdDevice
func NewCmdDevice(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command { return cli.Command{ Name: "device", Usage: "Manage your devices", ArgumentHelp: "[arguments...]", Subcommands: []cli.Command{ NewCmdDeviceRemove(cl, g), NewCmdDeviceList(cl, g), NewCmdDeviceAdd(cl, g), }, } }
go
func NewCmdDevice(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command { return cli.Command{ Name: "device", Usage: "Manage your devices", ArgumentHelp: "[arguments...]", Subcommands: []cli.Command{ NewCmdDeviceRemove(cl, g), NewCmdDeviceList(cl, g), NewCmdDeviceAdd(cl, g), }, } }
[ "func", "NewCmdDevice", "(", "cl", "*", "libcmdline", ".", "CommandLine", ",", "g", "*", "libkb", ".", "GlobalContext", ")", "cli", ".", "Command", "{", "return", "cli", ".", "Command", "{", "Name", ":", "\"", "\"", ",", "Usage", ":", "\"", "\"", ",", "ArgumentHelp", ":", "\"", "\"", ",", "Subcommands", ":", "[", "]", "cli", ".", "Command", "{", "NewCmdDeviceRemove", "(", "cl", ",", "g", ")", ",", "NewCmdDeviceList", "(", "cl", ",", "g", ")", ",", "NewCmdDeviceAdd", "(", "cl", ",", "g", ")", ",", "}", ",", "}", "\n", "}" ]
// NewCmdDevice creates the device command, which is just a holder // for subcommands.
[ "NewCmdDevice", "creates", "the", "device", "command", "which", "is", "just", "a", "holder", "for", "subcommands", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/cmd_device.go#L14-L25
159,168
keybase/client
go/engine/paperkey_gen.go
NewPaperKeyGen
func NewPaperKeyGen(g *libkb.GlobalContext, arg *PaperKeyGenArg) *PaperKeyGen { return &PaperKeyGen{ arg: arg, Contextified: libkb.NewContextified(g), } }
go
func NewPaperKeyGen(g *libkb.GlobalContext, arg *PaperKeyGenArg) *PaperKeyGen { return &PaperKeyGen{ arg: arg, Contextified: libkb.NewContextified(g), } }
[ "func", "NewPaperKeyGen", "(", "g", "*", "libkb", ".", "GlobalContext", ",", "arg", "*", "PaperKeyGenArg", ")", "*", "PaperKeyGen", "{", "return", "&", "PaperKeyGen", "{", "arg", ":", "arg", ",", "Contextified", ":", "libkb", ".", "NewContextified", "(", "g", ")", ",", "}", "\n", "}" ]
// NewPaperKeyGen creates a PaperKeyGen engine.
[ "NewPaperKeyGen", "creates", "a", "PaperKeyGen", "engine", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/paperkey_gen.go#L46-L51
159,169
keybase/client
go/kbfs/libkbfs/chat_local.go
newChatLocal
func newChatLocal(config Config) *chatLocal { return newChatLocalWithData(config, &chatLocalSharedData{ convs: make(convLocalByTypeMap), convsByID: make(convLocalByIDMap), newChannelCBs: map[Config]newConvCB{ config: nil, }, }) }
go
func newChatLocal(config Config) *chatLocal { return newChatLocalWithData(config, &chatLocalSharedData{ convs: make(convLocalByTypeMap), convsByID: make(convLocalByIDMap), newChannelCBs: map[Config]newConvCB{ config: nil, }, }) }
[ "func", "newChatLocal", "(", "config", "Config", ")", "*", "chatLocal", "{", "return", "newChatLocalWithData", "(", "config", ",", "&", "chatLocalSharedData", "{", "convs", ":", "make", "(", "convLocalByTypeMap", ")", ",", "convsByID", ":", "make", "(", "convLocalByIDMap", ")", ",", "newChannelCBs", ":", "map", "[", "Config", "]", "newConvCB", "{", "config", ":", "nil", ",", "}", ",", "}", ")", "\n", "}" ]
// newChatLocal constructs a new local chat implementation.
[ "newChatLocal", "constructs", "a", "new", "local", "chat", "implementation", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/chat_local.go#L75-L83
159,170
keybase/client
go/protocol/keybase1/tlf.go
CryptKeys
func (c TlfClient) CryptKeys(ctx context.Context, query TLFQuery) (res GetTLFCryptKeysRes, err error) { __arg := CryptKeysArg{Query: query} err = c.Cli.Call(ctx, "keybase.1.tlf.CryptKeys", []interface{}{__arg}, &res) return }
go
func (c TlfClient) CryptKeys(ctx context.Context, query TLFQuery) (res GetTLFCryptKeysRes, err error) { __arg := CryptKeysArg{Query: query} err = c.Cli.Call(ctx, "keybase.1.tlf.CryptKeys", []interface{}{__arg}, &res) return }
[ "func", "(", "c", "TlfClient", ")", "CryptKeys", "(", "ctx", "context", ".", "Context", ",", "query", "TLFQuery", ")", "(", "res", "GetTLFCryptKeysRes", ",", "err", "error", ")", "{", "__arg", ":=", "CryptKeysArg", "{", "Query", ":", "query", "}", "\n", "err", "=", "c", ".", "Cli", ".", "Call", "(", "ctx", ",", "\"", "\"", ",", "[", "]", "interface", "{", "}", "{", "__arg", "}", ",", "&", "res", ")", "\n", "return", "\n", "}" ]
// CryptKeys returns TLF crypt keys from all generations.
[ "CryptKeys", "returns", "TLF", "crypt", "keys", "from", "all", "generations", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/tlf.go#L90-L94
159,171
keybase/client
go/pvl/debug.go
debugServiceToString
func debugServiceToString(service keybase1.ProofType) string { s, err := serviceToString(service) if err != nil { return string(service) } return s }
go
func debugServiceToString(service keybase1.ProofType) string { s, err := serviceToString(service) if err != nil { return string(service) } return s }
[ "func", "debugServiceToString", "(", "service", "keybase1", ".", "ProofType", ")", "string", "{", "s", ",", "err", ":=", "serviceToString", "(", "service", ")", "\n", "if", "err", "!=", "nil", "{", "return", "string", "(", "service", ")", "\n", "}", "\n", "return", "s", "\n", "}" ]
// debugServiceToString returns the name of a service or number string if it is invalid.
[ "debugServiceToString", "returns", "the", "name", "of", "a", "service", "or", "number", "string", "if", "it", "is", "invalid", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/pvl/debug.go#L49-L55
159,172
keybase/client
go/stellar/stellarsvc/service.go
WalletInitLocal
func (s *Server) WalletInitLocal(ctx context.Context) (err error) { mctx, fin, err := s.Preamble(ctx, preambleArg{ RPCName: "WalletInitLocal", Err: &err, }) defer fin() if err != nil { return err } _, err = stellar.CreateWallet(mctx) return err }
go
func (s *Server) WalletInitLocal(ctx context.Context) (err error) { mctx, fin, err := s.Preamble(ctx, preambleArg{ RPCName: "WalletInitLocal", Err: &err, }) defer fin() if err != nil { return err } _, err = stellar.CreateWallet(mctx) return err }
[ "func", "(", "s", "*", "Server", ")", "WalletInitLocal", "(", "ctx", "context", ".", "Context", ")", "(", "err", "error", ")", "{", "mctx", ",", "fin", ",", "err", ":=", "s", ".", "Preamble", "(", "ctx", ",", "preambleArg", "{", "RPCName", ":", "\"", "\"", ",", "Err", ":", "&", "err", ",", "}", ")", "\n", "defer", "fin", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "_", ",", "err", "=", "stellar", ".", "CreateWallet", "(", "mctx", ")", "\n", "return", "err", "\n", "}" ]
// WalletInitLocal creates and posts an initial stellar bundle for a user. // Only succeeds if they do not already have one. // Safe to call even if the user has a bundle already.
[ "WalletInitLocal", "creates", "and", "posts", "an", "initial", "stellar", "bundle", "for", "a", "user", ".", "Only", "succeeds", "if", "they", "do", "not", "already", "have", "one", ".", "Safe", "to", "call", "even", "if", "the", "user", "has", "a", "bundle", "already", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/stellarsvc/service.go#L314-L326
159,173
keybase/client
go/stellar/stellarsvc/service.go
getLocalCurrencyAndExchangeRate
func getLocalCurrencyAndExchangeRate(mctx libkb.MetaContext, remoter remote.Remoter, account *stellar1.OwnAccountCLILocal, exchangeRates exchangeRateMap) error { displayCurrency, err := stellar.GetAccountDisplayCurrency(mctx, account.AccountID) if err != nil { return err } rate, ok := exchangeRates[displayCurrency] if !ok { var err error rate, err = remoter.ExchangeRate(mctx.Ctx(), displayCurrency) if err != nil { return err } exchangeRates[displayCurrency] = rate } account.ExchangeRate = &rate return nil }
go
func getLocalCurrencyAndExchangeRate(mctx libkb.MetaContext, remoter remote.Remoter, account *stellar1.OwnAccountCLILocal, exchangeRates exchangeRateMap) error { displayCurrency, err := stellar.GetAccountDisplayCurrency(mctx, account.AccountID) if err != nil { return err } rate, ok := exchangeRates[displayCurrency] if !ok { var err error rate, err = remoter.ExchangeRate(mctx.Ctx(), displayCurrency) if err != nil { return err } exchangeRates[displayCurrency] = rate } account.ExchangeRate = &rate return nil }
[ "func", "getLocalCurrencyAndExchangeRate", "(", "mctx", "libkb", ".", "MetaContext", ",", "remoter", "remote", ".", "Remoter", ",", "account", "*", "stellar1", ".", "OwnAccountCLILocal", ",", "exchangeRates", "exchangeRateMap", ")", "error", "{", "displayCurrency", ",", "err", ":=", "stellar", ".", "GetAccountDisplayCurrency", "(", "mctx", ",", "account", ".", "AccountID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "rate", ",", "ok", ":=", "exchangeRates", "[", "displayCurrency", "]", "\n", "if", "!", "ok", "{", "var", "err", "error", "\n", "rate", ",", "err", "=", "remoter", ".", "ExchangeRate", "(", "mctx", ".", "Ctx", "(", ")", ",", "displayCurrency", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "exchangeRates", "[", "displayCurrency", "]", "=", "rate", "\n", "}", "\n", "account", ".", "ExchangeRate", "=", "&", "rate", "\n", "return", "nil", "\n", "}" ]
// getLocalCurrencyAndExchangeRate gets display currency setting // for accountID and fetches exchange rate is set. // // Arguments `account` and `exchangeRates` may end up mutated.
[ "getLocalCurrencyAndExchangeRate", "gets", "display", "currency", "setting", "for", "accountID", "and", "fetches", "exchange", "rate", "is", "set", ".", "Arguments", "account", "and", "exchangeRates", "may", "end", "up", "mutated", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/stellarsvc/service.go#L348-L364
159,174
keybase/client
go/stellar/stellarsvc/service.go
checkDisplayAmount
func (s *Server) checkDisplayAmount(ctx context.Context, arg stellar1.SendCLILocalArg) error { if arg.DisplayAmount == "" { return nil } exchangeRate, err := s.remoter.ExchangeRate(ctx, arg.DisplayCurrency) if err != nil { return err } xlmAmount, err := stellarnet.ConvertOutsideToXLM(arg.DisplayAmount, exchangeRate.Rate) if err != nil { return err } currentAmt, err := stellarnet.ParseStellarAmount(xlmAmount) if err != nil { return err } argAmt, err := stellarnet.ParseStellarAmount(arg.Amount) if err != nil { return err } if percentageAmountChange(currentAmt, argAmt) > 1.0 { s.G().Log.CDebugf(ctx, "large exchange rate delta: argAmt: %d, currentAmt: %d", argAmt, currentAmt) return errors.New("current exchange rates have changed more than 1%") } return nil }
go
func (s *Server) checkDisplayAmount(ctx context.Context, arg stellar1.SendCLILocalArg) error { if arg.DisplayAmount == "" { return nil } exchangeRate, err := s.remoter.ExchangeRate(ctx, arg.DisplayCurrency) if err != nil { return err } xlmAmount, err := stellarnet.ConvertOutsideToXLM(arg.DisplayAmount, exchangeRate.Rate) if err != nil { return err } currentAmt, err := stellarnet.ParseStellarAmount(xlmAmount) if err != nil { return err } argAmt, err := stellarnet.ParseStellarAmount(arg.Amount) if err != nil { return err } if percentageAmountChange(currentAmt, argAmt) > 1.0 { s.G().Log.CDebugf(ctx, "large exchange rate delta: argAmt: %d, currentAmt: %d", argAmt, currentAmt) return errors.New("current exchange rates have changed more than 1%") } return nil }
[ "func", "(", "s", "*", "Server", ")", "checkDisplayAmount", "(", "ctx", "context", ".", "Context", ",", "arg", "stellar1", ".", "SendCLILocalArg", ")", "error", "{", "if", "arg", ".", "DisplayAmount", "==", "\"", "\"", "{", "return", "nil", "\n", "}", "\n\n", "exchangeRate", ",", "err", ":=", "s", ".", "remoter", ".", "ExchangeRate", "(", "ctx", ",", "arg", ".", "DisplayCurrency", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "xlmAmount", ",", "err", ":=", "stellarnet", ".", "ConvertOutsideToXLM", "(", "arg", ".", "DisplayAmount", ",", "exchangeRate", ".", "Rate", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "currentAmt", ",", "err", ":=", "stellarnet", ".", "ParseStellarAmount", "(", "xlmAmount", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "argAmt", ",", "err", ":=", "stellarnet", ".", "ParseStellarAmount", "(", "arg", ".", "Amount", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "percentageAmountChange", "(", "currentAmt", ",", "argAmt", ")", ">", "1.0", "{", "s", ".", "G", "(", ")", ".", "Log", ".", "CDebugf", "(", "ctx", ",", "\"", "\"", ",", "argAmt", ",", "currentAmt", ")", "\n", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// check that the display amount is within 1% of current exchange rates
[ "check", "that", "the", "display", "amount", "is", "within", "1%", "of", "current", "exchange", "rates" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/stellarsvc/service.go#L473-L504
159,175
keybase/client
go/libkb/connmgr.go
AddConnection
func (c *ConnectionManager) AddConnection(xp rpc.Transporter, closeListener chan error) ConnectionID { c.Lock() c.nxt++ // increment first, since 0 is reserved id := c.nxt c.lookup[id] = &rpcConnection{transporter: xp} c.Unlock() if closeListener != nil { go func() { <-closeListener c.removeConnection(id) }() } return id }
go
func (c *ConnectionManager) AddConnection(xp rpc.Transporter, closeListener chan error) ConnectionID { c.Lock() c.nxt++ // increment first, since 0 is reserved id := c.nxt c.lookup[id] = &rpcConnection{transporter: xp} c.Unlock() if closeListener != nil { go func() { <-closeListener c.removeConnection(id) }() } return id }
[ "func", "(", "c", "*", "ConnectionManager", ")", "AddConnection", "(", "xp", "rpc", ".", "Transporter", ",", "closeListener", "chan", "error", ")", "ConnectionID", "{", "c", ".", "Lock", "(", ")", "\n", "c", ".", "nxt", "++", "// increment first, since 0 is reserved", "\n", "id", ":=", "c", ".", "nxt", "\n", "c", ".", "lookup", "[", "id", "]", "=", "&", "rpcConnection", "{", "transporter", ":", "xp", "}", "\n", "c", ".", "Unlock", "(", ")", "\n\n", "if", "closeListener", "!=", "nil", "{", "go", "func", "(", ")", "{", "<-", "closeListener", "\n", "c", ".", "removeConnection", "(", "id", ")", "\n", "}", "(", ")", "\n", "}", "\n\n", "return", "id", "\n", "}" ]
// AddConnection adds a new connection to the table of Connection object, with a // related closeListener. We'll listen for a close on that channel, and when one occurs, // we'll remove the connection from the pool.
[ "AddConnection", "adds", "a", "new", "connection", "to", "the", "table", "of", "Connection", "object", "with", "a", "related", "closeListener", ".", "We", "ll", "listen", "for", "a", "close", "on", "that", "channel", "and", "when", "one", "occurs", "we", "ll", "remove", "the", "connection", "from", "the", "pool", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/connmgr.go#L50-L65
159,176
keybase/client
go/libkb/connmgr.go
LookupConnection
func (c *ConnectionManager) LookupConnection(i ConnectionID) rpc.Transporter { c.Lock() defer c.Unlock() if conn := c.lookup[i]; conn != nil { return conn.transporter } return nil }
go
func (c *ConnectionManager) LookupConnection(i ConnectionID) rpc.Transporter { c.Lock() defer c.Unlock() if conn := c.lookup[i]; conn != nil { return conn.transporter } return nil }
[ "func", "(", "c", "*", "ConnectionManager", ")", "LookupConnection", "(", "i", "ConnectionID", ")", "rpc", ".", "Transporter", "{", "c", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "Unlock", "(", ")", "\n", "if", "conn", ":=", "c", ".", "lookup", "[", "i", "]", ";", "conn", "!=", "nil", "{", "return", "conn", ".", "transporter", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// LookupConnection looks up a connection given a connectionID, or returns nil // if no such connection was found.
[ "LookupConnection", "looks", "up", "a", "connection", "given", "a", "connectionID", "or", "returns", "nil", "if", "no", "such", "connection", "was", "found", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/connmgr.go#L75-L82
159,177
keybase/client
go/libkb/connmgr.go
WaitForClientType
func (c *ConnectionManager) WaitForClientType(clientType keybase1.ClientType, timeout time.Duration) bool { if c.hasClientType(clientType) { return true } ticker := time.NewTicker(time.Second) deadline := time.After(timeout) defer ticker.Stop() for { select { case <-ticker.C: if c.hasClientType(clientType) { return true } case <-deadline: return false } } }
go
func (c *ConnectionManager) WaitForClientType(clientType keybase1.ClientType, timeout time.Duration) bool { if c.hasClientType(clientType) { return true } ticker := time.NewTicker(time.Second) deadline := time.After(timeout) defer ticker.Stop() for { select { case <-ticker.C: if c.hasClientType(clientType) { return true } case <-deadline: return false } } }
[ "func", "(", "c", "*", "ConnectionManager", ")", "WaitForClientType", "(", "clientType", "keybase1", ".", "ClientType", ",", "timeout", "time", ".", "Duration", ")", "bool", "{", "if", "c", ".", "hasClientType", "(", "clientType", ")", "{", "return", "true", "\n", "}", "\n", "ticker", ":=", "time", ".", "NewTicker", "(", "time", ".", "Second", ")", "\n", "deadline", ":=", "time", ".", "After", "(", "timeout", ")", "\n", "defer", "ticker", ".", "Stop", "(", ")", "\n", "for", "{", "select", "{", "case", "<-", "ticker", ".", "C", ":", "if", "c", ".", "hasClientType", "(", "clientType", ")", "{", "return", "true", "\n", "}", "\n", "case", "<-", "deadline", ":", "return", "false", "\n", "}", "\n", "}", "\n", "}" ]
// WaitForClientType returns true if client type is connected, or waits until timeout for the connection
[ "WaitForClientType", "returns", "true", "if", "client", "type", "is", "connected", "or", "waits", "until", "timeout", "for", "the", "connection" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/connmgr.go#L136-L153
159,178
keybase/client
go/libkb/connmgr.go
ApplyAll
func (c *ConnectionManager) ApplyAll(f ApplyFn) { c.Lock() defer c.Unlock() for k, v := range c.lookup { if !f(k, v.transporter) { break } } }
go
func (c *ConnectionManager) ApplyAll(f ApplyFn) { c.Lock() defer c.Unlock() for k, v := range c.lookup { if !f(k, v.transporter) { break } } }
[ "func", "(", "c", "*", "ConnectionManager", ")", "ApplyAll", "(", "f", "ApplyFn", ")", "{", "c", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "Unlock", "(", ")", "\n", "for", "k", ",", "v", ":=", "range", "c", ".", "lookup", "{", "if", "!", "f", "(", "k", ",", "v", ".", "transporter", ")", "{", "break", "\n", "}", "\n", "}", "\n", "}" ]
// ApplyAll applies the given function f to all connections in the table. // If you're going to do something blocking, please do it in a GoRoutine, // since we're holding the lock for all connections as we do this.
[ "ApplyAll", "applies", "the", "given", "function", "f", "to", "all", "connections", "in", "the", "table", ".", "If", "you", "re", "going", "to", "do", "something", "blocking", "please", "do", "it", "in", "a", "GoRoutine", "since", "we", "re", "holding", "the", "lock", "for", "all", "connections", "as", "we", "do", "this", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/connmgr.go#L176-L184
159,179
keybase/client
go/libkb/connmgr.go
ApplyAllDetails
func (c *ConnectionManager) ApplyAllDetails(f ApplyDetailsFn) { c.Lock() defer c.Unlock() for k, v := range c.lookup { status := v.details var details *keybase1.ClientDetails if status != nil { details = &status.Details } if !f(k, v.transporter, details) { break } } }
go
func (c *ConnectionManager) ApplyAllDetails(f ApplyDetailsFn) { c.Lock() defer c.Unlock() for k, v := range c.lookup { status := v.details var details *keybase1.ClientDetails if status != nil { details = &status.Details } if !f(k, v.transporter, details) { break } } }
[ "func", "(", "c", "*", "ConnectionManager", ")", "ApplyAllDetails", "(", "f", "ApplyDetailsFn", ")", "{", "c", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "Unlock", "(", ")", "\n", "for", "k", ",", "v", ":=", "range", "c", ".", "lookup", "{", "status", ":=", "v", ".", "details", "\n", "var", "details", "*", "keybase1", ".", "ClientDetails", "\n", "if", "status", "!=", "nil", "{", "details", "=", "&", "status", ".", "Details", "\n", "}", "\n", "if", "!", "f", "(", "k", ",", "v", ".", "transporter", ",", "details", ")", "{", "break", "\n", "}", "\n", "}", "\n", "}" ]
// ApplyAllDetails applies the given function f to all connections in the table. // If you're going to do something blocking, please do it in a GoRoutine, // since we're holding the lock for all connections as we do this.
[ "ApplyAllDetails", "applies", "the", "given", "function", "f", "to", "all", "connections", "in", "the", "table", ".", "If", "you", "re", "going", "to", "do", "something", "blocking", "please", "do", "it", "in", "a", "GoRoutine", "since", "we", "re", "holding", "the", "lock", "for", "all", "connections", "as", "we", "do", "this", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/connmgr.go#L189-L202
159,180
keybase/client
go/kbfs/libkbfs/bserver_disk.go
newBlockServerDisk
func newBlockServerDisk( codec kbfscodec.Codec, log logger.Logger, dirPath string, shutdownFunc func(logger.Logger)) *BlockServerDisk { bserv := &BlockServerDisk{ codec, log, dirPath, shutdownFunc, sync.RWMutex{}, make(map[tlf.ID]*blockServerDiskTlfStorage), } return bserv }
go
func newBlockServerDisk( codec kbfscodec.Codec, log logger.Logger, dirPath string, shutdownFunc func(logger.Logger)) *BlockServerDisk { bserv := &BlockServerDisk{ codec, log, dirPath, shutdownFunc, sync.RWMutex{}, make(map[tlf.ID]*blockServerDiskTlfStorage), } return bserv }
[ "func", "newBlockServerDisk", "(", "codec", "kbfscodec", ".", "Codec", ",", "log", "logger", ".", "Logger", ",", "dirPath", "string", ",", "shutdownFunc", "func", "(", "logger", ".", "Logger", ")", ")", "*", "BlockServerDisk", "{", "bserv", ":=", "&", "BlockServerDisk", "{", "codec", ",", "log", ",", "dirPath", ",", "shutdownFunc", ",", "sync", ".", "RWMutex", "{", "}", ",", "make", "(", "map", "[", "tlf", ".", "ID", "]", "*", "blockServerDiskTlfStorage", ")", ",", "}", "\n", "return", "bserv", "\n", "}" ]
// newBlockServerDisk constructs a new BlockServerDisk that stores // its data in the given directory.
[ "newBlockServerDisk", "constructs", "a", "new", "BlockServerDisk", "that", "stores", "its", "data", "in", "the", "given", "directory", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/bserver_disk.go#L48-L56
159,181
keybase/client
go/kbfs/libkbfs/bserver_disk.go
NewBlockServerDir
func NewBlockServerDir(codec kbfscodec.Codec, log logger.Logger, dirPath string) *BlockServerDisk { return newBlockServerDisk(codec, log, dirPath, nil) }
go
func NewBlockServerDir(codec kbfscodec.Codec, log logger.Logger, dirPath string) *BlockServerDisk { return newBlockServerDisk(codec, log, dirPath, nil) }
[ "func", "NewBlockServerDir", "(", "codec", "kbfscodec", ".", "Codec", ",", "log", "logger", ".", "Logger", ",", "dirPath", "string", ")", "*", "BlockServerDisk", "{", "return", "newBlockServerDisk", "(", "codec", ",", "log", ",", "dirPath", ",", "nil", ")", "\n", "}" ]
// NewBlockServerDir constructs a new BlockServerDisk that stores // its data in the given directory.
[ "NewBlockServerDir", "constructs", "a", "new", "BlockServerDisk", "that", "stores", "its", "data", "in", "the", "given", "directory", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/bserver_disk.go#L60-L63
159,182
keybase/client
go/kbfs/libkbfs/bserver_disk.go
NewBlockServerTempDir
func NewBlockServerTempDir(codec kbfscodec.Codec, log logger.Logger) (*BlockServerDisk, error) { tempdir, err := ioutil.TempDir(os.TempDir(), "kbfs_bserver_tmp") if err != nil { return nil, err } return newBlockServerDisk(codec, log, tempdir, func(log logger.Logger) { err := ioutil.RemoveAll(tempdir) if err != nil { log.Warning("error removing %s: %s", tempdir, err) } }), nil }
go
func NewBlockServerTempDir(codec kbfscodec.Codec, log logger.Logger) (*BlockServerDisk, error) { tempdir, err := ioutil.TempDir(os.TempDir(), "kbfs_bserver_tmp") if err != nil { return nil, err } return newBlockServerDisk(codec, log, tempdir, func(log logger.Logger) { err := ioutil.RemoveAll(tempdir) if err != nil { log.Warning("error removing %s: %s", tempdir, err) } }), nil }
[ "func", "NewBlockServerTempDir", "(", "codec", "kbfscodec", ".", "Codec", ",", "log", "logger", ".", "Logger", ")", "(", "*", "BlockServerDisk", ",", "error", ")", "{", "tempdir", ",", "err", ":=", "ioutil", ".", "TempDir", "(", "os", ".", "TempDir", "(", ")", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "newBlockServerDisk", "(", "codec", ",", "log", ",", "tempdir", ",", "func", "(", "log", "logger", ".", "Logger", ")", "{", "err", ":=", "ioutil", ".", "RemoveAll", "(", "tempdir", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Warning", "(", "\"", "\"", ",", "tempdir", ",", "err", ")", "\n", "}", "\n", "}", ")", ",", "nil", "\n", "}" ]
// NewBlockServerTempDir constructs a new BlockServerDisk that stores its // data in a temp directory which is cleaned up on shutdown.
[ "NewBlockServerTempDir", "constructs", "a", "new", "BlockServerDisk", "that", "stores", "its", "data", "in", "a", "temp", "directory", "which", "is", "cleaned", "up", "on", "shutdown", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/bserver_disk.go#L67-L79
159,183
keybase/client
go/kbfs/libkbfs/bserver_disk.go
Get
func (b *BlockServerDisk) Get( ctx context.Context, tlfID tlf.ID, id kbfsblock.ID, context kbfsblock.Context, _ DiskBlockCacheType) ( data []byte, serverHalf kbfscrypto.BlockCryptKeyServerHalf, err error) { if err := checkContext(ctx); err != nil { return nil, kbfscrypto.BlockCryptKeyServerHalf{}, err } defer func() { err = translateToBlockServerError(err) }() b.log.CDebugf(ctx, "BlockServerDisk.Get id=%s tlfID=%s context=%s", id, tlfID, context) tlfStorage, err := b.getStorage(tlfID) if err != nil { return nil, kbfscrypto.BlockCryptKeyServerHalf{}, err } tlfStorage.lock.RLock() defer tlfStorage.lock.RUnlock() if tlfStorage.store == nil { return nil, kbfscrypto.BlockCryptKeyServerHalf{}, errBlockServerDiskShutdown } data, keyServerHalf, err := tlfStorage.store.getDataWithContext( ctx, id, context) if err != nil { return nil, kbfscrypto.BlockCryptKeyServerHalf{}, err } return data, keyServerHalf, nil }
go
func (b *BlockServerDisk) Get( ctx context.Context, tlfID tlf.ID, id kbfsblock.ID, context kbfsblock.Context, _ DiskBlockCacheType) ( data []byte, serverHalf kbfscrypto.BlockCryptKeyServerHalf, err error) { if err := checkContext(ctx); err != nil { return nil, kbfscrypto.BlockCryptKeyServerHalf{}, err } defer func() { err = translateToBlockServerError(err) }() b.log.CDebugf(ctx, "BlockServerDisk.Get id=%s tlfID=%s context=%s", id, tlfID, context) tlfStorage, err := b.getStorage(tlfID) if err != nil { return nil, kbfscrypto.BlockCryptKeyServerHalf{}, err } tlfStorage.lock.RLock() defer tlfStorage.lock.RUnlock() if tlfStorage.store == nil { return nil, kbfscrypto.BlockCryptKeyServerHalf{}, errBlockServerDiskShutdown } data, keyServerHalf, err := tlfStorage.store.getDataWithContext( ctx, id, context) if err != nil { return nil, kbfscrypto.BlockCryptKeyServerHalf{}, err } return data, keyServerHalf, nil }
[ "func", "(", "b", "*", "BlockServerDisk", ")", "Get", "(", "ctx", "context", ".", "Context", ",", "tlfID", "tlf", ".", "ID", ",", "id", "kbfsblock", ".", "ID", ",", "context", "kbfsblock", ".", "Context", ",", "_", "DiskBlockCacheType", ")", "(", "data", "[", "]", "byte", ",", "serverHalf", "kbfscrypto", ".", "BlockCryptKeyServerHalf", ",", "err", "error", ")", "{", "if", "err", ":=", "checkContext", "(", "ctx", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "kbfscrypto", ".", "BlockCryptKeyServerHalf", "{", "}", ",", "err", "\n", "}", "\n\n", "defer", "func", "(", ")", "{", "err", "=", "translateToBlockServerError", "(", "err", ")", "\n", "}", "(", ")", "\n", "b", ".", "log", ".", "CDebugf", "(", "ctx", ",", "\"", "\"", ",", "id", ",", "tlfID", ",", "context", ")", "\n", "tlfStorage", ",", "err", ":=", "b", ".", "getStorage", "(", "tlfID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "kbfscrypto", ".", "BlockCryptKeyServerHalf", "{", "}", ",", "err", "\n", "}", "\n\n", "tlfStorage", ".", "lock", ".", "RLock", "(", ")", "\n", "defer", "tlfStorage", ".", "lock", ".", "RUnlock", "(", ")", "\n", "if", "tlfStorage", ".", "store", "==", "nil", "{", "return", "nil", ",", "kbfscrypto", ".", "BlockCryptKeyServerHalf", "{", "}", ",", "errBlockServerDiskShutdown", "\n", "}", "\n\n", "data", ",", "keyServerHalf", ",", "err", ":=", "tlfStorage", ".", "store", ".", "getDataWithContext", "(", "ctx", ",", "id", ",", "context", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "kbfscrypto", ".", "BlockCryptKeyServerHalf", "{", "}", ",", "err", "\n", "}", "\n", "return", "data", ",", "keyServerHalf", ",", "nil", "\n", "}" ]
// Get implements the BlockServer interface for BlockServerDisk.
[ "Get", "implements", "the", "BlockServer", "interface", "for", "BlockServerDisk", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/bserver_disk.go#L125-L156
159,184
keybase/client
go/kbfs/libkbfs/bserver_disk.go
Put
func (b *BlockServerDisk) Put( ctx context.Context, tlfID tlf.ID, id kbfsblock.ID, context kbfsblock.Context, buf []byte, serverHalf kbfscrypto.BlockCryptKeyServerHalf, _ DiskBlockCacheType) (err error) { if err := checkContext(ctx); err != nil { return err } defer func() { err = translateToBlockServerError(err) }() b.log.CDebugf(ctx, "BlockServerDisk.Put id=%s tlfID=%s context=%s size=%d", id, tlfID, context, len(buf)) if context.GetRefNonce() != kbfsblock.ZeroRefNonce { return errors.New("can't Put() a block with a non-zero refnonce") } tlfStorage, err := b.getStorage(tlfID) if err != nil { return err } tlfStorage.lock.Lock() defer tlfStorage.lock.Unlock() if tlfStorage.store == nil { return errBlockServerDiskShutdown } _, err = tlfStorage.store.put(ctx, true, id, context, buf, serverHalf) if err != nil { return err } err = tlfStorage.store.addReference(ctx, id, context, "tag") if err != nil { return err } return nil }
go
func (b *BlockServerDisk) Put( ctx context.Context, tlfID tlf.ID, id kbfsblock.ID, context kbfsblock.Context, buf []byte, serverHalf kbfscrypto.BlockCryptKeyServerHalf, _ DiskBlockCacheType) (err error) { if err := checkContext(ctx); err != nil { return err } defer func() { err = translateToBlockServerError(err) }() b.log.CDebugf(ctx, "BlockServerDisk.Put id=%s tlfID=%s context=%s size=%d", id, tlfID, context, len(buf)) if context.GetRefNonce() != kbfsblock.ZeroRefNonce { return errors.New("can't Put() a block with a non-zero refnonce") } tlfStorage, err := b.getStorage(tlfID) if err != nil { return err } tlfStorage.lock.Lock() defer tlfStorage.lock.Unlock() if tlfStorage.store == nil { return errBlockServerDiskShutdown } _, err = tlfStorage.store.put(ctx, true, id, context, buf, serverHalf) if err != nil { return err } err = tlfStorage.store.addReference(ctx, id, context, "tag") if err != nil { return err } return nil }
[ "func", "(", "b", "*", "BlockServerDisk", ")", "Put", "(", "ctx", "context", ".", "Context", ",", "tlfID", "tlf", ".", "ID", ",", "id", "kbfsblock", ".", "ID", ",", "context", "kbfsblock", ".", "Context", ",", "buf", "[", "]", "byte", ",", "serverHalf", "kbfscrypto", ".", "BlockCryptKeyServerHalf", ",", "_", "DiskBlockCacheType", ")", "(", "err", "error", ")", "{", "if", "err", ":=", "checkContext", "(", "ctx", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "defer", "func", "(", ")", "{", "err", "=", "translateToBlockServerError", "(", "err", ")", "\n", "}", "(", ")", "\n", "b", ".", "log", ".", "CDebugf", "(", "ctx", ",", "\"", "\"", ",", "id", ",", "tlfID", ",", "context", ",", "len", "(", "buf", ")", ")", "\n\n", "if", "context", ".", "GetRefNonce", "(", ")", "!=", "kbfsblock", ".", "ZeroRefNonce", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "tlfStorage", ",", "err", ":=", "b", ".", "getStorage", "(", "tlfID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "tlfStorage", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "tlfStorage", ".", "lock", ".", "Unlock", "(", ")", "\n", "if", "tlfStorage", ".", "store", "==", "nil", "{", "return", "errBlockServerDiskShutdown", "\n", "}", "\n\n", "_", ",", "err", "=", "tlfStorage", ".", "store", ".", "put", "(", "ctx", ",", "true", ",", "id", ",", "context", ",", "buf", ",", "serverHalf", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "err", "=", "tlfStorage", ".", "store", ".", "addReference", "(", "ctx", ",", "id", ",", "context", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Put implements the BlockServer interface for BlockServerDisk.
[ "Put", "implements", "the", "BlockServer", "interface", "for", "BlockServerDisk", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/bserver_disk.go#L201-L240
159,185
keybase/client
go/kbfs/libkbfs/bserver_disk.go
AddBlockReference
func (b *BlockServerDisk) AddBlockReference(ctx context.Context, tlfID tlf.ID, id kbfsblock.ID, context kbfsblock.Context) error { if err := checkContext(ctx); err != nil { return err } b.log.CDebugf(ctx, "BlockServerDisk.AddBlockReference id=%s "+ "tlfID=%s context=%s", id, tlfID, context) tlfStorage, err := b.getStorage(tlfID) if err != nil { return err } tlfStorage.lock.Lock() defer tlfStorage.lock.Unlock() if tlfStorage.store == nil { return errBlockServerDiskShutdown } hasRef, err := tlfStorage.store.hasAnyRef(ctx, id) if err != nil { return err } if !hasRef { return kbfsblock.ServerErrorBlockNonExistent{Msg: fmt.Sprintf("Block ID %s "+ "doesn't exist and cannot be referenced.", id)} } hasNonArchivedRef, err := tlfStorage.store.hasNonArchivedRef(ctx, id) if err != nil { return err } if !hasNonArchivedRef { return kbfsblock.ServerErrorBlockArchived{Msg: fmt.Sprintf("Block ID %s has "+ "been archived and cannot be referenced.", id)} } return tlfStorage.store.addReference(ctx, id, context, "") }
go
func (b *BlockServerDisk) AddBlockReference(ctx context.Context, tlfID tlf.ID, id kbfsblock.ID, context kbfsblock.Context) error { if err := checkContext(ctx); err != nil { return err } b.log.CDebugf(ctx, "BlockServerDisk.AddBlockReference id=%s "+ "tlfID=%s context=%s", id, tlfID, context) tlfStorage, err := b.getStorage(tlfID) if err != nil { return err } tlfStorage.lock.Lock() defer tlfStorage.lock.Unlock() if tlfStorage.store == nil { return errBlockServerDiskShutdown } hasRef, err := tlfStorage.store.hasAnyRef(ctx, id) if err != nil { return err } if !hasRef { return kbfsblock.ServerErrorBlockNonExistent{Msg: fmt.Sprintf("Block ID %s "+ "doesn't exist and cannot be referenced.", id)} } hasNonArchivedRef, err := tlfStorage.store.hasNonArchivedRef(ctx, id) if err != nil { return err } if !hasNonArchivedRef { return kbfsblock.ServerErrorBlockArchived{Msg: fmt.Sprintf("Block ID %s has "+ "been archived and cannot be referenced.", id)} } return tlfStorage.store.addReference(ctx, id, context, "") }
[ "func", "(", "b", "*", "BlockServerDisk", ")", "AddBlockReference", "(", "ctx", "context", ".", "Context", ",", "tlfID", "tlf", ".", "ID", ",", "id", "kbfsblock", ".", "ID", ",", "context", "kbfsblock", ".", "Context", ")", "error", "{", "if", "err", ":=", "checkContext", "(", "ctx", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "b", ".", "log", ".", "CDebugf", "(", "ctx", ",", "\"", "\"", "+", "\"", "\"", ",", "id", ",", "tlfID", ",", "context", ")", "\n", "tlfStorage", ",", "err", ":=", "b", ".", "getStorage", "(", "tlfID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "tlfStorage", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "tlfStorage", ".", "lock", ".", "Unlock", "(", ")", "\n", "if", "tlfStorage", ".", "store", "==", "nil", "{", "return", "errBlockServerDiskShutdown", "\n", "}", "\n\n", "hasRef", ",", "err", ":=", "tlfStorage", ".", "store", ".", "hasAnyRef", "(", "ctx", ",", "id", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "!", "hasRef", "{", "return", "kbfsblock", ".", "ServerErrorBlockNonExistent", "{", "Msg", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", "+", "\"", "\"", ",", "id", ")", "}", "\n", "}", "\n\n", "hasNonArchivedRef", ",", "err", ":=", "tlfStorage", ".", "store", ".", "hasNonArchivedRef", "(", "ctx", ",", "id", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "!", "hasNonArchivedRef", "{", "return", "kbfsblock", ".", "ServerErrorBlockArchived", "{", "Msg", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", "+", "\"", "\"", ",", "id", ")", "}", "\n", "}", "\n\n", "return", "tlfStorage", ".", "store", ".", "addReference", "(", "ctx", ",", "id", ",", "context", ",", "\"", "\"", ")", "\n", "}" ]
// AddBlockReference implements the BlockServer interface for BlockServerDisk.
[ "AddBlockReference", "implements", "the", "BlockServer", "interface", "for", "BlockServerDisk", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/bserver_disk.go#L280-L318
159,186
keybase/client
go/kbfs/libkbfs/bserver_disk.go
RemoveBlockReferences
func (b *BlockServerDisk) RemoveBlockReferences(ctx context.Context, tlfID tlf.ID, contexts kbfsblock.ContextMap) ( liveCounts map[kbfsblock.ID]int, err error) { if err := checkContext(ctx); err != nil { return nil, err } defer func() { err = translateToBlockServerError(err) }() b.log.CDebugf(ctx, "BlockServerDisk.RemoveBlockReference "+ "tlfID=%s contexts=%v", tlfID, contexts) tlfStorage, err := b.getStorage(tlfID) if err != nil { return nil, err } tlfStorage.lock.Lock() defer tlfStorage.lock.Unlock() if tlfStorage.store == nil { return nil, errBlockServerDiskShutdown } liveCounts = make(map[kbfsblock.ID]int) for id, idContexts := range contexts { liveCount, err := tlfStorage.store.removeReferences( ctx, id, idContexts, "") if err != nil { return nil, err } liveCounts[id] = liveCount if liveCount == 0 { err := tlfStorage.store.remove(ctx, id) if err != nil { return nil, err } } } return liveCounts, nil }
go
func (b *BlockServerDisk) RemoveBlockReferences(ctx context.Context, tlfID tlf.ID, contexts kbfsblock.ContextMap) ( liveCounts map[kbfsblock.ID]int, err error) { if err := checkContext(ctx); err != nil { return nil, err } defer func() { err = translateToBlockServerError(err) }() b.log.CDebugf(ctx, "BlockServerDisk.RemoveBlockReference "+ "tlfID=%s contexts=%v", tlfID, contexts) tlfStorage, err := b.getStorage(tlfID) if err != nil { return nil, err } tlfStorage.lock.Lock() defer tlfStorage.lock.Unlock() if tlfStorage.store == nil { return nil, errBlockServerDiskShutdown } liveCounts = make(map[kbfsblock.ID]int) for id, idContexts := range contexts { liveCount, err := tlfStorage.store.removeReferences( ctx, id, idContexts, "") if err != nil { return nil, err } liveCounts[id] = liveCount if liveCount == 0 { err := tlfStorage.store.remove(ctx, id) if err != nil { return nil, err } } } return liveCounts, nil }
[ "func", "(", "b", "*", "BlockServerDisk", ")", "RemoveBlockReferences", "(", "ctx", "context", ".", "Context", ",", "tlfID", "tlf", ".", "ID", ",", "contexts", "kbfsblock", ".", "ContextMap", ")", "(", "liveCounts", "map", "[", "kbfsblock", ".", "ID", "]", "int", ",", "err", "error", ")", "{", "if", "err", ":=", "checkContext", "(", "ctx", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "defer", "func", "(", ")", "{", "err", "=", "translateToBlockServerError", "(", "err", ")", "\n", "}", "(", ")", "\n", "b", ".", "log", ".", "CDebugf", "(", "ctx", ",", "\"", "\"", "+", "\"", "\"", ",", "tlfID", ",", "contexts", ")", "\n", "tlfStorage", ",", "err", ":=", "b", ".", "getStorage", "(", "tlfID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "tlfStorage", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "tlfStorage", ".", "lock", ".", "Unlock", "(", ")", "\n", "if", "tlfStorage", ".", "store", "==", "nil", "{", "return", "nil", ",", "errBlockServerDiskShutdown", "\n", "}", "\n\n", "liveCounts", "=", "make", "(", "map", "[", "kbfsblock", ".", "ID", "]", "int", ")", "\n", "for", "id", ",", "idContexts", ":=", "range", "contexts", "{", "liveCount", ",", "err", ":=", "tlfStorage", ".", "store", ".", "removeReferences", "(", "ctx", ",", "id", ",", "idContexts", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "liveCounts", "[", "id", "]", "=", "liveCount", "\n\n", "if", "liveCount", "==", "0", "{", "err", ":=", "tlfStorage", ".", "store", ".", "remove", "(", "ctx", ",", "id", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "liveCounts", ",", "nil", "\n", "}" ]
// RemoveBlockReferences implements the BlockServer interface for // BlockServerDisk.
[ "RemoveBlockReferences", "implements", "the", "BlockServer", "interface", "for", "BlockServerDisk", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/bserver_disk.go#L322-L363
159,187
keybase/client
go/kbfs/libkbfs/bserver_disk.go
ArchiveBlockReferences
func (b *BlockServerDisk) ArchiveBlockReferences(ctx context.Context, tlfID tlf.ID, contexts kbfsblock.ContextMap) (err error) { if err := checkContext(ctx); err != nil { return err } defer func() { err = translateToBlockServerError(err) }() b.log.CDebugf(ctx, "BlockServerDisk.ArchiveBlockReferences "+ "tlfID=%s contexts=%v", tlfID, contexts) tlfStorage, err := b.getStorage(tlfID) if err != nil { return err } tlfStorage.lock.Lock() defer tlfStorage.lock.Unlock() if tlfStorage.store == nil { return errBlockServerDiskShutdown } for id, idContexts := range contexts { for _, context := range idContexts { hasContext, _, err := tlfStorage.store.hasContext(ctx, id, context) if err != nil { return err } if !hasContext { return kbfsblock.ServerErrorBlockNonExistent{ Msg: fmt.Sprintf( "Block ID %s (context %s) doesn't "+ "exist and cannot be archived.", id, context), } } } } return tlfStorage.store.archiveReferences(ctx, contexts, "") }
go
func (b *BlockServerDisk) ArchiveBlockReferences(ctx context.Context, tlfID tlf.ID, contexts kbfsblock.ContextMap) (err error) { if err := checkContext(ctx); err != nil { return err } defer func() { err = translateToBlockServerError(err) }() b.log.CDebugf(ctx, "BlockServerDisk.ArchiveBlockReferences "+ "tlfID=%s contexts=%v", tlfID, contexts) tlfStorage, err := b.getStorage(tlfID) if err != nil { return err } tlfStorage.lock.Lock() defer tlfStorage.lock.Unlock() if tlfStorage.store == nil { return errBlockServerDiskShutdown } for id, idContexts := range contexts { for _, context := range idContexts { hasContext, _, err := tlfStorage.store.hasContext(ctx, id, context) if err != nil { return err } if !hasContext { return kbfsblock.ServerErrorBlockNonExistent{ Msg: fmt.Sprintf( "Block ID %s (context %s) doesn't "+ "exist and cannot be archived.", id, context), } } } } return tlfStorage.store.archiveReferences(ctx, contexts, "") }
[ "func", "(", "b", "*", "BlockServerDisk", ")", "ArchiveBlockReferences", "(", "ctx", "context", ".", "Context", ",", "tlfID", "tlf", ".", "ID", ",", "contexts", "kbfsblock", ".", "ContextMap", ")", "(", "err", "error", ")", "{", "if", "err", ":=", "checkContext", "(", "ctx", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "defer", "func", "(", ")", "{", "err", "=", "translateToBlockServerError", "(", "err", ")", "\n", "}", "(", ")", "\n", "b", ".", "log", ".", "CDebugf", "(", "ctx", ",", "\"", "\"", "+", "\"", "\"", ",", "tlfID", ",", "contexts", ")", "\n", "tlfStorage", ",", "err", ":=", "b", ".", "getStorage", "(", "tlfID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "tlfStorage", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "tlfStorage", ".", "lock", ".", "Unlock", "(", ")", "\n", "if", "tlfStorage", ".", "store", "==", "nil", "{", "return", "errBlockServerDiskShutdown", "\n", "}", "\n\n", "for", "id", ",", "idContexts", ":=", "range", "contexts", "{", "for", "_", ",", "context", ":=", "range", "idContexts", "{", "hasContext", ",", "_", ",", "err", ":=", "tlfStorage", ".", "store", ".", "hasContext", "(", "ctx", ",", "id", ",", "context", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "!", "hasContext", "{", "return", "kbfsblock", ".", "ServerErrorBlockNonExistent", "{", "Msg", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", "+", "\"", "\"", ",", "id", ",", "context", ")", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "tlfStorage", ".", "store", ".", "archiveReferences", "(", "ctx", ",", "contexts", ",", "\"", "\"", ")", "\n", "}" ]
// ArchiveBlockReferences implements the BlockServer interface for // BlockServerDisk.
[ "ArchiveBlockReferences", "implements", "the", "BlockServer", "interface", "for", "BlockServerDisk", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/bserver_disk.go#L367-L407
159,188
keybase/client
go/kbfs/libkbfs/bserver_disk.go
IsUnflushed
func (b *BlockServerDisk) IsUnflushed(ctx context.Context, tlfID tlf.ID, _ kbfsblock.ID) (bool, error) { if err := checkContext(ctx); err != nil { return false, err } tlfStorage, err := b.getStorage(tlfID) if err != nil { return false, err } tlfStorage.lock.RLock() defer tlfStorage.lock.RUnlock() if tlfStorage.store == nil { return false, errBlockServerDiskShutdown } return false, nil }
go
func (b *BlockServerDisk) IsUnflushed(ctx context.Context, tlfID tlf.ID, _ kbfsblock.ID) (bool, error) { if err := checkContext(ctx); err != nil { return false, err } tlfStorage, err := b.getStorage(tlfID) if err != nil { return false, err } tlfStorage.lock.RLock() defer tlfStorage.lock.RUnlock() if tlfStorage.store == nil { return false, errBlockServerDiskShutdown } return false, nil }
[ "func", "(", "b", "*", "BlockServerDisk", ")", "IsUnflushed", "(", "ctx", "context", ".", "Context", ",", "tlfID", "tlf", ".", "ID", ",", "_", "kbfsblock", ".", "ID", ")", "(", "bool", ",", "error", ")", "{", "if", "err", ":=", "checkContext", "(", "ctx", ")", ";", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n\n", "tlfStorage", ",", "err", ":=", "b", ".", "getStorage", "(", "tlfID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n\n", "tlfStorage", ".", "lock", ".", "RLock", "(", ")", "\n", "defer", "tlfStorage", ".", "lock", ".", "RUnlock", "(", ")", "\n", "if", "tlfStorage", ".", "store", "==", "nil", "{", "return", "false", ",", "errBlockServerDiskShutdown", "\n", "}", "\n\n", "return", "false", ",", "nil", "\n", "}" ]
// IsUnflushed implements the BlockServer interface for BlockServerDisk.
[ "IsUnflushed", "implements", "the", "BlockServer", "interface", "for", "BlockServerDisk", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/bserver_disk.go#L465-L483
159,189
keybase/client
go/kbfs/libkbfs/bserver_disk.go
Shutdown
func (b *BlockServerDisk) Shutdown(ctx context.Context) { tlfStorage := func() map[tlf.ID]*blockServerDiskTlfStorage { b.tlfStorageLock.Lock() defer b.tlfStorageLock.Unlock() // Make further accesses error out. tlfStorage := b.tlfStorage b.tlfStorage = nil return tlfStorage }() for _, s := range tlfStorage { func() { s.lock.Lock() defer s.lock.Unlock() if s.store == nil { // Already shutdown. return } // Make further accesses error out. s.store = nil }() } if b.shutdownFunc != nil { b.shutdownFunc(b.log) } }
go
func (b *BlockServerDisk) Shutdown(ctx context.Context) { tlfStorage := func() map[tlf.ID]*blockServerDiskTlfStorage { b.tlfStorageLock.Lock() defer b.tlfStorageLock.Unlock() // Make further accesses error out. tlfStorage := b.tlfStorage b.tlfStorage = nil return tlfStorage }() for _, s := range tlfStorage { func() { s.lock.Lock() defer s.lock.Unlock() if s.store == nil { // Already shutdown. return } // Make further accesses error out. s.store = nil }() } if b.shutdownFunc != nil { b.shutdownFunc(b.log) } }
[ "func", "(", "b", "*", "BlockServerDisk", ")", "Shutdown", "(", "ctx", "context", ".", "Context", ")", "{", "tlfStorage", ":=", "func", "(", ")", "map", "[", "tlf", ".", "ID", "]", "*", "blockServerDiskTlfStorage", "{", "b", ".", "tlfStorageLock", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "tlfStorageLock", ".", "Unlock", "(", ")", "\n", "// Make further accesses error out.", "tlfStorage", ":=", "b", ".", "tlfStorage", "\n", "b", ".", "tlfStorage", "=", "nil", "\n", "return", "tlfStorage", "\n", "}", "(", ")", "\n\n", "for", "_", ",", "s", ":=", "range", "tlfStorage", "{", "func", "(", ")", "{", "s", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "lock", ".", "Unlock", "(", ")", "\n", "if", "s", ".", "store", "==", "nil", "{", "// Already shutdown.", "return", "\n", "}", "\n\n", "// Make further accesses error out.", "s", ".", "store", "=", "nil", "\n", "}", "(", ")", "\n", "}", "\n\n", "if", "b", ".", "shutdownFunc", "!=", "nil", "{", "b", ".", "shutdownFunc", "(", "b", ".", "log", ")", "\n", "}", "\n", "}" ]
// Shutdown implements the BlockServer interface for BlockServerDisk.
[ "Shutdown", "implements", "the", "BlockServer", "interface", "for", "BlockServerDisk", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/bserver_disk.go#L486-L513
159,190
keybase/client
go/kbfs/libkbfs/bserver_disk.go
GetUserQuotaInfo
func (b *BlockServerDisk) GetUserQuotaInfo(ctx context.Context) (info *kbfsblock.QuotaInfo, err error) { if err := checkContext(ctx); err != nil { return nil, err } // Return a dummy value here. return &kbfsblock.QuotaInfo{Limit: math.MaxInt64}, nil }
go
func (b *BlockServerDisk) GetUserQuotaInfo(ctx context.Context) (info *kbfsblock.QuotaInfo, err error) { if err := checkContext(ctx); err != nil { return nil, err } // Return a dummy value here. return &kbfsblock.QuotaInfo{Limit: math.MaxInt64}, nil }
[ "func", "(", "b", "*", "BlockServerDisk", ")", "GetUserQuotaInfo", "(", "ctx", "context", ".", "Context", ")", "(", "info", "*", "kbfsblock", ".", "QuotaInfo", ",", "err", "error", ")", "{", "if", "err", ":=", "checkContext", "(", "ctx", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// Return a dummy value here.", "return", "&", "kbfsblock", ".", "QuotaInfo", "{", "Limit", ":", "math", ".", "MaxInt64", "}", ",", "nil", "\n", "}" ]
// GetUserQuotaInfo implements the BlockServer interface for BlockServerDisk.
[ "GetUserQuotaInfo", "implements", "the", "BlockServer", "interface", "for", "BlockServerDisk", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/bserver_disk.go#L519-L526
159,191
keybase/client
go/kbfs/libkbfs/bserver_disk.go
GetTeamQuotaInfo
func (b *BlockServerDisk) GetTeamQuotaInfo( ctx context.Context, _ keybase1.TeamID) ( info *kbfsblock.QuotaInfo, err error) { if err := checkContext(ctx); err != nil { return nil, err } // TODO: check team membership and return error if not a reader? // Return a dummy value here. return &kbfsblock.QuotaInfo{Limit: math.MaxInt64}, nil }
go
func (b *BlockServerDisk) GetTeamQuotaInfo( ctx context.Context, _ keybase1.TeamID) ( info *kbfsblock.QuotaInfo, err error) { if err := checkContext(ctx); err != nil { return nil, err } // TODO: check team membership and return error if not a reader? // Return a dummy value here. return &kbfsblock.QuotaInfo{Limit: math.MaxInt64}, nil }
[ "func", "(", "b", "*", "BlockServerDisk", ")", "GetTeamQuotaInfo", "(", "ctx", "context", ".", "Context", ",", "_", "keybase1", ".", "TeamID", ")", "(", "info", "*", "kbfsblock", ".", "QuotaInfo", ",", "err", "error", ")", "{", "if", "err", ":=", "checkContext", "(", "ctx", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// TODO: check team membership and return error if not a reader?", "// Return a dummy value here.", "return", "&", "kbfsblock", ".", "QuotaInfo", "{", "Limit", ":", "math", ".", "MaxInt64", "}", ",", "nil", "\n", "}" ]
// GetTeamQuotaInfo implements the BlockServer interface for BlockServerDisk.
[ "GetTeamQuotaInfo", "implements", "the", "BlockServer", "interface", "for", "BlockServerDisk", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/bserver_disk.go#L529-L540
159,192
keybase/client
go/engine/login_provision.go
newLoginProvision
func newLoginProvision(g *libkb.GlobalContext, arg *loginProvisionArg) *loginProvision { return &loginProvision{ Contextified: libkb.NewContextified(g), arg: arg, } }
go
func newLoginProvision(g *libkb.GlobalContext, arg *loginProvisionArg) *loginProvision { return &loginProvision{ Contextified: libkb.NewContextified(g), arg: arg, } }
[ "func", "newLoginProvision", "(", "g", "*", "libkb", ".", "GlobalContext", ",", "arg", "*", "loginProvisionArg", ")", "*", "loginProvision", "{", "return", "&", "loginProvision", "{", "Contextified", ":", "libkb", ".", "NewContextified", "(", "g", ")", ",", "arg", ":", "arg", ",", "}", "\n", "}" ]
// newLoginProvision creates a loginProvision engine.
[ "newLoginProvision", "creates", "a", "loginProvision", "engine", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/login_provision.go#L56-L61
159,193
keybase/client
go/engine/login_provision.go
paper
func (e *loginProvision) paper(m libkb.MetaContext, device *libkb.Device, keys *libkb.DeviceWithKeys) (err error) { defer m.Trace("loginProvision#paper", func() error { return err })() // get the paper key from the user if we're in the interactive flow if keys == nil { expectedPrefix := device.Description keys, err = e.getValidPaperKey(m, expectedPrefix) if err != nil { return err } } u := e.arg.User uv := u.ToUserVersion() nn := u.GetNormalizedName() // Set the active device to be a special paper key active device, which keeps // a cached copy around for DeviceKeyGen, which requires it to be in memory. // It also will establish a NIST so that API calls can proceed on behalf of the user. m = m.WithProvisioningKeyActiveDevice(keys, uv) m.LoginContext().SetUsernameUserVersion(nn, uv) // need lksec to store device keys locally if err := e.fetchLKS(m, keys.EncryptionKey()); err != nil { return err } if err := e.makeDeviceKeysWithSigner(m, keys.SigningKey()); err != nil { return err } // The DeviceWrap engine (called via makeDeviceKeysWithSigner) sets // the global ActiveDevice to be a valid device. So we're OK to remove // our temporary thread-local paperkey device installed just above. m = m.WithGlobalActiveDevice() // Cache the paper keys globally now that we're logged in. Note we must call // this after the m.WithGlobalActiveDevice() above, since we want to cache // the paper key on the global and not thread-local active device. m.ActiveDevice().CacheProvisioningKey(m, keys) e.saveToSecretStore(m) return nil }
go
func (e *loginProvision) paper(m libkb.MetaContext, device *libkb.Device, keys *libkb.DeviceWithKeys) (err error) { defer m.Trace("loginProvision#paper", func() error { return err })() // get the paper key from the user if we're in the interactive flow if keys == nil { expectedPrefix := device.Description keys, err = e.getValidPaperKey(m, expectedPrefix) if err != nil { return err } } u := e.arg.User uv := u.ToUserVersion() nn := u.GetNormalizedName() // Set the active device to be a special paper key active device, which keeps // a cached copy around for DeviceKeyGen, which requires it to be in memory. // It also will establish a NIST so that API calls can proceed on behalf of the user. m = m.WithProvisioningKeyActiveDevice(keys, uv) m.LoginContext().SetUsernameUserVersion(nn, uv) // need lksec to store device keys locally if err := e.fetchLKS(m, keys.EncryptionKey()); err != nil { return err } if err := e.makeDeviceKeysWithSigner(m, keys.SigningKey()); err != nil { return err } // The DeviceWrap engine (called via makeDeviceKeysWithSigner) sets // the global ActiveDevice to be a valid device. So we're OK to remove // our temporary thread-local paperkey device installed just above. m = m.WithGlobalActiveDevice() // Cache the paper keys globally now that we're logged in. Note we must call // this after the m.WithGlobalActiveDevice() above, since we want to cache // the paper key on the global and not thread-local active device. m.ActiveDevice().CacheProvisioningKey(m, keys) e.saveToSecretStore(m) return nil }
[ "func", "(", "e", "*", "loginProvision", ")", "paper", "(", "m", "libkb", ".", "MetaContext", ",", "device", "*", "libkb", ".", "Device", ",", "keys", "*", "libkb", ".", "DeviceWithKeys", ")", "(", "err", "error", ")", "{", "defer", "m", ".", "Trace", "(", "\"", "\"", ",", "func", "(", ")", "error", "{", "return", "err", "}", ")", "(", ")", "\n\n", "// get the paper key from the user if we're in the interactive flow", "if", "keys", "==", "nil", "{", "expectedPrefix", ":=", "device", ".", "Description", "\n", "keys", ",", "err", "=", "e", ".", "getValidPaperKey", "(", "m", ",", "expectedPrefix", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n\n", "u", ":=", "e", ".", "arg", ".", "User", "\n", "uv", ":=", "u", ".", "ToUserVersion", "(", ")", "\n", "nn", ":=", "u", ".", "GetNormalizedName", "(", ")", "\n\n", "// Set the active device to be a special paper key active device, which keeps", "// a cached copy around for DeviceKeyGen, which requires it to be in memory.", "// It also will establish a NIST so that API calls can proceed on behalf of the user.", "m", "=", "m", ".", "WithProvisioningKeyActiveDevice", "(", "keys", ",", "uv", ")", "\n", "m", ".", "LoginContext", "(", ")", ".", "SetUsernameUserVersion", "(", "nn", ",", "uv", ")", "\n\n", "// need lksec to store device keys locally", "if", "err", ":=", "e", ".", "fetchLKS", "(", "m", ",", "keys", ".", "EncryptionKey", "(", ")", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "err", ":=", "e", ".", "makeDeviceKeysWithSigner", "(", "m", ",", "keys", ".", "SigningKey", "(", ")", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// The DeviceWrap engine (called via makeDeviceKeysWithSigner) sets", "// the global ActiveDevice to be a valid device. So we're OK to remove", "// our temporary thread-local paperkey device installed just above.", "m", "=", "m", ".", "WithGlobalActiveDevice", "(", ")", "\n\n", "// Cache the paper keys globally now that we're logged in. Note we must call", "// this after the m.WithGlobalActiveDevice() above, since we want to cache", "// the paper key on the global and not thread-local active device.", "m", ".", "ActiveDevice", "(", ")", ".", "CacheProvisioningKey", "(", "m", ",", "keys", ")", "\n\n", "e", ".", "saveToSecretStore", "(", "m", ")", "\n", "return", "nil", "\n", "}" ]
// paper attempts to provision the device via a paper key.
[ "paper", "attempts", "to", "provision", "the", "device", "via", "a", "paper", "key", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/login_provision.go#L301-L344
159,194
keybase/client
go/engine/login_provision.go
pgpProvision
func (e *loginProvision) pgpProvision(m libkb.MetaContext) (err error) { defer m.Trace("loginProvision#pgpProvision", func() error { return err })() err = e.passphraseLogin(m) if err != nil { return err } // After obtaining login session, this will be called before the login state is released. // It tries to get the pgp key and uses it to provision new device keys for this device. signer, err := e.syncedPGPKey(m) if err != nil { return err } if err = e.makeDeviceKeysWithSigner(m, signer); err != nil { return err } e.saveToSecretStore(m) return nil }
go
func (e *loginProvision) pgpProvision(m libkb.MetaContext) (err error) { defer m.Trace("loginProvision#pgpProvision", func() error { return err })() err = e.passphraseLogin(m) if err != nil { return err } // After obtaining login session, this will be called before the login state is released. // It tries to get the pgp key and uses it to provision new device keys for this device. signer, err := e.syncedPGPKey(m) if err != nil { return err } if err = e.makeDeviceKeysWithSigner(m, signer); err != nil { return err } e.saveToSecretStore(m) return nil }
[ "func", "(", "e", "*", "loginProvision", ")", "pgpProvision", "(", "m", "libkb", ".", "MetaContext", ")", "(", "err", "error", ")", "{", "defer", "m", ".", "Trace", "(", "\"", "\"", ",", "func", "(", ")", "error", "{", "return", "err", "}", ")", "(", ")", "\n\n", "err", "=", "e", ".", "passphraseLogin", "(", "m", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// After obtaining login session, this will be called before the login state is released.", "// It tries to get the pgp key and uses it to provision new device keys for this device.", "signer", ",", "err", ":=", "e", ".", "syncedPGPKey", "(", "m", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "err", "=", "e", ".", "makeDeviceKeysWithSigner", "(", "m", ",", "signer", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "e", ".", "saveToSecretStore", "(", "m", ")", "\n", "return", "nil", "\n", "}" ]
// pgpProvision attempts to provision with a synced pgp key. It // needs to get a session first to look for a synced pgp key.
[ "pgpProvision", "attempts", "to", "provision", "with", "a", "synced", "pgp", "key", ".", "It", "needs", "to", "get", "a", "session", "first", "to", "look", "for", "a", "synced", "pgp", "key", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/login_provision.go#L405-L426
159,195
keybase/client
go/engine/login_provision.go
makeDeviceWrapArgs
func (e *loginProvision) makeDeviceWrapArgs(m libkb.MetaContext) (*DeviceWrapArgs, error) { if err := e.ensureLKSec(m); err != nil { return nil, err } devname, err := e.deviceName(m) if err != nil { return nil, err } e.devname = devname return &DeviceWrapArgs{ Me: e.arg.User, DeviceName: e.devname, DeviceType: e.arg.DeviceType, Lks: e.lks, PerUserKeyring: e.perUserKeyring, }, nil }
go
func (e *loginProvision) makeDeviceWrapArgs(m libkb.MetaContext) (*DeviceWrapArgs, error) { if err := e.ensureLKSec(m); err != nil { return nil, err } devname, err := e.deviceName(m) if err != nil { return nil, err } e.devname = devname return &DeviceWrapArgs{ Me: e.arg.User, DeviceName: e.devname, DeviceType: e.arg.DeviceType, Lks: e.lks, PerUserKeyring: e.perUserKeyring, }, nil }
[ "func", "(", "e", "*", "loginProvision", ")", "makeDeviceWrapArgs", "(", "m", "libkb", ".", "MetaContext", ")", "(", "*", "DeviceWrapArgs", ",", "error", ")", "{", "if", "err", ":=", "e", ".", "ensureLKSec", "(", "m", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "devname", ",", "err", ":=", "e", ".", "deviceName", "(", "m", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "e", ".", "devname", "=", "devname", "\n\n", "return", "&", "DeviceWrapArgs", "{", "Me", ":", "e", ".", "arg", ".", "User", ",", "DeviceName", ":", "e", ".", "devname", ",", "DeviceType", ":", "e", ".", "arg", ".", "DeviceType", ",", "Lks", ":", "e", ".", "lks", ",", "PerUserKeyring", ":", "e", ".", "perUserKeyring", ",", "}", ",", "nil", "\n", "}" ]
// makeDeviceWrapArgs creates a base set of args for DeviceWrap. // It ensures that LKSec is created. It also gets a new device // name for this device.
[ "makeDeviceWrapArgs", "creates", "a", "base", "set", "of", "args", "for", "DeviceWrap", ".", "It", "ensures", "that", "LKSec", "is", "created", ".", "It", "also", "gets", "a", "new", "device", "name", "for", "this", "device", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/login_provision.go#L445-L463
159,196
keybase/client
go/engine/login_provision.go
ensureLKSec
func (e *loginProvision) ensureLKSec(m libkb.MetaContext) error { if e.lks != nil { return nil } pps, err := e.ppStream(m) if err != nil { return err } e.lks = libkb.NewLKSec(pps, e.arg.User.GetUID()) return nil }
go
func (e *loginProvision) ensureLKSec(m libkb.MetaContext) error { if e.lks != nil { return nil } pps, err := e.ppStream(m) if err != nil { return err } e.lks = libkb.NewLKSec(pps, e.arg.User.GetUID()) return nil }
[ "func", "(", "e", "*", "loginProvision", ")", "ensureLKSec", "(", "m", "libkb", ".", "MetaContext", ")", "error", "{", "if", "e", ".", "lks", "!=", "nil", "{", "return", "nil", "\n", "}", "\n\n", "pps", ",", "err", ":=", "e", ".", "ppStream", "(", "m", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "e", ".", "lks", "=", "libkb", ".", "NewLKSec", "(", "pps", ",", "e", ".", "arg", ".", "User", ".", "GetUID", "(", ")", ")", "\n", "return", "nil", "\n", "}" ]
// ensureLKSec ensures we have LKSec for saving device keys.
[ "ensureLKSec", "ensures", "we", "have", "LKSec", "for", "saving", "device", "keys", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/login_provision.go#L466-L478
159,197
keybase/client
go/engine/login_provision.go
ppStream
func (e *loginProvision) ppStream(m libkb.MetaContext) (ret *libkb.PassphraseStream, err error) { defer m.Trace("loginProvision#ppStream", func() error { return err })() if ret = m.PassphraseStream(); ret != nil { return ret, nil } if err = e.passphraseLogin(m); err != nil { return nil, err } if ret = m.PassphraseStream(); ret != nil { return ret, nil } return nil, errors.New("no passphrase available") }
go
func (e *loginProvision) ppStream(m libkb.MetaContext) (ret *libkb.PassphraseStream, err error) { defer m.Trace("loginProvision#ppStream", func() error { return err })() if ret = m.PassphraseStream(); ret != nil { return ret, nil } if err = e.passphraseLogin(m); err != nil { return nil, err } if ret = m.PassphraseStream(); ret != nil { return ret, nil } return nil, errors.New("no passphrase available") }
[ "func", "(", "e", "*", "loginProvision", ")", "ppStream", "(", "m", "libkb", ".", "MetaContext", ")", "(", "ret", "*", "libkb", ".", "PassphraseStream", ",", "err", "error", ")", "{", "defer", "m", ".", "Trace", "(", "\"", "\"", ",", "func", "(", ")", "error", "{", "return", "err", "}", ")", "(", ")", "\n", "if", "ret", "=", "m", ".", "PassphraseStream", "(", ")", ";", "ret", "!=", "nil", "{", "return", "ret", ",", "nil", "\n", "}", "\n", "if", "err", "=", "e", ".", "passphraseLogin", "(", "m", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "ret", "=", "m", ".", "PassphraseStream", "(", ")", ";", "ret", "!=", "nil", "{", "return", "ret", ",", "nil", "\n", "}", "\n", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}" ]
// ppStream gets the passphrase stream, either cached or via // SecretUI.
[ "ppStream", "gets", "the", "passphrase", "stream", "either", "cached", "or", "via", "SecretUI", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/login_provision.go#L482-L494
159,198
keybase/client
go/engine/login_provision.go
deviceName
func (e *loginProvision) deviceName(m libkb.MetaContext) (string, error) { var names []string upk, _, err := m.G().GetUPAKLoader().LoadV2(libkb.NewLoadUserArgWithMetaContext(m).WithUID(e.arg.User.GetUID()).WithPublicKeyOptional().WithForcePoll(true).WithSelf(true)) if err != nil { m.Debug("error getting device names via upak: %s", err) m.Debug("proceeding to ask user for a device name despite error...") } else { names = upk.AllDeviceNames() } // Fully non-interactive flow if e.arg.DeviceName != "" { return e.automatedDeviceName(m, names, e.arg.DeviceName) } arg := keybase1.PromptNewDeviceNameArg{ ExistingDevices: names, } for i := 0; i < 10; i++ { devname, err := m.UIs().ProvisionUI.PromptNewDeviceName(m.Ctx(), arg) if err != nil { return "", err } if !libkb.CheckDeviceName.F(devname) { m.Debug("invalid device name supplied: %s", devname) arg.ErrorMessage = "Invalid device name. Device names should be " + libkb.CheckDeviceName.Hint continue } devname = libkb.CheckDeviceName.Transform(devname) var dupname string normalizedDevName := libkb.CheckDeviceName.Normalize(devname) for _, name := range names { if normalizedDevName == libkb.CheckDeviceName.Normalize(name) { dupname = name break } } if dupname != "" { m.Debug("Device name reused: %q == %q", devname, dupname) var dupnameErrMsg string // if we have a collision on the normalized values add some extra // info the error message so the user isn't confused why we // consider the names equal. if devname != dupname { dupnameErrMsg = fmt.Sprintf(" as %q", dupname) } arg.ErrorMessage = fmt.Sprintf("The device name %q is already taken%s. You can't reuse device names, even revoked ones, for security reasons. Otherwise, someone who stole one of your devices could cause a lot of confusion.", devname, dupnameErrMsg) continue } return devname, nil } return "", libkb.RetryExhaustedError{} }
go
func (e *loginProvision) deviceName(m libkb.MetaContext) (string, error) { var names []string upk, _, err := m.G().GetUPAKLoader().LoadV2(libkb.NewLoadUserArgWithMetaContext(m).WithUID(e.arg.User.GetUID()).WithPublicKeyOptional().WithForcePoll(true).WithSelf(true)) if err != nil { m.Debug("error getting device names via upak: %s", err) m.Debug("proceeding to ask user for a device name despite error...") } else { names = upk.AllDeviceNames() } // Fully non-interactive flow if e.arg.DeviceName != "" { return e.automatedDeviceName(m, names, e.arg.DeviceName) } arg := keybase1.PromptNewDeviceNameArg{ ExistingDevices: names, } for i := 0; i < 10; i++ { devname, err := m.UIs().ProvisionUI.PromptNewDeviceName(m.Ctx(), arg) if err != nil { return "", err } if !libkb.CheckDeviceName.F(devname) { m.Debug("invalid device name supplied: %s", devname) arg.ErrorMessage = "Invalid device name. Device names should be " + libkb.CheckDeviceName.Hint continue } devname = libkb.CheckDeviceName.Transform(devname) var dupname string normalizedDevName := libkb.CheckDeviceName.Normalize(devname) for _, name := range names { if normalizedDevName == libkb.CheckDeviceName.Normalize(name) { dupname = name break } } if dupname != "" { m.Debug("Device name reused: %q == %q", devname, dupname) var dupnameErrMsg string // if we have a collision on the normalized values add some extra // info the error message so the user isn't confused why we // consider the names equal. if devname != dupname { dupnameErrMsg = fmt.Sprintf(" as %q", dupname) } arg.ErrorMessage = fmt.Sprintf("The device name %q is already taken%s. You can't reuse device names, even revoked ones, for security reasons. Otherwise, someone who stole one of your devices could cause a lot of confusion.", devname, dupnameErrMsg) continue } return devname, nil } return "", libkb.RetryExhaustedError{} }
[ "func", "(", "e", "*", "loginProvision", ")", "deviceName", "(", "m", "libkb", ".", "MetaContext", ")", "(", "string", ",", "error", ")", "{", "var", "names", "[", "]", "string", "\n", "upk", ",", "_", ",", "err", ":=", "m", ".", "G", "(", ")", ".", "GetUPAKLoader", "(", ")", ".", "LoadV2", "(", "libkb", ".", "NewLoadUserArgWithMetaContext", "(", "m", ")", ".", "WithUID", "(", "e", ".", "arg", ".", "User", ".", "GetUID", "(", ")", ")", ".", "WithPublicKeyOptional", "(", ")", ".", "WithForcePoll", "(", "true", ")", ".", "WithSelf", "(", "true", ")", ")", "\n", "if", "err", "!=", "nil", "{", "m", ".", "Debug", "(", "\"", "\"", ",", "err", ")", "\n", "m", ".", "Debug", "(", "\"", "\"", ")", "\n", "}", "else", "{", "names", "=", "upk", ".", "AllDeviceNames", "(", ")", "\n", "}", "\n\n", "// Fully non-interactive flow", "if", "e", ".", "arg", ".", "DeviceName", "!=", "\"", "\"", "{", "return", "e", ".", "automatedDeviceName", "(", "m", ",", "names", ",", "e", ".", "arg", ".", "DeviceName", ")", "\n", "}", "\n\n", "arg", ":=", "keybase1", ".", "PromptNewDeviceNameArg", "{", "ExistingDevices", ":", "names", ",", "}", "\n\n", "for", "i", ":=", "0", ";", "i", "<", "10", ";", "i", "++", "{", "devname", ",", "err", ":=", "m", ".", "UIs", "(", ")", ".", "ProvisionUI", ".", "PromptNewDeviceName", "(", "m", ".", "Ctx", "(", ")", ",", "arg", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "if", "!", "libkb", ".", "CheckDeviceName", ".", "F", "(", "devname", ")", "{", "m", ".", "Debug", "(", "\"", "\"", ",", "devname", ")", "\n", "arg", ".", "ErrorMessage", "=", "\"", "\"", "+", "libkb", ".", "CheckDeviceName", ".", "Hint", "\n", "continue", "\n", "}", "\n", "devname", "=", "libkb", ".", "CheckDeviceName", ".", "Transform", "(", "devname", ")", "\n", "var", "dupname", "string", "\n", "normalizedDevName", ":=", "libkb", ".", "CheckDeviceName", ".", "Normalize", "(", "devname", ")", "\n", "for", "_", ",", "name", ":=", "range", "names", "{", "if", "normalizedDevName", "==", "libkb", ".", "CheckDeviceName", ".", "Normalize", "(", "name", ")", "{", "dupname", "=", "name", "\n", "break", "\n", "}", "\n", "}", "\n\n", "if", "dupname", "!=", "\"", "\"", "{", "m", ".", "Debug", "(", "\"", "\"", ",", "devname", ",", "dupname", ")", "\n", "var", "dupnameErrMsg", "string", "\n", "// if we have a collision on the normalized values add some extra", "// info the error message so the user isn't confused why we", "// consider the names equal.", "if", "devname", "!=", "dupname", "{", "dupnameErrMsg", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "dupname", ")", "\n", "}", "\n", "arg", ".", "ErrorMessage", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "devname", ",", "dupnameErrMsg", ")", "\n", "continue", "\n", "}", "\n\n", "return", "devname", ",", "nil", "\n", "}", "\n", "return", "\"", "\"", ",", "libkb", ".", "RetryExhaustedError", "{", "}", "\n", "}" ]
// deviceName gets a new device name from the user.
[ "deviceName", "gets", "a", "new", "device", "name", "from", "the", "user", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/login_provision.go#L511-L566
159,199
keybase/client
go/engine/login_provision.go
makeDeviceKeys
func (e *loginProvision) makeDeviceKeys(m libkb.MetaContext, args *DeviceWrapArgs) error { eng := NewDeviceWrap(m.G(), args) if err := RunEngine2(m, eng); err != nil { return err } // Finish provisoning by calling SwitchConfigAndActiveDevice. we // can't undo that, so do not error out after that. if err := eng.SwitchConfigAndActiveDevice(m); err != nil { return err } e.signingKey = eng.SigningKey() e.encryptionKey = eng.EncryptionKey() return nil }
go
func (e *loginProvision) makeDeviceKeys(m libkb.MetaContext, args *DeviceWrapArgs) error { eng := NewDeviceWrap(m.G(), args) if err := RunEngine2(m, eng); err != nil { return err } // Finish provisoning by calling SwitchConfigAndActiveDevice. we // can't undo that, so do not error out after that. if err := eng.SwitchConfigAndActiveDevice(m); err != nil { return err } e.signingKey = eng.SigningKey() e.encryptionKey = eng.EncryptionKey() return nil }
[ "func", "(", "e", "*", "loginProvision", ")", "makeDeviceKeys", "(", "m", "libkb", ".", "MetaContext", ",", "args", "*", "DeviceWrapArgs", ")", "error", "{", "eng", ":=", "NewDeviceWrap", "(", "m", ".", "G", "(", ")", ",", "args", ")", "\n", "if", "err", ":=", "RunEngine2", "(", "m", ",", "eng", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "// Finish provisoning by calling SwitchConfigAndActiveDevice. we", "// can't undo that, so do not error out after that.", "if", "err", ":=", "eng", ".", "SwitchConfigAndActiveDevice", "(", "m", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "e", ".", "signingKey", "=", "eng", ".", "SigningKey", "(", ")", "\n", "e", ".", "encryptionKey", "=", "eng", ".", "EncryptionKey", "(", ")", "\n\n", "return", "nil", "\n", "}" ]
// makeDeviceKeys uses DeviceWrap to generate device keys.
[ "makeDeviceKeys", "uses", "DeviceWrap", "to", "generate", "device", "keys", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/login_provision.go#L586-L601