Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenkyle committed Jul 18, 2017
2 parents c56133d + 428008d commit 77af3b1
Show file tree
Hide file tree
Showing 9 changed files with 173 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -7,3 +7,4 @@
/pkg/
/spec/reports/
/tmp/
/vendor
1 change: 1 addition & 0 deletions .ruby-version
@@ -0,0 +1 @@
2.4.1
3 changes: 2 additions & 1 deletion Rakefile
Expand Up @@ -11,4 +11,5 @@ end

YARD::Rake::YardocTask.new

task :default => [:spec, :features]
task :default => [:test]
task :test => [:spec, :features]
32 changes: 26 additions & 6 deletions features/local_functional.feature
Expand Up @@ -7,21 +7,41 @@ Background:
Given curl is installed
Given the default aruba stop signal is "INT"
Given I wait 1 seconds for a command to start up
Given a file named "index.html" with:
"""
<h1>Example Domain</h1>
"""
And I run `ruby -run -e httpd . -p 5000` in background

Scenario: shadowsocks origin version
And I wait 15 seconds for the command to start up
When I run `docker run --rm --net=host --entrypoint "ssserver" zhenkyle/docker-sslocal -k secret` in background
And I wait 1 seconds for a command to start up
And I run `sslocal-ruby -k secret -s 127.0.0.1` in background
And I run `curl --socks5-hostname 127.0.0.1 http://www.example.com/`
Then the output from "curl --socks5-hostname 127.0.0.1 http://www.example.com/" should contain "<h1>Example Domain</h1>"
When I run the following script:
"""bash
curl --socks5-hostname 127.0.0.1 http://$(ip route get 1 | awk '{print $NF;exit}'):5000/
"""
Then the output should contain "<h1>Example Domain</h1>"

Scenario: shadowsocks origin version with http_simple obfuscator
And I wait 15 seconds for the command to start up
When I run `docker run --rm --net=host zhenkyle/shadowsocksr ssserver -k secret -o http_simple` in background
And I wait 1 seconds for a command to start up
And I run `sslocal-ruby -s 127.0.0.1 -k secret -o http_simple` in background
And I run `curl --socks5-hostname 127.0.0.1 http://www.example.com/`
Then the output from "curl --socks5-hostname 127.0.0.1 http://www.example.com/" should contain "<h1>Example Domain</h1>"
When I run the following script:
"""bash
curl --socks5-hostname 127.0.0.1 http://$(ip route get 1 | awk '{print $NF;exit}'):5000/
"""
Then the output should contain "<h1>Example Domain</h1>"

Scenario: shadowsocks origin version with tls_ticket obfuscator
And I wait 15 seconds for the command to start up
When I run `docker run --rm --net=host zhenkyle/shadowsocksr ssserver -k secret -o tls1.2_ticket_auth_compatible` in background
And I wait 1 seconds for a command to start up
And I run `sslocal-ruby -s 127.0.0.1 -k secret -o tls1.2_ticket_auth_compatible` in background
And I run `curl --socks5-hostname 127.0.0.1 http://www.example.com/`
Then the output from "curl --socks5-hostname 127.0.0.1 http://www.example.com/" should contain "<h1>Example Domain</h1>"
When I run the following script:
"""bash
curl --socks5-hostname 127.0.0.1 http://$(ip route get 1 | awk '{print $NF;exit}'):5000/
"""
Then the output should contain "<h1>Example Domain</h1>"
23 changes: 17 additions & 6 deletions features/server_functional.feature
Expand Up @@ -7,21 +7,32 @@ Background:
Given curl is installed
Given the default aruba stop signal is "INT"
Given I wait 1 seconds for a command to start up
Given a file named "index.html" with:
"""
<h1>Example Domain</h1>
"""
And I run `ruby -run -e httpd . -p 5000` in background

Scenario: shadowsocks origin version
When I run `ssserver-ruby -k secret` in background
And I wait 15 seconds for the command to start up
And I run `docker run --rm --net=host zhenkyle/docker-sslocal -k secret -s 127.0.0.1` in background
And I run `curl --socks5-hostname 127.0.0.1 http://www.example.com/`
Then the output from "curl --socks5-hostname 127.0.0.1 http://www.example.com/" should contain "<h1>Example Domain</h1>"
And I wait 1 seconds for a command to start up
And I run `curl --socks5-hostname 127.0.0.1 http://127.0.0.1:5000/`
Then the output from "curl --socks5-hostname 127.0.0.1 http://127.0.0.1:5000/" should contain "<h1>Example Domain</h1>"

