Skip to content

Commit

Permalink
Merge pull request scrapinghub#37 from lins05/container-based-travis
Browse files Browse the repository at this point in the history
Use container based travis builds
  • Loading branch information
lins05 committed Oct 16, 2015
2 parents be62b92 + c6c5d0d commit a29f25b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
10 changes: 9 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
sudo: false
language: python
python: 2.7
cache:
directories:
- $HOME/.cache/pip
before_install:
- sudo cp scripts/slackbot-test-ctl /usr/local/bin
- mkdir -p $HOME/opt/local/bin
- export PATH=$HOME/opt/local/bin:$PATH
- pushd /tmp/ && git clone https://github.com/rofl0r/proxychains-ng.git && cd proxychains-ng && ./configure --prefix=$HOME/opt/local && make -j2 && make install && popd
- pip install shadowsocks
- cp scripts/slackbot-test-ctl $HOME/opt/local/bin
- slackbot-test-ctl init
- slackbot-test-ctl startproxy
install: pip install -r requirements.txt
Expand Down
25 changes: 13 additions & 12 deletions scripts/slackbot-test-ctl
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
set -x -e

ssconfig=/tmp/config.json
tsocksconfig=/tmp/tsocks.conf
export TSOCKS_CONF_FILE=$tsocksconfig
proxychainsconfig=/tmp/proxychains.conf

init_tsocks() {
init_proxychains() {
cat >$ssconfig <<EOF
{
"server":"127.0.0.1",
Expand All @@ -19,21 +18,23 @@ init_tsocks() {
}
EOF

cat >$tsocksconfig <<EOF
local = 127.0.0.0/255.0.0.0
server = 127.0.0.1
server_type = 5
server_port = 1800
cat >$proxychainsconfig <<EOF
strict_chain
quiet_mode
proxy_dns
remote_dns_subnet 224
tcp_read_time_out 15000
tcp_connect_time_out 8000
[ProxyList]
socks5 127.0.0.1 1800
EOF
}

main() {
local action=$1; shift
case $action in
init)
which sslocal || sudo pip install shadowsocks
which tsocks || sudo apt-get install tsocks
init_tsocks
init_proxychains
;;
startproxy)
pgrep -f "sslocal -c $ssconfig" || {
Expand All @@ -48,7 +49,7 @@ main() {
pkill -f "ssserver -c $ssconfig"
;;
run)
tsocks "$@"
proxychains4 -f $proxychainsconfig "$@"
;;
*)
echo "WARNING: unknown command $action"
Expand Down

0 comments on commit a29f25b

Please sign in to comment.