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
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
160,800
keybase/client
go/chat/boxer.go
boxV1
func (b *Boxer) boxV1(messagePlaintext chat1.MessagePlaintext, key types.CryptKey, signingKeyPair libkb.NaclSigningKeyPair) (res chat1.MessageBoxed, err error) { body := chat1.BodyPlaintextV1{ MessageBody: messagePlaintext.MessageBody, } plaintextBody := chat1.NewBodyPlaintextWithV1(body) encryptedBody, err := b.seal(plaintextBody, libkb.NaclSecretBoxKey(key.Material())) if err != nil { return res, err } // create the v1 header, adding hash bodyHash := b.hashV1(encryptedBody.E) if messagePlaintext.ClientHeader.MerkleRoot != nil { return res, fmt.Errorf("cannot box v1 message with merkle root") } header := chat1.HeaderPlaintextV1{ Conv: messagePlaintext.ClientHeader.Conv, TlfName: messagePlaintext.ClientHeader.TlfName, TlfPublic: messagePlaintext.ClientHeader.TlfPublic, MessageType: messagePlaintext.ClientHeader.MessageType, Prev: messagePlaintext.ClientHeader.Prev, Sender: messagePlaintext.ClientHeader.Sender, SenderDevice: messagePlaintext.ClientHeader.SenderDevice, MerkleRoot: nil, // MerkleRoot cannot be sent in MBv1 messages BodyHash: bodyHash[:], OutboxInfo: messagePlaintext.ClientHeader.OutboxInfo, OutboxID: messagePlaintext.ClientHeader.OutboxID, KbfsCryptKeysUsed: messagePlaintext.ClientHeader.KbfsCryptKeysUsed, } // sign the header and insert the signature sig, err := b.signMarshal(header, signingKeyPair, kbcrypto.SignaturePrefixChatMBv1) if err != nil { return res, err } header.HeaderSignature = &sig // create a plaintext header plaintextHeader := chat1.NewHeaderPlaintextWithV1(header) encryptedHeader, err := b.seal(plaintextHeader, libkb.NaclSecretBoxKey(key.Material())) if err != nil { return res, err } return chat1.MessageBoxed{ Version: chat1.MessageBoxedVersion_V1, ClientHeader: messagePlaintext.ClientHeader, BodyCiphertext: *encryptedBody, HeaderCiphertext: encryptedHeader.AsSealed(), KeyGeneration: key.Generation(), }, nil }
go
func (b *Boxer) boxV1(messagePlaintext chat1.MessagePlaintext, key types.CryptKey, signingKeyPair libkb.NaclSigningKeyPair) (res chat1.MessageBoxed, err error) { body := chat1.BodyPlaintextV1{ MessageBody: messagePlaintext.MessageBody, } plaintextBody := chat1.NewBodyPlaintextWithV1(body) encryptedBody, err := b.seal(plaintextBody, libkb.NaclSecretBoxKey(key.Material())) if err != nil { return res, err } // create the v1 header, adding hash bodyHash := b.hashV1(encryptedBody.E) if messagePlaintext.ClientHeader.MerkleRoot != nil { return res, fmt.Errorf("cannot box v1 message with merkle root") } header := chat1.HeaderPlaintextV1{ Conv: messagePlaintext.ClientHeader.Conv, TlfName: messagePlaintext.ClientHeader.TlfName, TlfPublic: messagePlaintext.ClientHeader.TlfPublic, MessageType: messagePlaintext.ClientHeader.MessageType, Prev: messagePlaintext.ClientHeader.Prev, Sender: messagePlaintext.ClientHeader.Sender, SenderDevice: messagePlaintext.ClientHeader.SenderDevice, MerkleRoot: nil, // MerkleRoot cannot be sent in MBv1 messages BodyHash: bodyHash[:], OutboxInfo: messagePlaintext.ClientHeader.OutboxInfo, OutboxID: messagePlaintext.ClientHeader.OutboxID, KbfsCryptKeysUsed: messagePlaintext.ClientHeader.KbfsCryptKeysUsed, } // sign the header and insert the signature sig, err := b.signMarshal(header, signingKeyPair, kbcrypto.SignaturePrefixChatMBv1) if err != nil { return res, err } header.HeaderSignature = &sig // create a plaintext header plaintextHeader := chat1.NewHeaderPlaintextWithV1(header) encryptedHeader, err := b.seal(plaintextHeader, libkb.NaclSecretBoxKey(key.Material())) if err != nil { return res, err } return chat1.MessageBoxed{ Version: chat1.MessageBoxedVersion_V1, ClientHeader: messagePlaintext.ClientHeader, BodyCiphertext: *encryptedBody, HeaderCiphertext: encryptedHeader.AsSealed(), KeyGeneration: key.Generation(), }, nil }
[ "func", "(", "b", "*", "Boxer", ")", "boxV1", "(", "messagePlaintext", "chat1", ".", "MessagePlaintext", ",", "key", "types", ".", "CryptKey", ",", "signingKeyPair", "libkb", ".", "NaclSigningKeyPair", ")", "(", "res", "chat1", ".", "MessageBoxed", ",", "err...
// boxMessageWithKeys encrypts and signs a keybase1.MessagePlaintext into a // chat1.MessageBoxed given a keybase1.CryptKey.
[ "boxMessageWithKeys", "encrypts", "and", "signs", "a", "keybase1", ".", "MessagePlaintext", "into", "a", "chat1", ".", "MessageBoxed", "given", "a", "keybase1", ".", "CryptKey", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/boxer.go#L1509-L1561
160,801
keybase/client
go/chat/boxer.go
boxV2orV3orV4
func (b *Boxer) boxV2orV3orV4(ctx context.Context, messagePlaintext chat1.MessagePlaintext, baseEncryptionKey types.CryptKey, ephemeralSeed *keybase1.TeamEk, signingKeyPair libkb.NaclSigningKeyPair, version chat1.MessageBoxedVersion, pairwiseMACRecipients []keybase1.KID) (res chat1.MessageBoxed, err error) { if messagePlaintext.ClientHeader.MerkleRoot == nil { return res, NewBoxingError("cannot send message without merkle root", false) } headerEncryptionKey, err := libkb.DeriveSymmetricKey( libkb.NaclSecretBoxKey(baseEncryptionKey.Material()), libkb.EncryptionReasonChatMessage) if err != nil { return res, err } // Regular messages use the same encryption key for the header and for the // body. Exploding messages use a derived ephemeral key for the body. bodyEncryptionKey := headerEncryptionKey if messagePlaintext.IsEphemeral() { bodyEncryptionKey, err = libkb.DeriveFromSecret(ephemeralSeed.Seed, libkb.DeriveReasonTeamEKExplodingChat) if err != nil { return res, err } // The MessagePlaintext supplied by the caller has a Lifetime, but we // expect the Generation is left uninitialized, and we set it here. messagePlaintext.ClientHeader.EphemeralMetadata.Generation = ephemeralSeed.Metadata.Generation } bodyVersioned := chat1.NewBodyPlaintextWithV1(chat1.BodyPlaintextV1{ MessageBody: messagePlaintext.MessageBody, }) bodyEncrypted, err := b.seal(bodyVersioned, bodyEncryptionKey) if err != nil { return res, err } bodyHash, err := b.makeBodyHash(*bodyEncrypted) if err != nil { return res, err } // create the v1 header, adding hash headerVersioned := chat1.NewHeaderPlaintextWithV1(chat1.HeaderPlaintextV1{ Conv: messagePlaintext.ClientHeader.Conv, TlfName: messagePlaintext.ClientHeader.TlfName, TlfPublic: messagePlaintext.ClientHeader.TlfPublic, MessageType: messagePlaintext.ClientHeader.MessageType, Prev: messagePlaintext.ClientHeader.Prev, Sender: messagePlaintext.ClientHeader.Sender, SenderDevice: messagePlaintext.ClientHeader.SenderDevice, BodyHash: bodyHash, MerkleRoot: messagePlaintext.ClientHeader.MerkleRoot, OutboxInfo: messagePlaintext.ClientHeader.OutboxInfo, OutboxID: messagePlaintext.ClientHeader.OutboxID, KbfsCryptKeysUsed: messagePlaintext.ClientHeader.KbfsCryptKeysUsed, EphemeralMetadata: messagePlaintext.ClientHeader.EphemeralMetadata, // In MessageBoxed.V2 HeaderSignature is nil. HeaderSignature: nil, }) // signencrypt the header headerSealed, err := b.signEncryptMarshal(headerVersioned, headerEncryptionKey, signingKeyPair, kbcrypto.SignaturePrefixChatMBv2) if err != nil { return res, err } // Make pairwise MACs if there are any pairwise recipients supplied. Note // that we still sign+encrypt with a signing key above. If we want // repudiability, it's the caller's responsibility to provide a zero // signing key or similar. Signing with a real key and also MAC'ing is // redundant, but it will let us test the MAC code in prod in a backwards // compatible way. if len(pairwiseMACRecipients) > 0 { pairwiseMACs, err := b.makeAllPairwiseMACs(ctx, headerSealed, pairwiseMACRecipients) if err != nil { return res, err } messagePlaintext.ClientHeader.PairwiseMacs = pairwiseMACs } // verify verifyKey := signingKeyPair.GetBinaryKID() return chat1.MessageBoxed{ Version: version, ServerHeader: nil, ClientHeader: messagePlaintext.ClientHeader, HeaderCiphertext: headerSealed.AsSealed(), BodyCiphertext: *bodyEncrypted, VerifyKey: verifyKey, KeyGeneration: baseEncryptionKey.Generation(), }, nil }
go
func (b *Boxer) boxV2orV3orV4(ctx context.Context, messagePlaintext chat1.MessagePlaintext, baseEncryptionKey types.CryptKey, ephemeralSeed *keybase1.TeamEk, signingKeyPair libkb.NaclSigningKeyPair, version chat1.MessageBoxedVersion, pairwiseMACRecipients []keybase1.KID) (res chat1.MessageBoxed, err error) { if messagePlaintext.ClientHeader.MerkleRoot == nil { return res, NewBoxingError("cannot send message without merkle root", false) } headerEncryptionKey, err := libkb.DeriveSymmetricKey( libkb.NaclSecretBoxKey(baseEncryptionKey.Material()), libkb.EncryptionReasonChatMessage) if err != nil { return res, err } // Regular messages use the same encryption key for the header and for the // body. Exploding messages use a derived ephemeral key for the body. bodyEncryptionKey := headerEncryptionKey if messagePlaintext.IsEphemeral() { bodyEncryptionKey, err = libkb.DeriveFromSecret(ephemeralSeed.Seed, libkb.DeriveReasonTeamEKExplodingChat) if err != nil { return res, err } // The MessagePlaintext supplied by the caller has a Lifetime, but we // expect the Generation is left uninitialized, and we set it here. messagePlaintext.ClientHeader.EphemeralMetadata.Generation = ephemeralSeed.Metadata.Generation } bodyVersioned := chat1.NewBodyPlaintextWithV1(chat1.BodyPlaintextV1{ MessageBody: messagePlaintext.MessageBody, }) bodyEncrypted, err := b.seal(bodyVersioned, bodyEncryptionKey) if err != nil { return res, err } bodyHash, err := b.makeBodyHash(*bodyEncrypted) if err != nil { return res, err } // create the v1 header, adding hash headerVersioned := chat1.NewHeaderPlaintextWithV1(chat1.HeaderPlaintextV1{ Conv: messagePlaintext.ClientHeader.Conv, TlfName: messagePlaintext.ClientHeader.TlfName, TlfPublic: messagePlaintext.ClientHeader.TlfPublic, MessageType: messagePlaintext.ClientHeader.MessageType, Prev: messagePlaintext.ClientHeader.Prev, Sender: messagePlaintext.ClientHeader.Sender, SenderDevice: messagePlaintext.ClientHeader.SenderDevice, BodyHash: bodyHash, MerkleRoot: messagePlaintext.ClientHeader.MerkleRoot, OutboxInfo: messagePlaintext.ClientHeader.OutboxInfo, OutboxID: messagePlaintext.ClientHeader.OutboxID, KbfsCryptKeysUsed: messagePlaintext.ClientHeader.KbfsCryptKeysUsed, EphemeralMetadata: messagePlaintext.ClientHeader.EphemeralMetadata, // In MessageBoxed.V2 HeaderSignature is nil. HeaderSignature: nil, }) // signencrypt the header headerSealed, err := b.signEncryptMarshal(headerVersioned, headerEncryptionKey, signingKeyPair, kbcrypto.SignaturePrefixChatMBv2) if err != nil { return res, err } // Make pairwise MACs if there are any pairwise recipients supplied. Note // that we still sign+encrypt with a signing key above. If we want // repudiability, it's the caller's responsibility to provide a zero // signing key or similar. Signing with a real key and also MAC'ing is // redundant, but it will let us test the MAC code in prod in a backwards // compatible way. if len(pairwiseMACRecipients) > 0 { pairwiseMACs, err := b.makeAllPairwiseMACs(ctx, headerSealed, pairwiseMACRecipients) if err != nil { return res, err } messagePlaintext.ClientHeader.PairwiseMacs = pairwiseMACs } // verify verifyKey := signingKeyPair.GetBinaryKID() return chat1.MessageBoxed{ Version: version, ServerHeader: nil, ClientHeader: messagePlaintext.ClientHeader, HeaderCiphertext: headerSealed.AsSealed(), BodyCiphertext: *bodyEncrypted, VerifyKey: verifyKey, KeyGeneration: baseEncryptionKey.Generation(), }, nil }
[ "func", "(", "b", "*", "Boxer", ")", "boxV2orV3orV4", "(", "ctx", "context", ".", "Context", ",", "messagePlaintext", "chat1", ".", "MessagePlaintext", ",", "baseEncryptionKey", "types", ".", "CryptKey", ",", "ephemeralSeed", "*", "keybase1", ".", "TeamEk", ",...
// V3 is just V2 but with exploding messages support. V4 is just V3, but it // signs with the zero key when pairwise MACs are included.
[ "V3", "is", "just", "V2", "but", "with", "exploding", "messages", "support", ".", "V4", "is", "just", "V3", "but", "it", "signs", "with", "the", "zero", "key", "when", "pairwise", "MACs", "are", "included", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/boxer.go#L1601-L1692
160,802
keybase/client
go/chat/boxer.go
seal
func (b *Boxer) seal(data interface{}, key libkb.NaclSecretBoxKey) (*chat1.EncryptedData, error) { s, err := b.marshal(data) if err != nil { return nil, err } var nonce [libkb.NaclDHNonceSize]byte if _, err := rand.Read(nonce[:]); err != nil { return nil, err } var encKey [libkb.NaclSecretBoxKeySize]byte = key sealed := secretbox.Seal(nil, []byte(s), &nonce, &encKey) enc := &chat1.EncryptedData{ V: 1, E: sealed, N: nonce[:], } return enc, nil }
go
func (b *Boxer) seal(data interface{}, key libkb.NaclSecretBoxKey) (*chat1.EncryptedData, error) { s, err := b.marshal(data) if err != nil { return nil, err } var nonce [libkb.NaclDHNonceSize]byte if _, err := rand.Read(nonce[:]); err != nil { return nil, err } var encKey [libkb.NaclSecretBoxKeySize]byte = key sealed := secretbox.Seal(nil, []byte(s), &nonce, &encKey) enc := &chat1.EncryptedData{ V: 1, E: sealed, N: nonce[:], } return enc, nil }
[ "func", "(", "b", "*", "Boxer", ")", "seal", "(", "data", "interface", "{", "}", ",", "key", "libkb", ".", "NaclSecretBoxKey", ")", "(", "*", "chat1", ".", "EncryptedData", ",", "error", ")", "{", "s", ",", "err", ":=", "b", ".", "marshal", "(", ...
// seal encrypts data into chat1.EncryptedData.
[ "seal", "encrypts", "data", "into", "chat1", ".", "EncryptedData", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/boxer.go#L1695-L1716
160,803
keybase/client
go/chat/boxer.go
open
func (b *Boxer) open(data chat1.EncryptedData, key libkb.NaclSecretBoxKey) ([]byte, error) { if len(data.N) != libkb.NaclDHNonceSize { return nil, libkb.DecryptBadNonceError{} } var nonce [libkb.NaclDHNonceSize]byte copy(nonce[:], data.N) plain, ok := secretbox.Open(nil, data.E, &nonce, (*[32]byte)(&key)) if !ok { return nil, libkb.DecryptOpenError{} } return plain, nil }
go
func (b *Boxer) open(data chat1.EncryptedData, key libkb.NaclSecretBoxKey) ([]byte, error) { if len(data.N) != libkb.NaclDHNonceSize { return nil, libkb.DecryptBadNonceError{} } var nonce [libkb.NaclDHNonceSize]byte copy(nonce[:], data.N) plain, ok := secretbox.Open(nil, data.E, &nonce, (*[32]byte)(&key)) if !ok { return nil, libkb.DecryptOpenError{} } return plain, nil }
[ "func", "(", "b", "*", "Boxer", ")", "open", "(", "data", "chat1", ".", "EncryptedData", ",", "key", "libkb", ".", "NaclSecretBoxKey", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "len", "(", "data", ".", "N", ")", "!=", "libkb", "."...
// open decrypts chat1.EncryptedData.
[ "open", "decrypts", "chat1", ".", "EncryptedData", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/boxer.go#L1719-L1731
160,804
keybase/client
go/chat/boxer.go
signMarshal
func (b *Boxer) signMarshal(data interface{}, kp libkb.NaclSigningKeyPair, prefix kbcrypto.SignaturePrefix) (chat1.SignatureInfo, error) { encoded, err := b.marshal(data) if err != nil { return chat1.SignatureInfo{}, err } return b.sign(encoded, kp, prefix) }
go
func (b *Boxer) signMarshal(data interface{}, kp libkb.NaclSigningKeyPair, prefix kbcrypto.SignaturePrefix) (chat1.SignatureInfo, error) { encoded, err := b.marshal(data) if err != nil { return chat1.SignatureInfo{}, err } return b.sign(encoded, kp, prefix) }
[ "func", "(", "b", "*", "Boxer", ")", "signMarshal", "(", "data", "interface", "{", "}", ",", "kp", "libkb", ".", "NaclSigningKeyPair", ",", "prefix", "kbcrypto", ".", "SignaturePrefix", ")", "(", "chat1", ".", "SignatureInfo", ",", "error", ")", "{", "en...
// signMarshal signs data with a NaclSigningKeyPair, returning a chat1.SignatureInfo. // It marshals data before signing.
[ "signMarshal", "signs", "data", "with", "a", "NaclSigningKeyPair", "returning", "a", "chat1", ".", "SignatureInfo", ".", "It", "marshals", "data", "before", "signing", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/boxer.go#L1735-L1742
160,805
keybase/client
go/chat/boxer.go
signEncryptMarshal
func (b *Boxer) signEncryptMarshal(data interface{}, encryptionKey libkb.NaclSecretBoxKey, signingKeyPair libkb.NaclSigningKeyPair, prefix kbcrypto.SignaturePrefix) (chat1.SignEncryptedData, error) { encoded, err := b.marshal(data) if err != nil { return chat1.SignEncryptedData{}, err } return b.signEncrypt(encoded, encryptionKey, signingKeyPair, prefix) }
go
func (b *Boxer) signEncryptMarshal(data interface{}, encryptionKey libkb.NaclSecretBoxKey, signingKeyPair libkb.NaclSigningKeyPair, prefix kbcrypto.SignaturePrefix) (chat1.SignEncryptedData, error) { encoded, err := b.marshal(data) if err != nil { return chat1.SignEncryptedData{}, err } return b.signEncrypt(encoded, encryptionKey, signingKeyPair, prefix) }
[ "func", "(", "b", "*", "Boxer", ")", "signEncryptMarshal", "(", "data", "interface", "{", "}", ",", "encryptionKey", "libkb", ".", "NaclSecretBoxKey", ",", "signingKeyPair", "libkb", ".", "NaclSigningKeyPair", ",", "prefix", "kbcrypto", ".", "SignaturePrefix", "...
// signEncryptMarshal signencrypts data given an encryption and signing key, returning a chat1.SignEncryptedData. // It marshals data before signing.
[ "signEncryptMarshal", "signencrypts", "data", "given", "an", "encryption", "and", "signing", "key", "returning", "a", "chat1", ".", "SignEncryptedData", ".", "It", "marshals", "data", "before", "signing", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/boxer.go#L1746-L1754
160,806
keybase/client
go/chat/boxer.go
sign
func (b *Boxer) sign(msg []byte, kp libkb.NaclSigningKeyPair, prefix kbcrypto.SignaturePrefix) (chat1.SignatureInfo, error) { sig, err := kp.SignV2(msg, prefix) if err != nil { return chat1.SignatureInfo{}, err } sigInfo := chat1.SignatureInfo{ V: sig.Version, S: sig.Sig[:], K: sig.Kid, } if b.testingSignatureMangle != nil { b.assertInTest() sigInfo.S = b.testingSignatureMangle(sigInfo.S) } return sigInfo, nil }
go
func (b *Boxer) sign(msg []byte, kp libkb.NaclSigningKeyPair, prefix kbcrypto.SignaturePrefix) (chat1.SignatureInfo, error) { sig, err := kp.SignV2(msg, prefix) if err != nil { return chat1.SignatureInfo{}, err } sigInfo := chat1.SignatureInfo{ V: sig.Version, S: sig.Sig[:], K: sig.Kid, } if b.testingSignatureMangle != nil { b.assertInTest() sigInfo.S = b.testingSignatureMangle(sigInfo.S) } return sigInfo, nil }
[ "func", "(", "b", "*", "Boxer", ")", "sign", "(", "msg", "[", "]", "byte", ",", "kp", "libkb", ".", "NaclSigningKeyPair", ",", "prefix", "kbcrypto", ".", "SignaturePrefix", ")", "(", "chat1", ".", "SignatureInfo", ",", "error", ")", "{", "sig", ",", ...
// sign signs msg with a NaclSigningKeyPair, returning a chat1.SignatureInfo.
[ "sign", "signs", "msg", "with", "a", "NaclSigningKeyPair", "returning", "a", "chat1", ".", "SignatureInfo", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/boxer.go#L1757-L1774
160,807
keybase/client
go/chat/boxer.go
signEncrypt
func (b *Boxer) signEncrypt(msg []byte, encryptionKey libkb.NaclSecretBoxKey, signingKeyPair libkb.NaclSigningKeyPair, prefix kbcrypto.SignaturePrefix) (chat1.SignEncryptedData, error) { if signingKeyPair.Private == nil { return chat1.SignEncryptedData{}, libkb.NoSecretKeyError{} } var nonce [signencrypt.NonceSize]byte if _, err := rand.Read(nonce[:]); err != nil { return chat1.SignEncryptedData{}, err } var encKey [signencrypt.SecretboxKeySize]byte = encryptionKey var signKey [ed25519.PrivateKeySize]byte = *signingKeyPair.Private signEncryptedBytes := signencrypt.SealWhole( msg, &encKey, &signKey, prefix, &nonce) signEncryptedInfo := chat1.SignEncryptedData{ V: 1, E: signEncryptedBytes, N: nonce[:], } if b.testingSignatureMangle != nil { b.assertInTest() signEncryptedInfo.E = b.testingSignatureMangle(signEncryptedInfo.E) } return signEncryptedInfo, nil }
go
func (b *Boxer) signEncrypt(msg []byte, encryptionKey libkb.NaclSecretBoxKey, signingKeyPair libkb.NaclSigningKeyPair, prefix kbcrypto.SignaturePrefix) (chat1.SignEncryptedData, error) { if signingKeyPair.Private == nil { return chat1.SignEncryptedData{}, libkb.NoSecretKeyError{} } var nonce [signencrypt.NonceSize]byte if _, err := rand.Read(nonce[:]); err != nil { return chat1.SignEncryptedData{}, err } var encKey [signencrypt.SecretboxKeySize]byte = encryptionKey var signKey [ed25519.PrivateKeySize]byte = *signingKeyPair.Private signEncryptedBytes := signencrypt.SealWhole( msg, &encKey, &signKey, prefix, &nonce) signEncryptedInfo := chat1.SignEncryptedData{ V: 1, E: signEncryptedBytes, N: nonce[:], } if b.testingSignatureMangle != nil { b.assertInTest() signEncryptedInfo.E = b.testingSignatureMangle(signEncryptedInfo.E) } return signEncryptedInfo, nil }
[ "func", "(", "b", "*", "Boxer", ")", "signEncrypt", "(", "msg", "[", "]", "byte", ",", "encryptionKey", "libkb", ".", "NaclSecretBoxKey", ",", "signingKeyPair", "libkb", ".", "NaclSigningKeyPair", ",", "prefix", "kbcrypto", ".", "SignaturePrefix", ")", "(", ...
// signEncrypt signencrypts msg.
[ "signEncrypt", "signencrypts", "msg", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/boxer.go#L1777-L1805
160,808
keybase/client
go/chat/boxer.go
signEncryptOpen
func (b *Boxer) signEncryptOpen(data chat1.SignEncryptedData, encryptionKey libkb.NaclSecretBoxKey, verifyKID []byte, prefix kbcrypto.SignaturePrefix) ([]byte, error) { var encKey [signencrypt.SecretboxKeySize]byte = encryptionKey verifyKey := kbcrypto.KIDToNaclSigningKeyPublic(verifyKID) if verifyKey == nil { return nil, kbcrypto.BadKeyError{} } var verKey [ed25519.PublicKeySize]byte = *verifyKey var nonce [signencrypt.NonceSize]byte if copy(nonce[:], data.N) != signencrypt.NonceSize { return nil, libkb.DecryptBadNonceError{} } plain, err := signencrypt.OpenWhole(data.E, &encKey, &verKey, prefix, &nonce) if err != nil { return nil, err } return plain, nil }
go
func (b *Boxer) signEncryptOpen(data chat1.SignEncryptedData, encryptionKey libkb.NaclSecretBoxKey, verifyKID []byte, prefix kbcrypto.SignaturePrefix) ([]byte, error) { var encKey [signencrypt.SecretboxKeySize]byte = encryptionKey verifyKey := kbcrypto.KIDToNaclSigningKeyPublic(verifyKID) if verifyKey == nil { return nil, kbcrypto.BadKeyError{} } var verKey [ed25519.PublicKeySize]byte = *verifyKey var nonce [signencrypt.NonceSize]byte if copy(nonce[:], data.N) != signencrypt.NonceSize { return nil, libkb.DecryptBadNonceError{} } plain, err := signencrypt.OpenWhole(data.E, &encKey, &verKey, prefix, &nonce) if err != nil { return nil, err } return plain, nil }
[ "func", "(", "b", "*", "Boxer", ")", "signEncryptOpen", "(", "data", "chat1", ".", "SignEncryptedData", ",", "encryptionKey", "libkb", ".", "NaclSecretBoxKey", ",", "verifyKID", "[", "]", "byte", ",", "prefix", "kbcrypto", ".", "SignaturePrefix", ")", "(", "...
// signEncryptOpen opens and verifies chat1.SignEncryptedData.
[ "signEncryptOpen", "opens", "and", "verifies", "chat1", ".", "SignEncryptedData", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/boxer.go#L1808-L1828
160,809
keybase/client
go/chat/boxer.go
verifyMessageV1
func (b *Boxer) verifyMessageV1(ctx context.Context, header chat1.HeaderPlaintext, msg chat1.MessageBoxed, skipBodyVerification bool) (verifyMessageRes, types.UnboxingError) { headerVersion, err := header.Version() if err != nil { return verifyMessageRes{}, NewPermanentUnboxingError(err) } switch headerVersion { case chat1.HeaderPlaintextVersion_V1: return b.verifyMessageHeaderV1(ctx, header.V1(), msg, skipBodyVerification) // NOTE: When adding new versions here, you must also update // chat1/extras.go so MessageUnboxedError.ParseableVersion understands the // new max version default: return verifyMessageRes{}, NewPermanentUnboxingError(NewHeaderVersionError(headerVersion, b.headerUnsupported(ctx, headerVersion, header))) } }
go
func (b *Boxer) verifyMessageV1(ctx context.Context, header chat1.HeaderPlaintext, msg chat1.MessageBoxed, skipBodyVerification bool) (verifyMessageRes, types.UnboxingError) { headerVersion, err := header.Version() if err != nil { return verifyMessageRes{}, NewPermanentUnboxingError(err) } switch headerVersion { case chat1.HeaderPlaintextVersion_V1: return b.verifyMessageHeaderV1(ctx, header.V1(), msg, skipBodyVerification) // NOTE: When adding new versions here, you must also update // chat1/extras.go so MessageUnboxedError.ParseableVersion understands the // new max version default: return verifyMessageRes{}, NewPermanentUnboxingError(NewHeaderVersionError(headerVersion, b.headerUnsupported(ctx, headerVersion, header))) } }
[ "func", "(", "b", "*", "Boxer", ")", "verifyMessageV1", "(", "ctx", "context", ".", "Context", ",", "header", "chat1", ".", "HeaderPlaintext", ",", "msg", "chat1", ".", "MessageBoxed", ",", "skipBodyVerification", "bool", ")", "(", "verifyMessageRes", ",", "...
// verifyMessage checks that a message is valid. // Only works on MessageBoxedVersion_V1
[ "verifyMessage", "checks", "that", "a", "message", "is", "valid", ".", "Only", "works", "on", "MessageBoxedVersion_V1" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/boxer.go#L1836-L1853
160,810
keybase/client
go/chat/boxer.go
verifyMessageHeaderV1
func (b *Boxer) verifyMessageHeaderV1(ctx context.Context, header chat1.HeaderPlaintextV1, msg chat1.MessageBoxed, skipBodyVerification bool) (verifyMessageRes, types.UnboxingError) { if !skipBodyVerification { // check body hash bh := b.hashV1(msg.BodyCiphertext.E) if !libkb.SecureByteArrayEq(bh[:], header.BodyHash) { return verifyMessageRes{}, NewPermanentUnboxingError(BodyHashInvalid{}) } } // check key validity // ValidSenderKey uses the server-given ctime, but emits senderDeviceRevokedAt as a workaround. // See ValidSenderKey for details. found, validAtCtime, revoked, ierr := b.ValidSenderKey(ctx, header.Sender, header.HeaderSignature.K, msg.ServerHeader.Ctime) if ierr != nil { return verifyMessageRes{}, ierr } if !found { return verifyMessageRes{}, NewPermanentUnboxingError(libkb.NoKeyError{Msg: "sender key not found"}) } if !validAtCtime { return verifyMessageRes{}, NewPermanentUnboxingError(libkb.NoKeyError{Msg: "key invalid for sender at message ctime"}) } // check signature hcopy := header hcopy.HeaderSignature = nil hpack, err := b.marshal(hcopy) if err != nil { return verifyMessageRes{}, NewPermanentUnboxingError(err) } if !b.verify(hpack, *header.HeaderSignature, kbcrypto.SignaturePrefixChatMBv1) { return verifyMessageRes{}, NewPermanentUnboxingError(libkb.BadSigError{E: "header signature invalid"}) } return verifyMessageRes{ senderDeviceRevokedAt: revoked, }, nil }
go
func (b *Boxer) verifyMessageHeaderV1(ctx context.Context, header chat1.HeaderPlaintextV1, msg chat1.MessageBoxed, skipBodyVerification bool) (verifyMessageRes, types.UnboxingError) { if !skipBodyVerification { // check body hash bh := b.hashV1(msg.BodyCiphertext.E) if !libkb.SecureByteArrayEq(bh[:], header.BodyHash) { return verifyMessageRes{}, NewPermanentUnboxingError(BodyHashInvalid{}) } } // check key validity // ValidSenderKey uses the server-given ctime, but emits senderDeviceRevokedAt as a workaround. // See ValidSenderKey for details. found, validAtCtime, revoked, ierr := b.ValidSenderKey(ctx, header.Sender, header.HeaderSignature.K, msg.ServerHeader.Ctime) if ierr != nil { return verifyMessageRes{}, ierr } if !found { return verifyMessageRes{}, NewPermanentUnboxingError(libkb.NoKeyError{Msg: "sender key not found"}) } if !validAtCtime { return verifyMessageRes{}, NewPermanentUnboxingError(libkb.NoKeyError{Msg: "key invalid for sender at message ctime"}) } // check signature hcopy := header hcopy.HeaderSignature = nil hpack, err := b.marshal(hcopy) if err != nil { return verifyMessageRes{}, NewPermanentUnboxingError(err) } if !b.verify(hpack, *header.HeaderSignature, kbcrypto.SignaturePrefixChatMBv1) { return verifyMessageRes{}, NewPermanentUnboxingError(libkb.BadSigError{E: "header signature invalid"}) } return verifyMessageRes{ senderDeviceRevokedAt: revoked, }, nil }
[ "func", "(", "b", "*", "Boxer", ")", "verifyMessageHeaderV1", "(", "ctx", "context", ".", "Context", ",", "header", "chat1", ".", "HeaderPlaintextV1", ",", "msg", "chat1", ".", "MessageBoxed", ",", "skipBodyVerification", "bool", ")", "(", "verifyMessageRes", ...
// verifyMessageHeaderV1 checks the body hash, header signature, and signing key validity.
[ "verifyMessageHeaderV1", "checks", "the", "body", "hash", "header", "signature", "and", "signing", "key", "validity", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/boxer.go#L1856-L1893
160,811
keybase/client
go/chat/boxer.go
verify
func (b *Boxer) verify(data []byte, si chat1.SignatureInfo, prefix kbcrypto.SignaturePrefix) bool { sigInfo := kbcrypto.NaclSigInfo{ Version: si.V, Prefix: prefix, Kid: si.K, Payload: data, } copy(sigInfo.Sig[:], si.S) _, err := sigInfo.Verify() return (err == nil) }
go
func (b *Boxer) verify(data []byte, si chat1.SignatureInfo, prefix kbcrypto.SignaturePrefix) bool { sigInfo := kbcrypto.NaclSigInfo{ Version: si.V, Prefix: prefix, Kid: si.K, Payload: data, } copy(sigInfo.Sig[:], si.S) _, err := sigInfo.Verify() return (err == nil) }
[ "func", "(", "b", "*", "Boxer", ")", "verify", "(", "data", "[", "]", "byte", ",", "si", "chat1", ".", "SignatureInfo", ",", "prefix", "kbcrypto", ".", "SignaturePrefix", ")", "bool", "{", "sigInfo", ":=", "kbcrypto", ".", "NaclSigInfo", "{", "Version", ...
// verify verifies the signature of data using SignatureInfo.
[ "verify", "verifies", "the", "signature", "of", "data", "using", "SignatureInfo", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/boxer.go#L1896-L1906
160,812
keybase/client
go/chat/boxer.go
compareHeadersMBV1
func (b *Boxer) compareHeadersMBV1(ctx context.Context, hServer chat1.MessageClientHeader, hSigned chat1.MessageClientHeaderVerified) types.UnboxingError { // Conv if !hServer.Conv.Eq(hSigned.Conv) { return NewPermanentUnboxingError(NewHeaderMismatchError("Conv")) } // TlfName if hServer.TlfName != hSigned.TlfName { return NewPermanentUnboxingError(NewHeaderMismatchError("TlfName")) } // TlfPublic if hServer.TlfPublic != hSigned.TlfPublic { return NewPermanentUnboxingError(NewHeaderMismatchError("TlfPublic")) } // MessageType if hServer.MessageType != hSigned.MessageType { return NewPermanentUnboxingError(NewHeaderMismatchError("MessageType")) } // Note: Supersedes, Deletes, and some other fields are not checked because they are not // part of MessageClientHeaderVerified. // Prev if len(hServer.Prev) != len(hSigned.Prev) { return NewPermanentUnboxingError(NewHeaderMismatchError("Prev")) } for i, a := range hServer.Prev { b := hSigned.Prev[i] if !a.Eq(b) { return NewPermanentUnboxingError(NewHeaderMismatchError("Prev")) } } // Sender // This prevents someone from re-using a header for another sender if !hServer.Sender.Eq(hSigned.Sender) { return NewPermanentUnboxingError(NewHeaderMismatchError("Sender")) } // SenderDevice if !bytes.Equal(hServer.SenderDevice.Bytes(), hSigned.SenderDevice.Bytes()) { return NewPermanentUnboxingError(NewHeaderMismatchError("SenderDevice")) } // _Don't_ check that the MerkleRoot's match. // The signed MerkleRoot should be nil as it was not part of the protocol // when clients were writing MBV1. But we just allow anything here. // There are V1 messages in the wild with hServer.MerkleRoot set but nothing signed. // OutboxID, OutboxInfo: Left unchecked as I'm not sure whether these hold in V1 messages. return nil }
go
func (b *Boxer) compareHeadersMBV1(ctx context.Context, hServer chat1.MessageClientHeader, hSigned chat1.MessageClientHeaderVerified) types.UnboxingError { // Conv if !hServer.Conv.Eq(hSigned.Conv) { return NewPermanentUnboxingError(NewHeaderMismatchError("Conv")) } // TlfName if hServer.TlfName != hSigned.TlfName { return NewPermanentUnboxingError(NewHeaderMismatchError("TlfName")) } // TlfPublic if hServer.TlfPublic != hSigned.TlfPublic { return NewPermanentUnboxingError(NewHeaderMismatchError("TlfPublic")) } // MessageType if hServer.MessageType != hSigned.MessageType { return NewPermanentUnboxingError(NewHeaderMismatchError("MessageType")) } // Note: Supersedes, Deletes, and some other fields are not checked because they are not // part of MessageClientHeaderVerified. // Prev if len(hServer.Prev) != len(hSigned.Prev) { return NewPermanentUnboxingError(NewHeaderMismatchError("Prev")) } for i, a := range hServer.Prev { b := hSigned.Prev[i] if !a.Eq(b) { return NewPermanentUnboxingError(NewHeaderMismatchError("Prev")) } } // Sender // This prevents someone from re-using a header for another sender if !hServer.Sender.Eq(hSigned.Sender) { return NewPermanentUnboxingError(NewHeaderMismatchError("Sender")) } // SenderDevice if !bytes.Equal(hServer.SenderDevice.Bytes(), hSigned.SenderDevice.Bytes()) { return NewPermanentUnboxingError(NewHeaderMismatchError("SenderDevice")) } // _Don't_ check that the MerkleRoot's match. // The signed MerkleRoot should be nil as it was not part of the protocol // when clients were writing MBV1. But we just allow anything here. // There are V1 messages in the wild with hServer.MerkleRoot set but nothing signed. // OutboxID, OutboxInfo: Left unchecked as I'm not sure whether these hold in V1 messages. return nil }
[ "func", "(", "b", "*", "Boxer", ")", "compareHeadersMBV1", "(", "ctx", "context", ".", "Context", ",", "hServer", "chat1", ".", "MessageClientHeader", ",", "hSigned", "chat1", ".", "MessageClientHeaderVerified", ")", "types", ".", "UnboxingError", "{", "// Conv"...
// See note on compareHeadersMBV2orV3.
[ "See", "note", "on", "compareHeadersMBV2orV3", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/boxer.go#L1996-L2050
160,813
keybase/client
go/libkb/saltpack_enc.go
SaltpackEncrypt
func SaltpackEncrypt(m MetaContext, arg *SaltpackEncryptArg) error { var receiverBoxKeys []saltpack.BoxPublicKey for _, k := range arg.Receivers { // Since signcryption became the default, we never use visible // recipients in encryption mode, except in tests. if arg.VisibleRecipientsForTesting { receiverBoxKeys = append(receiverBoxKeys, naclBoxPublicKey(k)) } else { receiverBoxKeys = append(receiverBoxKeys, hiddenNaclBoxPublicKey(k)) } } var bsk saltpack.BoxSecretKey if !arg.Sender.IsNil() { bsk = naclBoxSecretKey(arg.Sender) } // If the version is unspecified, default to the current version. saltpackVersion := arg.SaltpackVersion if saltpackVersion == (saltpack.Version{}) { saltpackVersion = saltpack.CurrentVersion() } var plainsink io.WriteCloser var err error if !arg.EncryptionOnlyMode { if arg.SaltpackVersion.Major == 1 { return errors.New("specifying saltpack version 1 requires repudiable authentication") } var signer saltpack.SigningSecretKey if !arg.SenderSigning.IsNil() { signer = saltSigner{arg.SenderSigning} } if arg.Binary { plainsink, err = saltpack.NewSigncryptSealStream(arg.Sink, emptyKeyring{}, signer, receiverBoxKeys, arg.SymmetricReceivers) } else { plainsink, err = saltpack.NewSigncryptArmor62SealStream(arg.Sink, emptyKeyring{}, signer, receiverBoxKeys, arg.SymmetricReceivers, KeybaseSaltpackBrand) } } else { if arg.Binary { plainsink, err = saltpack.NewEncryptStream(saltpackVersion, arg.Sink, bsk, receiverBoxKeys) } else { plainsink, err = saltpack.NewEncryptArmor62Stream(saltpackVersion, arg.Sink, bsk, receiverBoxKeys, KeybaseSaltpackBrand) } } if err != nil { return err } n, err := io.Copy(plainsink, arg.Source) if err != nil { return err } m.Debug("Encrypt: wrote %d bytes", n) if err := plainsink.Close(); err != nil { return err } return arg.Sink.Close() }
go
func SaltpackEncrypt(m MetaContext, arg *SaltpackEncryptArg) error { var receiverBoxKeys []saltpack.BoxPublicKey for _, k := range arg.Receivers { // Since signcryption became the default, we never use visible // recipients in encryption mode, except in tests. if arg.VisibleRecipientsForTesting { receiverBoxKeys = append(receiverBoxKeys, naclBoxPublicKey(k)) } else { receiverBoxKeys = append(receiverBoxKeys, hiddenNaclBoxPublicKey(k)) } } var bsk saltpack.BoxSecretKey if !arg.Sender.IsNil() { bsk = naclBoxSecretKey(arg.Sender) } // If the version is unspecified, default to the current version. saltpackVersion := arg.SaltpackVersion if saltpackVersion == (saltpack.Version{}) { saltpackVersion = saltpack.CurrentVersion() } var plainsink io.WriteCloser var err error if !arg.EncryptionOnlyMode { if arg.SaltpackVersion.Major == 1 { return errors.New("specifying saltpack version 1 requires repudiable authentication") } var signer saltpack.SigningSecretKey if !arg.SenderSigning.IsNil() { signer = saltSigner{arg.SenderSigning} } if arg.Binary { plainsink, err = saltpack.NewSigncryptSealStream(arg.Sink, emptyKeyring{}, signer, receiverBoxKeys, arg.SymmetricReceivers) } else { plainsink, err = saltpack.NewSigncryptArmor62SealStream(arg.Sink, emptyKeyring{}, signer, receiverBoxKeys, arg.SymmetricReceivers, KeybaseSaltpackBrand) } } else { if arg.Binary { plainsink, err = saltpack.NewEncryptStream(saltpackVersion, arg.Sink, bsk, receiverBoxKeys) } else { plainsink, err = saltpack.NewEncryptArmor62Stream(saltpackVersion, arg.Sink, bsk, receiverBoxKeys, KeybaseSaltpackBrand) } } if err != nil { return err } n, err := io.Copy(plainsink, arg.Source) if err != nil { return err } m.Debug("Encrypt: wrote %d bytes", n) if err := plainsink.Close(); err != nil { return err } return arg.Sink.Close() }
[ "func", "SaltpackEncrypt", "(", "m", "MetaContext", ",", "arg", "*", "SaltpackEncryptArg", ")", "error", "{", "var", "receiverBoxKeys", "[", "]", "saltpack", ".", "BoxPublicKey", "\n", "for", "_", ",", "k", ":=", "range", "arg", ".", "Receivers", "{", "// ...
// SaltpackEncrypt reads from the given source, encrypts it for the given // receivers from the given sender, and writes it to sink. If // Binary is false, the data written to sink will be armored.
[ "SaltpackEncrypt", "reads", "from", "the", "given", "source", "encrypts", "it", "for", "the", "given", "receivers", "from", "the", "given", "sender", "and", "writes", "it", "to", "sink", ".", "If", "Binary", "is", "false", "the", "data", "written", "to", "...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/saltpack_enc.go#L30-L90
160,814
keybase/client
go/libkb/merkle_client.go
FetchRootFromServer
func (mc *MerkleClient) FetchRootFromServer(m MetaContext, freshness time.Duration) (mr *MerkleRoot, err error) { defer m.VTrace(VLog0, "MerkleClient#FetchRootFromServer", func() error { return err })() // on startup, many threads might try to mash this call at once (via the Auditor or // other pathways). So protect this with a lock. mc.freshLock.Lock() defer mc.freshLock.Unlock() root := mc.LastRoot() now := m.G().Clock().Now() if root != nil && freshness > 0 && now.Sub(root.fetched) < freshness { m.VLogf(VLog0, "freshness=%d, and was current enough, so returning non-nil previously fetched root", freshness) return root, nil } return mc.fetchRootFromServer(m, root) }
go
func (mc *MerkleClient) FetchRootFromServer(m MetaContext, freshness time.Duration) (mr *MerkleRoot, err error) { defer m.VTrace(VLog0, "MerkleClient#FetchRootFromServer", func() error { return err })() // on startup, many threads might try to mash this call at once (via the Auditor or // other pathways). So protect this with a lock. mc.freshLock.Lock() defer mc.freshLock.Unlock() root := mc.LastRoot() now := m.G().Clock().Now() if root != nil && freshness > 0 && now.Sub(root.fetched) < freshness { m.VLogf(VLog0, "freshness=%d, and was current enough, so returning non-nil previously fetched root", freshness) return root, nil } return mc.fetchRootFromServer(m, root) }
[ "func", "(", "mc", "*", "MerkleClient", ")", "FetchRootFromServer", "(", "m", "MetaContext", ",", "freshness", "time", ".", "Duration", ")", "(", "mr", "*", "MerkleRoot", ",", "err", "error", ")", "{", "defer", "m", ".", "VTrace", "(", "VLog0", ",", "\...
// FetchRootFromServer fetches a root from the server. If the last-fetched root was fetched within // freshness ago, then OK to return the last-fetched root. Otherwise refetch. Similarly, if the freshness // passed is 0, then always refresh.
[ "FetchRootFromServer", "fetches", "a", "root", "from", "the", "server", ".", "If", "the", "last", "-", "fetched", "root", "was", "fetched", "within", "freshness", "ago", "then", "OK", "to", "return", "the", "last", "-", "fetched", "root", ".", "Otherwise", ...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/merkle_client.go#L601-L616
160,815
keybase/client
go/libkb/merkle_client.go
lookupPathAndSkipSequenceHelper
func (mc *MerkleClient) lookupPathAndSkipSequenceHelper(m MetaContext, q HTTPArgs, sigHints *SigHints, lastRoot *MerkleRoot, isUser bool) (apiRes *APIRes, err error) { defer m.VTrace(VLog1, "MerkleClient#lookupPathAndSkipSequence", func() error { return err })() // Poll for 10s and ask for a race-free state. w := 10 * int(CITimeMultiplier(mc.G())) q.Add("poll", I{w}) q.Add("c", B{true}) if isUser { q.Add("load_deleted", B{true}) q.Add("load_reset_chain", B{true}) } // Add the local db sigHints version if sigHints != nil { q.Add("sig_hints_low", I{sigHints.version}) } // Get back a series of skips from the last merkle root we had to the new // one we're getting back, and hold the server to it. lastSeqno := lastRoot.Seqno() if lastSeqno != nil { q.Add("last", I{int(*lastSeqno)}) } apiRes, err = m.G().API.Get(m, APIArg{ Endpoint: "merkle/path", SessionType: APISessionTypeNONE, Args: q, AppStatusCodes: []int{SCOk, SCNotFound, SCDeleted}, RetryCount: 3, InitialTimeout: 4 * time.Second, RetryMultiplier: 1.1, }) if err != nil { return nil, err } switch apiRes.AppStatus.Code { case SCNotFound: err = NotFoundError{} return nil, err case SCDeleted: err = UserDeletedError{} return nil, err } return apiRes, err }
go
func (mc *MerkleClient) lookupPathAndSkipSequenceHelper(m MetaContext, q HTTPArgs, sigHints *SigHints, lastRoot *MerkleRoot, isUser bool) (apiRes *APIRes, err error) { defer m.VTrace(VLog1, "MerkleClient#lookupPathAndSkipSequence", func() error { return err })() // Poll for 10s and ask for a race-free state. w := 10 * int(CITimeMultiplier(mc.G())) q.Add("poll", I{w}) q.Add("c", B{true}) if isUser { q.Add("load_deleted", B{true}) q.Add("load_reset_chain", B{true}) } // Add the local db sigHints version if sigHints != nil { q.Add("sig_hints_low", I{sigHints.version}) } // Get back a series of skips from the last merkle root we had to the new // one we're getting back, and hold the server to it. lastSeqno := lastRoot.Seqno() if lastSeqno != nil { q.Add("last", I{int(*lastSeqno)}) } apiRes, err = m.G().API.Get(m, APIArg{ Endpoint: "merkle/path", SessionType: APISessionTypeNONE, Args: q, AppStatusCodes: []int{SCOk, SCNotFound, SCDeleted}, RetryCount: 3, InitialTimeout: 4 * time.Second, RetryMultiplier: 1.1, }) if err != nil { return nil, err } switch apiRes.AppStatus.Code { case SCNotFound: err = NotFoundError{} return nil, err case SCDeleted: err = UserDeletedError{} return nil, err } return apiRes, err }
[ "func", "(", "mc", "*", "MerkleClient", ")", "lookupPathAndSkipSequenceHelper", "(", "m", "MetaContext", ",", "q", "HTTPArgs", ",", "sigHints", "*", "SigHints", ",", "lastRoot", "*", "MerkleRoot", ",", "isUser", "bool", ")", "(", "apiRes", "*", "APIRes", ","...
// `isUser` is true for loading a user and false for loading a team.
[ "isUser", "is", "true", "for", "loading", "a", "user", "and", "false", "for", "loading", "a", "team", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/merkle_client.go#L715-L763
160,816
keybase/client
go/libkb/merkle_client.go
readSkipSequenceFromAPIRes
func (mc *MerkleClient) readSkipSequenceFromAPIRes(m MetaContext, res *APIRes, thisRoot *MerkleRoot, lastRoot *MerkleRoot) (ret SkipSequence, err error) { defer m.VTrace(VLog1, "MerkleClient#readSkipSequenceFromAPIRes", func() error { return err })() if lastRoot == nil { m.VLogf(VLog0, "| lastRoot==nil") return nil, nil } if !thisRoot.HasSkips() { m.VLogf(VLog0, "| thisRoot has no skips") return nil, nil } skips := res.Body.AtKey("skips") if skips.IsNil() { m.VLogf(VLog1, "| skip list from API server is nil") return nil, nil } var v []string if err = skips.UnmarshalAgain(&v); err != nil { m.VLogf(VLog0, "| failed to unmarshal skip list as a list of strings") return nil, err } ret, err = readSkipSequenceFromStringList(v) if err != nil { return nil, err } // Create the skip sequence by bookending the list the server replies with // with: (1) the most recent root, sent back in this reply; and (2) our last // root, which we read out of cache (in memory or on disk). HOWEVER, in the // case of lookup up historical roots, the ordering might be reversed. So // we swap in that case. left, right := thisRoot.payload, lastRoot.payload if left.seqno() < right.seqno() { left, right = right, left } ret = append(SkipSequence{left}, ret...) ret = append(ret, right) return ret, nil }
go
func (mc *MerkleClient) readSkipSequenceFromAPIRes(m MetaContext, res *APIRes, thisRoot *MerkleRoot, lastRoot *MerkleRoot) (ret SkipSequence, err error) { defer m.VTrace(VLog1, "MerkleClient#readSkipSequenceFromAPIRes", func() error { return err })() if lastRoot == nil { m.VLogf(VLog0, "| lastRoot==nil") return nil, nil } if !thisRoot.HasSkips() { m.VLogf(VLog0, "| thisRoot has no skips") return nil, nil } skips := res.Body.AtKey("skips") if skips.IsNil() { m.VLogf(VLog1, "| skip list from API server is nil") return nil, nil } var v []string if err = skips.UnmarshalAgain(&v); err != nil { m.VLogf(VLog0, "| failed to unmarshal skip list as a list of strings") return nil, err } ret, err = readSkipSequenceFromStringList(v) if err != nil { return nil, err } // Create the skip sequence by bookending the list the server replies with // with: (1) the most recent root, sent back in this reply; and (2) our last // root, which we read out of cache (in memory or on disk). HOWEVER, in the // case of lookup up historical roots, the ordering might be reversed. So // we swap in that case. left, right := thisRoot.payload, lastRoot.payload if left.seqno() < right.seqno() { left, right = right, left } ret = append(SkipSequence{left}, ret...) ret = append(ret, right) return ret, nil }
[ "func", "(", "mc", "*", "MerkleClient", ")", "readSkipSequenceFromAPIRes", "(", "m", "MetaContext", ",", "res", "*", "APIRes", ",", "thisRoot", "*", "MerkleRoot", ",", "lastRoot", "*", "MerkleRoot", ")", "(", "ret", "SkipSequence", ",", "err", "error", ")", ...
// readSkipSequenceFromAPIRes returns a SkipSequence. We construct the sequence by starting with the // most recent merkle root, adding the "skip" pointers returned by the server, and finally bookending // with the merkle root we last fetched from the DB. In verifySkipSequence, we walk over this Sequence // to make sure that it obeys proper construction.
[ "readSkipSequenceFromAPIRes", "returns", "a", "SkipSequence", ".", "We", "construct", "the", "sequence", "by", "starting", "with", "the", "most", "recent", "merkle", "root", "adding", "the", "skip", "pointers", "returned", "by", "the", "server", "and", "finally", ...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/merkle_client.go#L789-L832
160,817
keybase/client
go/libkb/merkle_client.go
storeRoot
func (mc *MerkleClient) storeRoot(m MetaContext, root *MerkleRoot) { m.VLogf(VLog0, "storing merkle root: %d", *root.Seqno()) err := mc.G().LocalDb.Put(merkleHeadKey(), nil, root.ToJSON()) if err != nil { m.Error("Cannot commit Merkle root to local DB: %s", err) } else { mc.lastRoot = root } }
go
func (mc *MerkleClient) storeRoot(m MetaContext, root *MerkleRoot) { m.VLogf(VLog0, "storing merkle root: %d", *root.Seqno()) err := mc.G().LocalDb.Put(merkleHeadKey(), nil, root.ToJSON()) if err != nil { m.Error("Cannot commit Merkle root to local DB: %s", err) } else { mc.lastRoot = root } }
[ "func", "(", "mc", "*", "MerkleClient", ")", "storeRoot", "(", "m", "MetaContext", ",", "root", "*", "MerkleRoot", ")", "{", "m", ".", "VLogf", "(", "VLog0", ",", "\"", "\"", ",", "*", "root", ".", "Seqno", "(", ")", ")", "\n", "err", ":=", "mc",...
// storeRoot stores the root in the db and mem. // Must be called from under a lock.
[ "storeRoot", "stores", "the", "root", "in", "the", "db", "and", "mem", ".", "Must", "be", "called", "from", "under", "a", "lock", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/merkle_client.go#L936-L944
160,818
keybase/client
go/service/chat_local.go
newChatLocalHandler
func newChatLocalHandler(xp rpc.Transporter, g *globals.Context, gh *gregorHandler) *chatLocalHandler { h := &chatLocalHandler{ BaseHandler: NewBaseHandler(g.ExternalG(), xp), } h.Server = chat.NewServer(g, gh, h) return h }
go
func newChatLocalHandler(xp rpc.Transporter, g *globals.Context, gh *gregorHandler) *chatLocalHandler { h := &chatLocalHandler{ BaseHandler: NewBaseHandler(g.ExternalG(), xp), } h.Server = chat.NewServer(g, gh, h) return h }
[ "func", "newChatLocalHandler", "(", "xp", "rpc", ".", "Transporter", ",", "g", "*", "globals", ".", "Context", ",", "gh", "*", "gregorHandler", ")", "*", "chatLocalHandler", "{", "h", ":=", "&", "chatLocalHandler", "{", "BaseHandler", ":", "NewBaseHandler", ...
// newChatLocalHandler creates a chatLocalHandler.
[ "newChatLocalHandler", "creates", "a", "chatLocalHandler", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/service/chat_local.go#L21-L27
160,819
keybase/client
go/kbfs/libfuse/status_file.go
NewNonTLFStatusFile
func NewNonTLFStatusFile(fs *FS, entryValid *time.Duration) *SpecialReadFile { *entryValid = 0 return &SpecialReadFile{ read: func(ctx context.Context) ([]byte, time.Time, error) { return libfs.GetEncodedStatus(ctx, fs.config) }, } }
go
func NewNonTLFStatusFile(fs *FS, entryValid *time.Duration) *SpecialReadFile { *entryValid = 0 return &SpecialReadFile{ read: func(ctx context.Context) ([]byte, time.Time, error) { return libfs.GetEncodedStatus(ctx, fs.config) }, } }
[ "func", "NewNonTLFStatusFile", "(", "fs", "*", "FS", ",", "entryValid", "*", "time", ".", "Duration", ")", "*", "SpecialReadFile", "{", "*", "entryValid", "=", "0", "\n", "return", "&", "SpecialReadFile", "{", "read", ":", "func", "(", "ctx", "context", ...
// NewNonTLFStatusFile returns a special read file that contains a // text representation of the global KBFS status.
[ "NewNonTLFStatusFile", "returns", "a", "special", "read", "file", "that", "contains", "a", "text", "representation", "of", "the", "global", "KBFS", "status", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfuse/status_file.go#L19-L26
160,820
keybase/client
go/libkb/social_assertion.go
IsSocialAssertion
func IsSocialAssertion(ctx AssertionContext, s string) bool { _, ok := NormalizeSocialAssertion(ctx, s) return ok }
go
func IsSocialAssertion(ctx AssertionContext, s string) bool { _, ok := NormalizeSocialAssertion(ctx, s) return ok }
[ "func", "IsSocialAssertion", "(", "ctx", "AssertionContext", ",", "s", "string", ")", "bool", "{", "_", ",", "ok", ":=", "NormalizeSocialAssertion", "(", "ctx", ",", "s", ")", "\n", "return", "ok", "\n", "}" ]
// IsSocialAssertion returns true for strings that are valid // social assertions. They do not need to be normalized, so // user@twitter and twitter:user will work, as will // USER@Twitter.
[ "IsSocialAssertion", "returns", "true", "for", "strings", "that", "are", "valid", "social", "assertions", ".", "They", "do", "not", "need", "to", "be", "normalized", "so", "user" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/social_assertion.go#L14-L17
160,821
keybase/client
go/ephemeral/team_ek.go
teamEKRetryWrapper
func teamEKRetryWrapper(mctx libkb.MetaContext, retryFn func() error) (err error) { knownRaceConditions := []keybase1.StatusCode{ keybase1.StatusCode_SCSigWrongKey, keybase1.StatusCode_SCSigOldSeqno, keybase1.StatusCode_SCEphemeralKeyBadGeneration, keybase1.StatusCode_SCEphemeralKeyUnexpectedBox, keybase1.StatusCode_SCEphemeralKeyMissingBox, keybase1.StatusCode_SCEphemeralKeyWrongNumberOfKeys, } for tries := 0; tries < maxRetries; tries++ { if err = retryFn(); err == nil { return nil } retryableError := false for _, code := range knownRaceConditions { if libkb.IsAppStatusCode(err, code) { mctx.Debug("teamEKRetryWrapper found a retryable error on try %d: %s", tries, err) retryableError = true break } } if !retryableError { return err } } return nil }
go
func teamEKRetryWrapper(mctx libkb.MetaContext, retryFn func() error) (err error) { knownRaceConditions := []keybase1.StatusCode{ keybase1.StatusCode_SCSigWrongKey, keybase1.StatusCode_SCSigOldSeqno, keybase1.StatusCode_SCEphemeralKeyBadGeneration, keybase1.StatusCode_SCEphemeralKeyUnexpectedBox, keybase1.StatusCode_SCEphemeralKeyMissingBox, keybase1.StatusCode_SCEphemeralKeyWrongNumberOfKeys, } for tries := 0; tries < maxRetries; tries++ { if err = retryFn(); err == nil { return nil } retryableError := false for _, code := range knownRaceConditions { if libkb.IsAppStatusCode(err, code) { mctx.Debug("teamEKRetryWrapper found a retryable error on try %d: %s", tries, err) retryableError = true break } } if !retryableError { return err } } return nil }
[ "func", "teamEKRetryWrapper", "(", "mctx", "libkb", ".", "MetaContext", ",", "retryFn", "func", "(", ")", "error", ")", "(", "err", "error", ")", "{", "knownRaceConditions", ":=", "[", "]", "keybase1", ".", "StatusCode", "{", "keybase1", ".", "StatusCode_SCS...
// There are plenty of race conditions where the PTK or teamEK or // membership list can change out from under us while we're in the middle // of posting a new key, causing the post to fail. Detect these conditions // and retry.
[ "There", "are", "plenty", "of", "race", "conditions", "where", "the", "PTK", "or", "teamEK", "or", "membership", "list", "can", "change", "out", "from", "under", "us", "while", "we", "re", "in", "the", "middle", "of", "posting", "a", "new", "key", "causi...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/ephemeral/team_ek.go#L168-L194
160,822
keybase/client
go/ephemeral/team_ek.go
fetchTeamEKStatement
func fetchTeamEKStatement(mctx libkb.MetaContext, teamID keybase1.TeamID) ( statement *keybase1.TeamEkStatement, latestGeneration keybase1.EkGeneration, wrongKID bool, err error) { defer mctx.TraceTimed("fetchTeamEKStatement", func() error { return err })() apiArg := libkb.APIArg{ Endpoint: "team/team_ek", SessionType: libkb.APISessionTypeREQUIRED, Args: libkb.HTTPArgs{ "team_id": libkb.S{Val: string(teamID)}, }, } res, err := mctx.G().GetAPI().Get(mctx, apiArg) if err != nil { return nil, latestGeneration, false, err } parsedResponse := teamEKStatementResponse{} err = res.Body.UnmarshalAgain(&parsedResponse) if err != nil { return nil, latestGeneration, false, err } // If the result field in the response is null, the server is saying that // the team has never published a teamEKStatement, stale or otherwise. if parsedResponse.Sig == nil { mctx.Debug("team has no teamEKStatement at all") return nil, latestGeneration, false, nil } statement, latestGeneration, wrongKID, err = verifySigWithLatestPTK(mctx, teamID, *parsedResponse.Sig) // Check the wrongKID condition before checking the error, since an error // is still returned in this case. TODO: Turn this warning into an error // after EK support is sufficiently widespread. if wrongKID { mctx.Debug("It looks like someone rolled the PTK without generating new ephemeral keys. They might be on an old version.") return nil, latestGeneration, true, nil } else if err != nil { return nil, latestGeneration, false, err } return statement, latestGeneration, false, nil }
go
func fetchTeamEKStatement(mctx libkb.MetaContext, teamID keybase1.TeamID) ( statement *keybase1.TeamEkStatement, latestGeneration keybase1.EkGeneration, wrongKID bool, err error) { defer mctx.TraceTimed("fetchTeamEKStatement", func() error { return err })() apiArg := libkb.APIArg{ Endpoint: "team/team_ek", SessionType: libkb.APISessionTypeREQUIRED, Args: libkb.HTTPArgs{ "team_id": libkb.S{Val: string(teamID)}, }, } res, err := mctx.G().GetAPI().Get(mctx, apiArg) if err != nil { return nil, latestGeneration, false, err } parsedResponse := teamEKStatementResponse{} err = res.Body.UnmarshalAgain(&parsedResponse) if err != nil { return nil, latestGeneration, false, err } // If the result field in the response is null, the server is saying that // the team has never published a teamEKStatement, stale or otherwise. if parsedResponse.Sig == nil { mctx.Debug("team has no teamEKStatement at all") return nil, latestGeneration, false, nil } statement, latestGeneration, wrongKID, err = verifySigWithLatestPTK(mctx, teamID, *parsedResponse.Sig) // Check the wrongKID condition before checking the error, since an error // is still returned in this case. TODO: Turn this warning into an error // after EK support is sufficiently widespread. if wrongKID { mctx.Debug("It looks like someone rolled the PTK without generating new ephemeral keys. They might be on an old version.") return nil, latestGeneration, true, nil } else if err != nil { return nil, latestGeneration, false, err } return statement, latestGeneration, false, nil }
[ "func", "fetchTeamEKStatement", "(", "mctx", "libkb", ".", "MetaContext", ",", "teamID", "keybase1", ".", "TeamID", ")", "(", "statement", "*", "keybase1", ".", "TeamEkStatement", ",", "latestGeneration", "keybase1", ".", "EkGeneration", ",", "wrongKID", "bool", ...
// Returns nil if the team has never published a teamEK. If the team has // published a teamEK, but has since rolled their PTK without publishing a new // one, this function will also return nil and log a warning. This is a // transitional thing, and eventually when all "reasonably up to date" clients // in the wild have EK support, we will make that case an error.
[ "Returns", "nil", "if", "the", "team", "has", "never", "published", "a", "teamEK", ".", "If", "the", "team", "has", "published", "a", "teamEK", "but", "has", "since", "rolled", "their", "PTK", "without", "publishing", "a", "new", "one", "this", "function",...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/ephemeral/team_ek.go#L249-L290
160,823
keybase/client
go/ephemeral/team_ek.go
fetchTeamMemberStatements
func fetchTeamMemberStatements(mctx libkb.MetaContext, teamID keybase1.TeamID) (statementMap map[keybase1.UID]*keybase1.UserEkStatement, err error) { defer mctx.TraceTimed("fetchTeamMemberStatements", func() error { return err })() apiArg := libkb.APIArg{ Endpoint: "team/member_eks", SessionType: libkb.APISessionTypeREQUIRED, Args: libkb.HTTPArgs{ "team_id": libkb.S{Val: string(teamID)}, }, } res, err := mctx.G().GetAPI().Get(mctx, apiArg) if err != nil { return nil, err } parsedResponse := teamMemberEKStatementResponse{} err = res.Body.UnmarshalAgain(&parsedResponse) if err != nil { return nil, err } team, err := teams.Load(mctx.Ctx(), mctx.G(), keybase1.LoadTeamArg{ ID: teamID, ForceRepoll: true, }) if err != nil { return nil, err } statementMap = make(map[keybase1.UID]*keybase1.UserEkStatement) for uid, sig := range parsedResponse.Sigs { // Verify the server only returns actual members of our team. upak, _, err := mctx.G().GetUPAKLoader().LoadV2( libkb.NewLoadUserArgWithMetaContext(mctx).WithUID(uid)) if err != nil { return nil, err } uv := upak.Current.ToUserVersion() isMember := team.IsMember(mctx.Ctx(), uv) if !isMember { return nil, fmt.Errorf("Server lied about team membership! %v is not a member of team %v", uv, teamID) } memberStatement, _, wrongKID, err := verifySigWithLatestPUK(mctx, uid, sig) // Check the wrongKID condition before checking the error, since an error // is still returned in this case. TODO: Turn this warning into an error // after EK support is sufficiently widespread. if wrongKID { mctx.Debug("Member %v revoked a device without generating new ephemeral keys. They might be running an old version?", uid) // Don't box for this member since they have no valid userEK continue } else if err != nil { return nil, err } statementMap[uid] = memberStatement } return statementMap, nil }
go
func fetchTeamMemberStatements(mctx libkb.MetaContext, teamID keybase1.TeamID) (statementMap map[keybase1.UID]*keybase1.UserEkStatement, err error) { defer mctx.TraceTimed("fetchTeamMemberStatements", func() error { return err })() apiArg := libkb.APIArg{ Endpoint: "team/member_eks", SessionType: libkb.APISessionTypeREQUIRED, Args: libkb.HTTPArgs{ "team_id": libkb.S{Val: string(teamID)}, }, } res, err := mctx.G().GetAPI().Get(mctx, apiArg) if err != nil { return nil, err } parsedResponse := teamMemberEKStatementResponse{} err = res.Body.UnmarshalAgain(&parsedResponse) if err != nil { return nil, err } team, err := teams.Load(mctx.Ctx(), mctx.G(), keybase1.LoadTeamArg{ ID: teamID, ForceRepoll: true, }) if err != nil { return nil, err } statementMap = make(map[keybase1.UID]*keybase1.UserEkStatement) for uid, sig := range parsedResponse.Sigs { // Verify the server only returns actual members of our team. upak, _, err := mctx.G().GetUPAKLoader().LoadV2( libkb.NewLoadUserArgWithMetaContext(mctx).WithUID(uid)) if err != nil { return nil, err } uv := upak.Current.ToUserVersion() isMember := team.IsMember(mctx.Ctx(), uv) if !isMember { return nil, fmt.Errorf("Server lied about team membership! %v is not a member of team %v", uv, teamID) } memberStatement, _, wrongKID, err := verifySigWithLatestPUK(mctx, uid, sig) // Check the wrongKID condition before checking the error, since an error // is still returned in this case. TODO: Turn this warning into an error // after EK support is sufficiently widespread. if wrongKID { mctx.Debug("Member %v revoked a device without generating new ephemeral keys. They might be running an old version?", uid) // Don't box for this member since they have no valid userEK continue } else if err != nil { return nil, err } statementMap[uid] = memberStatement } return statementMap, nil }
[ "func", "fetchTeamMemberStatements", "(", "mctx", "libkb", ".", "MetaContext", ",", "teamID", "keybase1", ".", "TeamID", ")", "(", "statementMap", "map", "[", "keybase1", ".", "UID", "]", "*", "keybase1", ".", "UserEkStatement", ",", "err", "error", ")", "{"...
// Returns nil if all team members have never published a teamEK. Verifies that // the map of users the server returns are indeed valid team members of the // team and all signatures verify correctly for the users.
[ "Returns", "nil", "if", "all", "team", "members", "have", "never", "published", "a", "teamEK", ".", "Verifies", "that", "the", "map", "of", "users", "the", "server", "returns", "are", "indeed", "valid", "team", "members", "of", "the", "team", "and", "all",...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/ephemeral/team_ek.go#L369-L425
160,824
keybase/client
go/kbfs/libdokan/folderlist.go
userChanged
func (fl *FolderList) userChanged(ctx context.Context, _, newUser kbname.NormalizedUsername) { var fs []*Folder func() { fl.mu.Lock() defer fl.mu.Unlock() for _, tlf := range fl.folders { if tlf, ok := tlf.(*TLF); ok { fs = append(fs, tlf.folder) } } }() for _, f := range fs { f.TlfHandleChange(ctx, nil) } if newUser != kbname.NormalizedUsername("") { fl.fs.config.KBFSOps().ForceFastForward(ctx) } }
go
func (fl *FolderList) userChanged(ctx context.Context, _, newUser kbname.NormalizedUsername) { var fs []*Folder func() { fl.mu.Lock() defer fl.mu.Unlock() for _, tlf := range fl.folders { if tlf, ok := tlf.(*TLF); ok { fs = append(fs, tlf.folder) } } }() for _, f := range fs { f.TlfHandleChange(ctx, nil) } if newUser != kbname.NormalizedUsername("") { fl.fs.config.KBFSOps().ForceFastForward(ctx) } }
[ "func", "(", "fl", "*", "FolderList", ")", "userChanged", "(", "ctx", "context", ".", "Context", ",", "_", ",", "newUser", "kbname", ".", "NormalizedUsername", ")", "{", "var", "fs", "[", "]", "*", "Folder", "\n", "func", "(", ")", "{", "fl", ".", ...
// update things after user changed.
[ "update", "things", "after", "user", "changed", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libdokan/folderlist.go#L284-L301
160,825
keybase/client
go/teams/loader_ctx.go
getNewLinksFromServer
func (l *LoaderContextG) getNewLinksFromServer(ctx context.Context, teamID keybase1.TeamID, lows getLinksLows, readSubteamID *keybase1.TeamID) (*rawTeam, error) { return l.getLinksFromServerCommon(ctx, teamID, &lows, nil, readSubteamID) }
go
func (l *LoaderContextG) getNewLinksFromServer(ctx context.Context, teamID keybase1.TeamID, lows getLinksLows, readSubteamID *keybase1.TeamID) (*rawTeam, error) { return l.getLinksFromServerCommon(ctx, teamID, &lows, nil, readSubteamID) }
[ "func", "(", "l", "*", "LoaderContextG", ")", "getNewLinksFromServer", "(", "ctx", "context", ".", "Context", ",", "teamID", "keybase1", ".", "TeamID", ",", "lows", "getLinksLows", ",", "readSubteamID", "*", "keybase1", ".", "TeamID", ")", "(", "*", "rawTeam...
// Get new links from the server.
[ "Get", "new", "links", "from", "the", "server", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/loader_ctx.go#L105-L109
160,826
keybase/client
go/teams/loader_ctx.go
getLinksFromServer
func (l *LoaderContextG) getLinksFromServer(ctx context.Context, teamID keybase1.TeamID, requestSeqnos []keybase1.Seqno, readSubteamID *keybase1.TeamID) (*rawTeam, error) { return l.getLinksFromServerCommon(ctx, teamID, nil, requestSeqnos, readSubteamID) }
go
func (l *LoaderContextG) getLinksFromServer(ctx context.Context, teamID keybase1.TeamID, requestSeqnos []keybase1.Seqno, readSubteamID *keybase1.TeamID) (*rawTeam, error) { return l.getLinksFromServerCommon(ctx, teamID, nil, requestSeqnos, readSubteamID) }
[ "func", "(", "l", "*", "LoaderContextG", ")", "getLinksFromServer", "(", "ctx", "context", ".", "Context", ",", "teamID", "keybase1", ".", "TeamID", ",", "requestSeqnos", "[", "]", "keybase1", ".", "Seqno", ",", "readSubteamID", "*", "keybase1", ".", "TeamID...
// Get full links from the server. // Does not guarantee that the server returned the correct links, nor that they are unstubbed.
[ "Get", "full", "links", "from", "the", "server", ".", "Does", "not", "guarantee", "that", "the", "server", "returned", "the", "correct", "links", "nor", "that", "they", "are", "unstubbed", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/teams/loader_ctx.go#L113-L116
160,827
keybase/client
go/kbfs/libkbfs/coalescing_context.go
NewCoalescingContext
func NewCoalescingContext(parent context.Context) (*CoalescingContext, context.CancelFunc) { ctx := &CoalescingContext{ // Make the parent's `Value()` method available to consumers of this // context. For example, this maintains the parent's log debug tags. // TODO: Make _all_ parents' values available. Context: parent, doneCh: make(chan struct{}), mutateCh: make(chan context.Context), } closeCh := make(chan struct{}) ctx.selects = []reflect.SelectCase{ { Dir: reflect.SelectRecv, Chan: reflect.ValueOf(ctx.mutateCh), }, { Dir: reflect.SelectRecv, Chan: reflect.ValueOf(closeCh), }, } ctx.appendContext(parent) go ctx.loop() cancelFunc := func() { select { case <-closeCh: default: close(closeCh) } } return ctx, cancelFunc }
go
func NewCoalescingContext(parent context.Context) (*CoalescingContext, context.CancelFunc) { ctx := &CoalescingContext{ // Make the parent's `Value()` method available to consumers of this // context. For example, this maintains the parent's log debug tags. // TODO: Make _all_ parents' values available. Context: parent, doneCh: make(chan struct{}), mutateCh: make(chan context.Context), } closeCh := make(chan struct{}) ctx.selects = []reflect.SelectCase{ { Dir: reflect.SelectRecv, Chan: reflect.ValueOf(ctx.mutateCh), }, { Dir: reflect.SelectRecv, Chan: reflect.ValueOf(closeCh), }, } ctx.appendContext(parent) go ctx.loop() cancelFunc := func() { select { case <-closeCh: default: close(closeCh) } } return ctx, cancelFunc }
[ "func", "NewCoalescingContext", "(", "parent", "context", ".", "Context", ")", "(", "*", "CoalescingContext", ",", "context", ".", "CancelFunc", ")", "{", "ctx", ":=", "&", "CoalescingContext", "{", "// Make the parent's `Value()` method available to consumers of this", ...
// NewCoalescingContext creates a new CoalescingContext. The context _must_ be // canceled to avoid a goroutine leak.
[ "NewCoalescingContext", "creates", "a", "new", "CoalescingContext", ".", "The", "context", "_must_", "be", "canceled", "to", "avoid", "a", "goroutine", "leak", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/coalescing_context.go#L63-L93
160,828
keybase/client
go/kbfs/libkbfs/coalescing_context.go
AddContext
func (ctx *CoalescingContext) AddContext(other context.Context) error { select { case ctx.mutateCh <- other: return nil case <-ctx.doneCh: return context.Canceled } }
go
func (ctx *CoalescingContext) AddContext(other context.Context) error { select { case ctx.mutateCh <- other: return nil case <-ctx.doneCh: return context.Canceled } }
[ "func", "(", "ctx", "*", "CoalescingContext", ")", "AddContext", "(", "other", "context", ".", "Context", ")", "error", "{", "select", "{", "case", "ctx", ".", "mutateCh", "<-", "other", ":", "return", "nil", "\n", "case", "<-", "ctx", ".", "doneCh", "...
// AddContext adds a context to the set of contexts that we're waiting on.
[ "AddContext", "adds", "a", "context", "to", "the", "set", "of", "contexts", "that", "we", "re", "waiting", "on", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/coalescing_context.go#L118-L125
160,829
keybase/client
go/libkb/kex2_router.go
Post
func (k *KexRouter) Post(sessID kex2.SessionID, sender kex2.DeviceID, seqno kex2.Seqno, msg []byte) (err error) { mctx := k.M().WithLogTag("KEXR") mctx.Debug("+ KexRouter.Post(%x, %x, %d, ...)", sessID, sender, seqno) defer func() { mctx.Debug("- KexRouter.Post(%x, %x, %d) -> %s", sessID, sender, seqno, ErrToOk(err)) }() arg := APIArg{ Endpoint: "kex2/send", Args: HTTPArgs{ "I": HexArg(sessID[:]), "sender": HexArg(sender[:]), "seqno": I{Val: int(seqno)}, "msg": B64Arg(msg), }, } mctx = mctx.BackgroundWithLogTags() kexAPITimeout(&arg, time.Second*5) _, err = mctx.G().API.Post(mctx, arg) return err }
go
func (k *KexRouter) Post(sessID kex2.SessionID, sender kex2.DeviceID, seqno kex2.Seqno, msg []byte) (err error) { mctx := k.M().WithLogTag("KEXR") mctx.Debug("+ KexRouter.Post(%x, %x, %d, ...)", sessID, sender, seqno) defer func() { mctx.Debug("- KexRouter.Post(%x, %x, %d) -> %s", sessID, sender, seqno, ErrToOk(err)) }() arg := APIArg{ Endpoint: "kex2/send", Args: HTTPArgs{ "I": HexArg(sessID[:]), "sender": HexArg(sender[:]), "seqno": I{Val: int(seqno)}, "msg": B64Arg(msg), }, } mctx = mctx.BackgroundWithLogTags() kexAPITimeout(&arg, time.Second*5) _, err = mctx.G().API.Post(mctx, arg) return err }
[ "func", "(", "k", "*", "KexRouter", ")", "Post", "(", "sessID", "kex2", ".", "SessionID", ",", "sender", "kex2", ".", "DeviceID", ",", "seqno", "kex2", ".", "Seqno", ",", "msg", "[", "]", "byte", ")", "(", "err", "error", ")", "{", "mctx", ":=", ...
// Post implements Post in the kex2.MessageRouter interface.
[ "Post", "implements", "Post", "in", "the", "kex2", ".", "MessageRouter", "interface", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/kex2_router.go#L26-L47
160,830
keybase/client
go/libkb/kex2_router.go
Get
func (k *KexRouter) Get(sessID kex2.SessionID, receiver kex2.DeviceID, low kex2.Seqno, poll time.Duration) (msgs [][]byte, err error) { mctx := k.M().WithLogTag("KEXR") mctx.Debug("+ KexRouter.Get(%x, %x, %d, %s)", sessID, receiver, low, poll) defer func() { mctx.Debug("- KexRouter.Get(%x, %x, %d, %s) -> %s (messages: %d)", sessID, receiver, low, poll, ErrToOk(err), len(msgs)) }() if poll > HTTPPollMaximum { poll = HTTPPollMaximum } arg := APIArg{ Endpoint: "kex2/receive", Args: HTTPArgs{ "I": HexArg(sessID[:]), "receiver": HexArg(receiver[:]), "low": I{Val: int(low)}, "poll": I{Val: int(poll / time.Millisecond)}, }, } kexAPITimeout(&arg, 2*poll) var j kexResp if err = mctx.G().API.GetDecode(mctx.BackgroundWithLogTags(), arg, &j); err != nil { return nil, err } if j.Status.Code != SCOk { return nil, AppStatusError{Code: j.Status.Code, Name: j.Status.Name, Desc: j.Status.Desc} } for _, m := range j.Msgs { dec, err := base64.StdEncoding.DecodeString(m.Msg) if err != nil { return nil, err } msgs = append(msgs, dec) } return msgs, nil }
go
func (k *KexRouter) Get(sessID kex2.SessionID, receiver kex2.DeviceID, low kex2.Seqno, poll time.Duration) (msgs [][]byte, err error) { mctx := k.M().WithLogTag("KEXR") mctx.Debug("+ KexRouter.Get(%x, %x, %d, %s)", sessID, receiver, low, poll) defer func() { mctx.Debug("- KexRouter.Get(%x, %x, %d, %s) -> %s (messages: %d)", sessID, receiver, low, poll, ErrToOk(err), len(msgs)) }() if poll > HTTPPollMaximum { poll = HTTPPollMaximum } arg := APIArg{ Endpoint: "kex2/receive", Args: HTTPArgs{ "I": HexArg(sessID[:]), "receiver": HexArg(receiver[:]), "low": I{Val: int(low)}, "poll": I{Val: int(poll / time.Millisecond)}, }, } kexAPITimeout(&arg, 2*poll) var j kexResp if err = mctx.G().API.GetDecode(mctx.BackgroundWithLogTags(), arg, &j); err != nil { return nil, err } if j.Status.Code != SCOk { return nil, AppStatusError{Code: j.Status.Code, Name: j.Status.Name, Desc: j.Status.Desc} } for _, m := range j.Msgs { dec, err := base64.StdEncoding.DecodeString(m.Msg) if err != nil { return nil, err } msgs = append(msgs, dec) } return msgs, nil }
[ "func", "(", "k", "*", "KexRouter", ")", "Get", "(", "sessID", "kex2", ".", "SessionID", ",", "receiver", "kex2", ".", "DeviceID", ",", "low", "kex2", ".", "Seqno", ",", "poll", "time", ".", "Duration", ")", "(", "msgs", "[", "]", "[", "]", "byte",...
// Get implements Get in the kex2.MessageRouter interface.
[ "Get", "implements", "Get", "in", "the", "kex2", ".", "MessageRouter", "interface", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/libkb/kex2_router.go#L71-L110
160,831
keybase/client
go/client/cmd_simplefs_read.go
NewCmdSimpleFSRead
func NewCmdSimpleFSRead(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command { return cli.Command{ Name: "read", ArgumentHelp: "<path>", Usage: "output file contents to standard output", Action: func(c *cli.Context) { cl.ChooseCommand(&CmdSimpleFSRead{Contextified: libkb.NewContextified(g)}, "read", c) cl.SetNoStandalone() }, Flags: []cli.Flag{ cli.IntFlag{ Name: "b, buffersize", Value: readBufSizeDefault, Usage: "read buffer size", }, cli.IntFlag{ Name: "rev", Usage: "a revision number for the KBFS folder", }, cli.StringFlag{ Name: "time", Usage: "a time for the KBFS folder (eg \"2018-07-27 22:05\")", }, cli.StringFlag{ Name: "reltime, relative-time", Usage: "a relative time for the KBFS folder (eg \"5m\")", }, }, } }
go
func NewCmdSimpleFSRead(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command { return cli.Command{ Name: "read", ArgumentHelp: "<path>", Usage: "output file contents to standard output", Action: func(c *cli.Context) { cl.ChooseCommand(&CmdSimpleFSRead{Contextified: libkb.NewContextified(g)}, "read", c) cl.SetNoStandalone() }, Flags: []cli.Flag{ cli.IntFlag{ Name: "b, buffersize", Value: readBufSizeDefault, Usage: "read buffer size", }, cli.IntFlag{ Name: "rev", Usage: "a revision number for the KBFS folder", }, cli.StringFlag{ Name: "time", Usage: "a time for the KBFS folder (eg \"2018-07-27 22:05\")", }, cli.StringFlag{ Name: "reltime, relative-time", Usage: "a relative time for the KBFS folder (eg \"5m\")", }, }, } }
[ "func", "NewCmdSimpleFSRead", "(", "cl", "*", "libcmdline", ".", "CommandLine", ",", "g", "*", "libkb", ".", "GlobalContext", ")", "cli", ".", "Command", "{", "return", "cli", ".", "Command", "{", "Name", ":", "\"", "\"", ",", "ArgumentHelp", ":", "\"", ...
// NewCmdSimpleFSRead creates a new cli.Command.
[ "NewCmdSimpleFSRead", "creates", "a", "new", "cli", ".", "Command", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/client/cmd_simplefs_read.go#L27-L56
160,832
keybase/client
go/logger/buffer.go
NewAutoFlushingBufferedWriter
func NewAutoFlushingBufferedWriter(baseWriter io.Writer, flushFrequency time.Duration) (w io.Writer, shutdown chan struct{}, done chan struct{}) { result := &autoFlushingBufferedWriter{ bufferedWriter: bufio.NewWriter(baseWriter), backupWriter: bufio.NewWriter(baseWriter), frequency: flushFrequency, timer: newTriggerableTimer(flushFrequency), shutdown: make(chan struct{}), doneShutdown: make(chan struct{}), } go result.backgroundFlush() return result, result.shutdown, result.doneShutdown }
go
func NewAutoFlushingBufferedWriter(baseWriter io.Writer, flushFrequency time.Duration) (w io.Writer, shutdown chan struct{}, done chan struct{}) { result := &autoFlushingBufferedWriter{ bufferedWriter: bufio.NewWriter(baseWriter), backupWriter: bufio.NewWriter(baseWriter), frequency: flushFrequency, timer: newTriggerableTimer(flushFrequency), shutdown: make(chan struct{}), doneShutdown: make(chan struct{}), } go result.backgroundFlush() return result, result.shutdown, result.doneShutdown }
[ "func", "NewAutoFlushingBufferedWriter", "(", "baseWriter", "io", ".", "Writer", ",", "flushFrequency", "time", ".", "Duration", ")", "(", "w", "io", ".", "Writer", ",", "shutdown", "chan", "struct", "{", "}", ",", "done", "chan", "struct", "{", "}", ")", ...
// NewAutoFlushingBufferedWriter returns an io.Writer that buffers its output // and flushes automatically after `flushFrequency`.
[ "NewAutoFlushingBufferedWriter", "returns", "an", "io", ".", "Writer", "that", "buffers", "its", "output", "and", "flushes", "automatically", "after", "flushFrequency", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/logger/buffer.go#L99-L111
160,833
keybase/client
go/logger/buffer.go
EnableBufferedLogging
func EnableBufferedLogging() { writer, shutdown, done := NewAutoFlushingBufferedWriter(ErrorWriter(), loggingFrequency) stdErrLoggingShutdown = shutdown stdErrLoggingShutdownDone = done logBackend := logging.NewLogBackend(writer, "", 0) logging.SetBackend(logBackend) }
go
func EnableBufferedLogging() { writer, shutdown, done := NewAutoFlushingBufferedWriter(ErrorWriter(), loggingFrequency) stdErrLoggingShutdown = shutdown stdErrLoggingShutdownDone = done logBackend := logging.NewLogBackend(writer, "", 0) logging.SetBackend(logBackend) }
[ "func", "EnableBufferedLogging", "(", ")", "{", "writer", ",", "shutdown", ",", "done", ":=", "NewAutoFlushingBufferedWriter", "(", "ErrorWriter", "(", ")", ",", "loggingFrequency", ")", "\n", "stdErrLoggingShutdown", "=", "shutdown", "\n", "stdErrLoggingShutdownDone"...
// EnableBufferedLogging turns on buffered logging - this is a performance // boost at the expense of not getting all the logs in a crash.
[ "EnableBufferedLogging", "turns", "on", "buffered", "logging", "-", "this", "is", "a", "performance", "boost", "at", "the", "expense", "of", "not", "getting", "all", "the", "logs", "in", "a", "crash", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/logger/buffer.go#L130-L136
160,834
keybase/client
go/kbfs/dokan/loaddll.go
loadLibrary
func loadLibrary(epc *errorPrinter, path string) (windows.Handle, error) { hdl, err := windows.LoadLibrary(path) epc.Printf("LoadLibrary(%q) -> %v,%v\n", path, hdl, err) return hdl, err }
go
func loadLibrary(epc *errorPrinter, path string) (windows.Handle, error) { hdl, err := windows.LoadLibrary(path) epc.Printf("LoadLibrary(%q) -> %v,%v\n", path, hdl, err) return hdl, err }
[ "func", "loadLibrary", "(", "epc", "*", "errorPrinter", ",", "path", "string", ")", "(", "windows", ".", "Handle", ",", "error", ")", "{", "hdl", ",", "err", ":=", "windows", ".", "LoadLibrary", "(", "path", ")", "\n", "epc", ".", "Printf", "(", "\""...
// loadLibrary calls win32 LoadLibrary and logs the result.
[ "loadLibrary", "calls", "win32", "LoadLibrary", "and", "logs", "the", "result", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/dokan/loaddll.go#L38-L42
160,835
keybase/client
go/kbfs/dokan/loaddll.go
doLoadDLL
func doLoadDLL(epc *errorPrinter, path string) (windows.Handle, error) { var guessPath bool epc.Printf("loadDokanDLL %q\n", path) if path == "" { path = shortPath guessPath = true } else { path = filepath.FromSlash(path) } const loadLibrarySearchSystem32 = 0x800 const flags = loadLibrarySearchSystem32 hdl, err := windows.LoadLibraryEx(path, 0, flags) epc.Printf("loadDokanDLL LoadLibraryEx(%q,0,%x) -> %v,%v\n", path, flags, hdl, err) if err == nil || !guessPath { return hdl, err } // User probably has not installed KB2533623 which is a security update // from 2011. Without this Windows security update loading libraries // is unsafe on Windows. // Continue to try to load the DLL regardless. if runtime.GOARCH == `386` { hdl, err = loadLibrary(epc, syswow64+shortPath) if err == nil { return hdl, nil } } hdl, err = loadLibrary(epc, system32+shortPath) if err == nil { return hdl, nil } hdl, err = loadLibrary(epc, shortPath) if err == nil { return hdl, nil } err = fmt.Errorf("loadDokanDLL: cannot load Dokan DLL: %v", err) epc.Printf("ERROR: %v\n", err) return 0, err }
go
func doLoadDLL(epc *errorPrinter, path string) (windows.Handle, error) { var guessPath bool epc.Printf("loadDokanDLL %q\n", path) if path == "" { path = shortPath guessPath = true } else { path = filepath.FromSlash(path) } const loadLibrarySearchSystem32 = 0x800 const flags = loadLibrarySearchSystem32 hdl, err := windows.LoadLibraryEx(path, 0, flags) epc.Printf("loadDokanDLL LoadLibraryEx(%q,0,%x) -> %v,%v\n", path, flags, hdl, err) if err == nil || !guessPath { return hdl, err } // User probably has not installed KB2533623 which is a security update // from 2011. Without this Windows security update loading libraries // is unsafe on Windows. // Continue to try to load the DLL regardless. if runtime.GOARCH == `386` { hdl, err = loadLibrary(epc, syswow64+shortPath) if err == nil { return hdl, nil } } hdl, err = loadLibrary(epc, system32+shortPath) if err == nil { return hdl, nil } hdl, err = loadLibrary(epc, shortPath) if err == nil { return hdl, nil } err = fmt.Errorf("loadDokanDLL: cannot load Dokan DLL: %v", err) epc.Printf("ERROR: %v\n", err) return 0, err }
[ "func", "doLoadDLL", "(", "epc", "*", "errorPrinter", ",", "path", "string", ")", "(", "windows", ".", "Handle", ",", "error", ")", "{", "var", "guessPath", "bool", "\n", "epc", ".", "Printf", "(", "\"", "\\n", "\"", ",", "path", ")", "\n", "if", "...
// doLoadDLL tries to load the dokan DLL from various locations.
[ "doLoadDLL", "tries", "to", "load", "the", "dokan", "DLL", "from", "various", "locations", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/dokan/loaddll.go#L45-L83
160,836
keybase/client
go/kbfs/dokan/loaddll.go
loadDokanDLL
func loadDokanDLL(cfg *Config) error { var epc errorPrinter err := doLoadDokanAndGetSymbols(&epc, cfg.DllPath) cfg.FileSystem.Printf("%s", epc.buf.Bytes()) return err }
go
func loadDokanDLL(cfg *Config) error { var epc errorPrinter err := doLoadDokanAndGetSymbols(&epc, cfg.DllPath) cfg.FileSystem.Printf("%s", epc.buf.Bytes()) return err }
[ "func", "loadDokanDLL", "(", "cfg", "*", "Config", ")", "error", "{", "var", "epc", "errorPrinter", "\n", "err", ":=", "doLoadDokanAndGetSymbols", "(", "&", "epc", ",", "cfg", ".", "DllPath", ")", "\n", "cfg", ".", "FileSystem", ".", "Printf", "(", "\"",...
// loadDokanDLL tries to load the dokan DLL from // the given path. Empty path is allowed and will // result in the location being guessed.
[ "loadDokanDLL", "tries", "to", "load", "the", "dokan", "DLL", "from", "the", "given", "path", ".", "Empty", "path", "is", "allowed", "and", "will", "result", "in", "the", "location", "being", "guessed", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/dokan/loaddll.go#L121-L126
160,837
keybase/client
go/stellar/transform.go
transformPaymentStellar
func transformPaymentStellar(mctx libkb.MetaContext, acctID stellar1.AccountID, p stellar1.PaymentSummaryStellar, oc OwnAccountLookupCache) (*stellar1.PaymentLocal, error) { loc, err := newPaymentLocal(mctx, p.TxID, p.Ctime, p.Amount, p.Asset) if err != nil { return nil, err } isSender := p.From.Eq(acctID) isRecipient := p.To.Eq(acctID) switch { case isSender && isRecipient: loc.Delta = stellar1.BalanceDelta_NONE case isSender: loc.Delta = stellar1.BalanceDelta_DECREASE case isRecipient: loc.Delta = stellar1.BalanceDelta_INCREASE } loc.FromAccountID = p.From loc.FromType = stellar1.ParticipantType_STELLAR loc.ToAccountID = &p.To loc.ToType = stellar1.ParticipantType_STELLAR fillOwnAccounts(mctx, loc, oc) loc.StatusSimplified = stellar1.PaymentStatus_COMPLETED loc.StatusDescription = strings.ToLower(loc.StatusSimplified.String()) loc.Unread = p.Unread loc.IsInflation = p.IsInflation loc.InflationSource = p.InflationSource return loc, nil }
go
func transformPaymentStellar(mctx libkb.MetaContext, acctID stellar1.AccountID, p stellar1.PaymentSummaryStellar, oc OwnAccountLookupCache) (*stellar1.PaymentLocal, error) { loc, err := newPaymentLocal(mctx, p.TxID, p.Ctime, p.Amount, p.Asset) if err != nil { return nil, err } isSender := p.From.Eq(acctID) isRecipient := p.To.Eq(acctID) switch { case isSender && isRecipient: loc.Delta = stellar1.BalanceDelta_NONE case isSender: loc.Delta = stellar1.BalanceDelta_DECREASE case isRecipient: loc.Delta = stellar1.BalanceDelta_INCREASE } loc.FromAccountID = p.From loc.FromType = stellar1.ParticipantType_STELLAR loc.ToAccountID = &p.To loc.ToType = stellar1.ParticipantType_STELLAR fillOwnAccounts(mctx, loc, oc) loc.StatusSimplified = stellar1.PaymentStatus_COMPLETED loc.StatusDescription = strings.ToLower(loc.StatusSimplified.String()) loc.Unread = p.Unread loc.IsInflation = p.IsInflation loc.InflationSource = p.InflationSource return loc, nil }
[ "func", "transformPaymentStellar", "(", "mctx", "libkb", ".", "MetaContext", ",", "acctID", "stellar1", ".", "AccountID", ",", "p", "stellar1", ".", "PaymentSummaryStellar", ",", "oc", "OwnAccountLookupCache", ")", "(", "*", "stellar1", ".", "PaymentLocal", ",", ...
// transformPaymentStellar converts a stellar1.PaymentSummaryStellar into a stellar1.PaymentLocal.
[ "transformPaymentStellar", "converts", "a", "stellar1", ".", "PaymentSummaryStellar", "into", "a", "stellar1", ".", "PaymentLocal", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/transform.go#L108-L138
160,838
keybase/client
go/stellar/transform.go
transformPaymentDirect
func transformPaymentDirect(mctx libkb.MetaContext, acctID stellar1.AccountID, p stellar1.PaymentSummaryDirect, oc OwnAccountLookupCache) (*stellar1.PaymentLocal, error) { loc, err := newPaymentLocal(mctx, p.TxID, p.Ctime, p.Amount, p.Asset) if err != nil { return nil, err } isSender := p.FromStellar.Eq(acctID) isRecipient := p.ToStellar.Eq(acctID) switch { case isSender && isRecipient: loc.Delta = stellar1.BalanceDelta_NONE case isSender: loc.Delta = stellar1.BalanceDelta_DECREASE case isRecipient: loc.Delta = stellar1.BalanceDelta_INCREASE } loc.Worth, _, err = formatWorth(mctx, p.DisplayAmount, p.DisplayCurrency) if err != nil { return nil, err } loc.FromAccountID = p.FromStellar loc.FromType = stellar1.ParticipantType_STELLAR if username, err := lookupUsername(mctx, p.From.Uid); err == nil { loc.FromUsername = username loc.FromType = stellar1.ParticipantType_KEYBASE } loc.ToAccountID = &p.ToStellar loc.ToType = stellar1.ParticipantType_STELLAR if p.To != nil { if username, err := lookupUsername(mctx, p.To.Uid); err == nil { loc.ToUsername = username loc.ToType = stellar1.ParticipantType_KEYBASE } } fillOwnAccounts(mctx, loc, oc) switch { case loc.FromAccountName != "": // we are sender loc.WorthAtSendTime, _, err = formatWorthAtSendTime(mctx, p, true) case loc.ToAccountName != "": // we are recipient loc.WorthAtSendTime, _, err = formatWorthAtSendTime(mctx, p, false) } if err != nil { return nil, err } loc.StatusSimplified = p.TxStatus.ToPaymentStatus() loc.StatusDescription = strings.ToLower(loc.StatusSimplified.String()) loc.StatusDetail = p.TxErrMsg loc.Note, loc.NoteErr = decryptNote(mctx, p.TxID, p.NoteB64) loc.SourceAmountMax = p.SourceAmountMax loc.SourceAmountActual = p.SourceAmountActual loc.SourceAsset = p.SourceAsset return loc, nil }
go
func transformPaymentDirect(mctx libkb.MetaContext, acctID stellar1.AccountID, p stellar1.PaymentSummaryDirect, oc OwnAccountLookupCache) (*stellar1.PaymentLocal, error) { loc, err := newPaymentLocal(mctx, p.TxID, p.Ctime, p.Amount, p.Asset) if err != nil { return nil, err } isSender := p.FromStellar.Eq(acctID) isRecipient := p.ToStellar.Eq(acctID) switch { case isSender && isRecipient: loc.Delta = stellar1.BalanceDelta_NONE case isSender: loc.Delta = stellar1.BalanceDelta_DECREASE case isRecipient: loc.Delta = stellar1.BalanceDelta_INCREASE } loc.Worth, _, err = formatWorth(mctx, p.DisplayAmount, p.DisplayCurrency) if err != nil { return nil, err } loc.FromAccountID = p.FromStellar loc.FromType = stellar1.ParticipantType_STELLAR if username, err := lookupUsername(mctx, p.From.Uid); err == nil { loc.FromUsername = username loc.FromType = stellar1.ParticipantType_KEYBASE } loc.ToAccountID = &p.ToStellar loc.ToType = stellar1.ParticipantType_STELLAR if p.To != nil { if username, err := lookupUsername(mctx, p.To.Uid); err == nil { loc.ToUsername = username loc.ToType = stellar1.ParticipantType_KEYBASE } } fillOwnAccounts(mctx, loc, oc) switch { case loc.FromAccountName != "": // we are sender loc.WorthAtSendTime, _, err = formatWorthAtSendTime(mctx, p, true) case loc.ToAccountName != "": // we are recipient loc.WorthAtSendTime, _, err = formatWorthAtSendTime(mctx, p, false) } if err != nil { return nil, err } loc.StatusSimplified = p.TxStatus.ToPaymentStatus() loc.StatusDescription = strings.ToLower(loc.StatusSimplified.String()) loc.StatusDetail = p.TxErrMsg loc.Note, loc.NoteErr = decryptNote(mctx, p.TxID, p.NoteB64) loc.SourceAmountMax = p.SourceAmountMax loc.SourceAmountActual = p.SourceAmountActual loc.SourceAsset = p.SourceAsset return loc, nil }
[ "func", "transformPaymentDirect", "(", "mctx", "libkb", ".", "MetaContext", ",", "acctID", "stellar1", ".", "AccountID", ",", "p", "stellar1", ".", "PaymentSummaryDirect", ",", "oc", "OwnAccountLookupCache", ")", "(", "*", "stellar1", ".", "PaymentLocal", ",", "...
// transformPaymentDirect converts a stellar1.PaymentSummaryDirect into a stellar1.PaymentLocal.
[ "transformPaymentDirect", "converts", "a", "stellar1", ".", "PaymentSummaryDirect", "into", "a", "stellar1", ".", "PaymentLocal", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/transform.go#L152-L214
160,839
keybase/client
go/stellar/transform.go
TransformToAirdropStatus
func TransformToAirdropStatus(status remote.AirdropStatusAPI) stellar1.AirdropStatus { var out stellar1.AirdropStatus switch { case status.AlreadyRegistered: out.State = stellar1.AirdropAccepted case status.Qualifications.QualifiesOverall: out.State = stellar1.AirdropQualified default: out.State = stellar1.AirdropUnqualified } dq := stellar1.AirdropQualification{ Title: status.AirdropConfig.MinActiveDevicesTitle, Valid: status.Qualifications.HasEnoughDevices, } out.Rows = append(out.Rows, dq) aq := stellar1.AirdropQualification{ Title: status.AirdropConfig.AccountCreationTitle, } var used []string for k, q := range status.Qualifications.ServiceChecks { if q.Qualifies { aq.Valid = true break } if q.Username == "" { continue } if !q.IsOldEnough { continue } if q.IsUsedAlready { used = append(used, fmt.Sprintf("%s@%s", q.Username, k)) } } if !aq.Valid { aq.Subtitle = status.AirdropConfig.AccountCreationSubtitle if len(used) > 0 { usedDisplay := strings.Join(used, ", ") aq.Subtitle += " " + fmt.Sprintf(status.AirdropConfig.AccountUsed, usedDisplay) } } out.Rows = append(out.Rows, aq) return out }
go
func TransformToAirdropStatus(status remote.AirdropStatusAPI) stellar1.AirdropStatus { var out stellar1.AirdropStatus switch { case status.AlreadyRegistered: out.State = stellar1.AirdropAccepted case status.Qualifications.QualifiesOverall: out.State = stellar1.AirdropQualified default: out.State = stellar1.AirdropUnqualified } dq := stellar1.AirdropQualification{ Title: status.AirdropConfig.MinActiveDevicesTitle, Valid: status.Qualifications.HasEnoughDevices, } out.Rows = append(out.Rows, dq) aq := stellar1.AirdropQualification{ Title: status.AirdropConfig.AccountCreationTitle, } var used []string for k, q := range status.Qualifications.ServiceChecks { if q.Qualifies { aq.Valid = true break } if q.Username == "" { continue } if !q.IsOldEnough { continue } if q.IsUsedAlready { used = append(used, fmt.Sprintf("%s@%s", q.Username, k)) } } if !aq.Valid { aq.Subtitle = status.AirdropConfig.AccountCreationSubtitle if len(used) > 0 { usedDisplay := strings.Join(used, ", ") aq.Subtitle += " " + fmt.Sprintf(status.AirdropConfig.AccountUsed, usedDisplay) } } out.Rows = append(out.Rows, aq) return out }
[ "func", "TransformToAirdropStatus", "(", "status", "remote", ".", "AirdropStatusAPI", ")", "stellar1", ".", "AirdropStatus", "{", "var", "out", "stellar1", ".", "AirdropStatus", "\n", "switch", "{", "case", "status", ".", "AlreadyRegistered", ":", "out", ".", "S...
// TransformToAirdropStatus takes the result from api server status_check // and transforms it into stellar1.AirdropStatus.
[ "TransformToAirdropStatus", "takes", "the", "result", "from", "api", "server", "status_check", "and", "transforms", "it", "into", "stellar1", ".", "AirdropStatus", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/stellar/transform.go#L537-L584
160,840
keybase/client
go/chat/utils/locktab.go
deadlockDetect
func (c *ConversationLockTab) deadlockDetect(ctx context.Context, trace string, waiters map[string]bool) bool { // See if this trace is waiting on any other trace waitingOnTrace, ok := c.waits[trace] if !ok { // If not, no deadlock return false } // If we are waiting on a trace we have already encountered, then we have hit a deadlock if waiters[waitingOnTrace] { c.Debug(ctx, "deadlockDetect: deadlock detected: trace: %s waitingOnTrace: %s waiters: %v", trace, waitingOnTrace, waiters) return true } // Set the current trace as waiting, and then continue down the chain waiters[trace] = true return c.deadlockDetect(ctx, waitingOnTrace, waiters) }
go
func (c *ConversationLockTab) deadlockDetect(ctx context.Context, trace string, waiters map[string]bool) bool { // See if this trace is waiting on any other trace waitingOnTrace, ok := c.waits[trace] if !ok { // If not, no deadlock return false } // If we are waiting on a trace we have already encountered, then we have hit a deadlock if waiters[waitingOnTrace] { c.Debug(ctx, "deadlockDetect: deadlock detected: trace: %s waitingOnTrace: %s waiters: %v", trace, waitingOnTrace, waiters) return true } // Set the current trace as waiting, and then continue down the chain waiters[trace] = true return c.deadlockDetect(ctx, waitingOnTrace, waiters) }
[ "func", "(", "c", "*", "ConversationLockTab", ")", "deadlockDetect", "(", "ctx", "context", ".", "Context", ",", "trace", "string", ",", "waiters", "map", "[", "string", "]", "bool", ")", "bool", "{", "// See if this trace is waiting on any other trace", "waitingO...
// deadlockDetect tries to find a deadlock condition in the current set of waiting acquirers.
[ "deadlockDetect", "tries", "to", "find", "a", "deadlock", "condition", "in", "the", "current", "set", "of", "waiting", "acquirers", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/utils/locktab.go#L67-L83
160,841
keybase/client
go/chat/utils/locktab.go
Acquire
func (c *ConversationLockTab) Acquire(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID) (blocked bool, err error) { sleep := 200 * time.Millisecond for i := 0; i < c.maxAcquireRetries; i++ { blocked, err = c.doAcquire(ctx, uid, convID) if err != nil { if err != ErrConvLockTabDeadlock { return true, err } c.Debug(ctx, "Acquire: deadlock condition detected, sleeping and trying again: attempt: %d", i) time.Sleep(sleep) continue } return blocked, nil } c.Debug(ctx, "Acquire: giving up, max attempts reached") return true, ErrConvLockTabDeadlock }
go
func (c *ConversationLockTab) Acquire(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID) (blocked bool, err error) { sleep := 200 * time.Millisecond for i := 0; i < c.maxAcquireRetries; i++ { blocked, err = c.doAcquire(ctx, uid, convID) if err != nil { if err != ErrConvLockTabDeadlock { return true, err } c.Debug(ctx, "Acquire: deadlock condition detected, sleeping and trying again: attempt: %d", i) time.Sleep(sleep) continue } return blocked, nil } c.Debug(ctx, "Acquire: giving up, max attempts reached") return true, ErrConvLockTabDeadlock }
[ "func", "(", "c", "*", "ConversationLockTab", ")", "Acquire", "(", "ctx", "context", ".", "Context", ",", "uid", "gregor1", ".", "UID", ",", "convID", "chat1", ".", "ConversationID", ")", "(", "blocked", "bool", ",", "err", "error", ")", "{", "sleep", ...
// Acquire obtains a per user per conversation lock on a per trace basis. That is, the lock is a // shared lock for the current chat trace, and serves to synchronize large chat operations. If there is // no chat trace, this is a no-op.
[ "Acquire", "obtains", "a", "per", "user", "per", "conversation", "lock", "on", "a", "per", "trace", "basis", ".", "That", "is", "the", "lock", "is", "a", "shared", "lock", "for", "the", "current", "chat", "trace", "and", "serves", "to", "synchronize", "l...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/utils/locktab.go#L138-L154
160,842
keybase/client
go/chat/storage/storage_ephemeral_purge.go
EphemeralPurge
func (s *Storage) EphemeralPurge(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID, purgeInfo *chat1.EphemeralPurgeInfo) (newPurgeInfo *chat1.EphemeralPurgeInfo, explodedMsgs []chat1.MessageUnboxed, err Error) { defer s.Trace(ctx, func() error { return err }, "EphemeralPurge")() lock := locks.StorageLockTab.AcquireOnName(ctx, s.G(), convID.String()) defer lock.Release(ctx) if purgeInfo == nil { return nil, nil, nil } // Fetch secret key key, ierr := GetSecretBoxKey(ctx, s.G().ExternalG(), DefaultSecretUI) if ierr != nil { return nil, nil, MiscError{Msg: "unable to get secret key: " + ierr.Error()} } ctx, err = s.engine.Init(ctx, key, convID, uid) if err != nil { return nil, nil, err } maxMsgID, err := s.idtracker.getMaxMessageID(ctx, convID, uid) if err != nil { return nil, nil, err } // We don't care about holes. maxHoles := int(maxMsgID-purgeInfo.MinUnexplodedID) + 1 var target int if purgeInfo.MinUnexplodedID == 0 { target = 0 // we need to traverse the whole conversation } else { target = maxHoles } rc := NewHoleyResultCollector(maxHoles, NewSimpleResultCollector(target)) err = s.engine.ReadMessages(ctx, rc, convID, uid, maxMsgID, 0) switch err.(type) { case nil: // ok if len(rc.Result()) == 0 { err := s.ephemeralTracker.inactivatePurgeInfo(ctx, convID, uid) return nil, nil, err } case MissError: s.Debug(ctx, "record-only ephemeralTracker: no local messages") // We don't have these messages in cache, so don't retry this // conversation until further notice. err := s.ephemeralTracker.inactivatePurgeInfo(ctx, convID, uid) return nil, nil, err default: return nil, nil, err } newPurgeInfo, explodedMsgs, err = s.ephemeralPurgeHelper(ctx, convID, uid, rc.Result()) if err != nil { return nil, nil, err } err = s.ephemeralTracker.setPurgeInfo(ctx, convID, uid, newPurgeInfo) return newPurgeInfo, explodedMsgs, err }
go
func (s *Storage) EphemeralPurge(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID, purgeInfo *chat1.EphemeralPurgeInfo) (newPurgeInfo *chat1.EphemeralPurgeInfo, explodedMsgs []chat1.MessageUnboxed, err Error) { defer s.Trace(ctx, func() error { return err }, "EphemeralPurge")() lock := locks.StorageLockTab.AcquireOnName(ctx, s.G(), convID.String()) defer lock.Release(ctx) if purgeInfo == nil { return nil, nil, nil } // Fetch secret key key, ierr := GetSecretBoxKey(ctx, s.G().ExternalG(), DefaultSecretUI) if ierr != nil { return nil, nil, MiscError{Msg: "unable to get secret key: " + ierr.Error()} } ctx, err = s.engine.Init(ctx, key, convID, uid) if err != nil { return nil, nil, err } maxMsgID, err := s.idtracker.getMaxMessageID(ctx, convID, uid) if err != nil { return nil, nil, err } // We don't care about holes. maxHoles := int(maxMsgID-purgeInfo.MinUnexplodedID) + 1 var target int if purgeInfo.MinUnexplodedID == 0 { target = 0 // we need to traverse the whole conversation } else { target = maxHoles } rc := NewHoleyResultCollector(maxHoles, NewSimpleResultCollector(target)) err = s.engine.ReadMessages(ctx, rc, convID, uid, maxMsgID, 0) switch err.(type) { case nil: // ok if len(rc.Result()) == 0 { err := s.ephemeralTracker.inactivatePurgeInfo(ctx, convID, uid) return nil, nil, err } case MissError: s.Debug(ctx, "record-only ephemeralTracker: no local messages") // We don't have these messages in cache, so don't retry this // conversation until further notice. err := s.ephemeralTracker.inactivatePurgeInfo(ctx, convID, uid) return nil, nil, err default: return nil, nil, err } newPurgeInfo, explodedMsgs, err = s.ephemeralPurgeHelper(ctx, convID, uid, rc.Result()) if err != nil { return nil, nil, err } err = s.ephemeralTracker.setPurgeInfo(ctx, convID, uid, newPurgeInfo) return newPurgeInfo, explodedMsgs, err }
[ "func", "(", "s", "*", "Storage", ")", "EphemeralPurge", "(", "ctx", "context", ".", "Context", ",", "convID", "chat1", ".", "ConversationID", ",", "uid", "gregor1", ".", "UID", ",", "purgeInfo", "*", "chat1", ".", "EphemeralPurgeInfo", ")", "(", "newPurge...
// For a given conversation, purge all ephemeral messages from // purgeInfo.MinUnexplodedID to the present, updating bookkeeping for the next // time we need to purge this conv.
[ "For", "a", "given", "conversation", "purge", "all", "ephemeral", "messages", "from", "purgeInfo", ".", "MinUnexplodedID", "to", "the", "present", "updating", "bookkeeping", "for", "the", "next", "time", "we", "need", "to", "purge", "this", "conv", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/chat/storage/storage_ephemeral_purge.go#L19-L76
160,843
keybase/client
go/protocol/gregor1/extras.go
UIDListMerge
func UIDListMerge(list1 []UID, list2 []UID) []UID { m := make(map[string]UID) for _, uid := range list1 { m[uid.String()] = uid } for _, uid := range list2 { m[uid.String()] = uid } res := make([]UID, 0) for _, uid := range m { res = append(res, uid) } return res }
go
func UIDListMerge(list1 []UID, list2 []UID) []UID { m := make(map[string]UID) for _, uid := range list1 { m[uid.String()] = uid } for _, uid := range list2 { m[uid.String()] = uid } res := make([]UID, 0) for _, uid := range m { res = append(res, uid) } return res }
[ "func", "UIDListMerge", "(", "list1", "[", "]", "UID", ",", "list2", "[", "]", "UID", ")", "[", "]", "UID", "{", "m", ":=", "make", "(", "map", "[", "string", "]", "UID", ")", "\n", "for", "_", ",", "uid", ":=", "range", "list1", "{", "m", "[...
// Merge two lists of UIDs. Duplicates will be dropped. Not stably ordered.
[ "Merge", "two", "lists", "of", "UIDs", ".", "Duplicates", "will", "be", "dropped", ".", "Not", "stably", "ordered", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/gregor1/extras.go#L492-L505
160,844
keybase/client
go/kbfs/tlfhandle/resolve.go
ResolveAgain
func (h *Handle) ResolveAgain( ctx context.Context, resolver idutil.Resolver, idGetter IDGetter, osg idutil.OfflineStatusGetter) (*Handle, error) { if h.IsFinal() { // Don't attempt to further resolve final handles. return h, nil } return h.ResolveAgainForUser( ctx, resolver, idGetter, osg, keybase1.UID("")) }
go
func (h *Handle) ResolveAgain( ctx context.Context, resolver idutil.Resolver, idGetter IDGetter, osg idutil.OfflineStatusGetter) (*Handle, error) { if h.IsFinal() { // Don't attempt to further resolve final handles. return h, nil } return h.ResolveAgainForUser( ctx, resolver, idGetter, osg, keybase1.UID("")) }
[ "func", "(", "h", "*", "Handle", ")", "ResolveAgain", "(", "ctx", "context", ".", "Context", ",", "resolver", "idutil", ".", "Resolver", ",", "idGetter", "IDGetter", ",", "osg", "idutil", ".", "OfflineStatusGetter", ")", "(", "*", "Handle", ",", "error", ...
// ResolveAgain tries to resolve any unresolved assertions in the // given handle and returns a new handle with the results. As an // optimization, if h contains no unresolved assertions, it just // returns itself.
[ "ResolveAgain", "tries", "to", "resolve", "any", "unresolved", "assertions", "in", "the", "given", "handle", "and", "returns", "a", "new", "handle", "with", "the", "results", ".", "As", "an", "optimization", "if", "h", "contains", "no", "unresolved", "assertio...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/resolve.go#L433-L442
160,845
keybase/client
go/kbfs/tlfhandle/resolve.go
ResolvesTo
func (h Handle) ResolvesTo( ctx context.Context, codec kbfscodec.Codec, resolver idutil.Resolver, idGetter IDGetter, osg idutil.OfflineStatusGetter, other Handle) ( resolvesTo bool, partialResolvedH *Handle, err error) { // Check the conflict extension. var conflictAdded, finalizedAdded bool if !h.IsConflict() && other.IsConflict() { conflictAdded = true // Ignore the added extension for resolution comparison purposes. other.conflictInfo = nil } // Check the finalized extension. if h.IsFinal() { if conflictAdded { // Can't add conflict info to a finalized handle. return false, nil, HandleFinalizedError{} } } else if other.IsFinal() { finalizedAdded = true // Ignore the added extension for resolution comparison purposes. other.finalizedInfo = nil } if h.TypeForKeying() == tlf.TeamKeying { // Nothing to resolve for team-based TLFs, just use `other` by // itself. partialResolvedH = other.DeepCopy() } else { unresolvedAssertions := make(map[string]bool) for _, uw := range other.unresolvedWriters { unresolvedAssertions[uw.String()] = true } for _, ur := range other.unresolvedReaders { unresolvedAssertions[ur.String()] = true } // TODO: Once we keep track of the original assertions in // Handle, restrict the resolver to use other's assertions // only, so that we don't hit the network at all. partialResolvedH, err = h.ResolveAgain( ctx, partialResolver{resolver, unresolvedAssertions}, idGetter, osg) if err != nil { return false, nil, err } // If we're migrating, use the partially-resolved handle's // list of writers, readers, and conflict info, rather than // explicitly checking team membership. This is assuming that // we've already validated the migrating folder's name against // the user list in the current MD head (done via // `MDOps.GetIDForHandle()`). if other.TypeForKeying() == tlf.TeamKeying { if h.IsFinal() { return false, nil, errors.New("Can't migrate a finalized folder") } other.resolvedWriters = partialResolvedH.resolvedWriters other.resolvedReaders = partialResolvedH.resolvedReaders other.unresolvedWriters = partialResolvedH.unresolvedWriters other.unresolvedReaders = partialResolvedH.unresolvedReaders other.conflictInfo = partialResolvedH.conflictInfo } } if conflictAdded || finalizedAdded { resolvesTo, err = partialResolvedH.EqualsIgnoreName(codec, other) } else { resolvesTo, err = partialResolvedH.Equals(codec, other) } if err != nil { return false, nil, err } return resolvesTo, partialResolvedH, nil }
go
func (h Handle) ResolvesTo( ctx context.Context, codec kbfscodec.Codec, resolver idutil.Resolver, idGetter IDGetter, osg idutil.OfflineStatusGetter, other Handle) ( resolvesTo bool, partialResolvedH *Handle, err error) { // Check the conflict extension. var conflictAdded, finalizedAdded bool if !h.IsConflict() && other.IsConflict() { conflictAdded = true // Ignore the added extension for resolution comparison purposes. other.conflictInfo = nil } // Check the finalized extension. if h.IsFinal() { if conflictAdded { // Can't add conflict info to a finalized handle. return false, nil, HandleFinalizedError{} } } else if other.IsFinal() { finalizedAdded = true // Ignore the added extension for resolution comparison purposes. other.finalizedInfo = nil } if h.TypeForKeying() == tlf.TeamKeying { // Nothing to resolve for team-based TLFs, just use `other` by // itself. partialResolvedH = other.DeepCopy() } else { unresolvedAssertions := make(map[string]bool) for _, uw := range other.unresolvedWriters { unresolvedAssertions[uw.String()] = true } for _, ur := range other.unresolvedReaders { unresolvedAssertions[ur.String()] = true } // TODO: Once we keep track of the original assertions in // Handle, restrict the resolver to use other's assertions // only, so that we don't hit the network at all. partialResolvedH, err = h.ResolveAgain( ctx, partialResolver{resolver, unresolvedAssertions}, idGetter, osg) if err != nil { return false, nil, err } // If we're migrating, use the partially-resolved handle's // list of writers, readers, and conflict info, rather than // explicitly checking team membership. This is assuming that // we've already validated the migrating folder's name against // the user list in the current MD head (done via // `MDOps.GetIDForHandle()`). if other.TypeForKeying() == tlf.TeamKeying { if h.IsFinal() { return false, nil, errors.New("Can't migrate a finalized folder") } other.resolvedWriters = partialResolvedH.resolvedWriters other.resolvedReaders = partialResolvedH.resolvedReaders other.unresolvedWriters = partialResolvedH.unresolvedWriters other.unresolvedReaders = partialResolvedH.unresolvedReaders other.conflictInfo = partialResolvedH.conflictInfo } } if conflictAdded || finalizedAdded { resolvesTo, err = partialResolvedH.EqualsIgnoreName(codec, other) } else { resolvesTo, err = partialResolvedH.Equals(codec, other) } if err != nil { return false, nil, err } return resolvesTo, partialResolvedH, nil }
[ "func", "(", "h", "Handle", ")", "ResolvesTo", "(", "ctx", "context", ".", "Context", ",", "codec", "kbfscodec", ".", "Codec", ",", "resolver", "idutil", ".", "Resolver", ",", "idGetter", "IDGetter", ",", "osg", "idutil", ".", "OfflineStatusGetter", ",", "...
// ResolvesTo returns whether this handle resolves to the given one. // It also returns the partially-resolved version of h, i.e. h // resolved except for unresolved assertions in other; this should // equal other if and only if true is returned.
[ "ResolvesTo", "returns", "whether", "this", "handle", "resolves", "to", "the", "given", "one", ".", "It", "also", "returns", "the", "partially", "-", "resolved", "version", "of", "h", "i", ".", "e", ".", "h", "resolved", "except", "for", "unresolved", "ass...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/resolve.go#L465-L542
160,846
keybase/client
go/kbfs/tlfhandle/resolve.go
MutuallyResolvesTo
func (h Handle) MutuallyResolvesTo( ctx context.Context, codec kbfscodec.Codec, resolver idutil.Resolver, idGetter IDGetter, osg idutil.OfflineStatusGetter, other Handle, rev kbfsmd.Revision, tlfID tlf.ID, log logger.Logger) error { handleResolvesToOther, partialResolvedHandle, err := h.ResolvesTo(ctx, codec, resolver, idGetter, osg, other) if err != nil { return err } // TODO: If h has conflict info, other should, too. otherResolvesToHandle, partialResolvedOther, err := other.ResolvesTo(ctx, codec, resolver, idGetter, osg, h) if err != nil { return err } handlePath := h.GetCanonicalPath() otherPath := other.GetCanonicalPath() if !handleResolvesToOther && !otherResolvesToHandle { return HandleMismatchError{ rev, h.GetCanonicalPath(), tlfID, fmt.Errorf( "MD contained unexpected handle path %s (%s -> %s) (%s -> %s)", otherPath, h.GetCanonicalPath(), partialResolvedHandle.GetCanonicalPath(), other.GetCanonicalPath(), partialResolvedOther.GetCanonicalPath()), } } if handlePath != otherPath { log.CDebugf(ctx, "handle for %s resolved to %s", handlePath, otherPath) } return nil }
go
func (h Handle) MutuallyResolvesTo( ctx context.Context, codec kbfscodec.Codec, resolver idutil.Resolver, idGetter IDGetter, osg idutil.OfflineStatusGetter, other Handle, rev kbfsmd.Revision, tlfID tlf.ID, log logger.Logger) error { handleResolvesToOther, partialResolvedHandle, err := h.ResolvesTo(ctx, codec, resolver, idGetter, osg, other) if err != nil { return err } // TODO: If h has conflict info, other should, too. otherResolvesToHandle, partialResolvedOther, err := other.ResolvesTo(ctx, codec, resolver, idGetter, osg, h) if err != nil { return err } handlePath := h.GetCanonicalPath() otherPath := other.GetCanonicalPath() if !handleResolvesToOther && !otherResolvesToHandle { return HandleMismatchError{ rev, h.GetCanonicalPath(), tlfID, fmt.Errorf( "MD contained unexpected handle path %s (%s -> %s) (%s -> %s)", otherPath, h.GetCanonicalPath(), partialResolvedHandle.GetCanonicalPath(), other.GetCanonicalPath(), partialResolvedOther.GetCanonicalPath()), } } if handlePath != otherPath { log.CDebugf(ctx, "handle for %s resolved to %s", handlePath, otherPath) } return nil }
[ "func", "(", "h", "Handle", ")", "MutuallyResolvesTo", "(", "ctx", "context", ".", "Context", ",", "codec", "kbfscodec", ".", "Codec", ",", "resolver", "idutil", ".", "Resolver", ",", "idGetter", "IDGetter", ",", "osg", "idutil", ".", "OfflineStatusGetter", ...
// MutuallyResolvesTo checks that the target handle, and the provided // `other` handle, resolve to each other.
[ "MutuallyResolvesTo", "checks", "that", "the", "target", "handle", "and", "the", "provided", "other", "handle", "resolve", "to", "each", "other", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/resolve.go#L546-L584
160,847
keybase/client
go/kbfs/tlfhandle/resolve.go
ResolveImplicitTeam
func (nitk noImplicitTeamKBPKI) ResolveImplicitTeam( _ context.Context, _, _ string, _ tlf.Type, _ keybase1.OfflineAvailability) (idutil.ImplicitTeamInfo, error) { return idutil.ImplicitTeamInfo{}, errors.New("Skipping implicit team lookup for quick handle parsing") }
go
func (nitk noImplicitTeamKBPKI) ResolveImplicitTeam( _ context.Context, _, _ string, _ tlf.Type, _ keybase1.OfflineAvailability) (idutil.ImplicitTeamInfo, error) { return idutil.ImplicitTeamInfo{}, errors.New("Skipping implicit team lookup for quick handle parsing") }
[ "func", "(", "nitk", "noImplicitTeamKBPKI", ")", "ResolveImplicitTeam", "(", "_", "context", ".", "Context", ",", "_", ",", "_", "string", ",", "_", "tlf", ".", "Type", ",", "_", "keybase1", ".", "OfflineAvailability", ")", "(", "idutil", ".", "ImplicitTea...
// ResolveImplicitTeam implements the KBPKI interface for noImplicitTeamKBPKI.
[ "ResolveImplicitTeam", "implements", "the", "KBPKI", "interface", "for", "noImplicitTeamKBPKI", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/resolve.go#L987-L992
160,848
keybase/client
go/kbfs/tlfhandle/resolve.go
ParseHandlePreferredQuick
func ParseHandlePreferredQuick( ctx context.Context, kbpki idutil.KBPKI, osg idutil.OfflineStatusGetter, name string, ty tlf.Type) (handle *Handle, err error) { // Override the KBPKI with one that doesn't try to resolve // implicit teams. kbpki = noImplicitTeamKBPKI{kbpki} return ParseHandlePreferred(ctx, kbpki, nil, osg, name, ty) }
go
func ParseHandlePreferredQuick( ctx context.Context, kbpki idutil.KBPKI, osg idutil.OfflineStatusGetter, name string, ty tlf.Type) (handle *Handle, err error) { // Override the KBPKI with one that doesn't try to resolve // implicit teams. kbpki = noImplicitTeamKBPKI{kbpki} return ParseHandlePreferred(ctx, kbpki, nil, osg, name, ty) }
[ "func", "ParseHandlePreferredQuick", "(", "ctx", "context", ".", "Context", ",", "kbpki", "idutil", ".", "KBPKI", ",", "osg", "idutil", ".", "OfflineStatusGetter", ",", "name", "string", ",", "ty", "tlf", ".", "Type", ")", "(", "handle", "*", "Handle", ","...
// ParseHandlePreferredQuick parses a handle from a name, without // doing this time consuming checks needed for implicit-team checking // or TLF-ID-fetching.
[ "ParseHandlePreferredQuick", "parses", "a", "handle", "from", "a", "name", "without", "doing", "this", "time", "consuming", "checks", "needed", "for", "implicit", "-", "team", "checking", "or", "TLF", "-", "ID", "-", "fetching", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/tlfhandle/resolve.go#L997-L1004
160,849
keybase/client
go/engine/login_load_user.go
newLoginLoadUser
func newLoginLoadUser(g *libkb.GlobalContext, username string) *loginLoadUser { return &loginLoadUser{ Contextified: libkb.NewContextified(g), username: strings.TrimSpace(username), } }
go
func newLoginLoadUser(g *libkb.GlobalContext, username string) *loginLoadUser { return &loginLoadUser{ Contextified: libkb.NewContextified(g), username: strings.TrimSpace(username), } }
[ "func", "newLoginLoadUser", "(", "g", "*", "libkb", ".", "GlobalContext", ",", "username", "string", ")", "*", "loginLoadUser", "{", "return", "&", "loginLoadUser", "{", "Contextified", ":", "libkb", ".", "NewContextified", "(", "g", ")", ",", "username", ":...
// newLoginLoadUser creates a loginLoadUser engine. `username` argument is // optional.
[ "newLoginLoadUser", "creates", "a", "loginLoadUser", "engine", ".", "username", "argument", "is", "optional", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/engine/login_load_user.go#L27-L32
160,850
keybase/client
go/protocol/keybase1/simple_fs.go
SimpleFSListRecursive
func (c SimpleFSClient) SimpleFSListRecursive(ctx context.Context, __arg SimpleFSListRecursiveArg) (err error) { err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSListRecursive", []interface{}{__arg}, nil) return }
go
func (c SimpleFSClient) SimpleFSListRecursive(ctx context.Context, __arg SimpleFSListRecursiveArg) (err error) { err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSListRecursive", []interface{}{__arg}, nil) return }
[ "func", "(", "c", "SimpleFSClient", ")", "SimpleFSListRecursive", "(", "ctx", "context", ".", "Context", ",", "__arg", "SimpleFSListRecursiveArg", ")", "(", "err", "error", ")", "{", "err", "=", "c", ".", "Cli", ".", "Call", "(", "ctx", ",", "\"", "\"", ...
// Begin recursive list of items in directory at path. // If `refreshSubscription` is true and the path is a KBFS path, simpleFS // will begin sending `FSPathUpdated` notifications for the for the // corresponding TLF, until another call refreshes the subscription on a // different TLF.
[ "Begin", "recursive", "list", "of", "items", "in", "directory", "at", "path", ".", "If", "refreshSubscription", "is", "true", "and", "the", "path", "is", "a", "KBFS", "path", "simpleFS", "will", "begin", "sending", "FSPathUpdated", "notifications", "for", "the...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/simple_fs.go#L2068-L2071
160,851
keybase/client
go/protocol/keybase1/simple_fs.go
SimpleFSListRecursiveToDepth
func (c SimpleFSClient) SimpleFSListRecursiveToDepth(ctx context.Context, __arg SimpleFSListRecursiveToDepthArg) (err error) { err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSListRecursiveToDepth", []interface{}{__arg}, nil) return }
go
func (c SimpleFSClient) SimpleFSListRecursiveToDepth(ctx context.Context, __arg SimpleFSListRecursiveToDepthArg) (err error) { err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSListRecursiveToDepth", []interface{}{__arg}, nil) return }
[ "func", "(", "c", "SimpleFSClient", ")", "SimpleFSListRecursiveToDepth", "(", "ctx", "context", ".", "Context", ",", "__arg", "SimpleFSListRecursiveToDepthArg", ")", "(", "err", "error", ")", "{", "err", "=", "c", ".", "Cli", ".", "Call", "(", "ctx", ",", ...
// Begin recursive list of items in directory at path up to a given depth
[ "Begin", "recursive", "list", "of", "items", "in", "directory", "at", "path", "up", "to", "a", "given", "depth" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/simple_fs.go#L2074-L2077
160,852
keybase/client
go/protocol/keybase1/simple_fs.go
SimpleFSReadList
func (c SimpleFSClient) SimpleFSReadList(ctx context.Context, opID OpID) (res SimpleFSListResult, err error) { __arg := SimpleFSReadListArg{OpID: opID} err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSReadList", []interface{}{__arg}, &res) return }
go
func (c SimpleFSClient) SimpleFSReadList(ctx context.Context, opID OpID) (res SimpleFSListResult, err error) { __arg := SimpleFSReadListArg{OpID: opID} err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSReadList", []interface{}{__arg}, &res) return }
[ "func", "(", "c", "SimpleFSClient", ")", "SimpleFSReadList", "(", "ctx", "context", ".", "Context", ",", "opID", "OpID", ")", "(", "res", "SimpleFSListResult", ",", "err", "error", ")", "{", "__arg", ":=", "SimpleFSReadListArg", "{", "OpID", ":", "opID", "...
// Get list of Paths in progress. Can indicate status of pending // to get more entries.
[ "Get", "list", "of", "Paths", "in", "progress", ".", "Can", "indicate", "status", "of", "pending", "to", "get", "more", "entries", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/simple_fs.go#L2081-L2085
160,853
keybase/client
go/protocol/keybase1/simple_fs.go
SimpleFSCopy
func (c SimpleFSClient) SimpleFSCopy(ctx context.Context, __arg SimpleFSCopyArg) (err error) { err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSCopy", []interface{}{__arg}, nil) return }
go
func (c SimpleFSClient) SimpleFSCopy(ctx context.Context, __arg SimpleFSCopyArg) (err error) { err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSCopy", []interface{}{__arg}, nil) return }
[ "func", "(", "c", "SimpleFSClient", ")", "SimpleFSCopy", "(", "ctx", "context", ".", "Context", ",", "__arg", "SimpleFSCopyArg", ")", "(", "err", "error", ")", "{", "err", "=", "c", ".", "Cli", ".", "Call", "(", "ctx", ",", "\"", "\"", ",", "[", "]...
// Begin copy of file or directory
[ "Begin", "copy", "of", "file", "or", "directory" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/simple_fs.go#L2088-L2091
160,854
keybase/client
go/protocol/keybase1/simple_fs.go
SimpleFSSymlink
func (c SimpleFSClient) SimpleFSSymlink(ctx context.Context, __arg SimpleFSSymlinkArg) (err error) { err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSSymlink", []interface{}{__arg}, nil) return }
go
func (c SimpleFSClient) SimpleFSSymlink(ctx context.Context, __arg SimpleFSSymlinkArg) (err error) { err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSSymlink", []interface{}{__arg}, nil) return }
[ "func", "(", "c", "SimpleFSClient", ")", "SimpleFSSymlink", "(", "ctx", "context", ".", "Context", ",", "__arg", "SimpleFSSymlinkArg", ")", "(", "err", "error", ")", "{", "err", "=", "c", ".", "Cli", ".", "Call", "(", "ctx", ",", "\"", "\"", ",", "["...
// Make a symlink of file or directory
[ "Make", "a", "symlink", "of", "file", "or", "directory" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/simple_fs.go#L2094-L2097
160,855
keybase/client
go/protocol/keybase1/simple_fs.go
SimpleFSCopyRecursive
func (c SimpleFSClient) SimpleFSCopyRecursive(ctx context.Context, __arg SimpleFSCopyRecursiveArg) (err error) { err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSCopyRecursive", []interface{}{__arg}, nil) return }
go
func (c SimpleFSClient) SimpleFSCopyRecursive(ctx context.Context, __arg SimpleFSCopyRecursiveArg) (err error) { err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSCopyRecursive", []interface{}{__arg}, nil) return }
[ "func", "(", "c", "SimpleFSClient", ")", "SimpleFSCopyRecursive", "(", "ctx", "context", ".", "Context", ",", "__arg", "SimpleFSCopyRecursiveArg", ")", "(", "err", "error", ")", "{", "err", "=", "c", ".", "Cli", ".", "Call", "(", "ctx", ",", "\"", "\"", ...
// Begin recursive copy of directory
[ "Begin", "recursive", "copy", "of", "directory" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/simple_fs.go#L2100-L2103
160,856
keybase/client
go/protocol/keybase1/simple_fs.go
SimpleFSRename
func (c SimpleFSClient) SimpleFSRename(ctx context.Context, __arg SimpleFSRenameArg) (err error) { err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSRename", []interface{}{__arg}, nil) return }
go
func (c SimpleFSClient) SimpleFSRename(ctx context.Context, __arg SimpleFSRenameArg) (err error) { err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSRename", []interface{}{__arg}, nil) return }
[ "func", "(", "c", "SimpleFSClient", ")", "SimpleFSRename", "(", "ctx", "context", ".", "Context", ",", "__arg", "SimpleFSRenameArg", ")", "(", "err", "error", ")", "{", "err", "=", "c", ".", "Cli", ".", "Call", "(", "ctx", ",", "\"", "\"", ",", "[", ...
// Rename file or directory, KBFS side only
[ "Rename", "file", "or", "directory", "KBFS", "side", "only" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/simple_fs.go#L2112-L2115
160,857
keybase/client
go/protocol/keybase1/simple_fs.go
SimpleFSWrite
func (c SimpleFSClient) SimpleFSWrite(ctx context.Context, __arg SimpleFSWriteArg) (err error) { err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSWrite", []interface{}{__arg}, nil) return }
go
func (c SimpleFSClient) SimpleFSWrite(ctx context.Context, __arg SimpleFSWriteArg) (err error) { err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSWrite", []interface{}{__arg}, nil) return }
[ "func", "(", "c", "SimpleFSClient", ")", "SimpleFSWrite", "(", "ctx", "context", ".", "Context", ",", "__arg", "SimpleFSWriteArg", ")", "(", "err", "error", ")", "{", "err", "=", "c", ".", "Cli", ".", "Call", "(", "ctx", ",", "\"", "\"", ",", "[", ...
// Append content to opened file. // May be repeated until OpID is closed.
[ "Append", "content", "to", "opened", "file", ".", "May", "be", "repeated", "until", "OpID", "is", "closed", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/simple_fs.go#L2142-L2145
160,858
keybase/client
go/protocol/keybase1/simple_fs.go
SimpleFSRemove
func (c SimpleFSClient) SimpleFSRemove(ctx context.Context, __arg SimpleFSRemoveArg) (err error) { err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSRemove", []interface{}{__arg}, nil) return }
go
func (c SimpleFSClient) SimpleFSRemove(ctx context.Context, __arg SimpleFSRemoveArg) (err error) { err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSRemove", []interface{}{__arg}, nil) return }
[ "func", "(", "c", "SimpleFSClient", ")", "SimpleFSRemove", "(", "ctx", "context", ".", "Context", ",", "__arg", "SimpleFSRemoveArg", ")", "(", "err", "error", ")", "{", "err", "=", "c", ".", "Cli", ".", "Call", "(", "ctx", ",", "\"", "\"", ",", "[", ...
// Remove file or directory from filesystem
[ "Remove", "file", "or", "directory", "from", "filesystem" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/simple_fs.go#L2148-L2151
160,859
keybase/client
go/protocol/keybase1/simple_fs.go
SimpleFSStat
func (c SimpleFSClient) SimpleFSStat(ctx context.Context, __arg SimpleFSStatArg) (res Dirent, err error) { err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSStat", []interface{}{__arg}, &res) return }
go
func (c SimpleFSClient) SimpleFSStat(ctx context.Context, __arg SimpleFSStatArg) (res Dirent, err error) { err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSStat", []interface{}{__arg}, &res) return }
[ "func", "(", "c", "SimpleFSClient", ")", "SimpleFSStat", "(", "ctx", "context", ".", "Context", ",", "__arg", "SimpleFSStatArg", ")", "(", "res", "Dirent", ",", "err", "error", ")", "{", "err", "=", "c", ".", "Cli", ".", "Call", "(", "ctx", ",", "\""...
// Get info about file
[ "Get", "info", "about", "file" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/simple_fs.go#L2154-L2157
160,860
keybase/client
go/protocol/keybase1/simple_fs.go
SimpleFSGetRevisions
func (c SimpleFSClient) SimpleFSGetRevisions(ctx context.Context, __arg SimpleFSGetRevisionsArg) (err error) { err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSGetRevisions", []interface{}{__arg}, nil) return }
go
func (c SimpleFSClient) SimpleFSGetRevisions(ctx context.Context, __arg SimpleFSGetRevisionsArg) (err error) { err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSGetRevisions", []interface{}{__arg}, nil) return }
[ "func", "(", "c", "SimpleFSClient", ")", "SimpleFSGetRevisions", "(", "ctx", "context", ".", "Context", ",", "__arg", "SimpleFSGetRevisionsArg", ")", "(", "err", "error", ")", "{", "err", "=", "c", ".", "Cli", ".", "Call", "(", "ctx", ",", "\"", "\"", ...
// Get revision info for a directory entry
[ "Get", "revision", "info", "for", "a", "directory", "entry" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/simple_fs.go#L2160-L2163
160,861
keybase/client
go/protocol/keybase1/simple_fs.go
SimpleFSReadRevisions
func (c SimpleFSClient) SimpleFSReadRevisions(ctx context.Context, opID OpID) (res GetRevisionsResult, err error) { __arg := SimpleFSReadRevisionsArg{OpID: opID} err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSReadRevisions", []interface{}{__arg}, &res) return }
go
func (c SimpleFSClient) SimpleFSReadRevisions(ctx context.Context, opID OpID) (res GetRevisionsResult, err error) { __arg := SimpleFSReadRevisionsArg{OpID: opID} err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSReadRevisions", []interface{}{__arg}, &res) return }
[ "func", "(", "c", "SimpleFSClient", ")", "SimpleFSReadRevisions", "(", "ctx", "context", ".", "Context", ",", "opID", "OpID", ")", "(", "res", "GetRevisionsResult", ",", "err", "error", ")", "{", "__arg", ":=", "SimpleFSReadRevisionsArg", "{", "OpID", ":", "...
// Get list of revisions in progress. Can indicate status of pending // to get more revisions.
[ "Get", "list", "of", "revisions", "in", "progress", ".", "Can", "indicate", "status", "of", "pending", "to", "get", "more", "revisions", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/simple_fs.go#L2167-L2171
160,862
keybase/client
go/protocol/keybase1/simple_fs.go
SimpleFSMakeOpid
func (c SimpleFSClient) SimpleFSMakeOpid(ctx context.Context) (res OpID, err error) { err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSMakeOpid", []interface{}{SimpleFSMakeOpidArg{}}, &res) return }
go
func (c SimpleFSClient) SimpleFSMakeOpid(ctx context.Context) (res OpID, err error) { err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSMakeOpid", []interface{}{SimpleFSMakeOpidArg{}}, &res) return }
[ "func", "(", "c", "SimpleFSClient", ")", "SimpleFSMakeOpid", "(", "ctx", "context", ".", "Context", ")", "(", "res", "OpID", ",", "err", "error", ")", "{", "err", "=", "c", ".", "Cli", ".", "Call", "(", "ctx", ",", "\"", "\"", ",", "[", "]", "int...
// Convenience helper for generating new random value
[ "Convenience", "helper", "for", "generating", "new", "random", "value" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/simple_fs.go#L2174-L2177
160,863
keybase/client
go/protocol/keybase1/simple_fs.go
SimpleFSCancel
func (c SimpleFSClient) SimpleFSCancel(ctx context.Context, opID OpID) (err error) { __arg := SimpleFSCancelArg{OpID: opID} err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSCancel", []interface{}{__arg}, nil) return }
go
func (c SimpleFSClient) SimpleFSCancel(ctx context.Context, opID OpID) (err error) { __arg := SimpleFSCancelArg{OpID: opID} err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSCancel", []interface{}{__arg}, nil) return }
[ "func", "(", "c", "SimpleFSClient", ")", "SimpleFSCancel", "(", "ctx", "context", ".", "Context", ",", "opID", "OpID", ")", "(", "err", "error", ")", "{", "__arg", ":=", "SimpleFSCancelArg", "{", "OpID", ":", "opID", "}", "\n", "err", "=", "c", ".", ...
// Cancels a running operation, like copy.
[ "Cancels", "a", "running", "operation", "like", "copy", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/simple_fs.go#L2188-L2192
160,864
keybase/client
go/protocol/keybase1/simple_fs.go
SimpleFSCheck
func (c SimpleFSClient) SimpleFSCheck(ctx context.Context, opID OpID) (res OpProgress, err error) { __arg := SimpleFSCheckArg{OpID: opID} err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSCheck", []interface{}{__arg}, &res) return }
go
func (c SimpleFSClient) SimpleFSCheck(ctx context.Context, opID OpID) (res OpProgress, err error) { __arg := SimpleFSCheckArg{OpID: opID} err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSCheck", []interface{}{__arg}, &res) return }
[ "func", "(", "c", "SimpleFSClient", ")", "SimpleFSCheck", "(", "ctx", "context", ".", "Context", ",", "opID", "OpID", ")", "(", "res", "OpProgress", ",", "err", "error", ")", "{", "__arg", ":=", "SimpleFSCheckArg", "{", "OpID", ":", "opID", "}", "\n", ...
// Check progress of pending operation
[ "Check", "progress", "of", "pending", "operation" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/simple_fs.go#L2195-L2199
160,865
keybase/client
go/protocol/keybase1/simple_fs.go
SimpleFSGetOps
func (c SimpleFSClient) SimpleFSGetOps(ctx context.Context) (res []OpDescription, err error) { err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSGetOps", []interface{}{SimpleFSGetOpsArg{}}, &res) return }
go
func (c SimpleFSClient) SimpleFSGetOps(ctx context.Context) (res []OpDescription, err error) { err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSGetOps", []interface{}{SimpleFSGetOpsArg{}}, &res) return }
[ "func", "(", "c", "SimpleFSClient", ")", "SimpleFSGetOps", "(", "ctx", "context", ".", "Context", ")", "(", "res", "[", "]", "OpDescription", ",", "err", "error", ")", "{", "err", "=", "c", ".", "Cli", ".", "Call", "(", "ctx", ",", "\"", "\"", ",",...
// Get all the outstanding operations
[ "Get", "all", "the", "outstanding", "operations" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/simple_fs.go#L2202-L2205
160,866
keybase/client
go/protocol/keybase1/simple_fs.go
SimpleFSWait
func (c SimpleFSClient) SimpleFSWait(ctx context.Context, opID OpID) (err error) { __arg := SimpleFSWaitArg{OpID: opID} err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSWait", []interface{}{__arg}, nil) return }
go
func (c SimpleFSClient) SimpleFSWait(ctx context.Context, opID OpID) (err error) { __arg := SimpleFSWaitArg{OpID: opID} err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSWait", []interface{}{__arg}, nil) return }
[ "func", "(", "c", "SimpleFSClient", ")", "SimpleFSWait", "(", "ctx", "context", ".", "Context", ",", "opID", "OpID", ")", "(", "err", "error", ")", "{", "__arg", ":=", "SimpleFSWaitArg", "{", "OpID", ":", "opID", "}", "\n", "err", "=", "c", ".", "Cli...
// Blocking wait for the pending operation to finish
[ "Blocking", "wait", "for", "the", "pending", "operation", "to", "finish" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/simple_fs.go#L2208-L2212
160,867
keybase/client
go/protocol/keybase1/simple_fs.go
SimpleFSDumpDebuggingInfo
func (c SimpleFSClient) SimpleFSDumpDebuggingInfo(ctx context.Context) (err error) { err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSDumpDebuggingInfo", []interface{}{SimpleFSDumpDebuggingInfoArg{}}, nil) return }
go
func (c SimpleFSClient) SimpleFSDumpDebuggingInfo(ctx context.Context) (err error) { err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSDumpDebuggingInfo", []interface{}{SimpleFSDumpDebuggingInfoArg{}}, nil) return }
[ "func", "(", "c", "SimpleFSClient", ")", "SimpleFSDumpDebuggingInfo", "(", "ctx", "context", ".", "Context", ")", "(", "err", "error", ")", "{", "err", "=", "c", ".", "Cli", ".", "Call", "(", "ctx", ",", "\"", "\"", ",", "[", "]", "interface", "{", ...
// Instructs KBFS to dump debugging info into its logs.
[ "Instructs", "KBFS", "to", "dump", "debugging", "info", "into", "its", "logs", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/simple_fs.go#L2215-L2218
160,868
keybase/client
go/protocol/keybase1/simple_fs.go
SimpleFSClearConflictState
func (c SimpleFSClient) SimpleFSClearConflictState(ctx context.Context, path Path) (err error) { __arg := SimpleFSClearConflictStateArg{Path: path} err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSClearConflictState", []interface{}{__arg}, nil) return }
go
func (c SimpleFSClient) SimpleFSClearConflictState(ctx context.Context, path Path) (err error) { __arg := SimpleFSClearConflictStateArg{Path: path} err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSClearConflictState", []interface{}{__arg}, nil) return }
[ "func", "(", "c", "SimpleFSClient", ")", "SimpleFSClearConflictState", "(", "ctx", "context", ".", "Context", ",", "path", "Path", ")", "(", "err", "error", ")", "{", "__arg", ":=", "SimpleFSClearConflictStateArg", "{", "Path", ":", "path", "}", "\n", "err",...
// Clear the conflict state of a TLF.
[ "Clear", "the", "conflict", "state", "of", "a", "TLF", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/simple_fs.go#L2221-L2225
160,869
keybase/client
go/protocol/keybase1/simple_fs.go
SimpleFSSyncStatus
func (c SimpleFSClient) SimpleFSSyncStatus(ctx context.Context, filter ListFilter) (res FSSyncStatus, err error) { __arg := SimpleFSSyncStatusArg{Filter: filter} err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSSyncStatus", []interface{}{__arg}, &res) return }
go
func (c SimpleFSClient) SimpleFSSyncStatus(ctx context.Context, filter ListFilter) (res FSSyncStatus, err error) { __arg := SimpleFSSyncStatusArg{Filter: filter} err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSSyncStatus", []interface{}{__arg}, &res) return }
[ "func", "(", "c", "SimpleFSClient", ")", "SimpleFSSyncStatus", "(", "ctx", "context", ".", "Context", ",", "filter", "ListFilter", ")", "(", "res", "FSSyncStatus", ",", "err", "error", ")", "{", "__arg", ":=", "SimpleFSSyncStatusArg", "{", "Filter", ":", "fi...
// Get sync status.
[ "Get", "sync", "status", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/simple_fs.go#L2228-L2232
160,870
keybase/client
go/protocol/keybase1/simple_fs.go
SimpleFSListFavorites
func (c SimpleFSClient) SimpleFSListFavorites(ctx context.Context) (res FavoritesResult, err error) { err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSListFavorites", []interface{}{SimpleFSListFavoritesArg{}}, &res) return }
go
func (c SimpleFSClient) SimpleFSListFavorites(ctx context.Context) (res FavoritesResult, err error) { err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSListFavorites", []interface{}{SimpleFSListFavoritesArg{}}, &res) return }
[ "func", "(", "c", "SimpleFSClient", ")", "SimpleFSListFavorites", "(", "ctx", "context", ".", "Context", ")", "(", "res", "FavoritesResult", ",", "err", "error", ")", "{", "err", "=", "c", ".", "Cli", ".", "Call", "(", "ctx", ",", "\"", "\"", ",", "[...
// simpleFSListFavorites gets the current favorites, ignored folders, and new // folders from the KBFS cache.
[ "simpleFSListFavorites", "gets", "the", "current", "favorites", "ignored", "folders", "and", "new", "folders", "from", "the", "KBFS", "cache", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/simple_fs.go#L2270-L2273
160,871
keybase/client
go/protocol/keybase1/simple_fs.go
SimpleFSGetUserQuotaUsage
func (c SimpleFSClient) SimpleFSGetUserQuotaUsage(ctx context.Context) (res SimpleFSQuotaUsage, err error) { err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSGetUserQuotaUsage", []interface{}{SimpleFSGetUserQuotaUsageArg{}}, &res) return }
go
func (c SimpleFSClient) SimpleFSGetUserQuotaUsage(ctx context.Context) (res SimpleFSQuotaUsage, err error) { err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSGetUserQuotaUsage", []interface{}{SimpleFSGetUserQuotaUsageArg{}}, &res) return }
[ "func", "(", "c", "SimpleFSClient", ")", "SimpleFSGetUserQuotaUsage", "(", "ctx", "context", ".", "Context", ")", "(", "res", "SimpleFSQuotaUsage", ",", "err", "error", ")", "{", "err", "=", "c", ".", "Cli", ".", "Call", "(", "ctx", ",", "\"", "\"", ",...
// simpleFSGetUserQuotaUsage returns the quota usage for the logged-in // user. Any usage includes local journal usage as well.
[ "simpleFSGetUserQuotaUsage", "returns", "the", "quota", "usage", "for", "the", "logged", "-", "in", "user", ".", "Any", "usage", "includes", "local", "journal", "usage", "as", "well", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/simple_fs.go#L2277-L2280
160,872
keybase/client
go/protocol/keybase1/simple_fs.go
SimpleFSGetTeamQuotaUsage
func (c SimpleFSClient) SimpleFSGetTeamQuotaUsage(ctx context.Context, teamName TeamName) (res SimpleFSQuotaUsage, err error) { __arg := SimpleFSGetTeamQuotaUsageArg{TeamName: teamName} err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSGetTeamQuotaUsage", []interface{}{__arg}, &res) return }
go
func (c SimpleFSClient) SimpleFSGetTeamQuotaUsage(ctx context.Context, teamName TeamName) (res SimpleFSQuotaUsage, err error) { __arg := SimpleFSGetTeamQuotaUsageArg{TeamName: teamName} err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSGetTeamQuotaUsage", []interface{}{__arg}, &res) return }
[ "func", "(", "c", "SimpleFSClient", ")", "SimpleFSGetTeamQuotaUsage", "(", "ctx", "context", ".", "Context", ",", "teamName", "TeamName", ")", "(", "res", "SimpleFSQuotaUsage", ",", "err", "error", ")", "{", "__arg", ":=", "SimpleFSGetTeamQuotaUsageArg", "{", "T...
// simpleFSGetTeamQuotaUsage returns the quota usage for the given team, if // the logged-in user has access to that team. Any usage includes // local journal usage as well.
[ "simpleFSGetTeamQuotaUsage", "returns", "the", "quota", "usage", "for", "the", "given", "team", "if", "the", "logged", "-", "in", "user", "has", "access", "to", "that", "team", ".", "Any", "usage", "includes", "local", "journal", "usage", "as", "well", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/simple_fs.go#L2285-L2289
160,873
keybase/client
go/protocol/keybase1/simple_fs.go
SimpleFSReset
func (c SimpleFSClient) SimpleFSReset(ctx context.Context, path Path) (err error) { __arg := SimpleFSResetArg{Path: path} err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSReset", []interface{}{__arg}, nil) return }
go
func (c SimpleFSClient) SimpleFSReset(ctx context.Context, path Path) (err error) { __arg := SimpleFSResetArg{Path: path} err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSReset", []interface{}{__arg}, nil) return }
[ "func", "(", "c", "SimpleFSClient", ")", "SimpleFSReset", "(", "ctx", "context", ".", "Context", ",", "path", "Path", ")", "(", "err", "error", ")", "{", "__arg", ":=", "SimpleFSResetArg", "{", "Path", ":", "path", "}", "\n", "err", "=", "c", ".", "C...
// simpleFSReset completely resets the KBFS folder referenced in `path`. // It should only be called after explicit user confirmation.
[ "simpleFSReset", "completely", "resets", "the", "KBFS", "folder", "referenced", "in", "path", ".", "It", "should", "only", "be", "called", "after", "explicit", "user", "confirmation", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/protocol/keybase1/simple_fs.go#L2293-L2297
160,874
keybase/client
go/kbfs/libkbfs/mdserver_local_shared.go
isWriterOrValidRekey
func isWriterOrValidRekey(ctx context.Context, teamMemChecker kbfsmd.TeamMembershipChecker, codec kbfscodec.Codec, currentUID keybase1.UID, verifyingKey kbfscrypto.VerifyingKey, mergedMasterHead, newMd kbfsmd.RootMetadata, prevExtra, extra kbfsmd.ExtraMetadata) ( bool, error) { h, err := mergedMasterHead.MakeBareTlfHandle(prevExtra) if err != nil { return false, err } if h.Type() == tlf.SingleTeam { isWriter, err := teamMemChecker.IsTeamWriter( ctx, h.Writers[0].AsTeamOrBust(), currentUID, verifyingKey, keybase1.OfflineAvailability_NONE) if err != nil { return false, kbfsmd.ServerError{Err: err} } // Team TLFs can't be rekeyed, so readers aren't ever valid. return isWriter, nil } if h.IsWriter(currentUID.AsUserOrTeam()) { return true, nil } if h.IsReader(currentUID.AsUserOrTeam()) { // if this is a reader, are they acting within their // restrictions? return newMd.IsValidRekeyRequest( codec, mergedMasterHead, currentUID, prevExtra, extra) } return false, nil }
go
func isWriterOrValidRekey(ctx context.Context, teamMemChecker kbfsmd.TeamMembershipChecker, codec kbfscodec.Codec, currentUID keybase1.UID, verifyingKey kbfscrypto.VerifyingKey, mergedMasterHead, newMd kbfsmd.RootMetadata, prevExtra, extra kbfsmd.ExtraMetadata) ( bool, error) { h, err := mergedMasterHead.MakeBareTlfHandle(prevExtra) if err != nil { return false, err } if h.Type() == tlf.SingleTeam { isWriter, err := teamMemChecker.IsTeamWriter( ctx, h.Writers[0].AsTeamOrBust(), currentUID, verifyingKey, keybase1.OfflineAvailability_NONE) if err != nil { return false, kbfsmd.ServerError{Err: err} } // Team TLFs can't be rekeyed, so readers aren't ever valid. return isWriter, nil } if h.IsWriter(currentUID.AsUserOrTeam()) { return true, nil } if h.IsReader(currentUID.AsUserOrTeam()) { // if this is a reader, are they acting within their // restrictions? return newMd.IsValidRekeyRequest( codec, mergedMasterHead, currentUID, prevExtra, extra) } return false, nil }
[ "func", "isWriterOrValidRekey", "(", "ctx", "context", ".", "Context", ",", "teamMemChecker", "kbfsmd", ".", "TeamMembershipChecker", ",", "codec", "kbfscodec", ".", "Codec", ",", "currentUID", "keybase1", ".", "UID", ",", "verifyingKey", "kbfscrypto", ".", "Verif...
// Helper to aid in enforcement that only specified public keys can // access TLF metadata. mergedMasterHead can be nil, in which case // true is returned.
[ "Helper", "to", "aid", "in", "enforcement", "that", "only", "specified", "public", "keys", "can", "access", "TLF", "metadata", ".", "mergedMasterHead", "can", "be", "nil", "in", "which", "case", "true", "is", "returned", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/mdserver_local_shared.go#L48-L81
160,875
keybase/client
go/bind/keybase.go
Init
func Init(homeDir, mobileSharedHome, logFile, runModeStr string, accessGroupOverride bool, externalDNSNSFetcher ExternalDNSNSFetcher, nvh NativeVideoHelper) (err error) { defer func() { err = flattenError(err) if err == nil { setInited() } }() fmt.Printf("Go: Initializing: home: %s mobileSharedHome: %s\n", homeDir, mobileSharedHome) var ekLogFile string if logFile != "" { fmt.Printf("Go: Using log: %s\n", logFile) ekLogFile = logFile + ".ek" fmt.Printf("Go: Using eklog: %s\n", ekLogFile) } // Reduce OS threads on mobile so we don't have too much contention with JS thread oldProcs := runtime.GOMAXPROCS(0) newProcs := oldProcs / 2 runtime.GOMAXPROCS(newProcs) fmt.Printf("Go: setting GOMAXPROCS to: %d previous: %d\n", newProcs, oldProcs) startTrace(logFile) dnsNSFetcher := newDNSNSFetcher(externalDNSNSFetcher) dnsServers := dnsNSFetcher.GetServers() for _, srv := range dnsServers { fmt.Printf("Go: DNS Server: %s\n", srv) } kbCtx = libkb.NewGlobalContext() kbCtx.Init() kbCtx.SetProofServices(externals.NewProofServices(kbCtx)) // 10k uid -> FullName cache entries allowed kbCtx.SetUIDMapper(uidmap.NewUIDMap(10000)) usage := libkb.Usage{ Config: true, API: true, KbKeyring: true, } runMode, err := libkb.StringToRunMode(runModeStr) if err != nil { return err } config := libkb.AppConfig{ HomeDir: homeDir, MobileSharedHomeDir: mobileSharedHome, LogFile: logFile, EKLogFile: ekLogFile, RunMode: runMode, Debug: true, LocalRPCDebug: "", VDebugSetting: "mobile", // use empty string for same logging as desktop default SecurityAccessGroupOverride: accessGroupOverride, ChatInboxSourceLocalizeThreads: 5, LinkCacheSize: 1000, } err = kbCtx.Configure(config, usage) if err != nil { return err } svc := service.NewService(kbCtx, false) err = svc.StartLoopbackServer() if err != nil { return err } kbCtx.SetService() uir := service.NewUIRouter(kbCtx) kbCtx.SetUIRouter(uir) kbCtx.SetDNSNameServerFetcher(dnsNSFetcher) svc.SetupCriticalSubServices() svc.SetupChatModules(nil) svc.RunBackgroundOperations(uir) kbChatCtx = svc.ChatContextified.ChatG() kbChatCtx.NativeVideoHelper = newVideoHelper(nvh) logs := libkb.Logs{ Service: config.GetLogFile(), EK: config.GetEKLogFile(), } fmt.Printf("Go: Using config: %+v\n", kbCtx.Env.GetLogFileConfig(config.GetLogFile())) logSendContext = libkb.LogSendContext{ Contextified: libkb.NewContextified(kbCtx), Logs: logs, } // open the connection if err = Reset(); err != nil { return err } go func() { kbfsCtx := env.NewContextFromGlobalContext(kbCtx) kbfsParams := libkbfs.DefaultInitParams(kbfsCtx) // Setting this flag will enable KBFS debug logging to always // be true in a mobile setting. Change these back to the // commented-out values if we need to make a mobile release // before KBFS-on-mobile is ready. kbfsParams.Debug = true // false kbfsParams.Mode = libkbfs.InitConstrainedString // libkbfs.InitMinimalString kbfsConfig, _ = libkbfs.Init( context.Background(), kbfsCtx, kbfsParams, serviceCn{}, func() error { return nil }, kbCtx.Log) }() return nil }
go
func Init(homeDir, mobileSharedHome, logFile, runModeStr string, accessGroupOverride bool, externalDNSNSFetcher ExternalDNSNSFetcher, nvh NativeVideoHelper) (err error) { defer func() { err = flattenError(err) if err == nil { setInited() } }() fmt.Printf("Go: Initializing: home: %s mobileSharedHome: %s\n", homeDir, mobileSharedHome) var ekLogFile string if logFile != "" { fmt.Printf("Go: Using log: %s\n", logFile) ekLogFile = logFile + ".ek" fmt.Printf("Go: Using eklog: %s\n", ekLogFile) } // Reduce OS threads on mobile so we don't have too much contention with JS thread oldProcs := runtime.GOMAXPROCS(0) newProcs := oldProcs / 2 runtime.GOMAXPROCS(newProcs) fmt.Printf("Go: setting GOMAXPROCS to: %d previous: %d\n", newProcs, oldProcs) startTrace(logFile) dnsNSFetcher := newDNSNSFetcher(externalDNSNSFetcher) dnsServers := dnsNSFetcher.GetServers() for _, srv := range dnsServers { fmt.Printf("Go: DNS Server: %s\n", srv) } kbCtx = libkb.NewGlobalContext() kbCtx.Init() kbCtx.SetProofServices(externals.NewProofServices(kbCtx)) // 10k uid -> FullName cache entries allowed kbCtx.SetUIDMapper(uidmap.NewUIDMap(10000)) usage := libkb.Usage{ Config: true, API: true, KbKeyring: true, } runMode, err := libkb.StringToRunMode(runModeStr) if err != nil { return err } config := libkb.AppConfig{ HomeDir: homeDir, MobileSharedHomeDir: mobileSharedHome, LogFile: logFile, EKLogFile: ekLogFile, RunMode: runMode, Debug: true, LocalRPCDebug: "", VDebugSetting: "mobile", // use empty string for same logging as desktop default SecurityAccessGroupOverride: accessGroupOverride, ChatInboxSourceLocalizeThreads: 5, LinkCacheSize: 1000, } err = kbCtx.Configure(config, usage) if err != nil { return err } svc := service.NewService(kbCtx, false) err = svc.StartLoopbackServer() if err != nil { return err } kbCtx.SetService() uir := service.NewUIRouter(kbCtx) kbCtx.SetUIRouter(uir) kbCtx.SetDNSNameServerFetcher(dnsNSFetcher) svc.SetupCriticalSubServices() svc.SetupChatModules(nil) svc.RunBackgroundOperations(uir) kbChatCtx = svc.ChatContextified.ChatG() kbChatCtx.NativeVideoHelper = newVideoHelper(nvh) logs := libkb.Logs{ Service: config.GetLogFile(), EK: config.GetEKLogFile(), } fmt.Printf("Go: Using config: %+v\n", kbCtx.Env.GetLogFileConfig(config.GetLogFile())) logSendContext = libkb.LogSendContext{ Contextified: libkb.NewContextified(kbCtx), Logs: logs, } // open the connection if err = Reset(); err != nil { return err } go func() { kbfsCtx := env.NewContextFromGlobalContext(kbCtx) kbfsParams := libkbfs.DefaultInitParams(kbfsCtx) // Setting this flag will enable KBFS debug logging to always // be true in a mobile setting. Change these back to the // commented-out values if we need to make a mobile release // before KBFS-on-mobile is ready. kbfsParams.Debug = true // false kbfsParams.Mode = libkbfs.InitConstrainedString // libkbfs.InitMinimalString kbfsConfig, _ = libkbfs.Init( context.Background(), kbfsCtx, kbfsParams, serviceCn{}, func() error { return nil }, kbCtx.Log) }() return nil }
[ "func", "Init", "(", "homeDir", ",", "mobileSharedHome", ",", "logFile", ",", "runModeStr", "string", ",", "accessGroupOverride", "bool", ",", "externalDNSNSFetcher", "ExternalDNSNSFetcher", ",", "nvh", "NativeVideoHelper", ")", "(", "err", "error", ")", "{", "def...
// Init runs the Keybase services
[ "Init", "runs", "the", "Keybase", "services" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/bind/keybase.go#L133-L244
160,876
keybase/client
go/bind/keybase.go
LogSend
func LogSend(status string, feedback string, sendLogs bool, uiLogPath, traceDir, cpuProfileDir string) (res string, err error) { defer func() { err = flattenError(err) }() logSendContext.Logs.Desktop = uiLogPath logSendContext.Logs.Trace = traceDir logSendContext.Logs.CPUProfile = cpuProfileDir env := kbCtx.Env sendLogMaxSizeBytes := 10 * 1024 * 1024 // NOTE: If you increase this, check go/libkb/env.go:Env.GetLogFileConfig to make sure we store at least that much. return logSendContext.LogSend(status, feedback, sendLogs, sendLogMaxSizeBytes, env.GetUID(), env.GetInstallID(), true /* mergeExtendedStatus */) }
go
func LogSend(status string, feedback string, sendLogs bool, uiLogPath, traceDir, cpuProfileDir string) (res string, err error) { defer func() { err = flattenError(err) }() logSendContext.Logs.Desktop = uiLogPath logSendContext.Logs.Trace = traceDir logSendContext.Logs.CPUProfile = cpuProfileDir env := kbCtx.Env sendLogMaxSizeBytes := 10 * 1024 * 1024 // NOTE: If you increase this, check go/libkb/env.go:Env.GetLogFileConfig to make sure we store at least that much. return logSendContext.LogSend(status, feedback, sendLogs, sendLogMaxSizeBytes, env.GetUID(), env.GetInstallID(), true /* mergeExtendedStatus */) }
[ "func", "LogSend", "(", "status", "string", ",", "feedback", "string", ",", "sendLogs", "bool", ",", "uiLogPath", ",", "traceDir", ",", "cpuProfileDir", "string", ")", "(", "res", "string", ",", "err", "error", ")", "{", "defer", "func", "(", ")", "{", ...
// LogSend sends a log to Keybase
[ "LogSend", "sends", "a", "log", "to", "Keybase" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/bind/keybase.go#L274-L282
160,877
keybase/client
go/bind/keybase.go
WriteB64
func WriteB64(str string) (err error) { defer func() { err = flattenError(err) }() if conn == nil { return errors.New("connection not initialized") } data, err := base64.StdEncoding.DecodeString(str) if err != nil { return fmt.Errorf("Base64 decode error: %s; %s", err, str) } n, err := conn.Write(data) if err != nil { return fmt.Errorf("Write error: %s", err) } if n != len(data) { return errors.New("Did not write all the data") } return nil }
go
func WriteB64(str string) (err error) { defer func() { err = flattenError(err) }() if conn == nil { return errors.New("connection not initialized") } data, err := base64.StdEncoding.DecodeString(str) if err != nil { return fmt.Errorf("Base64 decode error: %s; %s", err, str) } n, err := conn.Write(data) if err != nil { return fmt.Errorf("Write error: %s", err) } if n != len(data) { return errors.New("Did not write all the data") } return nil }
[ "func", "WriteB64", "(", "str", "string", ")", "(", "err", "error", ")", "{", "defer", "func", "(", ")", "{", "err", "=", "flattenError", "(", "err", ")", "}", "(", ")", "\n", "if", "conn", "==", "nil", "{", "return", "errors", ".", "New", "(", ...
// WriteB64 sends a base64 encoded msgpack rpc payload
[ "WriteB64", "sends", "a", "base64", "encoded", "msgpack", "rpc", "payload" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/bind/keybase.go#L285-L302
160,878
keybase/client
go/bind/keybase.go
ReadB64
func ReadB64() (res string, err error) { defer func() { err = flattenError(err) }() if conn == nil { return "", errors.New("connection not initialized") } n, err := conn.Read(buffer) if n > 0 && err == nil { str := base64.StdEncoding.EncodeToString(buffer[0:n]) return str, nil } if err != nil { // Attempt to fix the connection Reset() return "", fmt.Errorf("Read error: %s", err) } return "", nil }
go
func ReadB64() (res string, err error) { defer func() { err = flattenError(err) }() if conn == nil { return "", errors.New("connection not initialized") } n, err := conn.Read(buffer) if n > 0 && err == nil { str := base64.StdEncoding.EncodeToString(buffer[0:n]) return str, nil } if err != nil { // Attempt to fix the connection Reset() return "", fmt.Errorf("Read error: %s", err) } return "", nil }
[ "func", "ReadB64", "(", ")", "(", "res", "string", ",", "err", "error", ")", "{", "defer", "func", "(", ")", "{", "err", "=", "flattenError", "(", "err", ")", "}", "(", ")", "\n", "if", "conn", "==", "nil", "{", "return", "\"", "\"", ",", "erro...
// ReadB64 is a blocking read for base64 encoded msgpack rpc data. // It is called serially by the mobile run loops.
[ "ReadB64", "is", "a", "blocking", "read", "for", "base64", "encoded", "msgpack", "rpc", "data", ".", "It", "is", "called", "serially", "by", "the", "mobile", "run", "loops", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/bind/keybase.go#L316-L334
160,879
keybase/client
go/bind/keybase.go
Reset
func Reset() error { if conn != nil { conn.Close() } var err error conn, err = kbCtx.LoopbackListener.Dial() if err != nil { return fmt.Errorf("Socket error: %s", err) } return nil }
go
func Reset() error { if conn != nil { conn.Close() } var err error conn, err = kbCtx.LoopbackListener.Dial() if err != nil { return fmt.Errorf("Socket error: %s", err) } return nil }
[ "func", "Reset", "(", ")", "error", "{", "if", "conn", "!=", "nil", "{", "conn", ".", "Close", "(", ")", "\n", "}", "\n\n", "var", "err", "error", "\n", "conn", ",", "err", "=", "kbCtx", ".", "LoopbackListener", ".", "Dial", "(", ")", "\n", "if",...
// Reset resets the socket connection
[ "Reset", "resets", "the", "socket", "connection" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/bind/keybase.go#L337-L348
160,880
keybase/client
go/bind/keybase.go
ForceGC
func ForceGC() { fmt.Printf("Flushing global caches\n") kbCtx.FlushCaches() fmt.Printf("Done flushing global caches\n") fmt.Printf("Starting force gc\n") debug.FreeOSMemory() fmt.Printf("Done force gc\n") }
go
func ForceGC() { fmt.Printf("Flushing global caches\n") kbCtx.FlushCaches() fmt.Printf("Done flushing global caches\n") fmt.Printf("Starting force gc\n") debug.FreeOSMemory() fmt.Printf("Done force gc\n") }
[ "func", "ForceGC", "(", ")", "{", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ")", "\n", "kbCtx", ".", "FlushCaches", "(", ")", "\n", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ")", "\n\n", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ")"...
// ForceGC Forces a gc
[ "ForceGC", "Forces", "a", "gc" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/bind/keybase.go#L351-L359
160,881
keybase/client
go/bind/keybase.go
pushPendingMessageFailure
func pushPendingMessageFailure(obrs []chat1.OutboxRecord, pusher PushNotifier) { for _, obr := range obrs { if !obr.IsUnfurl() { kbCtx.Log.Debug("pushPendingMessageFailure: pushing convID: %s", obr.ConvID) pusher.LocalNotification("failedpending", "Heads up! One or more pending messages failed to send. Tap here to retry them.", -1, "default", obr.ConvID.String(), "chat.failedpending") return } } kbCtx.Log.Debug("pushPendingMessageFailure: skipped notification for: %d items", len(obrs)) }
go
func pushPendingMessageFailure(obrs []chat1.OutboxRecord, pusher PushNotifier) { for _, obr := range obrs { if !obr.IsUnfurl() { kbCtx.Log.Debug("pushPendingMessageFailure: pushing convID: %s", obr.ConvID) pusher.LocalNotification("failedpending", "Heads up! One or more pending messages failed to send. Tap here to retry them.", -1, "default", obr.ConvID.String(), "chat.failedpending") return } } kbCtx.Log.Debug("pushPendingMessageFailure: skipped notification for: %d items", len(obrs)) }
[ "func", "pushPendingMessageFailure", "(", "obrs", "[", "]", "chat1", ".", "OutboxRecord", ",", "pusher", "PushNotifier", ")", "{", "for", "_", ",", "obr", ":=", "range", "obrs", "{", "if", "!", "obr", ".", "IsUnfurl", "(", ")", "{", "kbCtx", ".", "Log"...
// pushPendingMessageFailure sends at most one notification that a message // failed to send. We don't notify the user about background failures like // unfurling.
[ "pushPendingMessageFailure", "sends", "at", "most", "one", "notification", "that", "a", "message", "failed", "to", "send", ".", "We", "don", "t", "notify", "the", "user", "about", "background", "failures", "like", "unfurling", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/bind/keybase.go#L500-L511
160,882
keybase/client
go/bind/keybase.go
AppWillExit
func AppWillExit(pusher PushNotifier) { if !isInited() { return } defer kbCtx.Trace("AppWillExit", func() error { return nil })() ctx := context.Background() obrs, err := kbChatCtx.MessageDeliverer.ActiveDeliveries(ctx) if err == nil { // We are about to get killed with messages still to send, let the user // know they will get stuck pushPendingMessageFailure(obrs, pusher) } kbCtx.MobileAppState.Update(keybase1.MobileAppState_BACKGROUND) }
go
func AppWillExit(pusher PushNotifier) { if !isInited() { return } defer kbCtx.Trace("AppWillExit", func() error { return nil })() ctx := context.Background() obrs, err := kbChatCtx.MessageDeliverer.ActiveDeliveries(ctx) if err == nil { // We are about to get killed with messages still to send, let the user // know they will get stuck pushPendingMessageFailure(obrs, pusher) } kbCtx.MobileAppState.Update(keybase1.MobileAppState_BACKGROUND) }
[ "func", "AppWillExit", "(", "pusher", "PushNotifier", ")", "{", "if", "!", "isInited", "(", ")", "{", "return", "\n", "}", "\n", "defer", "kbCtx", ".", "Trace", "(", "\"", "\"", ",", "func", "(", ")", "error", "{", "return", "nil", "}", ")", "(", ...
// AppWillExit is called reliably on iOS when the app is about to terminate // not as reliably on android
[ "AppWillExit", "is", "called", "reliably", "on", "iOS", "when", "the", "app", "is", "about", "to", "terminate", "not", "as", "reliably", "on", "android" ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/bind/keybase.go#L515-L528
160,883
keybase/client
go/bind/keybase.go
AppBeginBackgroundTask
func AppBeginBackgroundTask(pusher PushNotifier) { if !isInited() { return } defer kbCtx.Trace("AppBeginBackgroundTask", func() error { return nil })() ctx := context.Background() // Poll active deliveries in case we can shutdown early beginTime := libkb.ForceWallClock(time.Now()) ticker := time.NewTicker(5 * time.Second) appState := kbCtx.MobileAppState.State() if appState != keybase1.MobileAppState_BACKGROUNDACTIVE { kbCtx.Log.Debug("AppBeginBackgroundTask: not in background mode, early out") return } var g *errgroup.Group g, ctx = errgroup.WithContext(ctx) g.Go(func() error { select { case appState = <-kbCtx.MobileAppState.NextUpdate(&appState): kbCtx.Log.Debug( "AppBeginBackgroundTask: app state change, aborting with no task shutdown: %v", appState) return errors.New("app state change") case <-ctx.Done(): return ctx.Err() } }) g.Go(func() error { ch, cancel := kbChatCtx.MessageDeliverer.NextFailure() defer cancel() select { case obrs := <-ch: kbCtx.Log.Debug( "AppBeginBackgroundTask: failure received, alerting the user: %d marked", len(obrs)) pushPendingMessageFailure(obrs, pusher) return errors.New("failure received") case <-ctx.Done(): return ctx.Err() } }) g.Go(func() error { successCount := 0 for { select { case <-ticker.C: obrs, err := kbChatCtx.MessageDeliverer.ActiveDeliveries(ctx) if err != nil { kbCtx.Log.Debug("AppBeginBackgroundTask: failed to query active deliveries: %s", err) continue } if len(obrs) == 0 { kbCtx.Log.Debug("AppBeginBackgroundTask: delivered everything: successCount: %d", successCount) // We can race the failure case here, so lets go a couple passes of no pending // convs before we abort due to ths condition. if successCount > 1 { return errors.New("delivered everything") } successCount++ } curTime := libkb.ForceWallClock(time.Now()) if curTime.Sub(beginTime) >= 10*time.Minute { kbCtx.Log.Debug("AppBeginBackgroundTask: failed to deliver and time is up, aborting") pushPendingMessageFailure(obrs, pusher) return errors.New("time expired") } case <-ctx.Done(): return ctx.Err() } } }) if err := g.Wait(); err != nil { kbCtx.Log.Debug("AppBeginBackgroundTask: dropped out of wait because: %s", err) } }
go
func AppBeginBackgroundTask(pusher PushNotifier) { if !isInited() { return } defer kbCtx.Trace("AppBeginBackgroundTask", func() error { return nil })() ctx := context.Background() // Poll active deliveries in case we can shutdown early beginTime := libkb.ForceWallClock(time.Now()) ticker := time.NewTicker(5 * time.Second) appState := kbCtx.MobileAppState.State() if appState != keybase1.MobileAppState_BACKGROUNDACTIVE { kbCtx.Log.Debug("AppBeginBackgroundTask: not in background mode, early out") return } var g *errgroup.Group g, ctx = errgroup.WithContext(ctx) g.Go(func() error { select { case appState = <-kbCtx.MobileAppState.NextUpdate(&appState): kbCtx.Log.Debug( "AppBeginBackgroundTask: app state change, aborting with no task shutdown: %v", appState) return errors.New("app state change") case <-ctx.Done(): return ctx.Err() } }) g.Go(func() error { ch, cancel := kbChatCtx.MessageDeliverer.NextFailure() defer cancel() select { case obrs := <-ch: kbCtx.Log.Debug( "AppBeginBackgroundTask: failure received, alerting the user: %d marked", len(obrs)) pushPendingMessageFailure(obrs, pusher) return errors.New("failure received") case <-ctx.Done(): return ctx.Err() } }) g.Go(func() error { successCount := 0 for { select { case <-ticker.C: obrs, err := kbChatCtx.MessageDeliverer.ActiveDeliveries(ctx) if err != nil { kbCtx.Log.Debug("AppBeginBackgroundTask: failed to query active deliveries: %s", err) continue } if len(obrs) == 0 { kbCtx.Log.Debug("AppBeginBackgroundTask: delivered everything: successCount: %d", successCount) // We can race the failure case here, so lets go a couple passes of no pending // convs before we abort due to ths condition. if successCount > 1 { return errors.New("delivered everything") } successCount++ } curTime := libkb.ForceWallClock(time.Now()) if curTime.Sub(beginTime) >= 10*time.Minute { kbCtx.Log.Debug("AppBeginBackgroundTask: failed to deliver and time is up, aborting") pushPendingMessageFailure(obrs, pusher) return errors.New("time expired") } case <-ctx.Done(): return ctx.Err() } } }) if err := g.Wait(); err != nil { kbCtx.Log.Debug("AppBeginBackgroundTask: dropped out of wait because: %s", err) } }
[ "func", "AppBeginBackgroundTask", "(", "pusher", "PushNotifier", ")", "{", "if", "!", "isInited", "(", ")", "{", "return", "\n", "}", "\n", "defer", "kbCtx", ".", "Trace", "(", "\"", "\"", ",", "func", "(", ")", "error", "{", "return", "nil", "}", ")...
// AppBeginBackgroundTask notifies us that an app background task has been started on our behalf. This // function will return once we no longer need any time in the background.
[ "AppBeginBackgroundTask", "notifies", "us", "that", "an", "app", "background", "task", "has", "been", "started", "on", "our", "behalf", ".", "This", "function", "will", "return", "once", "we", "no", "longer", "need", "any", "time", "in", "the", "background", ...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/bind/keybase.go#L571-L644
160,884
keybase/client
go/kbfs/libkbfs/crypto_local.go
NewCryptoLocal
func NewCryptoLocal(codec kbfscodec.Codec, signingKey kbfscrypto.SigningKey, cryptPrivateKey kbfscrypto.CryptPrivateKey, blockCryptVersioner blockCryptVersioner) *CryptoLocal { return &CryptoLocal{ MakeCryptoCommon(codec, blockCryptVersioner), kbfscrypto.SigningKeySigner{Key: signingKey}, cryptPrivateKey, make(map[keybase1.TeamID]perTeamKeyPairs), } }
go
func NewCryptoLocal(codec kbfscodec.Codec, signingKey kbfscrypto.SigningKey, cryptPrivateKey kbfscrypto.CryptPrivateKey, blockCryptVersioner blockCryptVersioner) *CryptoLocal { return &CryptoLocal{ MakeCryptoCommon(codec, blockCryptVersioner), kbfscrypto.SigningKeySigner{Key: signingKey}, cryptPrivateKey, make(map[keybase1.TeamID]perTeamKeyPairs), } }
[ "func", "NewCryptoLocal", "(", "codec", "kbfscodec", ".", "Codec", ",", "signingKey", "kbfscrypto", ".", "SigningKey", ",", "cryptPrivateKey", "kbfscrypto", ".", "CryptPrivateKey", ",", "blockCryptVersioner", "blockCryptVersioner", ")", "*", "CryptoLocal", "{", "retur...
// NewCryptoLocal constructs a new CryptoLocal instance with the given // signing key.
[ "NewCryptoLocal", "constructs", "a", "new", "CryptoLocal", "instance", "with", "the", "given", "signing", "key", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/crypto_local.go#L36-L46
160,885
keybase/client
go/kbfs/libkbfs/crypto_local.go
DecryptTLFCryptKeyClientHalf
func (c *CryptoLocal) DecryptTLFCryptKeyClientHalf(ctx context.Context, publicKey kbfscrypto.TLFEphemeralPublicKey, encryptedClientHalf kbfscrypto.EncryptedTLFCryptKeyClientHalf) ( kbfscrypto.TLFCryptKeyClientHalf, error) { return kbfscrypto.DecryptTLFCryptKeyClientHalf( c.cryptPrivateKey, publicKey, encryptedClientHalf) }
go
func (c *CryptoLocal) DecryptTLFCryptKeyClientHalf(ctx context.Context, publicKey kbfscrypto.TLFEphemeralPublicKey, encryptedClientHalf kbfscrypto.EncryptedTLFCryptKeyClientHalf) ( kbfscrypto.TLFCryptKeyClientHalf, error) { return kbfscrypto.DecryptTLFCryptKeyClientHalf( c.cryptPrivateKey, publicKey, encryptedClientHalf) }
[ "func", "(", "c", "*", "CryptoLocal", ")", "DecryptTLFCryptKeyClientHalf", "(", "ctx", "context", ".", "Context", ",", "publicKey", "kbfscrypto", ".", "TLFEphemeralPublicKey", ",", "encryptedClientHalf", "kbfscrypto", ".", "EncryptedTLFCryptKeyClientHalf", ")", "(", "...
// DecryptTLFCryptKeyClientHalf implements the Crypto interface for // CryptoLocal.
[ "DecryptTLFCryptKeyClientHalf", "implements", "the", "Crypto", "interface", "for", "CryptoLocal", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/crypto_local.go#L50-L56
160,886
keybase/client
go/kbfs/libkbfs/crypto_local.go
DecryptTLFCryptKeyClientHalfAny
func (c *CryptoLocal) DecryptTLFCryptKeyClientHalfAny(ctx context.Context, keys []EncryptedTLFCryptKeyClientAndEphemeral, _ bool) ( clientHalf kbfscrypto.TLFCryptKeyClientHalf, index int, err error) { if len(keys) == 0 { return kbfscrypto.TLFCryptKeyClientHalf{}, -1, errors.WithStack(NoKeysError{}) } var firstNonDecryptionErr error for i, k := range keys { clientHalf, err := c.DecryptTLFCryptKeyClientHalf( ctx, k.EPubKey, k.ClientHalf) if err != nil { _, isDecryptionError := errors.Cause(err).(libkb.DecryptionError) if firstNonDecryptionErr == nil && !isDecryptionError { firstNonDecryptionErr = err } continue } return clientHalf, i, nil } // This is to mimic the behavior in // CryptoClient.DecryptTLFCryptKeyClientHalfAny, which is to, // if all calls to prepareTLFCryptKeyClientHalf failed, return // the first prep error, and otherwise to return the error // from the service, which is usually libkb.DecryptionError. if firstNonDecryptionErr != nil { return kbfscrypto.TLFCryptKeyClientHalf{}, -1, firstNonDecryptionErr } return kbfscrypto.TLFCryptKeyClientHalf{}, -1, errors.WithStack(libkb.DecryptionError{}) }
go
func (c *CryptoLocal) DecryptTLFCryptKeyClientHalfAny(ctx context.Context, keys []EncryptedTLFCryptKeyClientAndEphemeral, _ bool) ( clientHalf kbfscrypto.TLFCryptKeyClientHalf, index int, err error) { if len(keys) == 0 { return kbfscrypto.TLFCryptKeyClientHalf{}, -1, errors.WithStack(NoKeysError{}) } var firstNonDecryptionErr error for i, k := range keys { clientHalf, err := c.DecryptTLFCryptKeyClientHalf( ctx, k.EPubKey, k.ClientHalf) if err != nil { _, isDecryptionError := errors.Cause(err).(libkb.DecryptionError) if firstNonDecryptionErr == nil && !isDecryptionError { firstNonDecryptionErr = err } continue } return clientHalf, i, nil } // This is to mimic the behavior in // CryptoClient.DecryptTLFCryptKeyClientHalfAny, which is to, // if all calls to prepareTLFCryptKeyClientHalf failed, return // the first prep error, and otherwise to return the error // from the service, which is usually libkb.DecryptionError. if firstNonDecryptionErr != nil { return kbfscrypto.TLFCryptKeyClientHalf{}, -1, firstNonDecryptionErr } return kbfscrypto.TLFCryptKeyClientHalf{}, -1, errors.WithStack(libkb.DecryptionError{}) }
[ "func", "(", "c", "*", "CryptoLocal", ")", "DecryptTLFCryptKeyClientHalfAny", "(", "ctx", "context", ".", "Context", ",", "keys", "[", "]", "EncryptedTLFCryptKeyClientAndEphemeral", ",", "_", "bool", ")", "(", "clientHalf", "kbfscrypto", ".", "TLFCryptKeyClientHalf"...
// DecryptTLFCryptKeyClientHalfAny implements the Crypto interface for // CryptoLocal.
[ "DecryptTLFCryptKeyClientHalfAny", "implements", "the", "Crypto", "interface", "for", "CryptoLocal", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/crypto_local.go#L60-L92
160,887
keybase/client
go/kbfs/libkbfs/crypto_local.go
DecryptTeamMerkleLeaf
func (c *CryptoLocal) DecryptTeamMerkleLeaf( ctx context.Context, teamID keybase1.TeamID, publicKey kbfscrypto.TLFEphemeralPublicKey, encryptedMerkleLeaf kbfscrypto.EncryptedMerkleLeaf, minKeyGen keybase1.PerTeamKeyGeneration) (decryptedData []byte, err error) { perTeamKeys := c.teamPrivateKeys[teamID] maxKeyGen := keybase1.PerTeamKeyGeneration(len(perTeamKeys)) for i := minKeyGen; i <= maxKeyGen; i++ { decryptedData, err := kbfscrypto.DecryptMerkleLeaf( perTeamKeys[i].privKey, publicKey, encryptedMerkleLeaf) if err == nil { return decryptedData, nil } } return nil, errors.WithStack(libkb.DecryptionError{}) }
go
func (c *CryptoLocal) DecryptTeamMerkleLeaf( ctx context.Context, teamID keybase1.TeamID, publicKey kbfscrypto.TLFEphemeralPublicKey, encryptedMerkleLeaf kbfscrypto.EncryptedMerkleLeaf, minKeyGen keybase1.PerTeamKeyGeneration) (decryptedData []byte, err error) { perTeamKeys := c.teamPrivateKeys[teamID] maxKeyGen := keybase1.PerTeamKeyGeneration(len(perTeamKeys)) for i := minKeyGen; i <= maxKeyGen; i++ { decryptedData, err := kbfscrypto.DecryptMerkleLeaf( perTeamKeys[i].privKey, publicKey, encryptedMerkleLeaf) if err == nil { return decryptedData, nil } } return nil, errors.WithStack(libkb.DecryptionError{}) }
[ "func", "(", "c", "*", "CryptoLocal", ")", "DecryptTeamMerkleLeaf", "(", "ctx", "context", ".", "Context", ",", "teamID", "keybase1", ".", "TeamID", ",", "publicKey", "kbfscrypto", ".", "TLFEphemeralPublicKey", ",", "encryptedMerkleLeaf", "kbfscrypto", ".", "Encry...
// DecryptTeamMerkleLeaf implements the Crypto interface for // CryptoLocal.
[ "DecryptTeamMerkleLeaf", "implements", "the", "Crypto", "interface", "for", "CryptoLocal", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/crypto_local.go#L119-L135
160,888
keybase/client
go/kbfs/libfs/update_history.go
GetEncodedUpdateHistory
func GetEncodedUpdateHistory( ctx context.Context, config libkbfs.Config, folderBranch data.FolderBranch) ( data []byte, t time.Time, err error) { history, err := config.KBFSOps().GetUpdateHistory(ctx, folderBranch) if err != nil { return nil, time.Time{}, err } data, err = json.Marshal(history) if err != nil { return nil, time.Time{}, err } data = append(data, '\n') return data, time.Time{}, nil }
go
func GetEncodedUpdateHistory( ctx context.Context, config libkbfs.Config, folderBranch data.FolderBranch) ( data []byte, t time.Time, err error) { history, err := config.KBFSOps().GetUpdateHistory(ctx, folderBranch) if err != nil { return nil, time.Time{}, err } data, err = json.Marshal(history) if err != nil { return nil, time.Time{}, err } data = append(data, '\n') return data, time.Time{}, nil }
[ "func", "GetEncodedUpdateHistory", "(", "ctx", "context", ".", "Context", ",", "config", "libkbfs", ".", "Config", ",", "folderBranch", "data", ".", "FolderBranch", ")", "(", "data", "[", "]", "byte", ",", "t", "time", ".", "Time", ",", "err", "error", "...
// GetEncodedUpdateHistory returns a JSON-encoded version of a TLF's // complete update history.
[ "GetEncodedUpdateHistory", "returns", "a", "JSON", "-", "encoded", "version", "of", "a", "TLF", "s", "complete", "update", "history", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/update_history.go#L18-L34
160,889
keybase/client
go/kbfs/libkbfs/keycache.go
NewKeyCacheStandard
func NewKeyCacheStandard(capacity int) *KeyCacheStandard { head, err := lru.New(capacity) if err != nil { panic(err.Error()) } return &KeyCacheStandard{head} }
go
func NewKeyCacheStandard(capacity int) *KeyCacheStandard { head, err := lru.New(capacity) if err != nil { panic(err.Error()) } return &KeyCacheStandard{head} }
[ "func", "NewKeyCacheStandard", "(", "capacity", "int", ")", "*", "KeyCacheStandard", "{", "head", ",", "err", ":=", "lru", ".", "New", "(", "capacity", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ".", "Error", "(", ")", ")", "\n", ...
// NewKeyCacheStandard constructs a new KeyCacheStandard with the given // cache capacity.
[ "NewKeyCacheStandard", "constructs", "a", "new", "KeyCacheStandard", "with", "the", "given", "cache", "capacity", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keycache.go#L28-L34
160,890
keybase/client
go/kbfs/libkbfs/keycache.go
GetTLFCryptKey
func (k *KeyCacheStandard) GetTLFCryptKey(tlf tlf.ID, keyGen kbfsmd.KeyGen) ( kbfscrypto.TLFCryptKey, error) { cacheKey := keyCacheKey{tlf, keyGen} if entry, ok := k.lru.Get(cacheKey); ok { if key, ok := entry.(kbfscrypto.TLFCryptKey); ok { return key, nil } // shouldn't really be possible return kbfscrypto.TLFCryptKey{}, KeyCacheHitError{tlf, keyGen} } return kbfscrypto.TLFCryptKey{}, KeyCacheMissError{tlf, keyGen} }
go
func (k *KeyCacheStandard) GetTLFCryptKey(tlf tlf.ID, keyGen kbfsmd.KeyGen) ( kbfscrypto.TLFCryptKey, error) { cacheKey := keyCacheKey{tlf, keyGen} if entry, ok := k.lru.Get(cacheKey); ok { if key, ok := entry.(kbfscrypto.TLFCryptKey); ok { return key, nil } // shouldn't really be possible return kbfscrypto.TLFCryptKey{}, KeyCacheHitError{tlf, keyGen} } return kbfscrypto.TLFCryptKey{}, KeyCacheMissError{tlf, keyGen} }
[ "func", "(", "k", "*", "KeyCacheStandard", ")", "GetTLFCryptKey", "(", "tlf", "tlf", ".", "ID", ",", "keyGen", "kbfsmd", ".", "KeyGen", ")", "(", "kbfscrypto", ".", "TLFCryptKey", ",", "error", ")", "{", "cacheKey", ":=", "keyCacheKey", "{", "tlf", ",", ...
// GetTLFCryptKey implements the KeyCache interface for KeyCacheStandard.
[ "GetTLFCryptKey", "implements", "the", "KeyCache", "interface", "for", "KeyCacheStandard", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keycache.go#L37-L48
160,891
keybase/client
go/kbfs/libkbfs/keycache.go
PutTLFCryptKey
func (k *KeyCacheStandard) PutTLFCryptKey( tlf tlf.ID, keyGen kbfsmd.KeyGen, key kbfscrypto.TLFCryptKey) error { cacheKey := keyCacheKey{tlf, keyGen} k.lru.Add(cacheKey, key) return nil }
go
func (k *KeyCacheStandard) PutTLFCryptKey( tlf tlf.ID, keyGen kbfsmd.KeyGen, key kbfscrypto.TLFCryptKey) error { cacheKey := keyCacheKey{tlf, keyGen} k.lru.Add(cacheKey, key) return nil }
[ "func", "(", "k", "*", "KeyCacheStandard", ")", "PutTLFCryptKey", "(", "tlf", "tlf", ".", "ID", ",", "keyGen", "kbfsmd", ".", "KeyGen", ",", "key", "kbfscrypto", ".", "TLFCryptKey", ")", "error", "{", "cacheKey", ":=", "keyCacheKey", "{", "tlf", ",", "ke...
// PutTLFCryptKey implements the KeyCache interface for KeyCacheStandard.
[ "PutTLFCryptKey", "implements", "the", "KeyCache", "interface", "for", "KeyCacheStandard", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libkbfs/keycache.go#L51-L56
160,892
keybase/client
go/kbfs/libfs/json.go
PrettyJSON
func PrettyJSON(value interface{}) ([]byte, error) { data, err := json.MarshalIndent(value, "", " ") if err != nil { return nil, err } data = append(data, '\n') return data, nil }
go
func PrettyJSON(value interface{}) ([]byte, error) { data, err := json.MarshalIndent(value, "", " ") if err != nil { return nil, err } data = append(data, '\n') return data, nil }
[ "func", "PrettyJSON", "(", "value", "interface", "{", "}", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "data", ",", "err", ":=", "json", ".", "MarshalIndent", "(", "value", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", "if", "err", "!=", ...
// PrettyJSON marshals a value to human-readable JSON.
[ "PrettyJSON", "marshals", "a", "value", "to", "human", "-", "readable", "JSON", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/json.go#L12-L19
160,893
keybase/client
go/kbfs/kbfssync/semaphore.go
Count
func (s *Semaphore) Count() int64 { s.lock.RLock() defer s.lock.RUnlock() return s.count }
go
func (s *Semaphore) Count() int64 { s.lock.RLock() defer s.lock.RUnlock() return s.count }
[ "func", "(", "s", "*", "Semaphore", ")", "Count", "(", ")", "int64", "{", "s", ".", "lock", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "lock", ".", "RUnlock", "(", ")", "\n", "return", "s", ".", "count", "\n", "}" ]
// Count returns the current resource count.
[ "Count", "returns", "the", "current", "resource", "count", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfssync/semaphore.go#L34-L38
160,894
keybase/client
go/kbfs/kbfssync/semaphore.go
tryAcquire
func (s *Semaphore) tryAcquire(n int64) (<-chan struct{}, int64) { s.lock.Lock() defer s.lock.Unlock() if n <= s.count { s.count -= n return nil, s.count } return s.onRelease, s.count }
go
func (s *Semaphore) tryAcquire(n int64) (<-chan struct{}, int64) { s.lock.Lock() defer s.lock.Unlock() if n <= s.count { s.count -= n return nil, s.count } return s.onRelease, s.count }
[ "func", "(", "s", "*", "Semaphore", ")", "tryAcquire", "(", "n", "int64", ")", "(", "<-", "chan", "struct", "{", "}", ",", "int64", ")", "{", "s", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "lock", ".", "Unlock", "(", ")", "...
// tryAcquire tries to acquire n resources. If successful, nil is // returned. Otherwise, a channel which will be closed when new // resources are available is returned. In either case, the // possibly-updated resource count is returned.
[ "tryAcquire", "tries", "to", "acquire", "n", "resources", ".", "If", "successful", "nil", "is", "returned", ".", "Otherwise", "a", "channel", "which", "will", "be", "closed", "when", "new", "resources", "are", "available", "is", "returned", ".", "In", "eithe...
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/kbfssync/semaphore.go#L44-L53
160,895
keybase/client
go/install/install_nix.go
LsofMount
func LsofMount(mountDir string, log Log) ([]CommonLsofResult, error) { log.Debug("Mount dir to lsof: %s", mountDir) if mountDir == "" { return nil, nil } if _, serr := os.Stat(mountDir); os.IsNotExist(serr) { log.Debug("%s, mount dir lsof target, doesn't exist", mountDir) return nil, nil } log.Debug("Checking mount (lsof)") processes, err := lsof.MountPoint(mountDir) if err != nil { // If there is an error in lsof it's ok to continue // An exit status of 1 means that the mount is not in use, and is // not really an error. log.Debug("Continuing despite error in lsof: %s", err) return nil, nil } var ret []CommonLsofResult for _, process := range processes { ret = append(ret, CommonLsofResult{process.PID, process.Command}) } return ret, nil }
go
func LsofMount(mountDir string, log Log) ([]CommonLsofResult, error) { log.Debug("Mount dir to lsof: %s", mountDir) if mountDir == "" { return nil, nil } if _, serr := os.Stat(mountDir); os.IsNotExist(serr) { log.Debug("%s, mount dir lsof target, doesn't exist", mountDir) return nil, nil } log.Debug("Checking mount (lsof)") processes, err := lsof.MountPoint(mountDir) if err != nil { // If there is an error in lsof it's ok to continue // An exit status of 1 means that the mount is not in use, and is // not really an error. log.Debug("Continuing despite error in lsof: %s", err) return nil, nil } var ret []CommonLsofResult for _, process := range processes { ret = append(ret, CommonLsofResult{process.PID, process.Command}) } return ret, nil }
[ "func", "LsofMount", "(", "mountDir", "string", ",", "log", "Log", ")", "(", "[", "]", "CommonLsofResult", ",", "error", ")", "{", "log", ".", "Debug", "(", "\"", "\"", ",", "mountDir", ")", "\n", "if", "mountDir", "==", "\"", "\"", "{", "return", ...
// LsofMount does not return an error if it was unable to lsof // the mountpoint or the mountpoint does not exist.
[ "LsofMount", "does", "not", "return", "an", "error", "if", "it", "was", "unable", "to", "lsof", "the", "mountpoint", "or", "the", "mountpoint", "does", "not", "exist", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/install/install_nix.go#L24-L48
160,896
keybase/client
go/kbfs/libfs/root_fs.go
Open
func (rfs *RootFS) Open(filename string) (f billy.File, err error) { if !rootWrappedNodeNames[filename] { // In particular, this FS doesn't let you open the folderlist // directories or anything in them. return nil, os.ErrNotExist } switch filename { case StatusFileName: return &wrappedReadFile{ name: StatusFileName, reader: func(ctx context.Context) ([]byte, time.Time, error) { return GetEncodedStatus(ctx, rfs.config) }, log: rfs.log, }, nil default: panic(fmt.Sprintf("Name %s was in map, but not in switch", filename)) } }
go
func (rfs *RootFS) Open(filename string) (f billy.File, err error) { if !rootWrappedNodeNames[filename] { // In particular, this FS doesn't let you open the folderlist // directories or anything in them. return nil, os.ErrNotExist } switch filename { case StatusFileName: return &wrappedReadFile{ name: StatusFileName, reader: func(ctx context.Context) ([]byte, time.Time, error) { return GetEncodedStatus(ctx, rfs.config) }, log: rfs.log, }, nil default: panic(fmt.Sprintf("Name %s was in map, but not in switch", filename)) } }
[ "func", "(", "rfs", "*", "RootFS", ")", "Open", "(", "filename", "string", ")", "(", "f", "billy", ".", "File", ",", "err", "error", ")", "{", "if", "!", "rootWrappedNodeNames", "[", "filename", "]", "{", "// In particular, this FS doesn't let you open the fol...
// Open implements the billy.Filesystem interface for RootFS.
[ "Open", "implements", "the", "billy", ".", "Filesystem", "interface", "for", "RootFS", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/root_fs.go#L41-L60
160,897
keybase/client
go/kbfs/libfs/root_fs.go
OpenFile
func (rfs *RootFS) OpenFile(filename string, flag int, _ os.FileMode) ( f billy.File, err error) { if flag&os.O_CREATE != 0 { return nil, errors.New("RootFS can't create files") } return rfs.Open(filename) }
go
func (rfs *RootFS) OpenFile(filename string, flag int, _ os.FileMode) ( f billy.File, err error) { if flag&os.O_CREATE != 0 { return nil, errors.New("RootFS can't create files") } return rfs.Open(filename) }
[ "func", "(", "rfs", "*", "RootFS", ")", "OpenFile", "(", "filename", "string", ",", "flag", "int", ",", "_", "os", ".", "FileMode", ")", "(", "f", "billy", ".", "File", ",", "err", "error", ")", "{", "if", "flag", "&", "os", ".", "O_CREATE", "!="...
// OpenFile implements the billy.Filesystem interface for RootFS.
[ "OpenFile", "implements", "the", "billy", ".", "Filesystem", "interface", "for", "RootFS", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/root_fs.go#L63-L70
160,898
keybase/client
go/kbfs/libfs/root_fs.go
Lstat
func (rfs *RootFS) Lstat(filename string) (fi os.FileInfo, err error) { if filename == "" { filename = "." } if filename == "." { return &wrappedReadFileInfo{ "keybase", 0, rfs.config.Clock().Now(), true}, nil } if !rootWrappedNodeNames[filename] { return nil, os.ErrNotExist } switch filename { case StatusFileName: wrf := &wrappedReadFile{ name: StatusFileName, reader: func(ctx context.Context) ([]byte, time.Time, error) { return GetEncodedStatus(ctx, rfs.config) }, log: rfs.log, } return wrf.GetInfo(), nil default: panic(fmt.Sprintf("Name %s was in map, but not in switch", filename)) } }
go
func (rfs *RootFS) Lstat(filename string) (fi os.FileInfo, err error) { if filename == "" { filename = "." } if filename == "." { return &wrappedReadFileInfo{ "keybase", 0, rfs.config.Clock().Now(), true}, nil } if !rootWrappedNodeNames[filename] { return nil, os.ErrNotExist } switch filename { case StatusFileName: wrf := &wrappedReadFile{ name: StatusFileName, reader: func(ctx context.Context) ([]byte, time.Time, error) { return GetEncodedStatus(ctx, rfs.config) }, log: rfs.log, } return wrf.GetInfo(), nil default: panic(fmt.Sprintf("Name %s was in map, but not in switch", filename)) } }
[ "func", "(", "rfs", "*", "RootFS", ")", "Lstat", "(", "filename", "string", ")", "(", "fi", "os", ".", "FileInfo", ",", "err", "error", ")", "{", "if", "filename", "==", "\"", "\"", "{", "filename", "=", "\"", "\"", "\n", "}", "\n", "if", "filena...
// Lstat implements the billy.Filesystem interface for RootFS.
[ "Lstat", "implements", "the", "billy", ".", "Filesystem", "interface", "for", "RootFS", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/root_fs.go#L73-L98
160,899
keybase/client
go/kbfs/libfs/root_fs.go
Stat
func (rfs *RootFS) Stat(filename string) (fi os.FileInfo, err error) { return rfs.Lstat(filename) }
go
func (rfs *RootFS) Stat(filename string) (fi os.FileInfo, err error) { return rfs.Lstat(filename) }
[ "func", "(", "rfs", "*", "RootFS", ")", "Stat", "(", "filename", "string", ")", "(", "fi", "os", ".", "FileInfo", ",", "err", "error", ")", "{", "return", "rfs", ".", "Lstat", "(", "filename", ")", "\n", "}" ]
// Stat implements the billy.Filesystem interface for RootFS.
[ "Stat", "implements", "the", "billy", ".", "Filesystem", "interface", "for", "RootFS", "." ]
b352622cd8cc94798cfacbcb56ada203c18e519e
https://github.com/keybase/client/blob/b352622cd8cc94798cfacbcb56ada203c18e519e/go/kbfs/libfs/root_fs.go#L101-L103