Esempio n. 1
0
func InvocationFromBase64(invoc g.Invocation) (g.Invocation, error) {
	enc := base64.StdEncoding
	var err error
	cmd, err := enc.DecodeString(invoc.Command)
	user, err := enc.DecodeString(invoc.User)
	host, err := enc.DecodeString(invoc.Host)
	shell, err := enc.DecodeString(invoc.Shell)
	dir, err := enc.DecodeString(invoc.Directory)
	tags := make([][]byte, len(invoc.Tags))
	for i, t := range invoc.Tags {
		tags[i], err = enc.DecodeString(t)
	}
	if err != nil {
		return invoc, err
	}
	invoc.Command = string(cmd)
	invoc.User = string(user)
	invoc.Host = string(host)
	invoc.Shell = string(shell)
	invoc.Directory = string(dir)
	for i, t := range tags {
		invoc.Tags[i] = string(t)
	}
	return invoc, nil
}
Esempio n. 2
0
func InvocationToBase64(invoc g.Invocation) g.Invocation {
	enc := base64.StdEncoding
	invoc.Command = enc.EncodeToString([]byte(invoc.Command))
	invoc.User = enc.EncodeToString([]byte(invoc.User))
	invoc.Host = enc.EncodeToString([]byte(invoc.Host))
	invoc.Shell = enc.EncodeToString([]byte(invoc.Shell))
	invoc.Directory = enc.EncodeToString([]byte(invoc.Directory))
	for i, t := range invoc.Tags {
		invoc.Tags[i] = enc.EncodeToString([]byte(t))
	}
	return invoc
}