Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
arror committed Dec 28, 2022
1 parent 559d666 commit 866c66f
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 122 deletions.
51 changes: 3 additions & 48 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,65 +20,20 @@ jobs:
- name: Setup enviornment
run: |
rustup target install aarch64-apple-ios
rustup target install aarch64-apple-ios-sim
rustup target install x86_64-apple-ios
rustup target install aarch64-apple-darwin
rustup target install x86_64-apple-darwin
cargo install cargo-lipo
- uses: actions/checkout@v3
with:
submodules: 'true'

- name: Build xcframework
- name: Make lib
run: |
cd tun2socks
make xcframework
cd target
zip -r Tun2SocksFramework.xcframework.zip Tun2SocksFramework.xcframework
- name: Detect checksum
run: |
export TEMP=`shasum -a 256 tun2socks/target/Tun2SocksFramework.xcframework.zip`
export CHECKSUM=${TEMP:0:64}
echo "FILE_CHECKSUM=${CHECKSUM}" >> $GITHUB_ENV
unset CHECKSUM
unset TEMP
- name: Update package file
run: |
echo "// swift-tools-version:5.5" > Package.swift
echo "" >> Package.swift
echo "import PackageDescription" >> Package.swift
echo "" >> Package.swift
echo "let package = Package(" >> Package.swift
echo " name: \"T2SKit\"," >> Package.swift
echo " products: [" >> Package.swift
echo " .library(name: \"T2SKit\", targets: [\"T2SKit\"])" >> Package.swift
echo " ]," >> Package.swift
echo " targets: [" >> Package.swift
echo " .target(name: \"T2SKit\", dependencies: [\"T2SKitC\", \"Tun2SocksFramework\"])," >> Package.swift
echo " .target(name: \"T2SKitC\", publicHeadersPath: \".\")," >> Package.swift
echo " .binaryTarget(" >> Package.swift
echo " name: \"Tun2SocksFramework\"," >> Package.swift
echo " url: \"https://github.com/AppleClash/T2SKit/releases/download/${{ github.event.inputs.version }}/Tun2SocksFramework.xcframework.zip\"," >> Package.swift
echo " checksum: \"${{ env.FILE_CHECKSUM }}\"" >> Package.swift
echo " )" >> Package.swift
echo " ]" >> Package.swift
echo ")" >> Package.swift
- name: Commit
run: |
git config --local user.email "[email protected]"
git config --local user.name "github-actions"
git config remote.origin.url "https://${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/AppleClash/T2SKit.git"
git add ./Package.swift
git commit -m "Release ${{ github.event.inputs.version }}!!!" -a
git push origin main
cargo lipo --release --package tun2socks --targets "aarch64-apple-ios"
- name: Upload Release
uses: softprops/action-gh-release@v1
with:
draft: false
tag_name: ${{ github.event.inputs.version }}
files: tun2socks/target/Tun2SocksFramework.xcframework.zip
files: target/universal/release/libtun2socks.a
7 changes: 7 additions & 0 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
import PackageDescription

let package = Package(
name: "T2SKit",
name: "Tun2Socks",
products: [
.library(name: "T2SKit", targets: ["T2SKit"])
.library(name: "Tun2Socks", targets: ["Tun2Socks"])
],
targets: [
.target(name: "T2SKit", dependencies: ["T2SKitC", "Tun2SocksFramework"]),
.target(name: "T2SKitC", publicHeadersPath: "."),
.target(name: "Tun2Socks", dependencies: ["Tun2SocksFramework"]),
.binaryTarget(
name: "Tun2SocksFramework",
url: "https://github.com/AppleClash/T2SKit/releases/download/1.3.0/Tun2SocksFramework.xcframework.zip",
Expand Down
54 changes: 0 additions & 54 deletions Sources/T2SKitC/T2SKitC.h

This file was deleted.

1 change: 0 additions & 1 deletion Sources/T2SKitC/dummy.c

This file was deleted.

4 changes: 0 additions & 4 deletions Sources/T2SKitC/module.modulemap

This file was deleted.

17 changes: 7 additions & 10 deletions Sources/T2SKit/T2SKit.swift → Sources/Tun2Socks/Tun2Socks.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import Foundation
import T2SKitC

public enum Tun2Socks {
@_silgen_name("run") private func rust_run(_ config: UnsafePointer<CChar>!)

@frozen public enum Tun2Socks {

public static func start(fd: Int32, host: String, port: Int) {
public static func run(tunFd: Int32, port: Int) {
let config: String = """
{
"log": {
Expand All @@ -13,7 +14,7 @@ public enum Tun2Socks {
{
"protocol": "tun",
"settings": {
"fd": \(fd)
"fd": \(tunFd)
},
"tag": "tun"
}
Expand All @@ -22,18 +23,14 @@ public enum Tun2Socks {
{
"protocol": "socks",
"settings": {
"address": "\(host)",
"address": "127.0.0.1",
"port": \(port)
},
"tag": "clash"
}
]
}
"""
start_tun2socks(config.cString(using: .utf8))
}

public static func stop() {
stop_tun2socks()
rust_run(config.cString(using: .utf8))
}
}
2 changes: 1 addition & 1 deletion tun2socks

0 comments on commit 866c66f

Please sign in to comment.