chore: remove unused files and code
Some checks failed
Build RPM Package / Build RPM Packages (CentOS 7, Rocky 8/9/10) (push) Has been cancelled

- Delete obsolete RPM maintainer scripts (postinst, prerm, postrm)
  Scripts are now embedded in ja4sentinel.spec
- Delete unused RPM test script (test-rpm.sh)
  Referenced non-existent el7 builds, not integrated in CI
- Remove unused constants and functions from api/types.go:
  - DefaultInterface, DefaultPort, DefaultBPFFilter
  - DefaultFlowTimeout, DefaultPacketBuffer
  - LogLevelDebug, LogLevelInfo, LogLevelWarn, LogLevelError
  - DefaultConfig() function
- Update Makefile with RPM_DIR variable for consistency

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
Jacquin Antoine
2026-03-01 00:26:48 +01:00
parent b137b3df85
commit 1bf0f46ce5
6 changed files with 8 additions and 235 deletions

View File

@ -17,6 +17,9 @@ BINARY_PATH=./cmd/ja4sentinel
DIST_DIR=dist DIST_DIR=dist
BUILD_DIR=build BUILD_DIR=build
# RPM build directory
RPM_DIR=$(DIST_DIR)/rpm
# Package version (strip 'v' prefix from git tags) # Package version (strip 'v' prefix from git tags)
# Set to explicit version for release builds, or use git-based version for dev builds # Set to explicit version for release builds, or use git-based version for dev builds
PKG_VERSION ?= 1.0.0 PKG_VERSION ?= 1.0.0
@ -97,23 +100,23 @@ package: package-rpm
## package-rpm: Build RPM packages for Rocky Linux 8/9/10, AlmaLinux (requires Docker) ## package-rpm: Build RPM packages for Rocky Linux 8/9/10, AlmaLinux (requires Docker)
package-rpm: package-rpm:
mkdir -p build/rpm/el8 build/rpm/el9 build/rpm/el10 mkdir -p $(RPM_DIR)/el8 $(RPM_DIR)/el9 $(RPM_DIR)/el10
@echo "Building RPM packages for Rocky Linux 8/9, AlmaLinux 10..." @echo "Building RPM packages for Rocky Linux 8/9, AlmaLinux 10..."
docker build --target output -t ja4sentinel-rpm-packager:latest \ docker build --target output -t ja4sentinel-rpm-packager:latest \
--build-arg VERSION=$(PKG_VERSION) \ --build-arg VERSION=$(PKG_VERSION) \
-f Dockerfile.package . -f Dockerfile.package .
@echo "Extracting RPM packages from Docker image..." @echo "Extracting RPM packages from Docker image..."
@docker run --rm -v $(PWD)/build:/output ja4sentinel-rpm-packager:latest sh -c \ @docker run --rm -v $(PWD)/$(RPM_DIR):/output/rpm ja4sentinel-rpm-packager:latest sh -c \
'cp -r /packages/rpm/el8 /output/rpm/ && \ 'cp -r /packages/rpm/el8 /output/rpm/ && \
cp -r /packages/rpm/el9 /output/rpm/ && \ cp -r /packages/rpm/el9 /output/rpm/ && \
cp -r /packages/rpm/el10 /output/rpm/' cp -r /packages/rpm/el10 /output/rpm/'
@echo "RPM packages created:" @echo "RPM packages created:"
@echo " Rocky Linux 8 (el8):" @echo " Rocky Linux 8 (el8):"
ls -la build/rpm/el8/ 2>/dev/null || echo " (no packages)" ls -la $(RPM_DIR)/el8/ 2>/dev/null || echo " (no packages)"
@echo " Rocky Linux 9 (el9):" @echo " Rocky Linux 9 (el9):"
ls -la build/rpm/el9/ 2>/dev/null || echo " (no packages)" ls -la $(RPM_DIR)/el9/ 2>/dev/null || echo " (no packages)"
@echo " AlmaLinux/Rocky 10 (el10):" @echo " AlmaLinux/Rocky 10 (el10):"
ls -la build/rpm/el10/ 2>/dev/null || echo " (no packages)" ls -la $(RPM_DIR)/el10/ 2>/dev/null || echo " (no packages)"
## test-package-rpm: Test RPM package installation in Docker ## test-package-rpm: Test RPM package installation in Docker
test-package-rpm: package-rpm test-package-rpm: package-rpm

