Skip to content
Permalink
Browse files
Added support for debbuging browser-based proxies
Can now use vnc to connect to a running firefox browser in the
container.
  • Loading branch information
cohosh committed May 7, 2019
1 parent 50ce0b4 commit 6775554566b71325b5716a4794529f5a686cc403
Showing with 33 additions and 5 deletions.
  1. +7 −1 Dockerfile
  2. +7 −0 README.md
  3. +18 −3 script.sh
  4. +1 −1 snowbox_run
@@ -1,5 +1,11 @@
FROM golang:1.11
RUN apt-get update && apt-get install -y git libx11-dev tor net-tools sudo
RUN apt-get update && apt-get install -y git libx11-dev tor net-tools sudo gdb strace x11vnc xvfb less apt-transport-https
## Setting up coffeescript for snowflake proxy
RUN echo "deb https://deb.nodesource.com/node_12.x stretch main\ndeb-src https://deb.nodesource.com/node_12.x stretch main" | tee /etc/apt/sources.list.d/nodesource.list
RUN curl -sL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
RUN apt-get update && apt-get install -y nodejs firefox-esr
RUN npm install -g coffeescript
##
RUN apt-get clean
RUN useradd -ms /bin/bash snowflake
RUN adduser snowflake sudo
@@ -20,3 +20,10 @@ Inside the snowbox container, execute ```./script.sh --build``` to build and run

### Attaching additional terminals to the test environment
Open a new terminal and execute ```./snowbox_run --attach```. Excluding the --attach argument will prompt the script to attempt an attachment if the container is already running.

### Running a browser-based proxy
To run and debug a browser-based proxy, you can connect to the docker container using VNC. On your host machine, run the following command:
```vncviewer localhost```
A window showing a running firefox session should appear. You can then navigate to
```file:/go/src/snowflake.git/proxy/build/embed.html```
to run the proxy.
@@ -25,6 +25,10 @@ done
# we manually copy files locally (avoiding go install so we don't have to recompile everytime)

if [ "$build" -ne "0" ]; then
#kill broker, proxy, client processes
pkill -f broker
pkill -f client

cd snowflake.git/broker

go get -d -v
@@ -37,6 +41,11 @@ if [ "$build" -ne "0" ]; then
cd ../client
go get -d -v
go build -v

cd ../proxy
cake build
#need to point to our localhost broker instead
sed -i 's/snowflake-broker.bamsoftware.com/localhost:8080/' build/snowflake.js

cd /go/src
fi
@@ -49,8 +58,8 @@ if [ "$client" -eq "0" ]; then

cd /go/bin

nohup broker -addr ":8080" -disable-tls > broker.log 2> broker.err &
nohup proxy-go -broker "http://localhost:8080" > proxy.log 2> proxy.err &
broker -addr ":8080" -disable-tls > broker.log 2> broker.err &
proxy-go -broker "http://localhost:8080" > proxy.log 2> proxy.err &
else
cd /go/bin

@@ -68,6 +77,12 @@ else
sed -i -e "/^-url http:\/\/localhost:8080\//a -log snowflake_client-$count.log" torrc-$count
echo "SOCKSPort $(($count+9050))" >> torrc-$count

nohup tor -f torrc-$count > client-$count.log 2> client-$count.err &
tor -f torrc-$count > client-$count.log 2> client-$count.err &
fi

# Start X and firefox for proxy
/usr/bin/Xvfb :1 -screen 0 1024x768x24 >/dev/null 2>&1 &
sleep 2
/usr/bin/x11vnc -display :1.0 >/dev/null 2>&1 &

DISPLAY=:1 firefox &
@@ -26,7 +26,7 @@ if [ "$attach" -eq "0" ]; then
if [ $? -ne 0 ]; then
printf 'Container already exists. Trying to attach...\n'
else
docker run --name snow_test -p 8080:8080 -it -v ${SNOWFLAKE_REPO}:/go/src/snowflake.git snowbox /bin/bash
docker run --name snow_test -p 8080:8080 -p 6060:6060 -p 5900:5900 -it -v ${SNOWFLAKE_REPO}:/go/src/snowflake.git --net=vnc --cap-add=SYS_PTRACE --security-opt seccomp=unconfined snowbox /bin/bash
exit
fi
fi

0 comments on commit 6775554

Please sign in to comment.