1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00
This commit is contained in:
suyuan 2023-06-23 08:47:44 +08:00
parent dacb6205fb
commit b3d17da339
14 changed files with 417 additions and 281 deletions

View file

@ -1,5 +1,7 @@
#
# Copyright (C) 2010-2015 OpenWrt.org
# Copyright (C) 2018-2019 Ycarus (Yannick Chabanois) <ycarus@zugaina.org>
# - Added gateway setting
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
@ -8,7 +10,8 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=6in4
PKG_RELEASE:=28
PKG_VERSION:=270
PKG_RELEASE:=2
PKG_LICENSE:=GPL-2.0
include $(INCLUDE_DIR)/package.mk

View file

@ -9,20 +9,6 @@
init_proto "$@"
}
# Function taken from 6to4 package (6to4.sh), flipped returns
test_6in4_rfc1918()
{
local oIFS="$IFS"; IFS="."; set -- $1; IFS="$oIFS"
[ $1 -eq 10 ] && return 1
[ $1 -eq 192 ] && [ $2 -eq 168 ] && return 1
[ $1 -eq 172 ] && [ $2 -ge 16 ] && [ $2 -le 31 ] && return 1
# RFC 6598
[ $1 -eq 100 ] && [ $2 -ge 64 ] && [ $2 -le 127 ] && return 1
return 0
}
proto_6in4_update() {
sh -c '
timeout=5
@ -45,8 +31,8 @@ proto_6in4_setup() {
local iface="$2"
local link="6in4-$cfg"
local mtu ttl tos ipaddr peeraddr ip6addr ip6prefix ip6prefixes tunlink tunnelid username password updatekey
json_get_vars mtu ttl tos ipaddr peeraddr ip6addr tunlink tunnelid username password updatekey
local mtu ttl tos ipaddr peeraddr ip6addr ip6prefix ip6prefixes tunlink tunnelid username password updatekey gateway
json_get_vars mtu ttl tos ipaddr peeraddr ip6addr tunlink tunnelid username password updatekey gateway
json_for_each_item proto_6in4_add_prefix ip6prefix ip6prefixes
[ -z "$peeraddr" ] && {
@ -55,7 +41,7 @@ proto_6in4_setup() {
return
}
( proto_add_host_dependency "$cfg" "$peeraddr" "$tunlink" )
[ -n "$tunlink" ] && ( proto_add_host_dependency "$cfg" "$peeraddr" "$tunlink" )
[ -z "$ipaddr" ] && {
local wanif="$tunlink"
@ -75,11 +61,15 @@ proto_6in4_setup() {
[ -n "$ip6addr" ] && {
local local6="${ip6addr%%/*}"
local mask6="${ip6addr##*/}"
[ "$local6" = "$mask6" ] && mask6=
[[ "$local6" = "$mask6" ]] && mask6=
proto_add_ipv6_address "$local6" "$mask6"
proto_add_ipv6_route "::" 0 "" "" "" "$local6/$mask6"
}
[ -n "$gateway" ] && {
proto_add_ipv6_route "::" 0 "$gateway"
}
for ip6prefix in $ip6prefixes; do
proto_add_ipv6_prefix "$ip6prefix"
proto_add_ipv6_route "::" 0 "" "" "" "$ip6prefix"
@ -111,11 +101,6 @@ proto_6in4_setup() {
}
local url="$http://ipv4.tunnelbroker.net/nic/update?hostname=$tunnelid"
test_6in4_rfc1918 "$ipaddr" && {
local url="${url}&myip=${ipaddr}"
}
local try=0
local max=3
@ -153,6 +138,7 @@ proto_6in4_init_config() {
proto_config_add_string "username"
proto_config_add_string "password"
proto_config_add_string "updatekey"
proto_config_add_string "gateway"
proto_config_add_int "mtu"
proto_config_add_int "ttl"
proto_config_add_string "tos"