𝒯𝐸𝒟𝐼𝒪𝑅𝐸𝐿𝐸𝐸

🌈MAGISK MODULES V2RAY使安卓手机“无缝”翻墙

🌈MAGISK MODULES V2RAY使安卓手机“无缝”翻墙
2019-08-11 · 8 min read
V2ray

A platform for building proxies to bypass network restrictions.

安装模块

打开Magisk Manager找到并下载安装v2ray模块

如图

config.json配置

v2ray模块默认随手机启动而启动,我们只需要替换/root/data/v2ray里面的配置文件config.json即可

修改默认的配置文件,删除在outbounds字段下的默认数据

使用你自己的v2ray配置替换掉即可,如图

注意:注意大括号是否对应

如何导出v2ray服务端配置?

这里以我自己的电脑举例,mac系统上安装的是v2rayU这款GUI软件

定位到/Applications/V2rayU.app/Contents/Resources下,找到config.json文件

注意:这里的config.json文件不能直接用于magisk v2ray,只需要复制我们需要的outbounds字段即可

修改appid.list

appid.list文件位于/data/v2ray路径下

一般的,我们将app的uid写入该文件中,即可定义特定的app走v2ray透明代理

这里我自己直接在该文件中写入0,即为定义全局app走透明代理(实测发现,不会影响到国内app的使用,应该是自动跳过了GFW内的流量

后记

配置完成后,可以重启一下手机,这样配置文件就生效了并且已经可以访问外网了

尽情享用吧!

贴一下config.json文件备份

// Config file of V2Ray. This file follows standard JSON format, with comments support.
// Uncomment entries below to satisfy your needs. Also read our manual for more detail at
// https://www.v2ray.com/
{
  "log": {
    // By default, V2Ray writes access log to stdout.
    // "access": "/path/to/access/log/file",

    // By default, V2Ray write error log to stdout.
    // "error": "/path/to/error/log/file",
    "error": "/data/v2ray/run/error.log",

    // Log level, one of "debug", "info", "warning", "error", "none"
    "loglevel": "warning"
  },
  // List of inbound proxy configurations.
  "inbounds": [{
    // Just listen for DNS proxy.
    "port": 65534,

    // Tag of the inbound for DNS proxy routing.
    "tag": "dns-in",

    // DNS proxy protocol must be dokodemo-door.
    "protocol": "dokodemo-door",

    // Setting of DNS proxy.
    "settings": {
      "port": 53,
      "address": "1.1.1.1",
      "network": "tcp,udp"
    }
  },{
    // Port to listen on. You may need root access if the value is less than 1024.
    "port": 65535,

    // IP address to listen on. Change to "0.0.0.0" to listen on all network interfaces.
    "listen": "0.0.0.0",

    // Tag of the inbound proxy. May be used for routing.
    "tag": "proxy-inbound",

    // Protocol name of inbound proxy.
    "protocol": "dokodemo-door",

    // Settings of the protocol. Varies based on protocol.
    "settings": {
      // Disable timeout setting for keeping persistent connection. Such as FCM.   
      //  "timeout": 10,
      "network": "tcp,udp",
      "followRedirect": true
    },

    // Enable sniffing on TCP connection.
    "sniffing": {
      "enabled": true,
      // Target domain will be overriden to the one carried by the connection, if the connection is HTTP or HTTPS.
      "destOverride": ["http", "tls"]
    }
  }],
  // List of outbound proxy configurations.
  "outbounds": [{
    "mux": {
      "enabled": false,
      "concurrency": 8
    },
    "protocol": "vmess",
    "streamSettings": {
      "tcpSettings": {
        "header": {
          "type": "none"
        }
      },
      "tlsSettings": {
        "allowInsecure": true
      },
      "security": "none",
      "network": "tcp"
    },
    "tag": "agentout",
    "settings": {
      "vnext": [
        {
          "address": "ip",
          "users": [
            {
              "id": "uuid",
              "alterId": xxx,
              "level": 0,
              "security": "xxx"
            }
          ],
          "port": xxxx
        }
      ]
    }
  },
  {
    "tag": "direct",
    "protocol": "freedom",
    "settings": {
      "domainStrategy": "AsIs",
      "redirect": "",
      "userLevel": 0
    }
  },
  {
    "tag": "blockout",
    "protocol": "blackhole",
    "settings": {
      "response": {
        "type": "none"
      }
    }
  }],

  // Transport is for global transport settings. If you have multiple transports with same settings
  // (say mKCP), you may put it here, instead of in each individual inbound/outbounds.
  //"transport": {},

  // Routing controls how traffic from inbounds are sent to outbounds.
  "routing": {
    "domainStrategy": "IPOnDemand",
    "rules":[
      {
        // Proxy DNS request
        "type": "field",
        "inboundTag": ["dns-in"],
        "outboundTag": "dns-out"
      },
      {
        // Bypass private IPs.
        "type": "field",
        "ip": ["geoip:private"],
        "outboundTag": "direct"
      },
      {
        // Bypass all china IPs.
        "type": "field",
        "ip": ["geoip:cn"],
        "outboundTag": "direct"
      },
      {
        // Bypass all china sites.
        "type": "field",
        "domain": ["geosite:cn"],
        "outboundTag": "direct"
      },
      {
        // Blocks major ads.
        "type": "field",
        "domain": ["geosite:category-ads"],
        "outboundTag": "blocked"
      }
    ]
  },

  // Dns settings for domain resolution.
  "dns": {
    // Static hosts, similar to hosts file.
    "hosts": {
      // Match v2ray.com to another domain on CloudFlare. This domain will be used when querying IPs for v2ray.com.
      "domain:v2ray.com": "www.vicemc.net",

      // The following settings help to eliminate DNS poisoning in mainland China.
      // It is safe to comment these out if this is not the case for you.
      "domain:github.io": "pages.github.com",
      "domain:wikipedia.org": "www.wikimedia.org",
      "domain:shadowsocks.org": "electronicsrealm.com"
    },
    "servers": [
      "1.1.1.1",
      "8.8.8.8",
      "9.9.9.9",
      {
        "address": "114.114.114.114",
        "port": 53,
        // List of domains that use this DNS first.
        "domains": [
          "geosite:cn"
        ]
      },
      "localhost"
    ]
  },

  // Policy controls some internal behavior of how V2Ray handles connections.
  // It may be on connection level by user levels in 'levels', or global settings in 'system.'
  "policy": {
    // Connection policys by user levels
    "levels": {
      "0": {
        "uplinkOnly": 0,
        "downlinkOnly": 0
      }
    },
    "system": {
      "statsInboundUplink": false,
      "statsInboundDownlink": false
    }
  },

  // Stats enables internal stats counter.
  // This setting can be used together with Policy and Api. 
  //"stats":{},

  // Api enables gRPC APIs for external programs to communicate with V2Ray instance.
  //"api": {
    //"tag": "api",
    //"services": [
    //  "HandlerService",
    //  "LoggerService",
    //  "StatsService"
    //]
  //},

  // You may add other entries to the configuration, but they will not be recognized by V2Ray.
  "other": {}
}

https://github.com/Magisk-Modules-Repo/v2ray