View File

@ -232,37 +232,3 @@ func NewLogRecord(ch TLSClientHello, fp *Fingerprints) LogRecord {
return rec return rec
} }
// Default values and constants
const (
DefaultInterface = "eth0"
DefaultPort = 443
DefaultBPFFilter = ""
DefaultFlowTimeout = 30 // seconds
DefaultPacketBuffer = 1000 // packet channel buffer size
// Logging levels
LogLevelDebug = "DEBUG"
LogLevelInfo = "INFO"
LogLevelWarn = "WARN"
LogLevelError = "ERROR"
)
// DefaultConfig returns an AppConfig with sensible default values.
// Uses eth0 as the default interface, port 443 for monitoring,
// no BPF filter, a 30-second flow timeout, and a 1000-packet
// channel buffer. Returns an empty outputs slice (caller must
// configure outputs explicitly).
func DefaultConfig() AppConfig {
return AppConfig{
Core: Config{
Interface: DefaultInterface,
ListenPorts: []uint16{DefaultPort},
BPFFilter: DefaultBPFFilter,
FlowTimeoutSec: DefaultFlowTimeout,
PacketBufferSize: DefaultPacketBuffer,
},
Outputs: []OutputConfig{},
}
}

View File

@ -1,45 +0,0 @@
#!/bin/bash
#
# postinst - Script d'installation post-RPM pour ja4sentinel
# Compatible CentOS 7, Rocky Linux 8/9/10
#
set -e
echo "==> ja4sentinel: Running post-installation script..."
# Set proper ownership
chown -R ja4sentinel:ja4sentinel /var/lib/ja4sentinel 2>/dev/null || true
chown -R ja4sentinel:ja4sentinel /var/run/ja4sentinel 2>/dev/null || true
chown -R ja4sentinel:ja4sentinel /var/log/ja4sentinel 2>/dev/null || true
chown -R ja4sentinel:ja4sentinel /etc/ja4sentinel 2>/dev/null || true
# Set proper permissions
chmod 750 /var/lib/ja4sentinel 2>/dev/null || true
chmod 750 /var/log/ja4sentinel 2>/dev/null || true
chmod 750 /etc/ja4sentinel 2>/dev/null || true
# Install config if not exists
if [ ! -f /etc/ja4sentinel/config.yml ]; then
echo "==> ja4sentinel: Installing default configuration..."
cp /usr/share/ja4sentinel/config.yml /etc/ja4sentinel/config.yml
chown ja4sentinel:ja4sentinel /etc/ja4sentinel/config.yml 2>/dev/null || true
chmod 640 /etc/ja4sentinel/config.yml
fi
# Reload systemd and enable service (only if systemd is running)
if [ -x /bin/systemctl ] && [ -d /run/systemd/system ]; then
echo "==> ja4sentinel: Reloading systemd daemon..."
/bin/systemctl daemon-reload
echo "==> ja4sentinel: Enabling ja4sentinel.service..."
/bin/systemctl enable ja4sentinel.service 2>/dev/null || :
echo "==> ja4sentinel: Starting ja4sentinel.service..."
/bin/systemctl start ja4sentinel.service 2>/dev/null || :
else
echo "==> ja4sentinel: systemd not detected (container environment), skipping service management..."
fi
echo "==> ja4sentinel: Post-installation complete."
exit 0

View File

@ -1,18 +0,0 @@
#!/bin/bash
#
# postrm - Script de post-désinstallation RPM pour ja4sentinel
# Compatible CentOS 7, Rocky Linux 8/9/10
#
set -e
echo "==> ja4sentinel: Running post-removal script..."
# Reload systemd after removal
if [ -x /bin/systemctl ]; then
echo "==> ja4sentinel: Reloading systemd daemon..."
/bin/systemctl daemon-reload
fi
echo "==> ja4sentinel: Post-removal complete."
exit 0

View File

@ -1,21 +0,0 @@
#!/bin/bash
#
# prerm - Script de pré-désinstallation RPM pour ja4sentinel
# Compatible CentOS 7, Rocky Linux 8/9/10
#
set -e
echo "==> ja4sentinel: Running pre-removal script..."
# Stop and disable service before removal
if [ -x /bin/systemctl ]; then
echo "==> ja4sentinel: Stopping ja4sentinel.service..."
/bin/systemctl stop ja4sentinel.service >/dev/null 2>&1 || :
echo "==> ja4sentinel: Disabling ja4sentinel.service..."
/bin/systemctl disable ja4sentinel.service >/dev/null 2>&1 || :
fi
echo "==> ja4sentinel: Pre-removal complete."
exit 0

View File

@ -1,112 +0,0 @@
#!/bin/bash
# Test RPM package installation on CentOS 7, Rocky Linux 8/9/10
# Note: We don't use set -e here because we want to continue testing even if one fails
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$(dirname "$SCRIPT_DIR")")"
BUILD_DIR="${PROJECT_ROOT}/build/rpm"
echo "=========================================="
echo " Testing RPM Package Installation"
echo "=========================================="
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Function to test RPM installation on a specific distribution
test_rpm_install() {
local distro=$1
local image=$2
local rpm_dir=$3
echo ""
echo -e "${YELLOW}Testing on ${distro} (${image})...${NC}"
# Check if RPM files exist in the directory
if [ ! -d "${BUILD_DIR}/${rpm_dir}" ] || [ -z "$(ls -A ${BUILD_DIR}/${rpm_dir}/*.rpm 2>/dev/null)" ]; then
echo -e "${RED} Warning: No RPM packages found in ${BUILD_DIR}/${rpm_dir}${NC}"
echo " Skipping ${distro} test..."
return 1
fi
# Determine package manager and install command
# Note: libpcap is required at runtime (dynamically linked)
local setup_cmd=""
local install_cmd=""
case "$image" in
centos:7)
# CentOS 7 is EOL, need to configure vault.centos.org
setup_cmd="sed -i 's/mirror.centos.org/vault.centos.org/g' /etc/yum.repos.d/*.repo && sed -i 's/^#.*baseurl=http/baseurl=http/g' /etc/yum.repos.d/*.repo && sed -i 's/^mirrorlist=http/#mirrorlist=http/g' /etc/yum.repos.d/*.repo"
install_cmd="${setup_cmd} && yum install -y libpcap && yum install -y /packages/*.rpm"
;;
rockylinux:*|almalinux:*)
install_cmd="dnf install -y libpcap && dnf install -y /packages/*.rpm"
;;
*)
install_cmd="dnf install -y libpcap && dnf install -y /packages/*.rpm"
;;
esac
# Test installation
if docker run --rm \
-v "${BUILD_DIR}/${rpm_dir}:/packages:ro" \
"${image}" \
sh -c "${install_cmd}"; then
echo -e " ${GREEN}${NC} ${distro}: Installation successful"
return 0
else
echo -e " ${RED}${NC} ${distro}: Installation failed"
return 1
fi
}
# Track test results
TESTS_PASSED=0
TESTS_FAILED=0
# Test on CentOS 7
if test_rpm_install "CentOS 7" "centos:7" "el7"; then
((TESTS_PASSED++))
else
((TESTS_FAILED++))
fi
# Test on Rocky Linux 8
if test_rpm_install "Rocky Linux 8" "rockylinux:8" "el8"; then
((TESTS_PASSED++))
else
((TESTS_FAILED++))
fi
# Test on Rocky Linux 9
if test_rpm_install "Rocky Linux 9" "rockylinux:9" "el9"; then
((TESTS_PASSED++))
else
((TESTS_FAILED++))
fi
# Test on AlmaLinux 10 (Rocky Linux 10 compatible)
if test_rpm_install "AlmaLinux 10" "almalinux:10" "el10"; then
((TESTS_PASSED++))
else
((TESTS_FAILED++))
fi
echo ""
echo "=========================================="
echo " Test Summary"
echo "=========================================="
echo -e " Passed: ${GREEN}${TESTS_PASSED}${NC}"
echo -e " Failed: ${RED}${TESTS_FAILED}${NC}"
echo "=========================================="
if [ ${TESTS_FAILED} -gt 0 ]; then
echo -e "${RED}Some tests failed!${NC}"
exit 1
else
echo -e "${GREEN}All RPM package tests passed!${NC}"
exit 0
fi