Skip to content

Commit

Permalink
Small improvements (#7) Thank you @nurfed1
Browse files Browse the repository at this point in the history
* Allow multiple domains

* Ensure proxy can be reached when in conflict with TARGET_ROUTES

Thank you @nurfed1
  • Loading branch information
nurfed1 authored Jan 19, 2024
1 parent 009e821 commit 6215e81
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ PROXY_ADDRESS=socks4://host.docker.internal:48501
# comma seperated list of routes to route
TARGET_ROUTES=10.10.10.0/24
TARGET_DNS_SERVER=10.10.10.254
TARGET_ROOT_DOMAIN=domain.local
TARGET_ROOT_DOMAINS=domain.local

# wireguard information.
#
Expand Down
5 changes: 4 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ services:

wiresocks:
image: ghcr.io/sensepost/wiresocks:latest
build:
dockerfile: Dockerfile
container_name: wiresocks
mem_limit: 1gb
memswap_limit: 2gb
Expand All @@ -13,7 +15,7 @@ services:
devices:
- /dev/net/tun:/dev/net/tun
environment:
- LOGLEVEL=info
- LOGLEVEL=${LOGLEVEL:-info}
- TUN=tun0
- ADDR=198.18.0.1/15
- MTU=9000
Expand Down Expand Up @@ -63,6 +65,7 @@ services:
- PEERS=${WG_PEERS}
- INTERNAL_SUBNET=10.13.13.0
- ALLOWEDIPS=10.13.13.0/24,${TARGET_ROUTES}
- TARGET_ROOT_DOMAINS=${TARGET_ROOT_DOMAINS}
volumes:
# this is where the wireguard peer configs will live
- ./config:/config
Expand Down
12 changes: 11 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@
TUN="${TUN:-tun0}"
ADDR="${ADDR:-198.18.0.1/15}"
LOGLEVEL="${LOGLEVEL:-info}"
PROXY_ADDRESS=${PROXY#*//}
DEFAULT_ROUTE=$(ip route | grep default | head -1)

config_proxy_route() {
echo 200 proxy >> /etc/iproute2/rt_tables
ip route add table proxy $DEFAULT_ROUTE
ip rule add fwmark 200 table 200
iptables -t mangle -A OUTPUT -p tcp -d ${PROXY_ADDRESS%:*} --dport ${PROXY_ADDRESS#*:} -j MARK --set-mark 200
}

create_tun() {
ip tuntap add mode tun dev "$TUN"
Expand All @@ -22,6 +31,7 @@ config_route() {

run() {

config_proxy_route
create_tun
config_route

Expand Down Expand Up @@ -61,4 +71,4 @@ run() {
$ARGS
}

run || exit 1
run || exit 1
14 changes: 11 additions & 3 deletions init.d/config-dns.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,26 @@
# a shell script to configure coredns to forward DNS traffic to
# an upstream server, forcing TCP lookups to be socks friendly

echo "configuring dns to ${TARGET_ROOT_DOMAIN} to lookup at ${TARGET_DNS_SERVER}..."
echo "configuring dns to ${TARGET_ROOT_DOMAINS} to lookup at ${TARGET_DNS_SERVER}..."

cat << EOF > /config/coredns/Corefile
${TARGET_ROOT_DOMAIN} {
for DOMAIN in ${TARGET_ROOT_DOMAINS//,/ };
do
cat << EOF
${DOMAIN} {
loop
log
forward . ${TARGET_DNS_SERVER}:53 {
force_tcp
}
}
EOF
done > /config/coredns/Corefile


cat << EOF >> /config/coredns/Corefile
. {
loop
forward . /etc/resolv.conf
}
EOF

0 comments on commit 6215e81

Please sign in to comment.