aboutsummaryrefslogtreecommitdiffstats
path: root/vagrant/setup_proxy.sh
blob: 2161f295a7b8f43aa75eff6a15de587fb3ac436a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh
set -ex

SOCKS5_IP=${SOCKS5_IP:-127.0.0.1}
SOCKS5_PORT=${SOCKS5:-1080}
DNS_SERVER=${DNS_SERVER:-10.248.2.5}

sudo apt-get install -y redsocks iptables

cat <<EOF | sudo tee /etc/redsocks.conf
base {
 log_debug = on;
 log_info = on;
 log = "file:/root/proxy.log";
 daemon = on;
 redirector = iptables;
}

redsocks {
 local_ip = 0.0.0.0;
 local_port = 6666;
 ip = $SOCKS5_IP;
 port = $SOCKS5_PORT;
 type = socks5;
}
EOF

echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
sudo iptables -t filter -F
sudo iptables -t mangle -F
sudo iptables -t nat -F

sudo iptables -t nat -N REDSOCKS || true
sudo iptables -t nat -A REDSOCKS -d 0.0.0.0/8 -j RETURN
sudo iptables -t nat -A REDSOCKS -d 10.0.0.0/8 -j RETURN
sudo iptables -t nat -A REDSOCKS -d 127.0.0.0/8 -j RETURN
sudo iptables -t nat -A REDSOCKS -d 169.254.0.0/16 -j RETURN
sudo iptables -t nat -A REDSOCKS -d 172.16.0.0/12 -j RETURN
sudo iptables -t nat -A REDSOCKS -d 192.168.0.0/16 -j RETURN
sudo iptables -t nat -A REDSOCKS -d 224.0.0.0/4 -j RETURN
sudo iptables -t nat -A REDSOCKS -d 240.0.0.0/4 -j RETURN
sudo iptables -t nat -A REDSOCKS -p tcp -j REDIRECT --to-ports 6666
sudo iptables -t nat -A OUTPUT -p tcp  -j REDSOCKS
sudo iptables -t nat -A PREROUTING -p tcp  -j REDSOCKS
sudo iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -j MASQUERADE
sudo iptables -t nat -A PREROUTING  -p udp --dport 53  -j DNAT --to-destination $DNS_SERVER

sudo service redsocks restart
wget --no-proxy  www.sina.com.cn -O /dev/null
span> := $(ROOT_DIR)/dist PACKAGE_DIR := $(OUTPUT_DIR)/packages SECRET_DIR := $(OUTPUT_DIR)/secrets HELM_BIN := helm HELM_VER := $(shell $(HELM_BIN) version --template "{{.Version}}") # use this if you would like to push onap charts to repo with other name # WARNING: Helm v3+ only # WARNING: Make sure to edit also requirements files HELM_REPO := local ifneq ($(SKIP_LINT),TRUE) HELM_LINT_CMD := $(HELM_BIN) lint else HELM_LINT_CMD := echo "Skipping linting of" endif SUBMODS := robot aai EXCLUDES := config oneclick readiness test dist helm $(PARENT_CHART) dcae $(SUBMODS) HELM_CHARTS := $(filter-out $(EXCLUDES), $(sort $(patsubst %/.,%,$(wildcard */.)))) $(PARENT_CHART) .PHONY: $(EXCLUDES) $(HELM_CHARTS) check-for-staging-images all: $(COMMON_CHARTS_DIR) $(SUBMODS) $(HELM_CHARTS) helm-repo-update plugins $(COMMON_CHARTS): @echo "\n[$@]" @make package-$@ $(HELM_CHARTS): @echo "\n[$@]" @make package-$@ $(SUBMODS): @echo "\n[$@]" @make submod-$@ @make package-$@ submod-%: @make $*/requirements.yaml %/requirements.yaml: $(error Submodule $* needs to be retrieved from gerrit. See https://wiki.onap.org/display/DW/OOM+-+Development+workflow+after+code+transfer+to+tech+teams ); fi make-%: @if [ -f $*/Makefile ]; then make -C $*; fi dep-%: make-% @if [ -f $*/requirements.yaml ]; then $(HELM_BIN) dep up $*; fi lint-%: dep-% @if [ -f $*/Chart.yaml ]; then $(HELM_LINT_CMD) $*; fi package-%: lint-% @mkdir -p $(PACKAGE_DIR) ifeq "$(findstring v3,$(HELM_VER))" "v3" @if [ -f $*/Chart.yaml ]; then PACKAGE_NAME=$$($(HELM_BIN) package -d $(PACKAGE_DIR) $* | cut -d":" -f2) && $(HELM_BIN) push -f $$PACKAGE_NAME $(HELM_REPO); fi else @if [ -f $*/Chart.yaml ]; then $(HELM_BIN) package -d $(PACKAGE_DIR) $*; fi @$(HELM_BIN) repo index $(PACKAGE_DIR) endif clean: @rm -f */requirements.lock @find . -type f -name '*.tgz' -delete @rm -rf $(PACKAGE_DIR)/* # publish helm plugins via distrubtion directory plugins: @cp -R $(HELM_BIN) $(PACKAGE_DIR)/ # start up a local helm repo to serve up helm chart packages # WARNING: Only helm < v3 supported repo: @mkdir -p $(PACKAGE_DIR) @$(HELM_BIN) serve --repo-path $(PACKAGE_DIR) & @sleep 3 @$(HELM_BIN) repo index $(PACKAGE_DIR) @$(HELM_BIN) repo add local http://127.0.0.1:8879 # stop local helm repo # WARNING: Only helm < v3 supported repo-stop: @pkill $(HELM_BIN) @$(HELM_BIN) repo remove local check-for-staging-images: $(ROOT_DIR)/contrib/tools/check-for-staging-images.sh helm-repo-update: ifeq "$(findstring v3,$(HELM_VER))" "v3" @$(HELM_BIN) repo update $(HELM_REPO) endif %: @: