Skip to content

Commit

Permalink
Add support for dante as a socks server
Browse files Browse the repository at this point in the history
$ install_dante
$ run_socks dante

will run a sock server on the vm

The ssh tunnel is removed.

Signed-off-by: Benjamin Hesmans <ben.hesmans@gmail.com>
  • Loading branch information
bhesmans committed Apr 13, 2020
1 parent e402e50 commit b94fa8c
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 5 deletions.
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This will create a new vm from scratch and build an mptcp kernel to run it.

Usage:

```
```
source mpsocks_lib
# build a debian image base
Expand All @@ -23,6 +23,10 @@ configure_host_nat
boot_vm
# wait for the vm to boot, this should be fast and leave this open in a console
# OPTIONNAL:
# Install dante to use as a socks server.
# https://www.inet.no/dante/
# install_dante
# Configure vm nw
configure_guest_nw
Expand All @@ -32,11 +36,18 @@ check_mptcp
# should print "Yay, you are MPTCP-capable! You can now rest in peace."
# Enable local socks server
run_sock
run_socks
# alternative without ssh : run_socks dante
# You can now confiure firefox to use socks server localhost on port 6666
# if you use ssh :
# You can now configure firefox to use socks server localhost on port 6666
# if you use dante :
# You can now configure firefox to use socks server 6.6.6.2 on port 6666
# Using firefox, go check http://amiusingmptcp.de/#check should be green
# you should have less overhead with dante because it doesn't tunnel at all
# Firefox will connect straight to the vm
# Once you're done, do some clean up
clean_host_nat
clean_host_tap
Expand Down
44 changes: 42 additions & 2 deletions mpsocks_lib
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ ssh_vm() {
ssh -o "UserKnownHostsFile /dev/null" -o "StrictHostKeyChecking no" -p 6222 root@localhost $@
}

ssh_vm_pseudoterm() {
ssh -t -o "UserKnownHostsFile /dev/null" -o "StrictHostKeyChecking no" -p 6222 root@localhost $@
}

configure_guest_nw() {
ssh_vm ip addr add 6.6.6.2/24 dev enp0s4
ssh_vm ip link set dev enp0s4 up
Expand All @@ -110,11 +114,47 @@ check_mptcp() {
ssh_vm wget -O- -U curl multipath-tcp.org 2>/dev/null
}

run_ssh_socks() {
ssh -o "UserKnownHostsFile /dev/null" -o "StrictHostKeyChecking no" -p 6222 -D 6666 -N root@localhost
}

run_socks() {
echo "^C to kill it !"
ssh -o "UserKnownHostsFile /dev/null" -o "StrictHostKeyChecking no" -p 6222 -D 6666 -N root@localhost
local method=${1:-ssh}
run_${method}_socks
}

install_dante() {
ssh_vm ip r del default
ssh_vm ip r add default via 10.0.2.2
ssh_vm apt-get install -y --allow-unauthenticated build-essential
ssh_vm mkdir tools
ssh_vm "wget -O- https://www.inet.no/dante/files/dante-1.4.2.tar.gz | tar -ixz --directory tools"
ssh_vm "cd tools/dante-1.4.2 && ./configure && make"
}

run_dante_socks() {
cat <<'EOF' | ssh_vm "cat - > /tmp/sockd.conf"
logoutput: stderr
internal: 6.6.6.2 port = 6666
external: 6.6.6.2
socksmethod: none
client pass {
from: 6.6.6.0/24 port 1-65535 to: 0.0.0.0/0
}
socks pass {
from: 6.6.6.0/24 to: 0.0.0.0/0
protocol: tcp udp
}
EOF
ssh_vm_pseudoterm tools/dante-1.4.2/sockd/sockd -f /tmp/sockd.conf
}

boot_vm() {
qemu-system-x86_64 -kernel ./mptcp/build-kvm/arch/x86/boot/bzImage -hda $IMG -append "root=/dev/sda rw console=ttyS0" --enable-kvm --nographic -device e1000,netdev=mgmt -device e1000,netdev=network0 -netdev tap,id=network0,ifname=mptcp,script=no,downscript=no -netdev user,id=mgmt,hostfwd=tcp:127.0.0.1:6222-:22
qemu-system-x86_64 -m 512 -kernel ./mptcp/build-kvm/arch/x86/boot/bzImage -hda $IMG -append "root=/dev/sda rw console=ttyS0" --enable-kvm --nographic -device e1000,netdev=mgmt -device e1000,netdev=network0 -netdev tap,id=network0,ifname=mptcp,script=no,downscript=no -netdev user,id=mgmt,hostfwd=tcp:127.0.0.1:6222-:22
}

0 comments on commit b94fa8c

Please sign in to comment.