Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DO NOT SUBMIT build(client): use Taskfile for tun2socks #1966

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
* @Jigsaw-Code/outline-dev

/src/tun2socks/ @Jigsaw-Code/outline-networking-owners
/client/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
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build_and_test_debug_client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ jobs:
go-version-file: '${{ github.workspace }}/go.mod'

- name: Build Tun2Socks (required for Test OutlineAppleLib)
run: npm run action client/src/tun2socks/build macos
run: npm run action client/tun2socks/build macos

- name: Test OutlineAppleLib
run: npm run action client/src/cordova/test macos
Expand Down Expand Up @@ -174,7 +174,7 @@ jobs:
go-version-file: '${{ github.workspace }}/go.mod'

- name: Build Tun2Socks (required for Test OutlineAppleLib)
run: npm run action client/src/tun2socks/build ios
run: npm run action client/tun2socks/build ios

- name: Test OutlineAppleLib
run: npm run action client/src/cordova/test ios
Expand Down Expand Up @@ -216,7 +216,7 @@ jobs:
go-version-file: '${{ github.workspace }}/go.mod'

- name: Build Tun2Socks (required for Test OutlineAppleLib)
run: npm run action client/src/tun2socks/build maccatalyst
run: npm run action client/tun2socks/build maccatalyst

- name: Test OutlineAppleLib
run: npm run action client/src/cordova/test maccatalyst
Expand Down
1 change: 1 addition & 0 deletions .task/checksum/tun2socks-gomobile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e949b9acfa60744d6d3013f9843b384d
69 changes: 0 additions & 69 deletions Makefile

This file was deleted.

4 changes: 4 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version: '3'

