Skip to content

Commit 7961b49

Browse files
author
EGAWA Hiroki
committed
wsshuttle: support ProxyCommand
1 parent fe21ef9 commit 7961b49

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,5 @@ route.exe delete 128.0.0.0 mask 128.0.0.0
6060
```
6161
6262
# Future Work
63-
- Support ProxyCommand
63+
- nothing
64+

wsshuttle

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ show(){
1414
xargs -n1 echo $rxs: |
1515
cat
1616
done
17+
exit 0
1718
}
1819
#r=aa; x=(bb cc); s=(dd ee); show r x s; exit
1920

@@ -28,23 +29,27 @@ parse_args(){
2829
args+=("$i")
2930
fi
3031
done
31-
#echo IS_DELETE: ,$IS_DELETE,;echo IS_DRY: ,$IS_DRY,;exit
32-
#for i in "${args[@]}"; do echo $i;done;exit
32+
#show IS_DELETE IS_DRY args
3333

3434
for((i = 1; i < ${#args[@]}; i++)); do
3535
if [[ ${args[$i-1]} =~ ^-[^-]*r$ ]]; then # -r
36-
ssh=$(ssh -v ${args[$i]} true 2>&1) &&
37-
break || { echo error: ssh failed; exit 1; }
36+
rhost=${args[$i]}
37+
break
38+
#ssh=$(ssh -v ${args[$i]} true 2>&1) &&
39+
#break || { echo error: ssh failed; exit 1; }
3840
fi
3941
done
4042
#echo "$ssh";exit
43+
#show rhost
4144

42-
ruser=$(echo "$ssh" | grep 'Authenticating' | awk -F\' '$0=$2')
43-
rip=$( echo "$ssh" | grep 'Authenticated' | awk -F'[][]' '$0=$2')
44-
rport=$(echo "$ssh" | grep 'Authenticated' | awk -F'[])]' '$0=$2')
45-
#args[$i]=$ruser@$rip$rport
46-
47-
#show args;exit
45+
while [[ ! -z $rhost ]]; do
46+
ssh=$(ssh -v $rhost true 2>&1 | tr -d '\r') ||
47+
{ echo error: ssh $rhost failed; exit 1; }
48+
rhost=$(echo "$ssh" | awk '/Executing proxy command:/{print $(NF)}')
49+
done
50+
rhost=$(echo "$ssh" | awk -F'[][]' '/Authenticated/{print $2}')
51+
rip=$(dig +short $rhost | head -n1)
52+
#show rhost rip
4853
}
4954

5055
set_xs(){
@@ -58,7 +63,7 @@ set_xs(){
5863
fi
5964
fi
6065
done
61-
#show x s;exit # 8.8.8.8[/24]
66+
#show x s # 8.8.8.8[/24]
6267

6368
f() {
6469
for i in "$@"; do # 8.8.8.8[/24]
@@ -75,19 +80,19 @@ set_xs(){
7580
}
7681
x=( $(f "${x[@]}") )
7782
s=( $(f "${s[@]}") )
78-
#show x s; exit # 8.8.8.0/255.255.255.0
83+
#show x s # 8.8.8.0/255.255.255.0
7984

8085
s=($(
8186
echo "${s[@]}" |
8287
sed 's,0.0.0.0/0.0.0.0,0.0.0.0/128.0.0.0 128.0.0.0/128.0.0.0,g'
8388
))
84-
#show s; exit
89+
#show s
8590

8691
x=( $(echo "${x[@]}" | xargs -n1 | sort -u) )
8792
s=( $(echo "${s[@]}" | xargs -n1 | sort -u) )
88-
#show x s; exit # uniq
93+
#show x s # uniq
8994

90-
#show x s; exit
95+
#show x s
9196
}
9297

9398
set_env(){
@@ -101,11 +106,7 @@ set_env(){
101106
WIN_IFIP=$(route.exe print -4 | awk '$1=="0.0.0.0"{print $4}')
102107
WIN_IFID=$( arp.exe -a | grep "^I.*: $WIN_IFIP" | awk '$0=strtonum($4)')
103108

104-
#echo WSL2_IP: $WSL2_IP
105-
#echo WIN_VIFID: $WIN_VIFID
106-
#echo GW_IP: $GW_IP
107-
#echo WIN_IFID: $WIN_IFID
108-
#exit
109+
#show WSL2_IP WIN_VIFID GW_IP WIN_IFID
109110
}
110111

111112
route_add(){

0 commit comments

Comments
 (0)