diff --git a/.docker/rootfs/etc/supervisor.d/supervisord.ini b/.docker/rootfs/etc/supervisor.d/supervisord.ini index b8ed2c8..c18933f 100644 --- a/.docker/rootfs/etc/supervisor.d/supervisord.ini +++ b/.docker/rootfs/etc/supervisor.d/supervisord.ini @@ -3,7 +3,6 @@ nodaemon = true [program:squid] command=/usr/sbin/squid -N -f /etc/squid/squid.conf -environment=LD_PRELOAD="/usr/lib/squid-preload.so" redirect_stderr=true stdout_logfile=/var/log/supervisor/squid.info.log stderr_logfile=/var/log/supervisor/squid.error.log diff --git a/Dockerfile b/Dockerfile index bea44cb..b8730f3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,7 @@ -FROM alpine:3.18 AS builder -COPY ./squid-preload.c /tmp/squid-preload.c -RUN apk add --no-cache gcc musl-dev && \ - gcc -fPIC -O3 -shared -Wl,-export-dynamic -o /tmp/squid-preload.so /tmp/squid-preload.c -lc - FROM smartentry/alpine:3.18 MAINTAINER Yifan Gao COPY .docker $ASSETS_DIR -COPY --from=builder /tmp/squid-preload.so $ASSETS_DIR/rootfs/usr/lib/squid-preload.so RUN smartentry.sh build diff --git a/squid-preload.c b/squid-preload.c deleted file mode 100644 index dcf3a32..0000000 --- a/squid-preload.c +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include -#include -#include -#include -#include - -// Bypass squid v5 crash bug -// when connecting to IPv6 addr in IPv4-only environment (Docker container, etc.) -// Ref: https://bugs.squid-cache.org/show_bug.cgi?id=5154 - -int (*original_getaddrinfo)(const char *restrict node, - const char *restrict service, - const struct addrinfo *restrict hints, - struct addrinfo **restrict res); - -int getaddrinfo(const char *restrict node, - const char *restrict service, - const struct addrinfo *restrict hints, - struct addrinfo **restrict res) -{ - if (!original_getaddrinfo) - { - original_getaddrinfo = dlsym(RTLD_NEXT, "getaddrinfo"); - assert(original_getaddrinfo); - } - struct addrinfo real_hints; - if (hints) - { - memcpy(&real_hints, hints, sizeof(struct addrinfo)); - } - else - { - memset(&real_hints, 0, sizeof(struct addrinfo)); - } - // IPv4 only, let's pretend that IPv6 never exists. - real_hints.ai_family = AF_INET; - return original_getaddrinfo(node, service, &real_hints, res); -}