mirror of
https://github.com/MetaCubeX/ClashMetaForAndroid.git
synced 2024-11-22 13:26:09 +03:00
Chore: update tun2socket
This commit is contained in:
parent
12220789a3
commit
271d56c01c
@ -39,8 +39,8 @@ abstract class ClashBuildTask : DefaultTask() {
|
|||||||
config.abis.forEach {
|
config.abis.forEach {
|
||||||
Command.ofGoRun(
|
Command.ofGoRun(
|
||||||
"make/make.go",
|
"make/make.go",
|
||||||
listOf("bridge", "native", "build", "android", it.goArch),
|
listOf("tun2socket", ".", "android", it.goArch),
|
||||||
input.resolve("tun2socket/bridge"),
|
input.resolve("tun2socket"),
|
||||||
environment.ofLwipBuild(it)
|
environment.ofLwipBuild(it)
|
||||||
).exec()
|
).exec()
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import golangSource
|
|||||||
|
|
||||||
abstract class ClashCleanTask : Delete() {
|
abstract class ClashCleanTask : Delete() {
|
||||||
fun applyFrom(project: Project, abis: List<NativeAbi>) {
|
fun applyFrom(project: Project, abis: List<NativeAbi>) {
|
||||||
val bridge = project.golangSource.resolve("tun2socket/bridge")
|
val bridge = project.golangSource.resolve("tun2socket")
|
||||||
|
|
||||||
delete(bridge.resolve("build"))
|
delete(bridge.resolve("build"))
|
||||||
|
|
||||||
|
@ -34,11 +34,25 @@ class Environment(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun ofLwipBuild(abi: NativeAbi): Map<String, String> {
|
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(
|
return mapOf(
|
||||||
"CMAKE_SYSTEM_NAME" to "Android",
|
"CC" to compiler.absolutePath,
|
||||||
"CMAKE_ANDROID_NDK" to ndkDirectory.absolutePath,
|
"AR" to ar.absolutePath,
|
||||||
"CMAKE_ANDROID_ARCH_ABI" to abi.value,
|
|
||||||
"CMAKE_SYSTEM_VERSION" to minSdkVersion.toString()
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,13 +3,14 @@ package com.github.kr328.clash.tools
|
|||||||
enum class NativeAbi(
|
enum class NativeAbi(
|
||||||
val value: String,
|
val value: String,
|
||||||
val compiler: String,
|
val compiler: String,
|
||||||
|
val archiver: String,
|
||||||
val goArch: String,
|
val goArch: String,
|
||||||
val goArm: String
|
val goArm: String
|
||||||
) {
|
) {
|
||||||
ArmeabiV7a("armeabi-v7a", "armv7a-linux-androideabi", "arm", "7"),
|
ArmeabiV7a("armeabi-v7a", "armv7a-linux-androideabi", "arm-linux-androideabi", "arm", "7"),
|
||||||
Arm64V8a("arm64-v8a", "aarch64-linux-android", "arm64", ""),
|
Arm64V8a("arm64-v8a", "aarch64-linux-android", "aarch64-linux-android", "arm64", ""),
|
||||||
X86("x86", "i686-linux-android", "386", ""),
|
X86("x86", "i686-linux-android", "i686-linux-android", "386", ""),
|
||||||
X64("x86_64", "x86_64-linux-android", "amd64", "");
|
X64("x86_64", "x86_64-linux-android", "x86_64-linux-android", "amd64", "");
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun parse(value: String): NativeAbi {
|
fun parse(value: String): NativeAbi {
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Dreamacro/clash/component/resolver"
|
"github.com/Dreamacro/clash/component/resolver"
|
||||||
"github.com/kr328/tun2socket/bridge"
|
"github.com/kr328/tun2socket"
|
||||||
|
|
||||||
D "github.com/miekg/dns"
|
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)
|
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() {
|
go func() {
|
||||||
answer, err := relayDnsPacket(pkt)
|
answer, err := relayDnsPacket(pkt)
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/Dreamacro/clash/transport/socks5"
|
"github.com/Dreamacro/clash/transport/socks5"
|
||||||
"github.com/kr328/tun2socket/bridge"
|
"github.com/kr328/tun2socket"
|
||||||
|
|
||||||
adapters "github.com/Dreamacro/clash/adapters/inbound"
|
adapters "github.com/Dreamacro/clash/adapters/inbound"
|
||||||
"github.com/Dreamacro/clash/common/pool"
|
"github.com/Dreamacro/clash/common/pool"
|
||||||
@ -15,7 +15,7 @@ import (
|
|||||||
type udpPacket struct {
|
type udpPacket struct {
|
||||||
source *net.UDPAddr
|
source *net.UDPAddr
|
||||||
data []byte
|
data []byte
|
||||||
udp bridge.UDP
|
udp tun2socket.UDP
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *udpPacket) Data() []byte {
|
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{
|
pkt := &udpPacket{
|
||||||
source: source,
|
source: source,
|
||||||
data: payload,
|
data: payload,
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 958ecb352f87f8a10303b6df31a7aa859ce3bcf3
|
Subproject commit c388e5d9f63850b7f693d1d7e1a5d6fbf51d0b8d
|
Loading…
Reference in New Issue
Block a user