diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index fd6e094fb4..917fc8e934 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,6 +1,6 @@ * @Jigsaw-Code/outline-dev -/outline/tun2socks/ @Jigsaw-Code/outline-networking-owners +/src/tun2socks/ @Jigsaw-Code/outline-networking-owners /src/cordova/plugin/ @Jigsaw-Code/outline-networking-owners /third_party/ @Jigsaw-Code/outline-networking-owners /tools/ @Jigsaw-Code/outline-networking-owners diff --git a/go.mod b/go.mod index 1211132812..346e0e5171 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.18 require ( github.com/Jigsaw-Code/outline-sdk v0.0.7 github.com/Jigsaw-Code/outline-sdk/x v0.0.0-20230807220427-893de7fdc6b8 - github.com/crazy-max/xgo v0.26.0 + github.com/crazy-max/xgo v0.30.0 github.com/eycorsican/go-tun2socks v1.16.11 github.com/stretchr/testify v1.8.4 golang.org/x/mobile v0.0.0-20230906132913-2077a3224571 diff --git a/go.sum b/go.sum index dbdcd2955c..cc030c21a2 100644 --- a/go.sum +++ b/go.sum @@ -4,6 +4,8 @@ github.com/Jigsaw-Code/outline-sdk/x v0.0.0-20230807220427-893de7fdc6b8 h1:BxOHm github.com/Jigsaw-Code/outline-sdk/x v0.0.0-20230807220427-893de7fdc6b8/go.mod h1:tBqJXpVm+kym+EAUdwNodcFxy872FfjVErfj8Br+gs0= github.com/crazy-max/xgo v0.26.0 h1:vK4OfeXJoDGvnjlzdTCgPbeWLKENbzj84DTpU/VRonM= github.com/crazy-max/xgo v0.26.0/go.mod h1:m/aqfKaN/cYzfw+Pzk7Mk0tkmShg3/rCS4Zdhdugi4o= +github.com/crazy-max/xgo v0.30.0 h1:2uunjwLBrVu5LKIS1dIDXz9U5OIX4H5LEsC3P6wFTto= +github.com/crazy-max/xgo v0.30.0/go.mod h1:m/aqfKaN/cYzfw+Pzk7Mk0tkmShg3/rCS4Zdhdugi4o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/eycorsican/go-tun2socks v1.16.11 h1:+hJDNgisrYaGEqoSxhdikMgMJ4Ilfwm/IZDrWRrbaH8= diff --git a/src/build/spawn_stream.mjs b/src/build/spawn_stream.mjs index 199583daf0..14b8ef3957 100644 --- a/src/build/spawn_stream.mjs +++ b/src/build/spawn_stream.mjs @@ -23,7 +23,7 @@ export const spawnStream = (command, ...parameters) => const stdout = []; const stderr = []; - console.debug(`Running [${[command, ...parameters.map(e => `'${e}'`)].join(' ')}]`); + console.debug(chalk.gray(`Running [${[command, ...parameters.map(e => `'${e}'`)].join(' ')}]...`)); const childProcess = spawn(command, parameters, {env: process.env}); const forEachMessageLine = (buffer, callback) => { diff --git a/src/tun2socks/build.action.mjs b/src/tun2socks/build.action.mjs index cca822ade2..b6471de844 100644 --- a/src/tun2socks/build.action.mjs +++ b/src/tun2socks/build.action.mjs @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import url from 'url'; import fs from 'node:fs/promises'; import {spawnStream} from '../build/spawn_stream.mjs'; @@ -19,14 +20,14 @@ import {getBuildParameters} from '../build/get_build_parameters.mjs'; import {getRootDir} from '../build/get_root_dir.mjs'; /** - * @description TODO: Add description + * @description Builds the tun2socks library for the specified platform. * * @param {string[]} parameters */ export async function main(...parameters) { const {platform} = getBuildParameters(parameters); - const outputDir = `${getRootDir()}/build/${platform}/tun2socks`; + const outputDir = `${getRootDir()}/build/${platform}`; await fs.mkdir(outputDir, {recursive: true}); @@ -34,37 +35,25 @@ export async function main(...parameters) { case 'android': return spawnStream( 'gomobile', - '-a', + 'bind', '-androidapi=33', - '-ldflags=-w', - '-tags=android', '-target=android', - '-work', - `-o=${outputDir}`, + `-o=${outputDir}/tun2socks.aar`, 'github.com/Jigsaw-Code/outline-client/src/tun2socks/outline/tun2socks', 'github.com/Jigsaw-Code/outline-client/src/tun2socks/outline/shadowsocks' ); case 'ios': - return spawnStream( - 'gomobile', - '-bundleid=org.outline.tun2socks', - '-iosversion=13.1', - "-ldflags='-s -w'", - '-target=ios,iossimulator', - `-o=${outputDir}`, - 'github.com/Jigsaw-Code/outline-client/src/tun2socks/outline/tun2socks', - 'github.com/Jigsaw-Code/outline-client/src/tun2socks/outline/shadowsocks' - ); case 'macos': + case 'maccatalyst': process.env.MACOSX_DEPLOYMENT_TARGET = '10.14'; return spawnStream( 'gomobile', + 'bind', '-bundleid=org.outline.tun2socks', '-iosversion=13.1', - "-ldflags='-s -w'", - '-target=macos,maccatalyst', - `-o=${outputDir}`, + `-target=${platform}`, + `-o=${outputDir}/tun2socks.xcframework`, 'github.com/Jigsaw-Code/outline-client/src/tun2socks/outline/tun2socks', 'github.com/Jigsaw-Code/outline-client/src/tun2socks/outline/shadowsocks' ); @@ -72,19 +61,21 @@ export async function main(...parameters) { return spawnStream( 'xgo', '-targets=windows/386', - "-ldflags='-s -w -X main.version=v1.16.11'", - `-dest=${outputDir}`, + `-dest=${outputDir}/tun2socks.exe`, '-pkg=outline/electron', - `${getRootDir()}/src/tun2socks` + 'github.com/Jigsaw-Code/outline-client/src/tun2socks' ); case 'linux': return spawnStream( 'xgo', '-targets=linux/amd64', - "-ldflags='-s -w -X main.version=v1.16.11'", - `-dest=${outputDir}`, + `-dest=${outputDir}/tun2socks`, '-pkg=outline/electron', - `${getRootDir()}/src/tun2socks` + 'github.com/Jigsaw-Code/outline-client/src/tun2socks' ); } } + +if (import.meta.url === url.pathToFileURL(process.argv[1]).href) { + await main(...process.argv.slice(2)); +}