Пример #1
0
func (bl BanList) writeMessage(client *Client) error {
	packet := MumbleProto.BanList{
		Query: proto.Bool(false),
	}

	for _, ban := range bl {
		if !ban.unban {
			maskSize, _ := ban.Mask.Size()
			packet.Bans = append(packet.Bans, &MumbleProto.BanList_BanEntry{
				Address:  ban.Address,
				Mask:     proto.Uint32(uint32(maskSize)),
				Reason:   &ban.Reason,
				Duration: proto.Uint32(uint32(ban.Duration / time.Second)),
			})
		}
	}

	return client.Conn.WriteProto(&packet)
}
Пример #2
0
func (bl BanList) writeTo(client *Client, w io.Writer) (int64, error) {
	packet := MumbleProto.BanList{
		Query: proto.Bool(false),
	}

	for _, ban := range bl {
		if !ban.unban {
			maskSize, _ := ban.mask.Size()
			packet.Bans = append(packet.Bans, &MumbleProto.BanList_BanEntry{
				Address:  ban.address,
				Mask:     proto.Uint32(uint32(maskSize)),
				Reason:   &ban.reason,
				Duration: proto.Uint32(uint32(ban.duration * time.Second)),
			})
		}
	}

	proto := protoMessage{&packet}
	return proto.writeTo(client, w)
}