diff --git a/.gitignore b/.gitignore
index 0cb6eeb..4ee6b64 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,4 @@
/pkg/
/spec/reports/
/tmp/
+/vendor
diff --git a/.ruby-version b/.ruby-version
new file mode 100644
index 0000000..005119b
--- /dev/null
+++ b/.ruby-version
@@ -0,0 +1 @@
+2.4.1
diff --git a/Rakefile b/Rakefile
index 2ba284a..8005b1e 100644
--- a/Rakefile
+++ b/Rakefile
@@ -11,4 +11,5 @@ end
YARD::Rake::YardocTask.new
-task :default => [:spec, :features]
+task :default => [:test]
+task :test => [:spec, :features]
diff --git a/features/local_functional.feature b/features/local_functional.feature
index 7e827dc..228d6fc 100644
--- a/features/local_functional.feature
+++ b/features/local_functional.feature
@@ -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:
+ """
+
Example Domain
+ """
+ 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 "Example Domain
"
+ 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 "Example Domain
"
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 "Example Domain
"
+ 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 "Example Domain
"
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 "Example Domain
"
+ 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 "Example Domain
"
diff --git a/features/server_functional.feature b/features/server_functional.feature
index 4857745..4ea1c2f 100644
--- a/features/server_functional.feature
+++ b/features/server_functional.feature
@@ -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:
+ """
+ Example Domain
+ """
+ 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 "Example Domain
"
+ 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 "Example Domain
"
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 "Example Domain
"
+ 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 "Example Domain
"
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 "Example Domain
"
+ 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 "Example Domain
"
diff --git a/script/bootstrap b/script/bootstrap
new file mode 100755
index 0000000..7aff9a1
--- /dev/null
+++ b/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
diff --git a/script/console b/script/console
new file mode 100755
index 0000000..4d39dcc
--- /dev/null
+++ b/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
\ No newline at end of file
diff --git a/script/setup b/script/setup
new file mode 100755
index 0000000..fd33161
--- /dev/null
+++ b/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!"
\ No newline at end of file
diff --git a/script/test b/script/test
new file mode 100755
index 0000000..7585f1a
--- /dev/null
+++ b/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
\ No newline at end of file