%global real_name filter-senderscore

Summary:	OpenSMTPD filter integration for SenderScore reputation
Name:		opensmtpd-%{real_name}
Version:	0.1.2
Release:	1%{?dist}

License:	ISC
URL:		https://github.com/poolpOrg/%{real_name}

Source0:	https://github.com/poolpOrg/%{real_name}/archive/refs/tags/%{version}.tar.gz#/%{real_name}-%{version}.tar.gz

BuildRequires:	golang

Requires: opensmtpd

%description
This filter performs a SenderScore lookup and allows OpenSMTPD to either block
or slow down a session based on the reputation of the source IP address.
The filter currently supports:
* blocking hosts with reputation below a certain value
* adding an X-SenderScore header with the score of the source IP address
* adding an X-Spam header to hosts with reputation below a certain value
* applying a time penalty proportional to the IP reputation
* whitelisting IP addresses or subnets

%prep
%autosetup -p1 -n %{real_name}-%{version}

%build

export CGO_CPPFLAGS="${CPPFLAGS}"
export CGO_CFLAGS="${CFLAGS}"
export CGO_CXXFLAGS="${CXXFLAGS}"
export CGO_LDFLAGS="${LDFLAGS}"
export GOFLAGS="-buildmode=pie -trimpath -mod=readonly -modcacherw"
export GOCODE=".:%{_datadir}/gocode"
go env -w GO111MODULE=off
go build -v -ldflags "-linkmode external" -o %{real_name}


%install
mkdir -p %{buildroot}/{%{_libexecdir}/opensmtpd,%{_mandir}/man8}
install -D %{real_name} -t %{buildroot}/%{_libexecdir}/opensmtpd
install %{real_name}.8 %{buildroot}%{_mandir}/man8


%files
%doc README.md
%if 0%{?rhel} >= 8
%license LICENSE
%else
%doc LICENSE
%endif
%{_libexecdir}/opensmtpd/%{real_name}
%{_mandir}/man8/%{real_name}.8*


%changelog
* Wed Oct 4 2023 Raven <raven@sysadmins.ws> - 0.1.2-1
- Initial release
