예제 #1
0
파일: spf2.go 프로젝트: porjo/libspf2
// SetIPv4Addr sets the sender IPv4
func (r *Request) SetIPv4Addr(addr string) error {
	var stat C.SPF_errcode_t
	stat = C.SPF_request_set_ipv4_str(r.r, C.CString(addr))
	if stat != C.SPF_E_SUCCESS {
		return &spfError{stat}
	}
	return nil
}
예제 #2
0
// SetIPAddr sets the IP address of the client (sending) MTA
func (r *request) setIpAddr(ip net.IP) error {
	var stat C.SPF_errcode_t
	cstring := C.CString(ip.String())
	defer C.free(unsafe.Pointer(cstring))
	if ip.To4() != nil {
		stat = C.SPF_request_set_ipv4_str(r.r, cstring)
	} else {
		stat = C.SPF_request_set_ipv6_str(r.r, cstring)
	}
	if stat != C.SPF_E_SUCCESS {
		return &spfError{stat}
	}
	return nil
}