🌴 Sync 2026-03-05 23:51:42

This commit is contained in:
github-actions[bot] committed 2026-03-05 23:51:42 +08:00
1 parent 97c049ed0a
commit 0acff03804
14253 files changed
+3893239

No files matched your search

+55
View File
@@ -0,0 +1,55 @@
#
# Copyright (C) 2015 OpenWrt-dist
# Copyright (C) 2015 Jian Chang <aa65535@live.com>
#
# This is free software, licensed under the GNU General Public License v3.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=ShadowVPN
PKG_VERSION:=0.2.0
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://github.com/aa65535/openwrt-shadowvpn/releases/download/v$(PKG_VERSION)
PKG_HASH:=skip
PKG_LICENSE:=GPL-3.0
PKG_LICENSE_FILES:=COPYING
PKG_MAINTAINER:=clowwindy <clowwindy42@gmail.com>
PKG_FIXUP:=autoreconf
PKG_BUILD_PARALLEL:=1
PKG_INSTALL:=1
include $(INCLUDE_DIR)/package.mk
define Package/ShadowVPN
SECTION:=net
CATEGORY:=Network
TITLE:=A fast, safe VPN based on libsodium
URL:=https://github.com/clowwindy/ShadowVPN
DEPENDS:=+kmod-tun +ip
endef
define Package/ShadowVPN/conffiles
/etc/config/shadowvpn
endef
define Package/ShadowVPN/install
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DATA) ./files/shadowvpn.config $(1)/etc/config/shadowvpn
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/shadowvpn.init $(1)/etc/init.d/shadowvpn
$(INSTALL_DIR) $(1)/etc/hotplug.d/iface
$(INSTALL_DATA) ./files/shadowvpn.hotplug $(1)/etc/hotplug.d/iface/30-shadowvpn
$(INSTALL_DIR) $(1)/etc/shadowvpn
$(INSTALL_DATA) ./files/client_up.sh $(1)/etc/shadowvpn/client_up.sh
$(INSTALL_DATA) ./files/client_down.sh $(1)/etc/shadowvpn/client_down.sh
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/shadowvpn $(1)/usr/bin/
endef
$(eval $(call BuildPackage,ShadowVPN))
+44
View File
@@ -0,0 +1,44 @@
#!/bin/sh
#
# Copyright (C) 2015 OpenWrt-dist
# Copyright (C) 2015 Jian Chang <aa65535@live.com>
#
# This is free software, licensed under the GNU General Public License v3.
# See /LICENSE for more information.
#
# This script will be executed when client is down.
# All key value pairs in ShadowVPN config file will be passed to this script
# as environment variables, except password.
PID=$(cat $pidfile 2>/dev/null)
loger() {
echo "$(date '+%c') down.$1 ShadowVPN[$PID] $2"
}
# Get uci setting
route_mode=$(uci get shadowvpn.@shadowvpn[-1].route_mode_save 2>/dev/null)
# Turn off NAT over VPN
iptables -t nat -D POSTROUTING -o $intf -j MASQUERADE
iptables -D FORWARD -i $intf -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -D FORWARD -o $intf -j ACCEPT
loger notice "Turn off NAT over $intf"
# Change routing table
ip route del $server
if [ "$route_mode" != 2 ]; then
ip route del 0.0.0.0/1
ip route del 128.0.0.0/1
loger notice "Default route changed to original route"
fi
# Remove route rules
if [ -f /tmp/shadowvpn_routes ]; then
sed -e "s/^/route del /" /tmp/shadowvpn_routes | ip -batch -
loger notice "Route rules have been removed"
fi
rm -rf /tmp/shadowvpn_routes
loger info "Script $0 completed"
+59
View File
@@ -0,0 +1,59 @@
#!/bin/sh
#
# Copyright (C) 2015 OpenWrt-dist
# Copyright (C) 2015 Jian Chang <aa65535@live.com>
#
# This is free software, licensed under the GNU General Public License v3.
# See /LICENSE for more information.
#
# This script will be executed when client is up.
# All key value pairs in ShadowVPN config file will be passed to this script
# as environment variables, except password.
PID=$(cat $pidfile 2>/dev/null)
loger() {
echo "$(date '+%c') up.$1 ShadowVPN[$PID] $2"
}
# Configure IP address and MTU of VPN interface
ip addr add $net dev $intf
ip link set $intf mtu $mtu
ip link set $intf up
# Get original gateway
gateway=$(ip route show 0/0 | sed -e 's/.* via \([^ ]*\).*/\1/')
loger info "The default gateway: via $gateway"
# Get uci setting
route_mode=$(uci get shadowvpn.@shadowvpn[-1].route_mode 2>/dev/null)
route_file=$(uci get shadowvpn.@shadowvpn[-1].route_file 2>/dev/null)
# Save uci setting
uci set shadowvpn.@shadowvpn[-1].route_mode_save=$route_mode
uci commit shadowvpn
# Turn on NAT over VPN
iptables -t nat -A POSTROUTING -o $intf -j MASQUERADE
iptables -I FORWARD 1 -i $intf -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -I FORWARD 1 -o $intf -j ACCEPT
loger notice "Turn on NAT over $intf"
# Change routing table
suf="dev $intf"
ip route add $server via $gateway
if [ "$route_mode" != 2 ]; then
ip route add 0.0.0.0/1 dev $intf
ip route add 128.0.0.0/1 dev $intf
loger notice "Default route changed to VPN tun"
suf="via $gateway"
fi
# Load route rules
if [ "$route_mode" != 0 -a -f "$route_file" ]; then
grep -E "^([0-9]{1,3}\.){3}[0-9]{1,3}" $route_file >/tmp/shadowvpn_routes
sed -e "s/^/route add /" -e "s/$/ $suf/" /tmp/shadowvpn_routes | ip -batch -
loger notice "Route rules have been loaded"
fi
loger info "Script $0 completed"
+12
View File
@@ -0,0 +1,12 @@
config shadowvpn
option enable '0'
option server '127.0.0.1'
option port '1123'
option password 'my_password'
option concurrency '1'
option net '10.7.0.2/24'
option mtu '1432'
option intf 'tun0'
option route_mode '1'
option route_file '/etc/chinadns_chnroute.txt'
+10
View File
@@ -0,0 +1,10 @@
#!/bin/sh
[ "$ACTION" = ifup ] || exit 0
device=$(ip route show 0/0 | sed -e 's/.* dev \([^ ]*\).*/\1/')
[ -z "$device" -o "$DEVICE" = "$device" ] || exit 0
/etc/init.d/shadowvpn restart
logger -t ShadowVPN "Restart ShadowVPN due to ifup of $INTERFACE ($DEVICE)"
+71
View File
@@ -0,0 +1,71 @@
#!/bin/sh /etc/rc.common
#
# Copyright (C) 2015 OpenWrt-dist
# Copyright (C) 2015 Jian Chang <aa65535@live.com>
#
# This is free software, licensed under the GNU General Public License v3.
# See /LICENSE for more information.
#
START=90
STOP=15
CONFIG=/var/etc/shadowvpn.conf
start_vpn() {
local enable server port password concurrency mtu intf
config_get_bool enable $1 enable
[ "$enable" = 1 ] || return 0
config_get server $1 server
config_get port $1 port
config_get user_token $1 user_token
config_get password $1 password
config_get concurrency $1 concurrency
config_get net $1 net
config_get mtu $1 mtu
config_get intf $1 intf
: ${server:?}
: ${port:?}
: ${password:?}
: ${user_token:=0000000000000000}
mkdir -p $(dirname $CONFIG)
cat <<-EOF >$CONFIG
server=$server
port=$port
password=$password
mode=client
concurrency=1
net=${net:-10.7.0.2/24}
mtu=${mtu:-1432}
intf=${intf:-tun0}
up=/etc/shadowvpn/client_up.sh
down=/etc/shadowvpn/client_down.sh
pidfile=/var/run/shadowvpn.pid
logfile=/var/log/shadowvpn.log
EOF
if [ "$user_token" != "0000000000000000" ]; then
echo "user_token=$user_token" >>$CONFIG
fi
/usr/bin/shadowvpn -c $CONFIG -s start
}
start() {
config_load shadowvpn
config_foreach start_vpn shadowvpn
}
stop() {
/usr/bin/shadowvpn -c $CONFIG -s stop
}
boot() {
if [ ! -c "/dev/net/tun" ]; then
mkdir -p /dev/net
mknod /dev/net/tun c 10 200
chmod 0666 /dev/net/tun
fi
until ip route show 0/0 | grep -q "^default"; do
sleep 1
done
start
}
+71
View File
@@ -0,0 +1,71 @@
diff --git a/Makefile.am b/Makefile.am
index d8461de..9b3fcbd 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,3 @@
-EXTRA_DIST = \
- autogen.sh \
- README.md \
- COPYING
+EXTRA_DIST = autogen.sh
-SUBDIRS = src samples
+SUBDIRS = src
diff --git a/configure.ac b/configure.ac
index dc562d4..f54171c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -79,6 +79,6 @@ AC_ARG_ENABLE([analyze],
AM_CONDITIONAL(STATIC, test x"$static" = x"true")
-AC_CONFIG_FILES([Makefile src/Makefile samples/Makefile])
+AC_CONFIG_FILES([Makefile src/Makefile])
AC_CONFIG_SUBDIRS([libsodium])
AC_OUTPUT
diff --git a/libsodium/Makefile.am b/libsodium/Makefile.am
index ee794b0..5a73134 100644
--- a/libsodium/Makefile.am
+++ b/libsodium/Makefile.am
@@ -1,19 +1,8 @@
ACLOCAL_AMFLAGS = -I m4
-EXTRA_DIST = \
- autogen.sh \
- libsodium.sln \
- libsodium.vcxproj \
- libsodium.vcxproj.filters \
- LICENSE \
- README.markdown \
- THANKS
+EXTRA_DIST = autogen.sh
-SUBDIRS = \
- dist-build \
- msvc-scripts \
- src \
- test
+SUBDIRS = src
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = @PACKAGE_NAME@.pc
diff --git a/libsodium/configure.ac b/libsodium/configure.ac
index 21b8f10..281e3ff 100644
--- a/libsodium/configure.ac
+++ b/libsodium/configure.ac
@@ -442,15 +442,10 @@ AH_VERBATIM([NDEBUG], [/* Always evaluate assert() calls */
#endif])
AC_CONFIG_FILES([Makefile
- dist-build/Makefile
libsodium.pc
- libsodium-uninstalled.pc
- msvc-scripts/Makefile
src/Makefile
src/libsodium/Makefile
src/libsodium/include/Makefile
src/libsodium/include/sodium/version.h
- test/default/Makefile
- test/Makefile
])
AC_OUTPUT
@@ -0,0 +1,110 @@
--- a/libsodium/src/libsodium/Makefile.am
+++ b/libsodium/src/libsodium/Makefile.am
@@ -31,6 +31,9 @@ libsodium_la_SOURCES = \
crypto_core/salsa20/ref/core_salsa20.c \
crypto_core/salsa20/core_salsa20_api.c \
crypto_core/salsa20/ref/api.h \
+ crypto_core/salsa208/ref/core_salsa208.c \
+ crypto_core/salsa208/core_salsa208_api.c \
+ crypto_core/salsa208/ref/api.h \
crypto_generichash/crypto_generichash.c \
crypto_generichash/blake2/generichash_blake2_api.c \
crypto_generichash/blake2/ref/api.h \
@@ -136,6 +139,10 @@ libsodium_la_SOURCES = \
crypto_stream/chacha20/ref/api.h \
crypto_stream/chacha20/ref/stream_chacha20_ref.c \
crypto_stream/salsa20/stream_salsa20_api.c \
+ crypto_stream/salsa208/stream_salsa208_api.c \
+ crypto_stream/salsa208/ref/api.h \
+ crypto_stream/salsa208/ref/stream_salsa208.c \
+ crypto_stream/salsa208/ref/xor_salsa208.c \
crypto_stream/xsalsa20/stream_xsalsa20_api.c \
crypto_stream/xsalsa20/ref/api.h \
crypto_stream/xsalsa20/ref/stream_xsalsa20.c \
@@ -204,9 +211,6 @@ libsodium_la_SOURCES += \
crypto_core/salsa2012/ref/core_salsa2012.c \
crypto_core/salsa2012/core_salsa2012_api.c \
crypto_core/salsa2012/ref/api.h \
- crypto_core/salsa208/ref/core_salsa208.c \
- crypto_core/salsa208/core_salsa208_api.c \
- crypto_core/salsa208/ref/api.h \
crypto_sign/edwards25519sha512batch/sign_edwards25519sha512batch_api.c \
crypto_sign/edwards25519sha512batch/ref/api.h \
crypto_sign/edwards25519sha512batch/ref/fe25519.h \
@@ -232,11 +236,7 @@ libsodium_la_SOURCES += \
crypto_stream/salsa2012/stream_salsa2012_api.c \
crypto_stream/salsa2012/ref/api.h \
crypto_stream/salsa2012/ref/stream_salsa2012.c \
- crypto_stream/salsa2012/ref/xor_salsa2012.c \
- crypto_stream/salsa208/stream_salsa208_api.c \
- crypto_stream/salsa208/ref/api.h \
- crypto_stream/salsa208/ref/stream_salsa208.c \
- crypto_stream/salsa208/ref/xor_salsa208.c
+ crypto_stream/salsa2012/ref/xor_salsa2012.c
endif
libsodium_la_LDFLAGS = \
--- a/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2.h
+++ b/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2.h
@@ -98,7 +98,7 @@ extern "C" {
uint8_t personal[BLAKE2B_PERSONALBYTES]; // 64
} blake2b_param;
-#ifndef DEFINE_BLAKE2B_STATE
+#if 1
typedef crypto_generichash_blake2b_state blake2b_state;
#else
ALIGN( 64 ) typedef struct blake2b_state_
@@ -110,7 +110,6 @@ typedef crypto_generichash_blake2b_state blake2b_state;
size_t buflen;
uint8_t last_node;
} blake2b_state;
-#endif
typedef struct blake2sp_state_
{
@@ -127,6 +126,8 @@ typedef crypto_generichash_blake2b_state blake2b_state;
uint8_t buf[4 * BLAKE2B_BLOCKBYTES];
size_t buflen;
} blake2bp_state;
+#endif
+
#pragma pack(pop)
// Streaming API
@@ -146,6 +147,7 @@ typedef crypto_generichash_blake2b_state blake2b_state;
int blake2b_update( blake2b_state *S, const uint8_t *in, uint64_t inlen );
int blake2b_final( blake2b_state *S, uint8_t *out, uint8_t outlen );
+#if 0
int blake2sp_init( blake2sp_state *S, const uint8_t outlen );
int blake2sp_init_key( blake2sp_state *S, const uint8_t outlen, const void *key, const uint8_t keylen );
int blake2sp_update( blake2sp_state *S, const uint8_t *in, uint64_t inlen );
@@ -155,6 +157,7 @@ typedef crypto_generichash_blake2b_state blake2b_state;
int blake2bp_init_key( blake2bp_state *S, const uint8_t outlen, const void *key, const uint8_t keylen );
int blake2bp_update( blake2bp_state *S, const uint8_t *in, uint64_t inlen );
int blake2bp_final( blake2bp_state *S, uint8_t *out, uint8_t outlen );
+#endif
// Simple API
int blake2s( uint8_t *out, const void *in, const void *key, const uint8_t outlen, const uint64_t inlen, uint8_t keylen );
--- a/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-ref.c
+++ b/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-ref.c
@@ -415,7 +415,7 @@ int blake2b_final( blake2b_state *S, uint8_t *out, uint8_t outlen )
/* inlen, at least, should be uint64_t. Others can be size_t. */
int blake2b( uint8_t *out, const void *in, const void *key, const uint8_t outlen, const uint64_t inlen, uint8_t keylen )
{
- blake2b_state S[1];
+ blake2b_state *S;
/* Verify parameters */
if ( NULL == in ) return -1;
@@ -441,7 +441,7 @@ int blake2b( uint8_t *out, const void *in, const void *key, const uint8_t outlen
int blake2b_salt_personal( uint8_t *out, const void *in, const void *key, const uint8_t outlen, const uint64_t inlen, uint8_t keylen,
const void *salt, const void *personal )
{
- blake2b_state S[1];
+ blake2b_state *S;
/* Verify parameters */
if ( NULL == in ) return -1;