コード例 #1
0
ファイル: driver_test.go プロジェクト: kensipe/gomes
func TestFrameworkReRegisteredMessageHandling(t *testing.T) {
	sched := NewMesosScheduler()
	sched.Reregistered = func(driver *SchedulerDriver, masterInfo *mesos.MasterInfo) {
		if masterInfo == nil {
			log.Fatalf("Scheduler.Reregistered expects masterInfo, but got nil")
		}

		if masterInfo.GetId() != "master-1" ||
			masterInfo.GetIp() != 123456 ||
			masterInfo.GetPort() != 12345 {
			log.Fatalf("Scheduler.Registered expected MasterInfo values are missing.")
		}
	}

	msg := &mesos.FrameworkReregisteredMessage{
		FrameworkId: &mesos.FrameworkID{Value: proto.String("test-framework-1")},
		MasterInfo: &mesos.MasterInfo{
			Id:   proto.String("master-1"),
			Ip:   proto.Uint32(123456),
			Port: proto.Uint32(12345),
		},
	}
	driver, err := NewSchedDriver(sched, &mesos.FrameworkInfo{}, "localhost:0")
	if err != nil {
		t.Fatal(err)
	}
	driver.schedMsgQ <- msg
}
コード例 #2
0
ファイル: freeze.go プロジェクト: rok-kek/grumble
// Update the datastore with the user's current state.
func (server *Server) UpdateFrozenUser(client *Client, state *mumbleproto.UserState) {
	// Full sync If there's no userstate messgae provided, or if there is one, and
	// it includes a registration operation.
	user := client.user
	nanos := time.Now().Unix()
	if state == nil || state.UserId != nil {
		fu, err := user.Freeze()
		if err != nil {
			server.Fatal(err)
		}
		fu.LastActive = proto.Uint64(uint64(nanos))
		err = server.freezelog.Put(fu)
		if err != nil {
			server.Fatal(err)
		}
	} else {
		fu := &freezer.User{}
		fu.Id = proto.Uint32(user.Id)
		if state.ChannelId != nil {
			fu.LastChannelId = proto.Uint32(uint32(client.Channel.Id))
		}
		if state.TextureHash != nil {
			fu.TextureBlob = proto.String(user.TextureBlob)
		}
		if state.CommentHash != nil {
			fu.CommentBlob = proto.String(user.CommentBlob)
		}
		fu.LastActive = proto.Uint64(uint64(nanos))
		err := server.freezelog.Put(fu)
		if err != nil {
			server.Fatal(err)
		}
	}
	server.numLogOps += 1
}
コード例 #3
0
ファイル: ticket_grabber.go プロジェクト: petemoore/printing3
func createSubmit(db *sqlx.DB, sub *scannedSubmit, submitNo int) *tickets.Ticket_Submit {
	var result tickets.Ticket_Submit
	result.SubmitNumber = proto.Uint32(uint32(submitNo))
	if sub.Arrived > 0 {
		result.Arrived = proto.Uint64(uint64(sub.Arrived))
	}
	if result.Compiled = proto.Bool(sub.Compiled == 1); !result.GetCompiled() {
		return &result
	}
	if sub.SchoolMode != 0 {
		result.School = &tickets.Ticket_Submit_School{TestsTaken: proto.Uint32(uint32(sub.Taken)), TestsPassed: proto.Uint32(uint32(sub.Passed))}
	} else {
		var description string
		var test int64
		err := db.QueryRow("select ResultDesc.Description, Results.Test from Results, ResultDesc where "+
			"Results.UID = ? and ResultDesc.ID = Results.Result and not ResultDesc.Success order by Results.Test",
			sub.TestingID).Scan(&description, &test)
		switch {
		case err == sql.ErrNoRows:
			if sub.Passed != 0 && sub.Passed == sub.Taken {
				result.Acm = &tickets.Ticket_Submit_ACM{Result: proto.String("ACCEPTED")}
			}
		case err != nil:
			log.Fatal(err)
			return nil
		default:
			result.Acm = &tickets.Ticket_Submit_ACM{Result: &description, TestId: proto.Uint32(uint32(test))}
		}
	}
	return &result
}
コード例 #4
0
ファイル: project.go プロジェクト: Khady/obiwan-kanbanobi
func MsgProjectDelete(conn net.Conn, msg *message.Msg) {
	proj := &Project{
		Id: *msg.Projects.Id,
	}
	var answer *message.Msg
	temp := getListOfUser(proj.Id)
	if err := proj.Del(dbPool); err != nil {
		answer = &message.Msg{
			Target:    message.TARGET_PROJECTS.Enum(),
			Command:   message.CMD_ERROR.Enum(),
			AuthorId:  proto.Uint32(*msg.AuthorId),
			SessionId: proto.String(*msg.SessionId),
			Error: &message.Msg_Error{
				ErrorId: proto.Uint32(32),
			},
		}
	} else {
		answer = &message.Msg{
			Target:    message.TARGET_PROJECTS.Enum(),
			Command:   message.CMD_SUCCES.Enum(),
			AuthorId:  proto.Uint32(*msg.AuthorId),
			SessionId: proto.String(*msg.SessionId),
		}
		sendMsgToallUser(temp, msg)
	}
	data, err := proto.Marshal(answer)
	if err != nil {
		LOGGER.Print("Impossible to marshal msg in MsgProjectUpdate", err, answer)
		return
	}
	conn.Write(write_int32(int32(len(data))))
	conn.Write(data)
}
コード例 #5
0
func TestParseSectionIntro_Valid(t *testing.T) {
	lines := []string{
		"10",
		"BUILDID",
		"NODEID 123 321 789",
		"12 23 34",
	}
	trace := Trace{}
	err := parseSectionIntro(lines, &trace)
	if err != nil {
		t.Fatal("Unexpected error:", err)
	}
	expectedTrace := Trace{
		FileFormatVersion: proto.Int32(10),
		BuildId:           proto.String("BUILDID"),
		NodeId:            proto.String("NODEID"),
		ProcessStartTimeMicroseconds: proto.Int64(123),
		SequenceNumber:               proto.Int32(321),
		TraceCreationTimestamp:       proto.Int64(789),
		PcapReceived:                 proto.Uint32(12),
		PcapDropped:                  proto.Uint32(23),
		InterfaceDropped:             proto.Uint32(34),
	}
	checkProtosEqual(t, &expectedTrace, &trace)
}
コード例 #6
0
func (self *InterfaceForProject) LeaveGroup(interfaceCMD *business.Command) (resultPacket Packet, err error) {
	//1.从interfaceCMD 中解析出所需要的信息
	//2.处理,并且得到结果
	//3.把结果写入CMD,并且做成Packet 返回。

	//1.解析...................................
	dialogid := interfaceCMD.GetGroupid()
	if dialogid == 0 {
		feedbackCMD.Result = proto.Uint32(2)
		feedbackCMD.ResultDescription = proto.String("no dialogid")
		resultPacket = *MakeInterfacePacket(feedbackCMD, 103)
		return resultPacket, err
	}
	//var uids []uint64
	//	uids = make([]uint64, 0, len(interfaceCMD.GetUid()))
	uids := interfaceCMD.GetUid()[:]
	if uids == nil {
		feedbackCMD.Result = proto.Uint32(2)
		feedbackCMD.ResultDescription = proto.String("no uid")
		resultPacket = *MakeInterfacePacket(feedbackCMD, 103)
		return resultPacket, err
	}
	////检测uid,dialogid是否合法。。。未完成********************

	//2.处理...................................

	//查询数据库的dialog表,给对应的uid添加当前时间戳。修该chatMap的dialogId的成员。

	//1.修改数据库dialog表,添加时间戳
	dbUpdateDialog, err := self.InterfaceDB.Db.Prepare("update dialog set timestamp=? where dialog_id=? and uid=?")

	if err != nil {
		ImBusinessLog("Prepare to update dialog error:", err)
		feedbackCMD.Result = proto.Uint32(1)
		feedbackCMD.ResultDescription = proto.String("IM error.")
		resultPacket = *MakeInterfacePacket(feedbackCMD, 103)
		return resultPacket, err
	}
	defer dbUpdateDialog.Close()
	for _, uid := range uids {
		_, err = dbUpdateDialog.Exec(time.Now().Format("2006-01-02 15:04:05"), dialogid, uid)
		if err != nil {
			ImBusinessLog("Update dialog error : ", err)
			feedbackCMD.Result = proto.Uint32(1)
			feedbackCMD.ResultDescription = proto.String("IM error.")
			resultPacket = *MakeInterfacePacket(feedbackCMD, 103)
			return resultPacket, err
		}
		//2.修改chatMap
		_, flag := SessionTable[uid]
		if flag == true {
			delete(SessionTable[uid].chatMap, dialogid)
		}
	}
	//3.打包...................................
	feedbackCMD.Result = proto.Uint32(0)
	feedbackCMD.ResultDescription = proto.String("OK")
	resultPacket = *MakeInterfacePacket(feedbackCMD, 103)
	return resultPacket, nil
}
コード例 #7
0
ファイル: mesosutil.go プロジェクト: vladimirvivien/gomes
func NewMasterInfo(id string, ip, port uint32) *mesos.MasterInfo {
	return &mesos.MasterInfo{
		Id:   proto.String(id),
		Ip:   proto.Uint32(ip),
		Port: proto.Uint32(port),
	}
}
コード例 #8
0
ファイル: freeze.go プロジェクト: rok-kek/grumble
// Freeze a ban into a flattened protobuf-based struct
// ready to be persisted to disk.
func FreezeBan(ban ban.Ban) (fb *freezer.Ban) {
	fb = new(freezer.Ban)

	fb.Ip = ban.IP
	fb.Mask = proto.Uint32(uint32(ban.Mask))
	fb.Username = proto.String(ban.Username)
	fb.CertHash = proto.String(ban.CertHash)
	fb.Reason = proto.String(ban.Reason)
	fb.Start = proto.Int64(ban.Start)
	fb.Duration = proto.Uint32(ban.Duration)
	return
}
コード例 #9
0
func unidentifiedUser(conn net.Conn, msg *message.Msg) {
	LOGGER.Print("unidentifiedUser")
	answer := &message.Msg{
		Target:    message.TARGET_IDENT.Enum(),
		Command:   message.CMD_ERROR.Enum(),
		AuthorId:  proto.Uint32(*msg.AuthorId),
		SessionId: proto.String(*msg.SessionId),
		Error: &message.Msg_Error{
			ErrorId: proto.Uint32(1),
		},
	}
	sendKanbanMsg(conn, answer)
}
コード例 #10
0
ファイル: freeze.go プロジェクト: rok-kek/grumble
// Freeze a ChannelACL into it a flattened protobuf-based structure
// ready to be persisted to disk.
func FreezeACL(aclEntry acl.ACL) (*freezer.ACL, error) {
	frozenAcl := &freezer.ACL{}
	if aclEntry.UserId != -1 {
		frozenAcl.UserId = proto.Uint32(uint32(aclEntry.UserId))
	} else {
		frozenAcl.Group = proto.String(aclEntry.Group)
	}
	frozenAcl.ApplyHere = proto.Bool(aclEntry.ApplyHere)
	frozenAcl.ApplySubs = proto.Bool(aclEntry.ApplySubs)
	frozenAcl.Allow = proto.Uint32(uint32(aclEntry.Allow))
	frozenAcl.Deny = proto.Uint32(uint32(aclEntry.Deny))
	return frozenAcl, nil
}
コード例 #11
0
ファイル: trading.go プロジェクト: jcoene/go-steam
// Responds to a TradeProposedEvent.
func (t *Trading) RespondRequest(requestId TradeRequestId, accept bool) {
	var resp uint32
	if accept {
		resp = 0
	} else {
		resp = 1
	}

	t.client.Write(NewClientMsgProtobuf(EMsg_EconTrading_InitiateTradeResponse, &CMsgTrading_InitiateTradeResponse{
		TradeRequestId: proto.Uint32(uint32(requestId)),
		Response:       proto.Uint32(resp),
	}))
}
コード例 #12
0
ファイル: client.go プロジェクト: carriercomm/grumble
// Send permission denied by who, what, where
func (c *Client) sendPermissionDenied(who *Client, where *Channel, what acl.Permission) {
	pd := &mumbleproto.PermissionDenied{
		Permission: proto.Uint32(uint32(what)),
		ChannelId:  proto.Uint32(uint32(where.Id)),
		Session:    proto.Uint32(who.Session()),
		Type:       mumbleproto.PermissionDenied_Permission.Enum(),
	}
	err := c.sendMessage(pd)
	if err != nil {
		c.Panicf("%v", err.Error())
		return
	}
}
コード例 #13
0
ファイル: schedproc_test.go プロジェクト: nekto0n/gomes
func TestFrameworkRegisteredMessage(t *testing.T) {
	// setup chanel to receive unmarshalled message
	eventQ := make(chan interface{})
	go func() {
		for msg := range eventQ {
			val, ok := msg.(*mesos.FrameworkRegisteredMessage)
			if !ok {
				t.Fatal("Failed to receive msg of type FrameworkRegisteredMessage")
			}
			if val.FrameworkId.GetValue() != "test-framework-1" {
				t.Fatal("Expected FrameworkRegisteredMessage.Framework.Id.Value not found.")
			}
			if val.MasterInfo.GetId() != "master-1" {
				t.Fatal("Expected FrameworkRegisteredMessage.Master.Id not found.")
			}
		}
	}()

	// Simulate FramworkRegisteredMessage request from master.
	proc, err := newSchedulerProcess(eventQ)
	if err != nil {
		t.Fatal(err)
	}
	proc.started = true
	proc.aborted = false
	if err != nil {
		t.Fatal("Unable to start Scheduler Process.	")
	}
	msg := &mesos.FrameworkRegisteredMessage{
		FrameworkId: &mesos.FrameworkID{Value: proto.String("test-framework-1")},
		MasterInfo: &mesos.MasterInfo{
			Id:   proto.String("master-1"),
			Ip:   proto.Uint32(123456),
			Port: proto.Uint32(12345),
		},
	}
	data, err := proto.Marshal(msg)
	if err != nil {
		t.Fatalf("Unable to marshal FrameworkRegisteredMessage, %v", err)
	}

	req := buildHttpRequest(t, "FrameworkRegisteredMessage", data)
	resp := httptest.NewRecorder()

	// ServeHTTP will unmarshal msg and place on passed channel (above)
	proc.ServeHTTP(resp, req)

	if resp.Code != http.StatusAccepted {
		t.Fatalf("Expecting server status %d but got status %d", http.StatusAccepted, resp.Code)
	}
}
コード例 #14
0
ファイル: freeze.go プロジェクト: rok-kek/grumble
// Freeze a User into a flattened protobuf-based structure
// ready to be persisted to disk.
func (user *User) Freeze() (fu *freezer.User, err error) {
	fu = new(freezer.User)

	fu.Id = proto.Uint32(user.Id)
	fu.Name = proto.String(user.Name)
	fu.CertHash = proto.String(user.CertHash)
	fu.Email = proto.String(user.Email)
	fu.TextureBlob = proto.String(user.TextureBlob)
	fu.CommentBlob = proto.String(user.CommentBlob)
	fu.LastChannelId = proto.Uint32(uint32(user.LastChannelId))
	fu.LastActive = proto.Uint64(user.LastActive)

	return
}
コード例 #15
0
ファイル: peer.go プロジェクト: Zoramite/ripple
func (p *Peer) handleHello(m *Manager, hello *protocol.Hello) {
	cookie, err := p.getSessionCookie()
	if err != nil {
		glog.Errorf("%s:Bad cookie: %s", p.String(), err.Error())
		p.UpdateStatus(HelloFailed)
		return
	}
	pubKey, err := crypto.ParsePublicKeyFromHash(hello.GetNodePublic())
	if err != nil {
		glog.Errorf("Bad public key: %X", hello.GetNodePublic())
		p.UpdateStatus(HelloFailed)
		return
	}
	ok, err := crypto.Verify(pubKey.SerializeUncompressed(), hello.GetNodeProof(), cookie)
	if !ok {
		glog.Errorf("%s:Bad signature: %X public key: %X hash: %X", p.String(), hello.GetNodeProof(), hello.GetNodePublic(), cookie)
		p.UpdateStatus(HelloFailed)
		return
	}
	if err != nil {
		glog.Errorf("%s:Bad signature verification: %s", p.String(), err.Error())
		p.UpdateStatus(HelloFailed)
		return
	}
	proof, err := m.Key.Sign(cookie)
	if err != nil {
		glog.Errorf("%s:Bad signature creation: %X", p.String(), cookie)
		p.UpdateStatus(HelloFailed)
		return
	}
	if err := p.ProcessHello(hello); err != nil {
		glog.Errorf("%s:%s", p.String(), err.Error())
		return
	}
	port, _ := strconv.ParseUint(m.Port, 10, 32)
	p.Outgoing <- &protocol.TMHello{
		FullVersion:     proto.String(m.Name),
		ProtoVersion:    proto.Uint32(uint32(maxVersion)),
		ProtoVersionMin: proto.Uint32(uint32(minVersion)),
		NodePublic:      []byte(m.PublicKey.String()),
		NodeProof:       proof,
		Ipv4Port:        proto.Uint32(uint32(port)),
		NetTime:         proto.Uint64(uint64(data.Now().Uint32())),
		NodePrivate:     proto.Bool(true),
		TestNet:         proto.Bool(false),
	}
	if hello.ProofOfWork != nil {
		go p.handleProofOfWork(hello.ProofOfWork)
	}
}
コード例 #16
0
ファイル: server.go プロジェクト: jwilkins/pond
func (s *Server) newAccount(from *[32]byte, req *pond.NewAccount) *pond.Reply {
	account := NewAccount(s, from)

	if !s.allowRegistration {
		log.Printf("rejected registration of new account")
		return &pond.Reply{Status: pond.Reply_REGISTRATION_DISABLED.Enum()}
	}

	var ok bool
	account.group, ok = new(bbssig.Group).Unmarshal(req.Group)
	if !ok {
		return &pond.Reply{Status: pond.Reply_PARSE_ERROR.Enum()}
	}

	path := account.Path()
	if _, err := os.Stat(path); err == nil {
		return &pond.Reply{Status: pond.Reply_IDENTITY_ALREADY_KNOWN.Enum()}
	}

	if _, ok := new(bbssig.Group).Unmarshal(req.Group); !ok {
		return &pond.Reply{Status: pond.Reply_PARSE_ERROR.Enum()}
	}

	if err := os.MkdirAll(path, 0700); err != nil {
		log.Printf("failed to create directory: %s", err)
		return &pond.Reply{Status: pond.Reply_INTERNAL_ERROR.Enum()}
	}

	if err := ioutil.WriteFile(filepath.Join(path, "group"), req.Group, 0600); err != nil {
		log.Printf("failed to write group file: %s", err)
		goto err
	}

	s.Lock()
	s.accounts[string(from[:])] = account
	s.Unlock()

	return &pond.Reply{
		AccountCreated: &pond.AccountCreated{
			Details: &pond.AccountDetails{
				Queue:    proto.Uint32(0),
				MaxQueue: proto.Uint32(maxQueue),
			},
		},
	}

err:
	os.Remove(account.Path())
	return &pond.Reply{Status: pond.Reply_INTERNAL_ERROR.Enum()}
}
コード例 #17
0
ファイル: message.go プロジェクト: rok-kek/grumble
func (server *Server) handlePingMessage(client *Client, msg *Message) {
	ping := &mumbleproto.Ping{}
	err := proto.Unmarshal(msg.buf, ping)
	if err != nil {
		client.Panic(err)
		return
	}

	if ping.Good != nil {
		client.crypt.RemoteGood = uint32(*ping.Good)
	}
	if ping.Late != nil {
		client.crypt.RemoteLate = *ping.Late
	}
	if ping.Lost != nil {
		client.crypt.RemoteLost = *ping.Lost
	}
	if ping.Resync != nil {
		client.crypt.RemoteResync = *ping.Resync
	}

	if ping.UdpPingAvg != nil {
		client.UdpPingAvg = *ping.UdpPingAvg
	}
	if ping.UdpPingVar != nil {
		client.UdpPingVar = *ping.UdpPingVar
	}
	if ping.UdpPackets != nil {
		client.UdpPackets = *ping.UdpPackets
	}

	if ping.TcpPingAvg != nil {
		client.TcpPingAvg = *ping.TcpPingAvg
	}
	if ping.TcpPingVar != nil {
		client.TcpPingVar = *ping.TcpPingVar
	}
	if ping.TcpPackets != nil {
		client.TcpPackets = *ping.TcpPackets
	}

	client.sendMessage(&mumbleproto.Ping{
		Timestamp: ping.Timestamp,
		Good:      proto.Uint32(uint32(client.crypt.Good)),
		Late:      proto.Uint32(uint32(client.crypt.Late)),
		Lost:      proto.Uint32(uint32(client.crypt.Lost)),
		Resync:    proto.Uint32(uint32(client.crypt.Resync)),
	})
}
コード例 #18
0
ファイル: server.go プロジェクト: rok-kek/grumble
// Send a client its permissions for channel.
func (server *Server) sendClientPermissions(client *Client, channel *Channel) {
	// No caching for SuperUser
	if client.IsSuperUser() {
		return
	}

	// fixme(mkrautz): re-add when we have ACL caching
	return

	perm := acl.Permission(acl.NonePermission)
	client.sendMessage(&mumbleproto.PermissionQuery{
		ChannelId:   proto.Uint32(uint32(channel.Id)),
		Permissions: proto.Uint32(uint32(perm)),
	})
}
コード例 #19
0
ファイル: freeze.go プロジェクト: Kissaki/grumble
// Freeze a ChannelACL into it a flattened protobuf-based structure
// ready to be persisted to disk.
func (acl *ChannelACL) Freeze() (facl *freezer.ACL, err error) {
	facl = new(freezer.ACL)

	if acl.UserId != -1 {
		facl.UserId = proto.Uint32(uint32(acl.UserId))
	} else {
		facl.Group = proto.String(acl.Group)
	}
	facl.ApplyHere = proto.Bool(acl.ApplyHere)
	facl.ApplySubs = proto.Bool(acl.ApplySubs)
	facl.Allow = proto.Uint32(uint32(acl.Allow))
	facl.Deny = proto.Uint32(uint32(acl.Deny))

	return
}
コード例 #20
0
ファイル: gamecoordinator.go プロジェクト: jcoene/go-steam
func (g *GameCoordinator) Write(msg IGCMsg) {
	buf := new(bytes.Buffer)
	msg.Serialize(buf)

	msgType := msg.GetMsgType()
	if msg.IsProto() {
		msgType = msgType | 0x80000000 // mask with protoMask
	}

	g.client.Write(NewClientMsgProtobuf(EMsg_ClientToGC, &CMsgGCClient{
		Msgtype: proto.Uint32(msgType),
		Appid:   proto.Uint32(msg.GetAppId()),
		Payload: buf.Bytes(),
	}))
}
コード例 #21
0
func sendHello(conn *net.TCPConn) {
	helloInfo := &Auth_C2S.HelloInfo{
		ClientType: proto.Int32(1),
		Version:    proto.Uint32(1),
	}
	sendMsg(conn, byte(C2S_HelloInfo_CMD), helloInfo)
}
コード例 #22
0
ファイル: wal.go プロジェクト: hyc/influxdb
func (self *WAL) processAppendEntry(e *appendEntry) {
	nextRequestNumber := self.state.getNextRequestNumber()
	e.request.RequestNumber = proto.Uint32(nextRequestNumber)

	if len(self.logFiles) == 0 {
		if _, err := self.createNewLog(nextRequestNumber); err != nil {
			e.confirmation <- &confirmation{0, err}
			return
		}
		self.state.FirstSuffix = nextRequestNumber
	}

	lastLogFile := self.logFiles[len(self.logFiles)-1]
	self.assignSequenceNumbers(e.shardId, e.request)
	logger.Debug("appending request %d", e.request.GetRequestNumber())
	err := lastLogFile.appendRequest(e.request, e.shardId)
	if err != nil {
		e.confirmation <- &confirmation{0, err}
		return
	}
	self.state.CurrentFileOffset = self.logFiles[len(self.logFiles)-1].offset()

	self.requestsSinceLastIndex++
	self.requestsSinceLastBookmark++
	self.requestsSinceLastFlush++
	self.requestsSinceRotation++
	logger.Debug("requestsSinceRotation: %d", self.requestsSinceRotation)
	if rotated, err := self.rotateTheLogFile(nextRequestNumber); err != nil || rotated {
		e.confirmation <- &confirmation{e.request.GetRequestNumber(), err}
		return
	}

	self.conditionalBookmarkAndIndex()
	e.confirmation <- &confirmation{e.request.GetRequestNumber(), nil}
}
コード例 #23
0
func sendHello(conn *UniqueConnection) {
	helloInfo := &Auth_C2S.HelloInfo{
		ClientType: proto.Int32(1),
		Version:    proto.Uint32(1),
	}
	sendMsg(false, 0, byte(C2S_HelloInfo_CMD), helloInfo, conn)
}
コード例 #24
0
ファイル: proto_helpers.go プロジェクト: petemoore/runlib
func NewBlob(data []byte) (*Blob, error) {
	if data == nil {
		return nil, nil
	}
	sha1sum, err := calcSha1(data)
	if err != nil {
		return nil, err
	}

	compressed, err := compress(data)
	if err != nil {
		return nil, err
	}

	result := &Blob{
		Sha1: sha1sum,
	}
	if len(compressed) < len(data)-8 {
		method := Blob_CompressionInfo_METHOD_ZLIB
		result.Compression = &Blob_CompressionInfo{
			Method:       &method,
			OriginalSize: proto.Uint32(uint32(len(data))),
		}
		result.Data = compressed
	} else {
		result.Data = data
	}
	return result, nil
}
コード例 #25
0
func TestParseSectionPacketSeries_Valid(t *testing.T) {
	lines := []string{
		"10 11",
		"0 10 23",
		"20 12 45",
		"10 10 20",
	}
	trace := Trace{}
	err := parseSectionPacketSeries(lines, &trace)
	if err != nil {
		t.Fatal("Unexpected error:", err)
	}
	expectedTrace := Trace{
		PacketSeriesDropped: proto.Uint32(11),
		PacketSeries: []*PacketSeriesEntry{
			&PacketSeriesEntry{
				TimestampMicroseconds: proto.Int64(10),
				Size:   proto.Int32(10),
				FlowId: proto.Int32(23),
			},
			&PacketSeriesEntry{
				TimestampMicroseconds: proto.Int64(30),
				Size:   proto.Int32(12),
				FlowId: proto.Int32(45),
			},
			&PacketSeriesEntry{
				TimestampMicroseconds: proto.Int64(40),
				Size:   proto.Int32(10),
				FlowId: proto.Int32(20),
			},
		},
	}
	checkProtosEqual(t, &expectedTrace, &trace)
}
コード例 #26
0
ファイル: freeze.go プロジェクト: rok-kek/grumble
// Given a target channel and a ChannelState protocol message, create a freezer.Channel that
// only includes the values changed by the given ChannelState message.  When done, write that
// frozen.Channel to the datastore.
func (server *Server) UpdateFrozenChannel(channel *Channel, state *mumbleproto.ChannelState) {
	fc := &freezer.Channel{}
	fc.Id = proto.Uint32(uint32(channel.Id))
	if state.Name != nil {
		fc.Name = state.Name
	}
	if state.Parent != nil {
		fc.ParentId = state.Parent
	}
	if len(state.LinksAdd) > 0 || len(state.LinksRemove) > 0 {
		links := []uint32{}
		for cid, _ := range channel.Links {
			links = append(links, uint32(cid))
		}
		fc.Links = links
	}
	if state.Position != nil {
		fc.Position = proto.Int64(int64(*state.Position))
	}
	if len(state.DescriptionHash) > 0 {
		fc.DescriptionBlob = proto.String(channel.DescriptionBlob)
	}
	err := server.freezelog.Put(fc)
	if err != nil {
		server.Fatal(err)
	}
	server.numLogOps += 1
}
コード例 #27
0
ファイル: project.go プロジェクト: Khady/obiwan-kanbanobi
// modifier pour faire des column
func ConvertTabOfColumnToMessage(p []Column) []*message.Msg_Columns {
	var ret []*message.Msg_Columns

	for n := 0; n < len(p); n++ {
		ret = append(ret, &message.Msg_Columns{
			Id:         proto.Uint32(p[n].Id),
			ProjectId:  proto.Uint32(p[n].Project_id),
			Name:       proto.String(p[n].Name),
			Desc:       proto.String(p[n].Content),
			Tags:       p[n].Tags,
			ScriptsIds: p[n].Scripts_id,
			Write:      p[n].Write,
		})
	}
	return ret
}
コード例 #28
0
ファイル: freeze.go プロジェクト: rok-kek/grumble
// Write a channel's ACL and Group data to disk. Mumble doesn't support
// incremental ACL updates and as such we must write all ACLs and groups
// to the datastore on each change.
func (server *Server) UpdateFrozenChannelACLs(channel *Channel) {
	fc := &freezer.Channel{}

	fc.Id = proto.Uint32(uint32(channel.Id))
	fc.InheritAcl = proto.Bool(channel.ACL.InheritACL)

	acls := []*freezer.ACL{}
	for _, aclEntry := range channel.ACL.ACLs {
		facl, err := FreezeACL(aclEntry)
		if err != nil {
			return
		}
		acls = append(acls, facl)
	}
	fc.Acl = acls

	groups := []*freezer.Group{}
	for _, grp := range channel.ACL.Groups {
		fgrp, err := FreezeGroup(grp)
		if err != nil {
			return
		}
		groups = append(groups, fgrp)
	}
	fc.Groups = groups

	err := server.freezelog.Put(fc)
	if err != nil {
		server.Fatal(err)
	}
	server.numLogOps += 1
}
コード例 #29
0
ファイル: extend.go プロジェクト: robcat/ripple
func NewGetLedgerTransactions(sequence uint32, nodeids [][]byte) *TMGetLedger {
	return &TMGetLedger{
		Itype:     TMLedgerInfoType_liTX_NODE.Enum(),
		LedgerSeq: proto.Uint32(sequence),
		NodeIDs:   nodeids,
	}
}
コード例 #30
0
ファイル: freeze.go プロジェクト: rok-kek/grumble
// Mark a channel as deleted in the datastore.
func (server *Server) DeleteFrozenChannel(channel *Channel) {
	err := server.freezelog.Put(&freezer.ChannelRemove{Id: proto.Uint32(uint32(channel.Id))})
	if err != nil {
		server.Fatal(err)
	}
	server.numLogOps += 1
}