includes:
tun2socks: ./client/tun2socks/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dependencies {
// To make this project editable directly in the source tree, we need to load
// tun2socks.aar from its original path in the third_party directory. We do
// this by relative path:
compileOnly fileTree(dir: '../../../../../output/build/android',
compileOnly fileTree(dir: '../../../../../../output/client/tun2socks/android',
include: ['tun2socks.aar'])
// Note: A flatDir repository might be preferable, but this is not compatible
// with a composite build (https://github.com/gradle/gradle/issues/911).
Expand Down
2 changes: 1 addition & 1 deletion client/src/cordova/apple/OutlineAppleLib/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ let package = Package(
),
.binaryTarget(
name: "Tun2socks",
path: "../../../../output/build/apple/Tun2socks.xcframework"
path: "../../../../../output/client/tun2socks/apple/Tun2socks.xcframework"
),
.testTarget(
name: "OutlineTunnelTest",
Expand Down
2 changes: 1 addition & 1 deletion client/src/cordova/build.action.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export async function main(...parameters) {
const {platform, buildMode, verbose} = getBuildParameters(parameters);

await runAction('client/src/www/build', ...parameters);
await runAction('client/src/tun2socks/build', ...parameters);
await runAction('client/tun2socks/build', ...parameters);
await runAction('client/src/cordova/setup', ...parameters);

if (verbose) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
const fs = require('fs/promises');
// const child_process = require('child_process');
const path = require('node:path');
import {getRootDir} from '../../../../../../src/build/get_root_dir.mjs';

const ANDROID_LIBS_FOLDER_PATH = path.join('plugins', 'cordova-plugin-outline', 'android', 'libs');
const TUN2SOCKS_ANDROID_FOLDER_PATH = path.join('output', 'build', 'android');
const TUN2SOCKS_ANDROID_FOLDER_PATH = path.join(getRootDir(), 'output', 'client', 'tun2socks', 'android');

module.exports = async function () {
console.log('Copying Android third party libraries...');
Expand Down
2 changes: 1 addition & 1 deletion client/src/cordova/setup.action.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export async function main(...parameters) {
const {platform, buildMode, verbose, buildNumber, versionName} = getBuildParameters(parameters);

await runAction('client/src/www/build', ...parameters);
await runAction('client/src/tun2socks/build', ...parameters);
await runAction('client/tun2socks/build', ...parameters);

await rmfr(path.resolve(getRootDir(), 'platforms'));
await rmfr(path.resolve(getRootDir(), 'plugins'));
Expand Down
1 change: 1 addition & 0 deletions client/tun2socks/.task/checksum/gomobile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e949b9acfa60744d6d3013f9843b384d
88 changes: 88 additions & 0 deletions client/tun2socks/Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
version: '3'

run: when_changed

vars:
# This needs to be updated if the file moves.
REPO_ROOT:
sh: "readlink -f {{.TASKFILE_DIR}}/../.."
OUT_DIR: "{{.REPO_ROOT}}/output/client/tun2socks"
BIN_DIR: "{{.OUT_DIR}}/build"
VERSION: "v1.16.11"
# -w disable DWARF generation
LD_FLAGS: "-static -w -X main.version={{.VERSION}}"
ELECTRON_MAIN_PKG: "{{.TASKFILE_DIR}}/outline/electron"
MOBILE_PKG: "{{.TASKFILE_DIR}}/outline/tun2socks"
GOMOBILE_BIND_CMD: "env PATH=\"{{.BIN_DIR}}:${PATH}\" '{{.BIN_DIR}}/gomobile' bind -ldflags '-w'"

tasks:
windows:
desc: "Build tun2socks binary for Windows"
vars:
TARGET_DIR: "{{.OUT_DIR}}/windows"
cmds:
- rm -rf "{{.TARGET_DIR}}" && mkdir -p "{{.TARGET_DIR}}"
- GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC='zig cc -target x86_64-windows' go build -trimpath -ldflags=--extldflags='{{.LD_FLAGS}}' -o '{{.TARGET_DIR}}/tun2socks.exe' '{{.ELECTRON_MAIN_PKG}}'

linux:
desc: "Build the tun2socks binary for Linux"
vars:
TARGET_DIR: '{{.OUT_DIR}}/linux'
cmds:
- rm -rf "{{.TARGET_DIR}}" && mkdir -p "{{.TARGET_DIR}}"
- GOOS=linux GOARCH=amd64 CGO_ENABLED=1 CC='zig cc -target x86_64-linux' go build -trimpath -ldflags=--extldflags='{{.LD_FLAGS}}' -o '{{.TARGET_DIR}}/tun2socks' '{{.ELECTRON_MAIN_PKG}}'

android:
desc: "Build the tun2socks.aar library for Android"
vars:
TARGET_DIR: "{{.OUT_DIR}}/android"
cmds:
- rm -rf "{{.TARGET_DIR}}" && mkdir -p "{{.TARGET_DIR}}"
# -androidapi should match the minSdkVersion that the Android client supports.
- "{{.GOMOBILE_BIND_CMD}} -target=android -androidapi 22 -o '{{.TARGET_DIR}}/tun2socks.aar' '{{.TASKFILE_DIR}}/outline/tun2socks' '{{.TASKFILE_DIR}}/outline/shadowsocks'"
deps: ["gomobile"]

ios:
desc: "Build the Tun2socks.xcframework library for iOS"
vars:
TARGET_DIR: '{{.OUT_DIR}}/ios'
cmds:
- rm -rf "{{.TARGET_DIR}}" && mkdir -p "{{.TARGET_DIR}}"
# -iosversion should match the target version that the iOS client supports.
- "{{.GOMOBILE_BIND_CMD}} -target=ios,iossimulator -iosversion=12.0 -bundleid org.outline.tun2socks -o '{{.TARGET_DIR}}/Tun2socks.xcframework' '{{.TASKFILE_DIR}}/outline/tun2socks' '{{.TASKFILE_DIR}}/outline/shadowsocks'"
deps: ["gomobile"]

macos:
desc: "Build the Tun2socks.xcframework library for macOS"
vars:
TARGET_DIR: '{{.OUT_DIR}}/macos'
cmds:
- rm -rf "{{.TARGET_DIR}}" && mkdir -p "{{.TARGET_DIR}}"
# MACOSX_DEPLOYMENT_TARGET and -iosversion should match the versions that the macOS client supports.
- export MACOSX_DEPLOYMENT_TARGET=10.14; {{.GOMOBILE_BIND_CMD}} -target=macos,maccatalyst -iosversion=13.1 -bundleid org.outline.tun2socks -o '{{.TARGET_DIR}}/Tun2socks.xcframework' '{{.TASKFILE_DIR}}/outline/tun2socks' '{{.TASKFILE_DIR}}/outline/shadowsocks'
deps: ["gomobile"]

apple:
desc: "Build combined Tun2socks.xcframework library for Apple platforms"
vars:
TARGET_DIR: '{{.OUT_DIR}}/apple'
cmds:
- rm -rf "{{.TARGET_DIR}}" && mkdir -p "{{.TARGET_DIR}}"
- |
find '{{.OUT_DIR}}/macos/Tun2socks.xcframework' '{{.OUT_DIR}}/ios/Tun2socks.xcframework' -name "Tun2socks.framework" -type d |
xargs -I {} echo " -framework {} " |
xargs xcrun xcodebuild -create-xcframework -output '{{.TARGET_DIR}}/Tun2socks.xcframework'
deps: ["ios", "macos"]

gomobile:
desc: "Build Go Mobile"
cmds:
- mkdir -p "{{.BIN_DIR}}"
- go build -o "{{.BIN_DIR}}" golang.org/x/mobile/cmd/gomobile golang.org/x/mobile/cmd/gobind
sources: ["{{.REPO_ROOT}}/go.sum"]
generates: ["{{.BIN_DIR}}/gomobile", "{{.BIN_DIR}}/gobind"]

clean:
cmds:
- rm -r "{{.REPO_ROOT}}/output/client/tun2socks" .task
- go clean -i -r '{{.TASKFILE_DIR}}/outline/tun2socks' '{{.TASKFILE_DIR}}/outline/shadowsocks'
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

import url from 'url';
import os from 'os';
import {spawnStream} from '../../../src/build/spawn_stream.mjs';
import {getBuildParameters} from '../build/get_build_parameters.mjs';
import {spawnStream} from '../../src/build/spawn_stream.mjs';
import {getBuildParameters} from '../src/build/get_build_parameters.mjs';

/**
* @description Builds the tun2socks library for the specified platform.
Expand All @@ -37,11 +37,12 @@ export async function main(...parameters) {
'build',
'-o',
`output/build/${targetPlatform}/tun2socks${targetPlatform === 'windows' ? '.exe' : ''}`,
'github.com/Jigsaw-Code/outline-apps/client/src/tun2socks/outline/electron'
'github.com/Jigsaw-Code/outline-apps/client/tun2socks/outline/electron'
);
}

await spawnStream('make', ['ios', 'macos', 'maccatalyst'].includes(targetPlatform) ? 'apple' : targetPlatform);
const taskName = ['ios', 'macos', 'maccatalyst'].includes(targetPlatform) ? 'apple' : targetPlatform
await spawnStream('go', 'run', 'github.com/go-task/task/v3/cmd/task', '-v', `tun2socks:${taskName}`);
}

if (import.meta.url === url.pathToFileURL(process.argv[1]).href) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"net/http"
"time"

"github.com/Jigsaw-Code/outline-apps/client/src/tun2socks/outline"
"github.com/Jigsaw-Code/outline-apps/client/src/tun2socks/outline/neterrors"
"github.com/Jigsaw-Code/outline-apps/client/tun2socks/outline"
"github.com/Jigsaw-Code/outline-apps/client/tun2socks/outline/neterrors"
"github.com/Jigsaw-Code/outline-sdk/transport"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import (
"syscall"
"time"

"github.com/Jigsaw-Code/outline-apps/client/src/tun2socks/outline/internal/utf8"
"github.com/Jigsaw-Code/outline-apps/client/src/tun2socks/outline/neterrors"
"github.com/Jigsaw-Code/outline-apps/client/src/tun2socks/outline/shadowsocks"
"github.com/Jigsaw-Code/outline-apps/client/src/tun2socks/outline/tun2socks"
"github.com/Jigsaw-Code/outline-apps/client/tun2socks/outline/internal/utf8"
"github.com/Jigsaw-Code/outline-apps/client/tun2socks/outline/neterrors"
"github.com/Jigsaw-Code/outline-apps/client/tun2socks/outline/shadowsocks"
"github.com/Jigsaw-Code/outline-apps/client/tun2socks/outline/tun2socks"
"github.com/eycorsican/go-tun2socks/common/log"
_ "github.com/eycorsican/go-tun2socks/common/log/simple" // Register a simple logger.
"github.com/eycorsican/go-tun2socks/core"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import (
"strconv"
"time"

"github.com/Jigsaw-Code/outline-apps/client/src/tun2socks/outline"
"github.com/Jigsaw-Code/outline-apps/client/src/tun2socks/outline/connectivity"
"github.com/Jigsaw-Code/outline-apps/client/src/tun2socks/outline/internal/utf8"
"github.com/Jigsaw-Code/outline-apps/client/tun2socks/outline"
"github.com/Jigsaw-Code/outline-apps/client/tun2socks/outline/connectivity"
"github.com/Jigsaw-Code/outline-apps/client/tun2socks/outline/internal/utf8"
"github.com/Jigsaw-Code/outline-sdk/transport"
"github.com/Jigsaw-Code/outline-sdk/transport/shadowsocks"
"github.com/eycorsican/go-tun2socks/common/log"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (

"github.com/Jigsaw-Code/outline-sdk/transport"

"github.com/Jigsaw-Code/outline-apps/client/src/tun2socks/outline/connectivity"
"github.com/Jigsaw-Code/outline-apps/client/src/tun2socks/tunnel"
"github.com/Jigsaw-Code/outline-apps/client/tun2socks/outline/connectivity"
"github.com/Jigsaw-Code/outline-apps/client/tun2socks/tunnel"
)

// Tunnel represents a tunnel from a TUN device to a server.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ package tun2socks
import (
"runtime/debug"

"github.com/Jigsaw-Code/outline-apps/client/src/tun2socks/outline/shadowsocks"
"github.com/Jigsaw-Code/outline-apps/client/src/tun2socks/tunnel"
"github.com/Jigsaw-Code/outline-apps/client/tun2socks/outline/shadowsocks"
"github.com/Jigsaw-Code/outline-apps/client/tun2socks/tunnel"
"github.com/eycorsican/go-tun2socks/common/log"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"runtime/debug"
"time"

"github.com/Jigsaw-Code/outline-apps/client/src/tun2socks/outline/shadowsocks"
"github.com/Jigsaw-Code/outline-apps/client/tun2socks/outline/shadowsocks"
)

// TunWriter is an interface that allows for outputting packets to the TUN (VPN).
Expand Down
File renamed without changes.
31 changes: 23 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,26 +1,41 @@
module github.com/Jigsaw-Code/outline-apps

go 1.20
go 1.21

require (
github.com/Jigsaw-Code/outline-sdk v0.0.14-0.20240216220040-f741c57bf854
github.com/Jigsaw-Code/outline-sdk/x v0.0.0-20240223000159-142376ee10ea
github.com/crazy-max/xgo v0.30.0
github.com/eycorsican/go-tun2socks v1.16.11
github.com/stretchr/testify v1.8.2
github.com/go-task/task/v3 v3.36.0
github.com/stretchr/testify v1.9.0
golang.org/x/mobile v0.0.0-20231127183840-76ac6878050a
golang.org/x/sys v0.15.0
golang.org/x/sys v0.19.0
)

require (
github.com/Masterminds/semver/v3 v3.2.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/joho/godotenv v1.5.1 // indirect
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-zglob v0.0.4 // indirect
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/radovskyb/watcher v1.0.7 // indirect
github.com/sajari/fuzzy v1.0.0 // indirect
github.com/shadowsocks/go-shadowsocks2 v0.1.5 // indirect
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8 // indirect
golang.org/x/crypto v0.17.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/zeebo/xxh3 v1.0.2 // indirect
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/tools v0.16.0 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/term v0.19.0 // indirect
golang.org/x/tools v0.17.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
mvdan.cc/sh/v3 v3.8.0 // indirect
)
Loading
Loading