Beispiel #1
0
func main() {
	// requests

	var req sasl.Request
	req.Login = "******"
	req.Password = "******"
	req.Service = ""
	req.Realm = "example.com"

	data, err := req.Marshal()
	if err != nil {
		fmt.Println("request encoding error:", err)
		return
	}
	fmt.Printf("Request encoded: %q\n", data)

	var req2 sasl.Request
	if err = req2.Unmarshal(data); err != nil {
		fmt.Println("request decoding error:", err)
		return
	}
	fmt.Printf("Request decoded: %+v\n", req2)

	// responses

	var resp sasl.Response
	resp.Result = false
	resp.Message = "invalid username/password"

	if data, err = resp.Marshal(); err != nil {
		fmt.Println("response encoding error:", err)
	}
	fmt.Printf("Response encoded: %q\n", data)

	var resp2 sasl.Response
	if err = resp2.Unmarshal(data); err != nil {
		fmt.Println("response decoding error:", err)
		return
	}
	fmt.Printf("Response decoded: %+v\n", resp2)

}
Beispiel #2
0
func main() {
	fmt.Println("Request:")

	var req sasl.Request
	req.Login = "******"
	req.Password = "******"
	req.Service = ""
	req.Realm = "example.com"

	if err := req.Encode(os.Stdout); err != nil {
		fmt.Println("encoding error:", err)
	}

	fmt.Println("\n\nResponse:")

	var resp sasl.Response
	resp.Result = false
	resp.Message = "invalid username/password"

	if err := resp.Encode(os.Stdout); err != nil {
		fmt.Println("encoding error:", err)
	}
}