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:
parent
42a8edfa04
commit
ae94b4498f
@ -1,7 +1,6 @@
|
||||
[Interface]
|
||||
Address = $_VPN_IP
|
||||
PrivateKey = $_PRIVATE_KEY
|
||||
Table = $_TABLE
|
||||
|
||||
[Peer]
|
||||
PublicKey = $_SERVER_PUBLIC_KEY
|
||||
|
14
wg.sh
14
wg.sh
@ -41,7 +41,7 @@ generate_cidr_ip_file_if() {
|
||||
local i=$((beg+2))
|
||||
while [[ $i -lt $end ]]; do
|
||||
ip=$(dec2ip $i)
|
||||
echo "$ip/$mask" >> $AVAILABLE_IP_FILE
|
||||
echo "$ip/$mask" >> $AVAILABLE_IP_FILE
|
||||
i=$((i+1))
|
||||
done
|
||||
}
|
||||
@ -49,7 +49,7 @@ generate_cidr_ip_file_if() {
|
||||
get_vpn_ip() {
|
||||
local ip=$(head -1 $AVAILABLE_IP_FILE)
|
||||
if [[ $ip ]]; then
|
||||
local mat="${ip/\//\\\/}"
|
||||
local mat="${ip/\//\\\/}"
|
||||
sed -i "/^$mat$/d" $AVAILABLE_IP_FILE
|
||||
fi
|
||||
echo "$ip"
|
||||
@ -71,17 +71,13 @@ add_user() {
|
||||
echo "no available ip"
|
||||
exit 1
|
||||
fi
|
||||
_TABLE=auto
|
||||
if [[ ! -z "$route" ]]; then
|
||||
_TABLE=off
|
||||
fi
|
||||
eval "echo \"$(cat "${template_file}")\"" > $userdir/wg0.conf
|
||||
qrencode -o $userdir/$user.png < $userdir/wg0.conf
|
||||
|
||||
# change wg config
|
||||
local ip=${_VPN_IP%/*}/32
|
||||
if [[ ! -z "$route" ]]; then
|
||||
ip="0.0.0.0/0,::/0"
|
||||
ip="0.0.0.0/0,::/0"
|
||||
fi
|
||||
local public_key=`cat $userdir/publickey`
|
||||
wg set $interface peer $public_key allowed-ips $ip
|
||||
@ -164,7 +160,7 @@ init_server() {
|
||||
|
||||
if [[ -s $WG_CONF_FILE ]]; then
|
||||
echo "$WG_CONF_FILE exist"
|
||||
exit 1
|
||||
exit 1
|
||||
fi
|
||||
generate_cidr_ip_file_if
|
||||
eval "echo \"$(cat "${template_file}")\"" > $WG_CONF_FILE
|
||||
@ -185,7 +181,7 @@ usage() {
|
||||
-l: list all users
|
||||
-c: clear all
|
||||
-g: generate ip file
|
||||
-r: enable router(allow 0.0.0.0/0)
|
||||
-r: enable route all traffic(allow 0.0.0.0/0)
|
||||
"
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user