Scenario: shadowsocks origin version with http_simple obfuscator
When I run `ssserver-ruby -k secret -o http_simple` in background
And I wait 15 seconds for the command to start up
And I run `docker run --rm --net=host zhenkyle/shadowsocksr sslocal -s 127.0.0.1 -k secret -o http_simple` in background
And I run `curl --socks5-hostname 127.0.0.1 http://www.example.com/`
Then the output from "curl --socks5-hostname 127.0.0.1 http://www.example.com/" should contain "<h1>Example Domain</h1>"
And I wait 1 seconds for a command to start up
And I run `curl --socks5-hostname 127.0.0.1 http://127.0.0.1:5000/`
Then the output from "curl --socks5-hostname 127.0.0.1 http://127.0.0.1:5000/" should contain "<h1>Example Domain</h1>"

Scenario: shadowsocks origin version with tls_ticket obfuscator
When I run `ssserver-ruby -k secret -o tls1.2_ticket_auth_compatible` in background
And I wait 15 seconds for the command to start up
And I run `docker run --rm --net=host zhenkyle/shadowsocksr sslocal -s 127.0.0.1 -k secret -o tls1.2_ticket_auth_compatible` in background
And I run `curl --socks5-hostname 127.0.0.1 http://www.example.com/`
Then the output from "curl --socks5-hostname 127.0.0.1 http://www.example.com/" should contain "<h1>Example Domain</h1>"
And I wait 1 seconds for a command to start up
And I run `curl --socks5-hostname 127.0.0.1 http://127.0.0.1:5000/`
Then the output from "curl --socks5-hostname 127.0.0.1 http://127.0.0.1:5000/" should contain "<h1>Example Domain</h1>"
67 changes: 67 additions & 0 deletions script/bootstrap
@@ -0,0 +1,67 @@
#!/bin/sh

# script/bootstrap: Resolve all dependencies that the application requires to
# run.

set -e

cd "$(dirname "$0")/.."

which rvm >/dev/null 2>&1 && {
echo "Sorry, $0 can not be used with rvm."
exit 1
}

if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ]; then
brew bundle check >/dev/null 2>&1 || {
echo "==> Installing Homebrew dependencies…"
brew bundle
}
elif [ "$(uname -s)" = "Linux" ] && [ -f "/etc/debian_version" ]; then

# Install rbenv if needed
which rbenv >/dev/null 2>&1 || {
echo "==> Installing Dependencie -- rbenv"
sudo apt-get update && sudo apt-get install -y autoconf bison build-essential \
libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
cd ~/.rbenv && src/configure && make -C src
grep 'export PATH="$HOME/.rbenv/bin:$PATH"' ~/.bashrc > /dev/null 2>&1 || {
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
}
grep 'eval "$(rbenv init -)"' ~/.bashrc > /dev/null 2>&1 || {
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
}
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
}

# Install docker if needed
which docker >/dev/null 2>&1 || {
echo "==> Installing Dependencie -- docker"
sudo apt-get update && sudo apt-get install docker.io -y
sudo usermod -aG docker $USER
newgrp docker
}

else
echo "Sorry, only support macOS & Debain system."
exit 1
fi

if [ -f ".ruby-version" ] && [ -z "$(rbenv version-name 2>/dev/null)" ]; then
echo "==> Installing Ruby…"
rbenv install --skip-existing
which bundle >/dev/null 2>&1 || {
gem install bundler
rbenv rehash
}
fi

if [ -f "Gemfile" ]; then
echo "==> Installing gem dependencies…"
bundle check --path vendor/gems >/dev/null 2>&1 || {
bundle install --path vendor/gems --quiet --without production
}
fi
15 changes: 15 additions & 0 deletions script/console
@@ -0,0 +1,15 @@
#!/bin/sh

# script/console: Launch a console for the application. Optionally allow an
# environment to be passed in to let the script handle the
# specific requirements for connecting to a console for that
# environment.

set -e

cd "$(dirname "$0")/.."

# no argument provided, so just run the local console in the development
# environment. Ensure the application is setup first.
script/setup
bin/console
21 changes: 21 additions & 0 deletions script/setup
@@ -0,0 +1,21 @@
#!/bin/sh

# script/setup: Set up application for the first time after cloning, or set it
# back to the initial first unused state.

set -e

cd "$(dirname "$0")/.."

script/bootstrap


if [ -z `docker images -q zhenkyle/docker-sslocal` ]; then
docker pull zhenkyle/docker-sslocal
fi

if [ -z `docker images -q zhenkyle/shadowsocksr` ]; then
docker pull zhenkyle/shadowsocksr
fi

echo "==> App is now ready to go!"
23 changes: 23 additions & 0 deletions script/test
@@ -0,0 +1,23 @@
#!/bin/sh

# script/test: Run test suite for application. Optionally pass in a path to an
# individual test file to run a single test.


set -e

cd "$(dirname "$0")/.."

[ -z "$DEBUG" ] || set -x

script/setup

echo "==> Running tests…"

if [ -n "$1" ]; then
# pass arguments to test call. This is useful for calling a single test.
echo "use: bin/rspec $1"
echo " or: bin/cucumber $1"
else
bin/rake test
fi

0 comments on commit 77af3b1

Please sign in to comment.