func newNode()

in dp_check/dp_check.go [921:944]


func newNode(zone string, ipv6Capable bool) *v3corepb.Node {
	var r [8]byte
	if _, err := rand.Read(r[:]); err != nil {
		infoLog.Printf("failed to create random token: %v, node ID will not be unique", err)
	}
	var id strings.Builder
	fmt.Fprintf(&id, "dp-check-xds-%d", binary.LittleEndian.Uint64(r[:]))
	infoLog.Printf("ADS stream will use node ID: %s", id.String())
	ret := &v3corepb.Node{
		Id:                   id.String(),
		UserAgentName:        userAgentName,
		UserAgentVersionType: &v3corepb.Node_UserAgentVersion{UserAgentVersion: userAgentVersion},
		ClientFeatures:       []string{clientFeatureNoOverprovisioning},
	}
	ret.Locality = &v3corepb.Locality{Zone: zone}
	if ipv6Capable {
		ret.Metadata = &structpb.Struct{
			Fields: map[string]*structpb.Value{
				ipv6CapableMetadataName: structpb.NewBoolValue(true),
			},
		}
	}
	return ret
}