Skip to content

Commit

Permalink
v1.0.2 (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
shahradelahi committed Aug 18, 2024
1 parent dbadcc8 commit 0011868
Show file tree
Hide file tree
Showing 14 changed files with 87 additions and 1,201 deletions.
5 changes: 5 additions & 0 deletions .changeset/weak-rivers-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"docker-torproxy": patch
---

Fixed a few minor issues and updated dependencies
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: 8
version: 9
- uses: actions/setup-node@v4
with:
node-version: 20
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: 8
version: 9
- uses: actions/setup-node@v4
with:
node-version: 18
Expand Down
7 changes: 3 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
ARG ALPINE_VERSION=3.19
ARG GOST_VERSION=3.0.0-rc10
ARG LYREBIRD_VERSION=0.2.0
ARG LYREBIRD_VERSION=0.3.0
ARG MEEK_VERSION=0.38.0
ARG SNOWFLAKE_VERSION=2.9.2

FROM --platform=${BUILDPLATFORM} gogost/gost:${GOST_VERSION} AS gost
FROM --platform=${BUILDPLATFORM} alpine:${ALPINE_VERSION} as alpine
FROM --platform=${BUILDPLATFORM} alpine:${ALPINE_VERSION} AS alpine
ENV TZ=UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ >/etc/timezone
RUN apk update \
Expand Down Expand Up @@ -84,8 +84,7 @@ COPY --from=pluggables /usr/local/bin/meek-client /usr/local/bin/meek-client
COPY --from=pluggables /usr/local/bin/snowflake-client /usr/local/bin/snowflake-client
COPY --from=gost /bin/gost /usr/local/bin/gost

RUN mkdir -p /etc/tor/torrc.d /var/log/gogost /var/lib/tor /etc/tor \
&& chown -R 101:101 /var/lib/tor
RUN mkdir -p /etc/tor/torrc.d /var/log/gogost /etc/tor

COPY internal /etc/torproxy/internal
COPY scripts/* /usr/local/bin/
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
command:
- -L="http://:8080"
- -L="socks5://username:secure-password@:1080"
- -L="ss://AES-256-CFB:secure-password@:8338"
- -L="ss://aes-256-cfb:secure-password@:8338"

volumes:
persist-data:
Expand Down
12 changes: 4 additions & 8 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

set -e

TOR_CONFIG_DIR="${TOR_CONFIG_DIR:-/etc/tor}"
TOR_CONFIG="${TOR_CONFIG_DIR}/torrc"

source /etc/torproxy/internal/index.sh
setup_logrotate

Expand All @@ -16,10 +13,10 @@ fi

screen -wipe &> /dev/null || true

if [ ! -f "${TOR_CONFIG}" ]; then
if [ ! -f "$TOR_CONFIG" ]; then
generate_tor_config
else
log NOTICE "Using existing tor config file at ${TOR_CONFIG}"
log NOTICE "Using existing tor config file at $TOR_CONFIG"
fi
load_tor_env
setup_dns
Expand All @@ -35,8 +32,7 @@ echo -e "Gost: \c" && gost -V | cut -d' ' -f2
echo -e "Nyx: \c" && nyx --version | head -n 1 | awk '{print $3}'
echo -e "\n======================= Tor Config ======================="
grep -v "^#" "$TOR_CONFIG" | grep -v "^$"
echo -e "============================================================\n"
echo -e "==========================================================\n"
sleep 1

start_gost_server "$@"
exec tor -f "$TOR_CONFIG"
exec bash -c "(trap 'kill 0' SIGINT EXIT; (tor -f $TOR_CONFIG) & (gost -F=socks5://127.0.0.1:$(current_socks_port) $*) &> /var/log/gogost/gogost.log)"
1 change: 1 addition & 0 deletions internal/dns.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ server=::1#${_TOR_DNS_PORT}
log-facility=/var/log/dnsmasq/dnsmasq.log
EOF
mkdir -p /var/log/dnsmasq
uown dnsmasq /var/log/dnsmasq
dnsmasq
}
15 changes: 0 additions & 15 deletions internal/gost.sh

This file was deleted.

6 changes: 5 additions & 1 deletion internal/index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
source /etc/torproxy/internal/screen.sh
source /etc/torproxy/internal/tor.sh
source /etc/torproxy/internal/dns.sh
source /etc/torproxy/internal/gost.sh

function uppercase() {
echo "$1" | tr '[:lower:]' '[:upper:]'
Expand All @@ -14,6 +13,11 @@ function to_camel_case() {
echo "${1}" | awk -F_ '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) tolower(substr($i,2));}1' OFS=""
}

function uown() {
_UID="$(id -u "$1")"
chown -R "$_UID":"$_UID" "$2"
}

function log() {
# Feb 20 16:48:35 UTC [notice] message
echo -e "$(date +"%b %d %H:%M:%S %Z") [$(uppercase "$1")] $2"
Expand Down
16 changes: 13 additions & 3 deletions internal/tor.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/bin/bash

TOR_CONFIG_DIR="${TOR_CONFIG_DIR:-/etc/tor}"
TOR_CONFIG="${TOR_CONFIG_DIR}/torrc"

generate_tor_config() {
tee "$TOR_CONFIG" &> /dev/null << EOF
####### AUTO-GENERATED FILE, DO NOT EDIT #######
VirtualAddrNetwork ${TOR_VIRTUAL_ADDR_NETWORK:-10.192.0.0/10}
#AutomapHostsOnResolve 1
AutomapHostsOnResolve ${TOR_AUTOMAP_HOSTS_ON_RESOLVE:-1}
Expand Down Expand Up @@ -158,8 +160,12 @@ cleanse_tor_config() {
}

fix_tor_permissions() {
chown -R 101:101 /var/lib/tor
chmod +x /var/lib/tor
local DATA_DIR="${TOR_DATA_DIR:-/var/lib/tor}"
if [ ! -d "$DATA_DIR" ]; then
mkdir -p "$DATA_DIR"
fi
uown tor "$DATA_DIR"
chmod 700 "$DATA_DIR"
}

# gets any environment variables that start with TOR_ and adds them to the config file
Expand Down Expand Up @@ -206,3 +212,7 @@ load_tor_env() {
get_torrc_option() {
grep -i "^$1" "$TOR_CONFIG" | awk '{print $2}'
}

current_socks_port() {
get_torrc_option "SocksPort"
}
4 changes: 2 additions & 2 deletions kubernetes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ spec:
- containerPort: 8338
protocol: TCP
name: ss-8338
command:
args:
- -L=socks5://${PROXY_USERNAME}:${PROXY_PASSWORD}@:1080
- -L=http://${PROXY_USERNAME}:${PROXY_PASSWORD}@:8080
- -L=ss://AES-256-CFB:${PROXY_PASSWORD}@:8338
- -L=ss://aes-256-cfb:${PROXY_PASSWORD}@:8338

---
apiVersion: v1
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"version": "1.0.1",
"private": true,
"scripts": {
"dev": "docker compose -f docker-compose.yml -f docker-compose.dev.yml up --forece-recreate",
"dev": "docker compose -f docker-compose.yml -f docker-compose.dev.yml up --force-recreate",
"build": "docker buildx build -t ghcr.io/shahradelahi/torproxy .",
"start": "docker compose -f docker-compose.yml up --forece-recreate",
"start": "docker compose -f docker-compose.yml up --force-recreate",
"format": "prettier --write .",
"format:check": "prettier --check .",
"ci:publish": "pnpm build && changeset publish"
Expand All @@ -20,10 +20,10 @@
],
"author": "Shahrad Elahi <[email protected]> (https://github.com/shahradelahi)",
"license": "GPL-3.0",
"packageManager": "pnpm@8.15.7",
"packageManager": "pnpm@9.7.0",
"dependencies": {
"@changesets/cli": "^2.27.1",
"prettier": "^3.2.5",
"@changesets/cli": "^2.27.7",
"prettier": "^3.3.3",
"prettier-plugin-sh": "^0.14.0"
}
}
Loading

0 comments on commit 0011868

Please sign in to comment.