當前位置: 首頁>>代碼示例>>Golang>>正文


Golang protocol.UID類代碼示例

本文整理匯總了Golang中github.com/keybase/client/go/protocol.UID的典型用法代碼示例。如果您正苦於以下問題:Golang UID類的具體用法?Golang UID怎麽用?Golang UID使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了UID類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: RunSyncer

func RunSyncer(s Syncer, uid keybase1.UID, loggedIn bool, sr SessionReader) (err error) {
	if uid.IsNil() {
		return NotFoundError{"No UID given to syncer"}
	}

	// unnecessary for secret syncer, but possibly useful for tracker syncer.
	s.Lock()
	defer s.Unlock()

	s.G().Log.Debug("+ Syncer.Load(%s)", uid)
	defer func() {
		s.G().Log.Debug("- Syncer.Load(%s) -> %s", uid, ErrToOk(err))
	}()

	if err = s.loadFromStorage(uid); err != nil {
		return
	}
	if s.needsLogin() && !loggedIn {
		s.G().Log.Debug("| Won't sync with server since we're not logged in")
		return
	}
	if err = s.syncFromServer(uid, sr); err != nil {
		return
	}
	if err = s.store(uid); err != nil {
		return
	}

	return
}
開發者ID:paul-pearce,項目名稱:client-beta,代碼行數:30,代碼來源:syncer.go

示例2: getLocalUser

func (m localUserMap) getLocalUser(uid keybase1.UID) (LocalUser, error) {
	user, ok := m[uid]
	if !ok {
		return LocalUser{}, NoSuchUserError{uid.String()}
	}
	return user, nil
}
開發者ID:gozes,項目名稱:kbfs-beta,代碼行數:7,代碼來源:keybase_daemon_local.go

示例3: CheckUIDAgainstCasedUsername

// CheckUIDAgainstCasedUsername takes the input string, does not convert toLower,
// and then hashes it to recover a UID. This is a workaround for some
// users whose UIDs were computed incorrectly.
func CheckUIDAgainstCasedUsername(uid keybase1.UID, username string) (err error) {
	u2 := UsernameToUIDPreserveCase(username)
	if uid.NotEqual(u2) {
		err = UIDMismatchError{fmt.Sprintf("%s != %s (via %s)", uid, u2, username)}
	}
	return
}
開發者ID:paul-pearce,項目名稱:client-beta,代碼行數:10,代碼來源:uid.go

示例4: getUserCard

func getUserCard(g *libkb.GlobalContext, uid keybase1.UID, useSession bool) (ret *keybase1.UserCard, err error) {
	defer g.Trace("getUserCard", func() error { return err })()

	arg := libkb.APIArg{
		Endpoint:     "user/card",
		NeedSession:  useSession,
		Contextified: libkb.NewContextified(g),
		Args:         libkb.HTTPArgs{"uid": libkb.S{Val: uid.String()}},
	}

	var card card

	if err = g.API.GetDecode(arg, &card); err != nil {
		g.Log.Warning("error getting user/card for %s: %s\n", uid, err)
		return nil, err
	}

	g.Log.Debug("user card: %+v", card)

	ret = &keybase1.UserCard{
		Following:     card.FollowSummary.Following,
		Followers:     card.FollowSummary.Followers,
		Uid:           uid,
		FullName:      card.Profile.FullName,
		Location:      card.Profile.Location,
		Bio:           card.Profile.Bio,
		Website:       card.Profile.Website,
		Twitter:       card.Profile.Twitter,
		YouFollowThem: card.YouFollowThem,
		TheyFollowYou: card.TheyFollowYou,
	}
	return ret, nil
}
開發者ID:mark-adams,項目名稱:client,代碼行數:33,代碼來源:identify.go

示例5: LoadUserPlusKeys

func LoadUserPlusKeys(g *GlobalContext, uid keybase1.UID, cacheOK bool) (keybase1.UserPlusKeys, error) {
	var up keybase1.UserPlusKeys
	if uid.IsNil() {
		return up, fmt.Errorf("Nil UID")
	}

	arg := NewLoadUserArg(g)
	arg.UID = uid
	arg.PublicKeyOptional = true
	u, err := LoadUser(arg)
	if err != nil {
		return up, err
	}
	if u == nil {
		return up, fmt.Errorf("Nil user, nil error from LoadUser")
	}

	// export user to UserPlusKeys
	up.Uid = u.GetUID()
	up.Username = u.GetNormalizedName().String()
	if u.GetComputedKeyFamily() != nil {
		up.DeviceKeys = u.GetComputedKeyFamily().ExportDeviceKeys()
	}

	return up, nil
}
開發者ID:mattcurrycom,項目名稱:client,代碼行數:26,代碼來源:loaduser.go

