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

box4magisk透明代理与没有前置代理功能的VPN服务组成代理链 #23

Closed
WeeAris opened this issue Jun 4, 2023 · 2 comments

Comments

@WeeAris
Copy link

WeeAris commented Jun 4, 2023

准确的说就是使用box4magisk的透明代理作为其他VPN应用的前置代理,组成代理链。我使用clash meta核心,将VPN应用(Adguard VPN和NekoBox)加入TPROXY白名单进行实验,流量会回环。
以下是我的部分配置文件:

scripts/box.config

#!/system/bin/sh

bin_name="clash"

redir_port="7891"
tproxy_port="1536"
clash_dns_port="1053"
clash_dns_listen="0.0.0.0:${clash_dns_port}"
clash_fake_ip_range="28.0.0.1/8"
tun_device="tun0"

box_user_group="root:net_admin"
# If you want to change the user or group, you must make the Box core in the /system/bin directory, otherwise the changes will not take effect.
# If you are using Magisk, you can copy the Box core files (sing-box, clash, etc.) to /data/adb/modules/bin_files/system/bin/ and reboot the phone
bin_name_list=("sing-box" "clash" "xray" "v2ray")
box_path="/data/adb/box"
bin_path="${box_path}/bin/${bin_name}"
run_path="${box_path}/run"
pid_file="${run_path}/${bin_name}.pid"


intranet=(0.0.0.0/8 10.0.0.0/8 100.64.0.0/10 127.0.0.0/8 169.254.0.0/16 192.0.0.0/24 192.0.2.0/24 192.88.99.0/24 192.168.0.0/16 198.51.100.0/24 203.0.113.0/24 224.0.0.0/4 240.0.0.0/4 255.255.255.255/32)
intranet6=(::/128 ::1/128 ::ffff:0:0/96 100::/64 64:ff9b::/96 2001::/32 2001:10::/28 2001:20::/28 2001:db8::/32 2002::/16 fe80::/10 ff00::/8)

ipv6="disable"

proxy_method="TPROXY"
# REDIRECT: TCP only / TPROXY: TCP + UDP / MIXED: REDIRECT TCP + TUN UDP

proxy_mode="whitelist"
# blacklist / whitelist / core
user_packages_list=("0:com.android.proxyhandler" "0:com.android.vpndialogs" "0:android" "0:com.adguard.vpn")

clash/config.yaml

mixed-port: 7890
redir-port: 7891
tproxy-port: 1536
allow-lan: false
mode: rule
geodata-mode: true
unified-delay: true
log-level: warning
ipv6: true
external-controller: 127.0.0.1:9999
external-ui: /storage/emulated/0/MT2/Yacd-meta-gh-pages/
secret: "masaka"
enable-process: true
find-process-mode: strict
#tcp-concurrent: true
global-client-fingerprint: chrome

geox-url:
  geoip: "https://cdn.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@releases/download/latest/geoip.dat"
  geosite: "https://cdn.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@releases/download/latest/geosite.dat"
  mmdb: "https://cdn.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@releases/download/latest/country.mmdb"

profile:
  store-selected: true
  store-fake-ip: false

sniffer:
  enable: true
  sniff:
    TLS:
      ports: [443, 8443]
    HTTP:
      ports: [80, 8080-8880]
      override-destination: true

tun:
  enable: true
  device: tun0
  stack: system
  dns-hijack:
    - 'any:53'
  auto-route: false # 如使用box4ksu的应用黑白名单,须关闭
  auto-detect-interface: true
  mtu: 9000
  strict_route: false # 如使用box4ksu的应用黑白名单,须关闭
    
dns:
  enable: true
  listen: 0.0.0.0:1053
  ipv6: false
  enhanced-mode: redir-host # 如使用box4ksu的应用黑名单,须禁用fake-ip
  default-nameserver:
    - 'https://223.5.5.5/dns-query'
  nameserver:
    - 'https://1.1.1.1/dns-query#dns'
  proxy-server-nameserver:
    - 'https://1.12.12.12/dns-query'
  nameserver-policy:
    "geosite:cn,private":
      - 'https://doh.pub/dns-query'
      - 'https://dns.alidns.com/dns-query'

@CHIZI-0618
Copy link
Owner

CHIZI-0618 commented Jul 18, 2023

看起来你启用了 clash 的 tun 配置,请不要再使用 模块的 tproxy。
更新,看到你没有启用 auto route,所以 tun 没有实际启用。

Tun 与 Tproxy 应该是可以共用的,但由核心提供的自动路由( auto route )功能不能满足要求,要自己写路由表。

如果想要 tun 与其他 VPN 共用,可以参考 https://sing-box.sagernet.org/configuration/route/#override_android_vpn 使用该参数,sing-box 与 Clash.Meta 都使用了 sing-tun 实现,所以 https://sing-box.sagernet.org/configuration/inbound/tun 页面的配置绝大多数共用。

@KINGYJL
Copy link

KINGYJL commented May 17, 2024

为什么我用你的不成功。用box_for_root 能成功

@CHIZI-0618 CHIZI-0618 closed this as not planned Won't fix, can't repro, duplicate, stale Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants