Last active
October 18, 2024 08:42
-
-
Save ifduyue/50b62bad497dc51e8ff48f78d433222a to your computer and use it in GitHub Desktop.
socks5 and http proxy with tor and sthp (https://github.com/KaranGauswami/socks-to-http-proxy)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM alpine:3.20 AS build | |
RUN apk --no-cache --update --upgrade add git musl-dev cargo \ | |
&& git clone https://github.com/KaranGauswami/socks-to-http-proxy.git \ | |
&& cd socks-to-http-proxy \ | |
&& cargo build --release | |
FROM alpine:3.20 | |
COPY --from=build /socks-to-http-proxy/target/release/sthp /usr/local/bin/ | |
COPY sthp /etc/init.d/ | |
RUN apk --no-cache --update --upgrade add openrc libgcc tor \ | |
&& sed -i 's/^\(tty\d\:\:\)/#\1/g' /etc/inittab \ | |
&& sed -i \ | |
# Change subsystem type to "docker" | |
-e 's/#rc_sys=".*"/rc_sys="docker"/g' \ | |
# Allow all variables through | |
-e 's/#rc_env_allow=".*"/rc_env_allow="\*"/g' \ | |
# Start crashed services | |
-e 's/#rc_crashed_stop=.*/rc_crashed_stop=NO/g' \ | |
-e 's/#rc_crashed_start=.*/rc_crashed_start=YES/g' \ | |
# Define extra dependencies for services | |
-e 's/#rc_provide=".*"/rc_provide="loopback net"/g' \ | |
/etc/rc.conf \ | |
# Remove unnecessary services | |
&& rm -f /etc/init.d/hwdrivers \ | |
/etc/init.d/hwclock \ | |
/etc/init.d/hwdrivers \ | |
/etc/init.d/modules \ | |
/etc/init.d/modules-load \ | |
/etc/init.d/modloop \ | |
/etc/init.d/machine-id \ | |
# Can't do cgroups | |
&& sed -i 's/\tcgroup_add_service/\t#cgroup_add_service/g' /lib/rc/sh/openrc-run.sh \ | |
&& sed -i 's/VSERVER/DOCKER/Ig' /lib/rc/sh/init.sh \ | |
&& mv /etc/tor/torrc.sample /etc/tor/torrc \ | |
&& sed -i \ | |
-e 's/#SOCKSPort 192.168.0.1:9100/SOCKSPort 0.0.0.0:9050/g' \ | |
-e 's/#ControlPort 9051/ControlPort 9052/g' \ | |
-e 's/#%include \/etc\/torrc\.d\/\*\.conf/%include \/etc\/torrc\.d\/\*\.conf/g' \ | |
/etc/tor/torrc \ | |
&& rc-update add tor \ | |
&& rc-update add sthp | |
ENTRYPOINT ["/sbin/init"] | |
EXPOSE 9050/tcp 9051/tcp 8118/tcp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# build | |
# docker build -t tor-sthp:latest . | |
# run | |
docker run -d --restart unless-stopped -ti --rm -p 9050:9050 -p 9051:9051 -p 8118:8118 tor-sthp:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/sbin/openrc-run | |
description="Sets up sthp" | |
start() { | |
ebegin "Setting up sthp" | |
sthp -p 8118 --listen-ip 0.0.0.0 -s 127.0.0.1:9050 & | |
eend $? | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment