Cenmrev / V2RayX

GUI for v2ray-core on macOS
GNU General Public License v3.0
7.65k stars 1.14k forks source link

pac.js更新python版本脚本 #303

Open jipiyan opened 5 years ago

jipiyan commented 5 years ago

请回答下列问题。不按模板发的 issue 将直接被关闭。

0) 如果你没有遇到任何错误和不正常,请在此处回答你想发表的内容:

pac.js更新python版本脚本

1) 你正在使用哪个版本的 V2RayX,你的 macOS 系统版本?

2) 如果你在操作 V2RayX 的时候遇到程序崩溃/无反应,请描述你的操作,之后在命令行(终端.app)里运行/Applications/V2RayX.app/Contents/MacOS/V2RayX,重复上述操作直至软件崩溃,把终端里的输出贴到下面指定的地方。

在这里贴上终端的输出

3) 如果 V2RayX 没有发生崩溃,但是有一些不正常行为,比如上次勾选了 mux,再次打开,mux 的钩没有了。请描述你遇到的不正常行为。

4) 如果 V2RayX 一切正常,但网络依然不如你所预料,请首先把 log level 切换到 debug,再次访问你想访问的网站。然后点击 V2RayX 的 view current config.json,将弹出的浏览器内的配置文件粘贴到下面指定的地方,但是隐藏掉ip/端口/id等信息。

在这里粘贴配置文件内容

然后点击 V2RayX 的view log,把 error.log 中的输出贴到下方:

在这里贴上 error.log

5) 其他你认为可以帮助开发者和你一起解决问题的信息:

根据leizihui的java脚本改编

import requests
import base64

url = "https://bitbucket.org/gfwlist/gfwlist/raw/HEAD/gfwlist.txt"
r = requests.get(url)
encrypt_str = r.text.strip()
decrypt_str = base64.b64decode(encrypt_str.encode('utf8'))
decrypt_str = decrypt_str.decode('utf8')
decrypt_strs = decrypt_str.split('\n')
js_strs = []
for each_str in decrypt_strs:
    if each_str is None:
        continue
    if each_str.startswith('|'):
        js_strs.append(each_str.replace('|', ''))
    if each_str.startswith('.'):
        js_strs.append(each_str[1:])
js_str = "var V2Ray = \"SOCKS5 127.0.0.1:1081; SOCKS 127.0.0.1:1081; HTTP 127.0.0.1:8001; HTTPS 127.0.0.1:8001; DIRECT;\";\n\n"
js_str += "var domains = [\n"
for each_str in js_strs:
    js_str += '    "' + each_str + '",\n'
js_str = js_str[:-2] + "\n];\n\n"
js_str += "function FindProxyForURL(url, host) {\n"
js_str += "    for (var i = domains.length - 1; i >= 0; i--) {\n"
js_str += "        if (dnsDomainIs(host, domains[i])) {\n"
js_str += "            return V2Ray;\n"
js_str += "        }\n"
js_str += "    }\n"
js_str += "    return \"DIRECT\";\n"
js_str += "}\n"
with open('pac.js', 'w', encoding='utf-8') as f:
    f.write(js_str)
    f.close()
abigchopstick commented 4 years ago

awesome, does it work?

abigchopstick commented 4 years ago

MacBook-Pro-2:Moca huangsu$ python updatepac.py Traceback (most recent call last): File "updatepac.py", line 1, in import requests ImportError: No module named requests

jipiyan commented 4 years ago

MacBook-Pro-2:Moca huangsu$ python updatepac.py Traceback (most recent call last): File "updatepac.py", line 1, in import requests ImportError: No module named requests

please install the requests package pip install requests

ps:The requests library is the de facto standard for making HTTP requests in Python. It abstracts the complexities of making requests behind a beautiful, simple API so that you can focus on interacting with services and consuming data in your application.

abigchopstick commented 4 years ago

python updatepac.py Traceback (most recent call last): File "updatepac.py", line 31, in with open('pac.js', 'w', encoding='utf-8') as f: TypeError: 'encoding' is an invalid keyword argument for this function

removed encoding option and it worked! awesome, thanks!

BTW, this should work for all pac lists in the same format right? I want it to try the cdn list (whitelist).

jipiyan commented 4 years ago

python updatepac.py Traceback (most recent call last): File "updatepac.py", line 31, in with open('pac.js', 'w', encoding='utf-8') as f: TypeError: 'encoding' is an invalid keyword argument for this function

removed encoding option and it worked! awesome, thanks!

I forgot mension my python version is 3.6.9

abigchopstick commented 4 years ago

can you try this one?

https://raw.githubusercontent.com/neko-dev/gfw_whitelist/master/gfw_whitelist.txt

or maybe this? https://github.com/ACL4SSR/ACL4SSR

thanks!!

jipiyan commented 4 years ago

can you try this one?

https://raw.githubusercontent.com/neko-dev/gfw_whitelist/master/gfw_whitelist.txt

or maybe this? https://github.com/ACL4SSR/ACL4SSR

thanks!!

V2ray's pac.js uses a blacklist. And I don't think it's necessary to write another rule for whitelist.

abigchopstick commented 4 years ago

Cool, actually I found there's a routing rule that can bypass all cn_ip, which is probably good enough for me, thanks for the script, and it works without encoding in 2.7 version.

On Thu, Dec 26, 2019 at 6:09 PM jipiyan notifications@github.com wrote:

can you try this one?

https://raw.githubusercontent.com/neko-dev/gfw_whitelist/master/gfw_whitelist.txt

or maybe this? https://github.com/ACL4SSR/ACL4SSR

thanks!!

V2ray's pac.js uses a blacklist. And I don't think it's necessary to write another rule for whitelist.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Cenmrev/V2RayX/issues/303?email_source=notifications&email_token=AF6HRGRC3BYP2XMU24D6IELQ2R7FHA5CNFSM4JL5EGAKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHVLK4Y#issuecomment-569030003, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF6HRGWXUSOZZ5V7FS5CAMTQ2R7FHANCNFSM4JL5EGAA .

zhenchao125 commented 4 years ago

scala script https://github.com/zhenchao125/self-tool