1
0
mirror of https://github.com/faicker/wg-config.git synced 2020-11-18 19:53:49 -08:00

Remove Table attribute in client conf

Signed-off-by: Faicker Mo <faicker.mo@gmail.com>
This commit is contained in:
Faicker Mo 2020-01-04 19:18:28 +08:00
parent 42a8edfa04
commit ae94b4498f
2 changed files with 5 additions and 10 deletions

View File

@ -1,7 +1,6 @@
[Interface] [Interface]
Address = $_VPN_IP Address = $_VPN_IP
PrivateKey = $_PRIVATE_KEY PrivateKey = $_PRIVATE_KEY
Table = $_TABLE
[Peer] [Peer]
PublicKey = $_SERVER_PUBLIC_KEY PublicKey = $_SERVER_PUBLIC_KEY

14
wg.sh
View File

@ -41,7 +41,7 @@ generate_cidr_ip_file_if() {
local i=$((beg+2)) local i=$((beg+2))
while [[ $i -lt $end ]]; do while [[ $i -lt $end ]]; do
ip=$(dec2ip $i) ip=$(dec2ip $i)
echo "$ip/$mask" >> $AVAILABLE_IP_FILE echo "$ip/$mask" >> $AVAILABLE_IP_FILE
i=$((i+1)) i=$((i+1))
done done
} }
@ -49,7 +49,7 @@ generate_cidr_ip_file_if() {
get_vpn_ip() { get_vpn_ip() {
local ip=$(head -1 $AVAILABLE_IP_FILE) local ip=$(head -1 $AVAILABLE_IP_FILE)
if [[ $ip ]]; then if [[ $ip ]]; then
local mat="${ip/\//\\\/}" local mat="${ip/\//\\\/}"
sed -i "/^$mat$/d" $AVAILABLE_IP_FILE sed -i "/^$mat$/d" $AVAILABLE_IP_FILE
fi fi
echo "$ip" echo "$ip"
@ -71,17 +71,13 @@ add_user() {
echo "no available ip" echo "no available ip"
exit 1 exit 1
fi fi
_TABLE=auto
if [[ ! -z "$route" ]]; then
_TABLE=off
fi
eval "echo \"$(cat "${template_file}")\"" > $userdir/wg0.conf eval "echo \"$(cat "${template_file}")\"" > $userdir/wg0.conf
qrencode -o $userdir/$user.png < $userdir/wg0.conf qrencode -o $userdir/$user.png < $userdir/wg0.conf
# change wg config # change wg config
local ip=${_VPN_IP%/*}/32 local ip=${_VPN_IP%/*}/32
if [[ ! -z "$route" ]]; then if [[ ! -z "$route" ]]; then
ip="0.0.0.0/0,::/0" ip="0.0.0.0/0,::/0"
fi fi
local public_key=`cat $userdir/publickey` local public_key=`cat $userdir/publickey`
wg set $interface peer $public_key allowed-ips $ip wg set $interface peer $public_key allowed-ips $ip
@ -164,7 +160,7 @@ init_server() {
if [[ -s $WG_CONF_FILE ]]; then if [[ -s $WG_CONF_FILE ]]; then
echo "$WG_CONF_FILE exist" echo "$WG_CONF_FILE exist"
exit 1 exit 1
fi fi
generate_cidr_ip_file_if generate_cidr_ip_file_if
eval "echo \"$(cat "${template_file}")\"" > $WG_CONF_FILE eval "echo \"$(cat "${template_file}")\"" > $WG_CONF_FILE
@ -185,7 +181,7 @@ usage() {
-l: list all users -l: list all users
-c: clear all -c: clear all
-g: generate ip file -g: generate ip file
-r: enable router(allow 0.0.0.0/0) -r: enable route all traffic(allow 0.0.0.0/0)
" "
} }