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

希望能為屏蔽中國IP功能推出可選項 #59

Open
SeaKarin opened this issue Apr 10, 2024 · 2 comments
Open

希望能為屏蔽中國IP功能推出可選項 #59

SeaKarin opened this issue Apr 10, 2024 · 2 comments

Comments

@SeaKarin
Copy link

問題描述

在本人更換到此腳本之後,發現很多國內網站無法打開,因為一直在使用Azure,因為很多網站封禁了該網段,所以沒有在意。
之後嘗試訪問了bilibili HK(手機端/網頁端) 均無法訪問 這讓我很疑惑,因為在伺服器內wget能夠正常的GET到網站內容。
理論上即使屏蔽了中國IP,網頁端也能夠正常訪問,但是不清楚怎麽回事仍然無法訪問,可能是因為geoip的數據庫錯誤?
而手機端則需要通過訪問阿裏雲的公共API獲取IP,不能訪問也是理所當然。

解決方法

在/etc/xray/config.json删除此项

{
  "type": "field",
  "ip": ["geoip:cn"],
  "marktag": "ban_geoip_cn",
  "outboundTag": "block"
}

完整配置文件

{
  "log": {
    "access": "/var/log/xray/access.log",
    "error": "/var/log/xray/error.log",
    "loglevel": "warning"
  },
  "dns": {},
  "api": {
    "tag": "api",
    "services": [
      "HandlerService",
      "LoggerService",
      "StatsService"
    ]
  },
  "stats": {},
  "policy": {
    "levels": {
      "0": {
        "handshake": 3,
        "connIdle": 243,
        "uplinkOnly": 4,
        "downlinkOnly": 7,
        "statsUserUplink": true,
        "statsUserDownlink": true
      }
    },
    "system": {
      "statsInboundUplink": true,
      "statsInboundDownlink": true,
      "statsOutboundUplink": true,
      "statsOutboundDownlink": true
    }
  },
  "routing": {
    "domainStrategy": "IPIfNonMatch",
    "rules": [
      {
        "type": "field",
        "inboundTag": ["api"],
        "outboundTag": "api"
      },
      {
        "type": "field",
        "protocol": ["bittorrent"],
        "outboundTag": "block"
      },
      {
        "type": "field",
        "domain": ["geosite:openai"],
        "outboundTag": "direct"
      },
      {
        "type": "field",
        "ip": ["geoip:private"],
        "outboundTag": "block"
      }
    ]
  },
  "inbounds": [
    {
      "tag": "api",
      "port": 24345,
      "listen": "127.0.0.1",
      "protocol": "dokodemo-door",
      "settings": {
        "address": "127.0.0.1"
      }
    }
  ],
  "outbounds": [
    {
      "tag": "direct",
      "protocol": "freedom"
    },
    {
      "tag": "block",
      "protocol": "blackhole"
    }
  ]
}

另外
由於本人在泉州市,目前有著上網白名單機製(原因你懂得,因為有個金門縣)導致很多即使是國內IP,內容正規的網站也無法打開。
所以對此功能還是有一點依賴性,希望能夠在下個版本推出是否屏蔽中國IP的可選項。
另外說實話配置文件沒有縮進讓我有點難理解。。。下面還有一行

{
  "type": "field",
  "domain": ["geosite:openai"],
  "marktag": "fix_openai",
  "outboundTag": "direct"
}

我也是有點沒看懂,為何要將openai的ip進行直連?通過tag能看出貌似是要修復什麽問題,能具體說一下嗎?

@233boy
Copy link
Owner

233boy commented Apr 10, 2024

@SeaKarin 你不要开全局代理啊,这样就不会造成国内网站访问不了,强制开启这个是避免通过代理访问了国内的网站。那个 GPT 的是因为有些人的主机可能会解析出错,会被 BAN,所以放到前面路由来提前直连

@SeaKarin
Copy link
Author

SeaKarin commented Apr 10, 2024

@SeaKarin 你不要开全局代理啊,这样就不会造成国内网站访问不了,强制开启这个是避免通过代理访问了国内的网站。那个 GPT 的是因为有些人的主机可能会解析出错,会被 BAN,所以放到前面路由来提前直连
我清楚如果不開全局代理就不會造成國內網站訪問不了

在上方也説明了,本人在泉州,該地區有著特殊的白名單審查制度,詳情請查看
在使用泉州地區的電信/廣電/移動 ISP,即使訪問部分國內IP合法內容的網站,由於該網站不在白名單規則內,也會導致無法訪問,因此需要通過代理。(僅針對於通過域名解析的HTTP/HTTPS 80/443,IP訪問不受影響)
幷且geoip的數據庫也存在一定的問題,中國大陸IP識別不準确,在訪問bilibili HongKong(通過CDN嘗試使用新加坡、日本的IP仍然被傳入block)也會傳入block,這種一刀切的方法确實會導致很多問題。
當然我也知道解決方法,我只是提个功能建議,讓部分有著和我一樣的網絡環境或者有相同的需求能够得到解決方案。

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

2 participants