[WIP] shadowsocks implementation added
This commit is contained in:
parent
40996888c9
commit
6583090d4f
2259 changed files with 417734 additions and 92 deletions
|
|
@ -41,24 +41,68 @@ error() {
|
|||
|
||||
XCODEBUILD="/usr/bin/xcodebuild"
|
||||
WORKINGDIR=`pwd`
|
||||
PATCH="/usr/bin/patch"
|
||||
export PATH=$GOPATH:$PATH
|
||||
|
||||
compile_openvpn_adapter() {
|
||||
cd 3rd/OpenVPNAdapter
|
||||
|
||||
$XCODEBUILD -scheme OpenVPNAdapter -configuration Debug -xcconfig Configuration/amnezia.xcconfig -sdk iphoneos -destination 'generic/platform=iOS' -project OpenVPNAdapter.xcodeproj
|
||||
$XCODEBUILD -scheme OpenVPNAdapter -configuration Release -xcconfig Configuration/amnezia.xcconfig -sdk iphoneos -destination 'generic/platform=iOS' -project OpenVPNAdapter.xcodeproj
|
||||
|
||||
cd ../../
|
||||
}
|
||||
|
||||
|
||||
prepare_to_build_vpn() {
|
||||
cat $WORKINGDIR/3rd/OpenVPNAdapter/Configuration/Project.xcconfig > $WORKINGDIR/3rd/OpenVPNAdapter/Configuration/amnezia.xcconfig
|
||||
cat << EOF >> $WORKINGDIR/3rd/OpenVPNAdapter/Configuration/amnezia.xcconfig
|
||||
PROJECT_TEMP_DIR = $WORKINGDIR/3rd/OpenVPNAdapter/build/OpenVPNAdapter.build
|
||||
CONFIGURATION_BUILD_DIR = $WORKINGDIR/3rd/OpenVPNAdapter/build/Debug-iphoneos
|
||||
BUILT_PRODUCTS_DIR = $WORKINGDIR/3rd/OpenVPNAdapter/build/Debug-iphoneos
|
||||
CONFIGURATION_BUILD_DIR = $WORKINGDIR/3rd/OpenVPNAdapter/build/Release-iphoneos
|
||||
BUILT_PRODUCTS_DIR = $WORKINGDIR/3rd/OpenVPNAdapter/build/Release-iphoneos
|
||||
EOF
|
||||
}
|
||||
|
||||
prepare_to_build_ss() {
|
||||
cat $WORKINGDIR/scripts/ss_ios.xcconfig > $WORKINGDIR/3rd/ShadowSocks/ss_ios.xcconfig
|
||||
}
|
||||
|
||||
patch_ss() {
|
||||
cd 3rd/ShadowSocks
|
||||
|
||||
# $PATCH -p1 -N --dry-run --silent < ../../scripts/ss_patch.diff 2>/dev/null
|
||||
#If the patch has not been applied then the $? which is the exit status
|
||||
#for last command would have a success status code = 0
|
||||
# if [ $? -eq 0 ];
|
||||
# then
|
||||
# #apply the patch
|
||||
# $PATCH -p1 < ../../scripts/ss_patch.diff
|
||||
# fi
|
||||
|
||||
}
|
||||
|
||||
compile_ss_frameworks() {
|
||||
$XCODEBUILD -scheme ShadowSocks -configuration Release -xcconfig ss_ios.xcconfig -sdk iphoneos -destination 'generic/platform=iOS' -project ShadowSocks.xcodeproj
|
||||
|
||||
cd ../../
|
||||
}
|
||||
|
||||
prepare_to_build_pp() {
|
||||
cat $WORKINGDIR/scripts/pp_ios.xcconfig > $WORKINGDIR/3rd/PacketProcessor/pp_ios.xcconfig
|
||||
}
|
||||
|
||||
|
||||
compile_packet_processor() {
|
||||
cd 3rd/PacketProcessor
|
||||
|
||||
$XCODEBUILD -scheme PacketProcessor -configuration Release -xcconfig pp_ios.xcconfig -sdk iphoneos -destination 'generic/platform=iOS' -project PacketProcessor.xcodeproj
|
||||
|
||||
cd ../../
|
||||
}
|
||||
|
||||
compile_tun2socks() {
|
||||
gomobile bind -a -ldflags="-w -s" -bundleid org.amnezia.tun2socks -target=ios/arm64 -tags ios -o ./build/ios/Tun2Socks.xcframework github.com/Jigsaw-Code/outline-go-tun2socks/outline/apple github.com/Jigsaw-Code/outline-go-tun2socks/outline/shadowsocks
|
||||
}
|
||||
|
||||
die() {
|
||||
if [[ "$1" ]]; then
|
||||
error "$1"
|
||||
|
|
|
|||
|
|
@ -33,6 +33,9 @@ helpFunction() {
|
|||
print N "This script compiles AmneziaVPN for MacOS/iOS"
|
||||
print N ""
|
||||
|
||||
#export QT_IOS_BIN="$HOME/Qt/5.15.2/ios/bin"
|
||||
#export PATH=$QT_IOS_BIN:$PATH
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
key="$1"
|
||||
|
||||
|
|
@ -212,7 +215,28 @@ if [ "$OS" = "ios" ]; then
|
|||
compile_openvpn_adapter
|
||||
else
|
||||
print Y "No OpenVPNAdapter will be built"
|
||||
fi
|
||||
|
||||
if [ "$OS" = "ios" ]; then
|
||||
print Y "Prepare to build ShadowSocks..."
|
||||
prepare_to_build_ss
|
||||
print Y "Patching the ShadowSocks project..."
|
||||
patch_ss
|
||||
ruby ../../scripts/ss_project_patcher.rb "ShadowSocks.xcodeproj"
|
||||
print G "done."
|
||||
print Y "Building ShadowSocks Framework..."
|
||||
compile_ss_frameworks
|
||||
else
|
||||
print Y "No ShadowSocket Library will be built"
|
||||
fi
|
||||
|
||||
if [ "$OS" = "ios" ]; then
|
||||
print Y "Prepare to build Packet Processor..."
|
||||
prepare_to_build_pp
|
||||
print Y "Building PacketProcessor Framework..."
|
||||
compile_packet_processor
|
||||
else
|
||||
print Y "No Packet Processor will be built"
|
||||
fi
|
||||
|
||||
print Y "Creating the xcode project via qmake..."
|
||||
|
|
@ -231,6 +255,11 @@ print Y "Patching the xcode project..."
|
|||
ruby scripts/xcode_patcher.rb "AmneziaVPN.xcodeproj" "$SHORTVERSION" "$FULLVERSION" "$OSRUBY" "$NETWORKEXTENSION" "$ADJUST_SDK_TOKEN" || die "Failed to merge xcode with wireguard"
|
||||
print G "done."
|
||||
|
||||
if command -v "sed" &>/dev/null; then
|
||||
sed -i '' '/<key>BuildSystemType<\/key>/d' AmneziaVPN.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
|
||||
sed -i '' '/<string>Original<\/string>/d' AmneziaVPN.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
|
||||
fi
|
||||
|
||||
print Y "Opening in XCode..."
|
||||
open AmneziaVPN.xcodeproj
|
||||
print G "All done!"
|
||||
|
|
|
|||
22
client/scripts/pp_ios.xcconfig
Normal file
22
client/scripts/pp_ios.xcconfig
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
SUPPORTED_PLATFORMS = iphoneos
|
||||
TARGETED_DEVICE_FAMILY = 1,2
|
||||
|
||||
HEADER_SEARCH_PATHS = $(inherited) $(SRCROOT)/client/3rd/PacketProcessor/PacketProcessor
|
||||
//CLANG_CXX_LANGUAGE_STANDARD = gnu++14
|
||||
//CLANG_CXX_LIBRARY = libc++
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// iOS-specific settings
|
||||
//
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.3
|
||||
|
||||
SDKROOT[arch=arm64] = iphoneos
|
||||
SDKROOT[arch=armv7] = iphoneos
|
||||
SDKROOT[arch=armv7s] = iphoneos
|
||||
|
||||
VALID_ARCHS[sdk=iphoneos*] = arm64
|
||||
|
||||
PROJECT_TEMP_DIR = /Users/sanchez/work/vied/ios/vpn/desktop-client-bkp/client/3rd/PacketProcessor/build/PacketProcessor.build
|
||||
CONFIGURATION_BUILD_DIR = /Users/sanchez/work/vied/ios/vpn/desktop-client-bkp/client/3rd/PacketProcessor/build/Release-iphoneos
|
||||
BUILT_PRODUCTS_DIR = /Users/sanchez/work/vied/ios/vpn/desktop-client-bkp/client/3rd/PacketProcessor/build/Release-iphoneos
|
||||
24
client/scripts/ss_ios.xcconfig
Normal file
24
client/scripts/ss_ios.xcconfig
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
SUPPORTED_PLATFORMS = iphoneos
|
||||
TARGETED_DEVICE_FAMILY = 1,2
|
||||
|
||||
HEADER_SEARCH_PATHS = $(inherited) $(SRCROOT)/client/3rd/ShadowSocks/ShadowSocks
|
||||
//HEADER_SEARCH_PATHS = $(inherited) $(SRCROOT)/client/3rd/ShadowSocks/ShadowSocks $(SRCROOT)/client/3rd/ShadowSocks/ShadowSocks/libcares/include $(SRCROOT)/client/3rd/ShadowSocks/ShadowSocks/libev/arm64/include $(SRCROOT)/client/3rd/ShadowSocks/ShadowSocks/libsodium/include $(SRCROOT)/client/3rd/ShadowSocks/ShadowSocks/mbedtls/include $(SRCROOT)/client/3rd/ShadowSocks/ShadowSocks/pcre/arm64/include $(SRCROOT)/client/3rd/ShadowSocks/ShadowSocks/shadowsocks-libev/include
|
||||
|
||||
//CLANG_CXX_LANGUAGE_STANDARD = gnu++14
|
||||
//CLANG_CXX_LIBRARY = libc++
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// iOS-specific settings
|
||||
//
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.3
|
||||
|
||||
SDKROOT[arch=arm64] = iphoneos
|
||||
SDKROOT[arch=armv7] = iphoneos
|
||||
SDKROOT[arch=armv7s] = iphoneos
|
||||
|
||||
VALID_ARCHS[sdk=iphoneos*] = arm64
|
||||
|
||||
PROJECT_TEMP_DIR = /Users/sanchez/work/vied/ios/vpn/desktop-client-bkp/client/3rd/ShadowSocks/build/ShadowSocks.build
|
||||
CONFIGURATION_BUILD_DIR = /Users/sanchez/work/vied/ios/vpn/desktop-client-bkp/client/3rd/ShadowSocks/build/Release-iphoneos
|
||||
BUILT_PRODUCTS_DIR = /Users/sanchez/work/vied/ios/vpn/desktop-client-bkp/client/3rd/ShadowSocks/build/Release-iphoneos
|
||||
87
client/scripts/ss_patch.diff
Normal file
87
client/scripts/ss_patch.diff
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
diff --git a/ShadowPath/Privoxy/pcre/pcreposix.c b/ShadowPath/Privoxy/pcre/pcreposix.c
|
||||
--- a/ShadowPath/Privoxy/pcre/pcreposix.c
|
||||
+++ b/ShadowPath/Privoxy/pcre/pcreposix.c
|
||||
@@ -146,13 +146,13 @@ message = (errcode >= (int)(sizeof(pstring)/sizeof(char *)))?
|
||||
length = strlen(message) + 1;
|
||||
|
||||
addmessage = " at offset ";
|
||||
-addlength = (preg != NULL && (int)preg->re_erroffset != -1)?
|
||||
+addlength = (preg != NULL && (int)preg->re_nsub != -1)?
|
||||
strlen(addmessage) + 6 : 0;
|
||||
|
||||
if (errbuf_size > 0)
|
||||
{
|
||||
if (addlength > 0 && errbuf_size >= length + addlength)
|
||||
- sprintf(errbuf, "%s%s%-6d", message, addmessage, (int)preg->re_erroffset);
|
||||
+ sprintf(errbuf, "%s%s%-6d", message, addmessage, (int)preg->re_nsub);
|
||||
else
|
||||
{
|
||||
strncpy(errbuf, message, errbuf_size - 1);
|
||||
@@ -173,7 +173,7 @@ return length + addlength;
|
||||
void
|
||||
pcre_regfree(regex_t *preg)
|
||||
{
|
||||
-(pcre_free)(preg->re_pcre);
|
||||
+(pcre_free)(preg->re_g);
|
||||
}
|
||||
|
||||
|
||||
@@ -203,12 +203,12 @@ int options = 0;
|
||||
if ((cflags & REG_ICASE) != 0) options |= PCRE_CASELESS;
|
||||
if ((cflags & REG_NEWLINE) != 0) options |= PCRE_MULTILINE;
|
||||
|
||||
-preg->re_pcre = pcre_compile(pattern, options, &errorptr, &erroffset, NULL);
|
||||
-preg->re_erroffset = erroffset;
|
||||
+preg->re_g = pcre_compile(pattern, options, &errorptr, &erroffset, NULL);
|
||||
+preg->re_nsub = erroffset;
|
||||
|
||||
-if (preg->re_pcre == NULL) return pcre_posix_error_code(errorptr);
|
||||
+if (preg->re_g == NULL) return pcre_posix_error_code(errorptr);
|
||||
|
||||
-preg->re_nsub = pcre_info(preg->re_pcre, NULL, NULL);
|
||||
+preg->re_nsub = pcre_info(preg->re_g, NULL, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ int *ovector = NULL;
|
||||
if ((eflags & REG_NOTBOL) != 0) options |= PCRE_NOTBOL;
|
||||
if ((eflags & REG_NOTEOL) != 0) options |= PCRE_NOTEOL;
|
||||
|
||||
-preg->re_erroffset = (size_t)(-1); /* Only has meaning after compile */
|
||||
+preg->re_nsub = (size_t)(-1); /* Only has meaning after compile */
|
||||
|
||||
if (nmatch > 0)
|
||||
{
|
||||
@@ -243,7 +243,7 @@ if (nmatch > 0)
|
||||
if (ovector == NULL) return REG_ESPACE;
|
||||
}
|
||||
|
||||
-rc = pcre_exec(preg->re_pcre, NULL, string, (int)strlen(string), 0, options,
|
||||
+rc = pcre_exec(preg->re_g, NULL, string, (int)strlen(string), 0, options,
|
||||
ovector, nmatch * 3);
|
||||
|
||||
if (rc == 0) rc = nmatch; /* All captured slots were filled in */
|
||||
diff --git a/ShadowPath/shadowsocks-libev/src/http.h b/ShadowPath/shadowsocks-libev/src/http.h
|
||||
index 914815a..e312dd3 100644
|
||||
--- a/ShadowPath/shadowsocks-libev/src/http.h
|
||||
+++ b/ShadowPath/shadowsocks-libev/src/http.h
|
||||
@@ -29,6 +29,6 @@
|
||||
#include <stdio.h>
|
||||
#include "protocol.h"
|
||||
|
||||
-const protocol_t *const http_protocol;
|
||||
+extern const protocol_t *const http_protocol;
|
||||
|
||||
#endif
|
||||
diff --git a/ShadowPath/shadowsocks-libev/src/tls.h b/ShadowPath/shadowsocks-libev/src/tls.h
|
||||
index 3998913..ddbee11 100644
|
||||
--- a/ShadowPath/shadowsocks-libev/src/tls.h
|
||||
+++ b/ShadowPath/shadowsocks-libev/src/tls.h
|
||||
@@ -28,6 +28,6 @@
|
||||
|
||||
#include "protocol.h"
|
||||
|
||||
-const protocol_t *const tls_protocol;
|
||||
+extern const protocol_t *const tls_protocol;
|
||||
|
||||
#endif
|
||||
55
client/scripts/ss_project_patcher.rb
Normal file
55
client/scripts/ss_project_patcher.rb
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
#!/usr/bin/ruby
|
||||
|
||||
require 'xcodeproj'
|
||||
|
||||
class SSPatcher
|
||||
attr :project
|
||||
attr :target_main
|
||||
|
||||
def run(file)
|
||||
open_project file
|
||||
open_target_main
|
||||
|
||||
patch_main_target
|
||||
|
||||
@project.save
|
||||
end
|
||||
|
||||
def open_project(file)
|
||||
@project = Xcodeproj::Project.open(file)
|
||||
die 'Failed to open the project file: ' + file if @project.nil?
|
||||
end
|
||||
|
||||
def open_target_main
|
||||
@target_main = @project.native_targets
|
||||
.select { |target| target.name == 'ShadowSocks' }
|
||||
.first
|
||||
return @target_main if not @target_main.nil?
|
||||
|
||||
die 'Unable to open ShadowSocks target'
|
||||
end
|
||||
|
||||
def patch_main_target
|
||||
@target_main.resources_build_phase.files.each do |f|
|
||||
puts f.display_name
|
||||
if f.display_name === "LICENSE"
|
||||
f.remove_from_project
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def die(msg)
|
||||
print $msg
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
|
||||
if ARGV.length < 1
|
||||
puts "Usage: <script> project_file"
|
||||
exit 1
|
||||
end
|
||||
|
||||
|
||||
r = SSPatcher.new
|
||||
r.run ARGV[0]
|
||||
exit 0
|
||||
|
|
@ -357,17 +357,27 @@ class XCodeprojPatcher
|
|||
framework_ref = frameworks_group.new_file('NetworkExtension.framework')
|
||||
frameworks_build_phase.add_file_reference(framework_ref)
|
||||
|
||||
framework_ref = frameworks_group.new_file('3rd/OpenVPNAdapter/build/Debug-iphoneos/LZ4.framework')
|
||||
framework_ref = frameworks_group.new_file('3rd/OpenVPNAdapter/build/Release-iphoneos/LZ4.framework')
|
||||
frameworks_build_phase.add_file_reference(framework_ref)
|
||||
|
||||
framework_ref = frameworks_group.new_file('3rd/OpenVPNAdapter/build/Debug-iphoneos/mbedTLS.framework')
|
||||
framework_ref = frameworks_group.new_file('3rd/OpenVPNAdapter/build/Release-iphoneos/mbedTLS.framework')
|
||||
frameworks_build_phase.add_file_reference(framework_ref)
|
||||
|
||||
framework_ref = frameworks_group.new_file('3rd/OpenVPNAdapter/build/Debug-iphoneos/OpenVPNClient.framework')
|
||||
framework_ref = frameworks_group.new_file('3rd/OpenVPNAdapter/build/Release-iphoneos/OpenVPNClient.framework')
|
||||
frameworks_build_phase.add_file_reference(framework_ref)
|
||||
|
||||
framework_ref = frameworks_group.new_file('3rd/OpenVPNAdapter/build/Debug-iphoneos/OpenVPNAdapter.framework')
|
||||
framework_ref = frameworks_group.new_file('3rd/OpenVPNAdapter/build/Release-iphoneos/OpenVPNAdapter.framework')
|
||||
frameworks_build_phase.add_file_reference(framework_ref)
|
||||
|
||||
framework_ref = frameworks_group.new_file('3rd/ShadowSocks/build/Release-iphoneos/ShadowSocks.framework')
|
||||
frameworks_build_phase.add_file_reference(framework_ref)
|
||||
|
||||
# framework_ref = frameworks_group.new_file('3rd/PacketProcessor/build/Release-iphoneos/PacketProcessor.framework')
|
||||
# frameworks_build_phase.add_file_reference(framework_ref)
|
||||
|
||||
framework_ref = frameworks_group.new_file('3rd/outline-go-tun2socks/build/ios/Tun2Socks.xcframework')
|
||||
frameworks_build_phase.add_file_reference(framework_ref)
|
||||
|
||||
|
||||
# This fails: @target_main.add_dependency @target_extension
|
||||
container_proxy = @project.new(Xcodeproj::Project::PBXContainerItemProxy)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue