mirror of
https://github.com/MetaCubeX/ClashMetaForAndroid.git
synced 2024-11-16 08:22:17 +08:00
Chore: update tun2socket
This commit is contained in:
parent
12220789a3
commit
271d56c01c
|
@ -39,8 +39,8 @@ abstract class ClashBuildTask : DefaultTask() {
|
|||
config.abis.forEach {
|
||||
Command.ofGoRun(
|
||||
"make/make.go",
|
||||
listOf("bridge", "native", "build", "android", it.goArch),
|
||||
input.resolve("tun2socket/bridge"),
|
||||
listOf("tun2socket", ".", "android", it.goArch),
|
||||
input.resolve("tun2socket"),
|
||||
environment.ofLwipBuild(it)
|
||||
).exec()
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import golangSource
|
|||
|
||||
abstract class ClashCleanTask : Delete() {
|
||||
fun applyFrom(project: Project, abis: List<NativeAbi>) {
|
||||
val bridge = project.golangSource.resolve("tun2socket/bridge")
|
||||
val bridge = project.golangSource.resolve("tun2socket")
|
||||
|
||||
delete(bridge.resolve("build"))
|
||||
|
||||
|
|
|
@ -34,11 +34,25 @@ class Environment(
|
|||
}
|
||||
|
||||
fun ofLwipBuild(abi: NativeAbi): Map<String, String> {
|
||||
val host = when {
|
||||
Os.isFamily(Os.FAMILY_WINDOWS) ->
|
||||
"windows"
|
||||
Os.isFamily(Os.FAMILY_MAC) ->
|
||||
"darwin"
|
||||
Os.isFamily(Os.FAMILY_UNIX) ->
|
||||
"linux"
|
||||
else ->
|
||||
throw GradleException("Unsupported host: ${System.getProperty("os.name")}")
|
||||
}
|
||||
|
||||
val compiler = ndkDirectory.resolve("toolchains/llvm/prebuilt/$host-x86_64/bin")
|
||||
.resolve("${abi.compiler}${minSdkVersion}-clang")
|
||||
val ar = ndkDirectory.resolve("toolchains/llvm/prebuilt/$host-x86_64/bin")
|
||||
.resolve("${abi.archiver}-ar")
|
||||
|
||||
return mapOf(
|
||||
"CMAKE_SYSTEM_NAME" to "Android",
|
||||
"CMAKE_ANDROID_NDK" to ndkDirectory.absolutePath,
|
||||
"CMAKE_ANDROID_ARCH_ABI" to abi.value,
|
||||
"CMAKE_SYSTEM_VERSION" to minSdkVersion.toString()
|
||||
"CC" to compiler.absolutePath,
|
||||
"AR" to ar.absolutePath,
|
||||
)
|
||||
}
|
||||
}
|
|
@ -3,13 +3,14 @@ package com.github.kr328.clash.tools
|
|||
enum class NativeAbi(
|
||||
val value: String,
|
||||
val compiler: String,
|
||||
val archiver: String,
|
||||
val goArch: String,
|
||||
val goArm: String
|
||||
) {
|
||||
ArmeabiV7a("armeabi-v7a", "armv7a-linux-androideabi", "arm", "7"),
|
||||
Arm64V8a("arm64-v8a", "aarch64-linux-android", "arm64", ""),
|
||||
X86("x86", "i686-linux-android", "386", ""),
|
||||
X64("x86_64", "x86_64-linux-android", "amd64", "");
|
||||
ArmeabiV7a("armeabi-v7a", "armv7a-linux-androideabi", "arm-linux-androideabi", "arm", "7"),
|
||||
Arm64V8a("arm64-v8a", "aarch64-linux-android", "aarch64-linux-android", "arm64", ""),
|
||||
X86("x86", "i686-linux-android", "i686-linux-android", "386", ""),
|
||||
X64("x86_64", "x86_64-linux-android", "x86_64-linux-android", "amd64", "");
|
||||
|
||||
companion object {
|
||||
fun parse(value: String): NativeAbi {
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/Dreamacro/clash/component/resolver"
|
||||
"github.com/kr328/tun2socket/bridge"
|
||||
"github.com/kr328/tun2socket"
|
||||
|
||||
D "github.com/miekg/dns"
|
||||
)
|
||||
|
@ -22,7 +22,7 @@ func shouldHijackDns(dns net.IP, target net.IP, targetPort int) bool {
|
|||
return net.IPv4zero.Equal(dns) || target.Equal(dns)
|
||||
}
|
||||
|
||||
func hijackUDPDns(pkt []byte, lAddr, rAddr net.Addr, udp bridge.UDP) {
|
||||
func hijackUDPDns(pkt []byte, lAddr, rAddr net.Addr, udp tun2socket.UDP) {
|
||||
go func() {
|
||||
answer, err := relayDnsPacket(pkt)
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"net"
|
||||
|
||||
"github.com/Dreamacro/clash/transport/socks5"
|
||||
"github.com/kr328/tun2socket/bridge"
|
||||
"github.com/kr328/tun2socket"
|
||||
|
||||
adapters "github.com/Dreamacro/clash/adapters/inbound"
|
||||
"github.com/Dreamacro/clash/common/pool"
|
||||
|
@ -15,7 +15,7 @@ import (
|
|||
type udpPacket struct {
|
||||
source *net.UDPAddr
|
||||
data []byte
|
||||
udp bridge.UDP
|
||||
udp tun2socket.UDP
|
||||
}
|
||||
|
||||
func (u *udpPacket) Data() []byte {
|
||||
|
@ -38,7 +38,7 @@ func (u *udpPacket) LocalAddr() net.Addr {
|
|||
}
|
||||
}
|
||||
|
||||
func handleUDP(payload []byte, source *net.UDPAddr, target *net.UDPAddr, udp bridge.UDP) {
|
||||
func handleUDP(payload []byte, source *net.UDPAddr, target *net.UDPAddr, udp tun2socket.UDP) {
|
||||
pkt := &udpPacket{
|
||||
source: source,
|
||||
data: payload,
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 958ecb352f87f8a10303b6df31a7aa859ce3bcf3
|
||||
Subproject commit c388e5d9f63850b7f693d1d7e1a5d6fbf51d0b8d
|
Loading…
Reference in New Issue
Block a user