示例6: identifySender

func (e *SaltpackSenderIdentify) identifySender(ctx *Context) (err error) {
	defer e.G().Trace("SaltpackDecrypt::identifySender", func() error { return err })()

	var lin bool
	var uid keybase1.UID
	if lin, uid, err = IsLoggedIn(e, ctx); err == nil && lin && uid.Equal(e.res.Uid) {
		e.G().Log.Debug("| Sender is self")
		e.res.SenderType = keybase1.SaltpackSenderType_SELF
		return nil
	}

	iarg := keybase1.Identify2Arg{
		Uid:                   e.res.Uid,
		UseDelegateUI:         !e.arg.interactive,
		AlwaysBlock:           e.arg.interactive,
		ForceRemoteCheck:      e.arg.forceRemoteCheck,
		NoErrorOnTrackFailure: true,
		Reason:                e.arg.reason,
		UserAssertion:         e.arg.userAssertion,
	}
	eng := NewIdentify2WithUID(e.G(), &iarg)
	if err = RunEngine(eng, ctx); err != nil {
		return err
	}
	switch eng.getTrackType() {
	case identify2NoTrack:
		e.res.SenderType = keybase1.SaltpackSenderType_NOT_TRACKED
	case identify2TrackOK:
		e.res.SenderType = keybase1.SaltpackSenderType_TRACKING_OK
	default:
		e.res.SenderType = keybase1.SaltpackSenderType_TRACKING_BROKE
	}
	return nil
}
開發者ID:Varjelus,項目名稱:keybase-client,代碼行數:34,代碼來源:saltpack_sender_identify.go

示例7: NewRekeyPermissionError

// NewRekeyPermissionError constructs a RekeyPermissionError for the given
// directory and user.
func NewRekeyPermissionError(ctx context.Context, config Config, dir *TlfHandle,
	uid keybase1.UID) error {
	dirname := dir.ToString(ctx, config)
	if name, err2 := config.KBPKI().GetNormalizedUsername(ctx, uid); err2 == nil {
		return RekeyPermissionError{string(name), dirname}
	}
	return RekeyPermissionError{uid.String(), dirname}
}
開發者ID:gozes,項目名稱:kbfs-beta,代碼行數:10,代碼來源:errors.go

示例8: GetMyUID

func (g *GlobalContext) GetMyUID() keybase1.UID {
	var uid keybase1.UID

	g.LoginState().LocalSession(func(s *Session) {
		uid = s.GetUID()
	}, "G - GetMyUID - GetUID")
	if uid.Exists() {
		return uid
	}

	return g.Env.GetUID()
}
開發者ID:paul-pearce,項目名稱:client-beta,代碼行數:12,代碼來源:globals.go

示例9: MatchUser

func (mul *MerkleUserLeaf) MatchUser(u *User, uid keybase1.UID, nun NormalizedUsername) (err error) {
	if mul.username != u.GetName() {
		err = MerkleClashError{fmt.Sprintf("vs loaded object: username %s != %s", mul.username, u.GetName())}
	} else if mul.uid.NotEqual(u.GetUID()) {
		err = MerkleClientError{fmt.Sprintf("vs loaded object: UID %s != %s", mul.uid, u.GetUID())}
	} else if !nun.IsNil() && !NewNormalizedUsername(mul.username).Eq(nun) {
		err = MerkleClashError{fmt.Sprintf("vs given arg: username %s != %s", mul.username, nun)}
	} else if uid.NotEqual(mul.uid) {
		err = MerkleClashError{fmt.Sprintf("vs given arg: UID %s != %s", uid, mul.uid)}
	}
	return
}
開發者ID:mattcurrycom,項目名稱:client,代碼行數:12,代碼來源:merkle_client.go

示例10: MatchUser

func (mul *MerkleUserLeaf) MatchUser(u *User, uid keybase1.UID, un string) (err error) {
	if mul.username != u.GetName() {
		err = MerkleClashError{fmt.Sprintf("vs loaded object: username %s != %s", mul.username, u.GetName())}
	} else if mul.uid.NotEqual(u.GetUID()) {
		err = MerkleClientError{fmt.Sprintf("vs loaded object: UID %s != %s", mul.uid, u.GetUID())}
	} else if len(un) > 0 && mul.username != un {
		err = MerkleClashError{fmt.Sprintf("vs given arg: username %s != %s", mul.username, un)}
	} else if uid.NotEqual(mul.uid) {
		err = MerkleClashError{fmt.Sprintf("vs given arg: UID %s != %s", uid, mul.uid)}
	}
	return
}
開發者ID:paul-pearce,項目名稱:client-beta,代碼行數:12,代碼來源:merkle_client.go

