This file is indexed.

/usr/share/gocode/src/github.com/weaveworks/mesh/meshconn/pkt.go is in golang-github-weaveworks-mesh-dev 0+git20161024.3dd75b1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package meshconn

import (
	"bytes"
	"encoding/gob"

	"github.com/weaveworks/mesh"
)

type pkt struct {
	SrcName mesh.PeerName
	SrcUID  mesh.PeerUID
	Buf     []byte
}

func makePkt(buf []byte) pkt {
	var p pkt
	if err := gob.NewDecoder(bytes.NewBuffer(buf)).Decode(&p); err != nil {
		panic(err)
	}
	return p
}

func (p pkt) encode() []byte {
	var buf bytes.Buffer
	if err := gob.NewEncoder(&buf).Encode(p); err != nil {
		panic(err)
	}
	return buf.Bytes()
}

// pktSlice implements mesh.GossipData.
type pktSlice []pkt

var _ mesh.GossipData = &pktSlice{}

func (s pktSlice) Encode() [][]byte {
	bufs := make([][]byte, len(s))
	for i, pkt := range s {
		bufs[i] = pkt.encode()
	}
	return bufs
}

func (s pktSlice) Merge(other mesh.GossipData) mesh.GossipData {
	o := other.(pktSlice)
	merged := make(pktSlice, 0, len(s)+len(o))
	merged = append(merged, s...)
	merged = append(merged, o...)
	return merged
}