예제 #1
0
//export Go_xxfi_connect
func Go_xxfi_connect(ctx *C.SMFICTX, hostname *C.char, hostaddr *C._SOCK_ADDR) C.sfsistat {
	ctxptr := ctx2int(ctx)
	var ip net.IP

	if hostaddr.sa_family == C.AF_INET {
		hostaddrin := (*sockaddr_in)(unsafe.Pointer(hostaddr))
		ip_addr := make([]byte, 4)
		binary.LittleEndian.PutUint32(ip_addr, hostaddrin.sin_addr)
		ip = net.IPv4(ip_addr[0], ip_addr[1], ip_addr[2], ip_addr[3])

	} else if hostaddr.sa_family == C.AF_INET6 {
		sa_in := (*C.struct_sockaddr_in6)(unsafe.Pointer(hostaddr))
		ip = net.IP(C.GoBytes(unsafe.Pointer(&sa_in.sin6_addr), 16))
	} else {
		if milter.GetDebug() {
			logger.Println("hostaddr.sa_family value not implemented")
		}
		ip = net.ParseIP("::")
	}

	m := milter.(checkForConnect)
	code := m.Connect(ctxptr, C.GoString(hostname), ip)
	if milter.GetDebug() {
		logger.Printf("Connect callback returned: %d\n", code)
	}
	return C.sfsistat(code)
}
예제 #2
0
//export Go_xxfi_header
func Go_xxfi_header(ctx *C.SMFICTX, headerf, headerv *C.char) C.sfsistat {
	m := milter.(checkForHeader)
	code := m.Header(ctx2int(ctx), C.GoString(headerf), C.GoString(headerv))
	if milter.GetDebug() {
		logger.Printf("Header callback returned: %d\n", code)
	}
	return C.sfsistat(code)
}
예제 #3
0
파일: gomilter.go 프로젝트: davrux/gomilter
//export Go_xxfi_helo
func Go_xxfi_helo(ctx *C.SMFICTX, helohost *C.char) C.sfsistat {
	m := milter.(checkForHelo)
	code := m.Helo(ctx2int(ctx), C.GoString(helohost))
	if milter.GetDebug() {
		LoggerPrintf("Helo callback returned: %d\n", code)
	}
	return C.sfsistat(code)
}
예제 #4
0
//export Go_xxfi_close
func Go_xxfi_close(ctx *C.SMFICTX) C.sfsistat {
	// Call our application's callback
	m := milter.(checkForClose)
	code := m.Close(ctx2int(ctx))
	if milter.GetDebug() {
		logger.Printf("Close callback returned: %d\n", code)
	}
	return C.sfsistat(code)
}
예제 #5
0
//export Go_xxfi_envrcpt
func Go_xxfi_envrcpt(ctx *C.SMFICTX, argv **C.char) C.sfsistat {
	// Call our application's callback
	m := milter.(checkForEnvRcpt)
	code := m.EnvRcpt(ctx2int(ctx), cStringArrayToSlice(argv))
	if milter.GetDebug() {
		logger.Printf("EnvRcpt callback returned: %d\n", code)
	}
	return C.sfsistat(code)
}
예제 #6
0
파일: gomilter.go 프로젝트: davrux/gomilter
//export Go_xxfi_abort
func Go_xxfi_abort(ctx *C.SMFICTX) C.sfsistat {
	// Call our application's callback
	m := milter.(checkForAbort)
	code := m.Abort(ctx2int(ctx))
	if milter.GetDebug() {
		LoggerPrintf("Abort callback returned: %d\n", code)
	}
	return C.sfsistat(code)
}
예제 #7
0
//export Go_xxfi_body
func Go_xxfi_body(ctx *C.SMFICTX, bodyp *C.uchar, bodylen C.size_t) C.sfsistat {
	// Create a byte slice from the body pointer.
	// The body pointer just points to a sequence of bytes
	// Our bit slice is backed by the original body. No copy is made here
	// Be aware that converting the byte slice to string will make a copy
	var b []byte
	b = (*[1 << 30]byte)(unsafe.Pointer(bodyp))[0:bodylen]
	// Call our application's callback
	m := milter.(checkForBody)
	code := m.Body(ctx2int(ctx), b)
	if milter.GetDebug() {
		logger.Printf("Body callback returned: %d\n", code)
	}
	return C.sfsistat(code)
}