示例11: GetTLFCryptKeyServerHalfID

// GetTLFCryptKeyServerHalfID implements the Crypto interface for CryptoCommon.
func (c *CryptoCommon) GetTLFCryptKeyServerHalfID(
	user keybase1.UID, deviceKID keybase1.KID,
	serverHalf TLFCryptKeyServerHalf) (TLFCryptKeyServerHalfID, error) {
	key := serverHalf.data[:]
	data := append(user.ToBytes(), deviceKID.ToBytes()...)
	hmac, err := DefaultHMAC(key, data)
	if err != nil {
		return TLFCryptKeyServerHalfID{}, err
	}
	return TLFCryptKeyServerHalfID{
		ID: hmac,
	}, nil
}
開發者ID:gozes,項目名稱:kbfs-beta,代碼行數:14,代碼來源:crypto_common.go

示例12: lookupMerkleLeaf

func lookupMerkleLeaf(g *GlobalContext, uid keybase1.UID, local *User) (f *MerkleUserLeaf, err error) {
	if uid.IsNil() {
		err = fmt.Errorf("uid parameter for lookupMerkleLeaf empty")
		return
	}
	q := NewHTTPArgs()
	q.Add("uid", UIDArg(uid))

	f, err = g.MerkleClient.LookupUser(q)
	if err == nil && f == nil && local != nil {
		err = fmt.Errorf("User not found in server Merkle tree")
	}
	return
}
開發者ID:mattcurrycom,項目名稱:client,代碼行數:14,代碼來源:loaduser.go

示例13: NewUserConfig

func NewUserConfig(id keybase1.UID, name NormalizedUsername, salt []byte, dev keybase1.DeviceID) *UserConfig {
	ret := &UserConfig{
		ID:               id.String(),
		Name:             name,
		Salt:             hex.EncodeToString(salt),
		Device:           nil,
		importedID:       id,
		importedSalt:     salt,
		importedDeviceID: dev,
	}
	if dev.Exists() {
		tmp := dev.String()
		ret.Device = &tmp
	}
	return ret
}
開發者ID:paul-pearce,項目名稱:client-beta,代碼行數:16,代碼來源:userconfig.go

示例14: LoadUserPlusKeys

func LoadUserPlusKeys(g *GlobalContext, uid keybase1.UID, cacheOK bool) (keybase1.UserPlusKeys, error) {
	var up keybase1.UserPlusKeys
	if uid.IsNil() {
		return up, fmt.Errorf("Nil UID")
	}

	if cacheOK {
		up, err := g.UserCache.Get(uid)
		if err == nil {
			return *up, nil
		}
		if err != nil {
			// not going to bail on cache error, just log it:
			if _, ok := err.(NotFoundError); !ok {
				g.Log.Debug("UserCache Get error: %s", err)
			}
		}
	}

	arg := NewLoadUserArg(g)
	arg.UID = uid
	arg.PublicKeyOptional = true
	u, err := LoadUser(arg)
	if err != nil {
		return up, err
	}
	if u == nil {
		return up, fmt.Errorf("Nil user, nil error from LoadUser")
	}

	// export user to UserPlusKeys
	up.Uid = u.GetUID()
	up.Username = u.GetNormalizedName().String()
	if u.GetComputedKeyFamily() != nil {
		up.DeviceKeys = u.GetComputedKeyFamily().ExportDeviceKeys()
	}

	err = g.UserCache.Insert(&up)
	if err != nil {
		g.Log.Debug("UserCache Set error: %s", err)
	}

	return up, nil
}
開發者ID:polluks,項目名稱:client,代碼行數:44,代碼來源:loaduser.go

示例15: GetUser

func (u *userKeyAPI) GetUser(ctx context.Context, uid keybase1.UID) (
	un libkb.NormalizedUsername, sibkeys, subkeys []keybase1.KID, err error) {
	u.log.Debug("+ GetUser")
	defer func() {
		u.log.Debug("- GetUser -> %v", err)
	}()
	var ukr userKeyRes
	err = u.api.GetDecode(libkb.APIArg{
		Endpoint: "user/keys",
		Args: libkb.HTTPArgs{
			"uid": libkb.S{Val: uid.String()},
		},
	}, &ukr)
	if err != nil {
		return "", nil, nil, err
	}
	un = libkb.NewNormalizedUsername(ukr.Username)
	return un, ukr.PublicKeys.Sibkeys, ukr.PublicKeys.Subkeys, nil
}
開發者ID:Varjelus,項目名稱:keybase-client,代碼行數:19,代碼來源:user_keys_api.go


注:本文中的github.com/keybase/client/go/protocol.UID類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。