예제 #1
0
파일: channel.go 프로젝트: yinqiwen/gsnova
func randCryptoCtx() event.CryptoContext {
	r := rand.New(rand.NewSource(time.Now().UnixNano()))
	tmp := uint64(r.Int63())
	var ctx event.CryptoContext
	ctx.EncryptIV = tmp
	ctx.DecryptIV = tmp
	ctx.Method = event.GetDefaultCryptoMethod()
	return ctx
}
예제 #2
0
파일: utils.go 프로젝트: yinqiwen/gsnova
func NewAuthEvent(secureTransport bool) *event.AuthEvent {
	auth := &event.AuthEvent{}
	auth.User = GConf.Auth
	//auth.Mac = getDeviceId()
	r := rand.New(rand.NewSource(time.Now().UnixNano()))
	auth.SetId(uint32(r.Int31()))
	auth.Rand = []byte(helper.RandAsciiString(int(r.Int31n(128))))
	if secureTransport && strings.EqualFold(GConf.Encrypt.Method, "auto") {
		auth.EncryptMethod = uint8(event.NoneEncrypter)
	} else {
		auth.EncryptMethod = event.GetDefaultCryptoMethod()
	}
	return auth
}