Git Product home page Git Product logo

gfwlist2privoxy's People

Contributors

c-rainstorm avatar elfsundae avatar zfl9 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gfwlist2privoxy's Issues

脚本 bug "echo -e"

在脚步中有 一下语句:
echo -e "# Generated by gfwlist2privoxy at $(date '+%F %T')\n{+forward-override{forward-socks5 $1 .}}" >${gfwlist_action}
这个本身是 OK 的,但是在 Linux dns 4.18.0-13-generic #14-Ubuntu SMP Wed Dec 5 09:04:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux ,执行 sh gfwlist2privoxy MYPROXY:PORT 后,会出错:

Fatal error: can't load actions file '/etc/privoxy/gfwlist.action': line 1 should begin with a '{': -e

经过检查,是在 gfwlist.action第一行,多出了 -e
所以请修复一下,我就不提 PR 了。

PS:感谢你的项目,很好用。

macOS 脚本修改后不可用

另一种可行方案

privoxy config file:

forward-socks5 / 127.0.0.1 .
listen-address 0.0.0.0:8118

gfwlist2privoxy 脚本修改

macOS 上一些命令行参数与 linux 版本不同,做了一下简单修改,
不知道是否因为脚本改动的原因导致按照生成的配置文件不可用,能否麻烦帮我看一下?谢谢!

#!/bin/bash

## gfwlist.action 文件
gfwlist_action='gfwlist.action'

## socks5 代理地址,必须为 ip:port 形式
socks5_proxy=$1
if [[ ! "${socks5_proxy}" =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}:[0-9]{1,5}$ ]]; then
    echo -e "\e[35minvalid address:\e[0m \"${socks5_proxy}\"" 1>&2
    echo -e "\e[37mUsage:\e[0m \e[32m$0\e[0m \e[36m'address:port'\e[0m" 1>&2
    exit 1
else
    echo "{+forward-override{forward-socks5 ${socks5_proxy} .}}" > ${gfwlist_action}
fi

## 用到的临时文件
gfwlist_txt=$(mktemp)
gfwlist_regex=$(mktemp)
gfwlist_scheme=$(mktemp)
gfwlist_begin=$(mktemp)
gfwlist_main=$(mktemp)
gfwlist_temp=$(mktemp)

## 获取 gfwlist.txt
curl -skL https://raw.github.com/gfwlist/gfwlist/master/gfwlist.txt | base64 --decode | egrep -v '^$|^!|^@@|^\[AutoProxy' > ${gfwlist_txt}

## 分离不同的语法
cat ${gfwlist_txt} | egrep '^/' > ${gfwlist_regex}                  # '/regex/' 正则
cat ${gfwlist_txt} | egrep '^\|\|' > ${gfwlist_scheme}              # '||pattern' 协议符
cat ${gfwlist_txt} | egrep '^\|[^\|]' > ${gfwlist_begin}            # '|pattern' 边界符
cat ${gfwlist_txt} | egrep -v '^/|^\|\||^\|[^\|]' > ${gfwlist_main} # 与 privoxy.action 语法接近的部分

## 处理正则语法 (目前只能手动添加,因为将正则替换为 shell 通配符太复杂了)
echo '.google.' >> ${gfwlist_main}
echo '.blogspot.' >> ${gfwlist_main}
echo '.twimg.edgesuite.net' >> ${gfwlist_main}

## 处理协议符,直接删除即可,在 privoxy.action 中没有所谓的协议字段
cat ${gfwlist_scheme} | sed -E 's@^\|\|(.*)$@\1@g' >> ${gfwlist_main}

## 处理边界符,删除边界符,然后删除可能有的协议字段
cat ${gfwlist_begin} | sed -E 's@^\|(.*)$@\1@g' | sed -E '\@^https?://@ s@^https?://(.*)$@\1@g' >> ${gfwlist_main}

## 处理 gfwlist_main 文件,去除尾部的 uri 部分,只保留域名
cat ${gfwlist_main} | sed -E '\@/@ s@^([^/]*).*$@\1@g' | sort | uniq -i > ${gfwlist_temp}

## 处理 ipv4 地址
cat ${gfwlist_temp} | grep -E '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$' >> ${gfwlist_action}

## 处理域名,在开头添加 '.',然后删除重复内容
cat ${gfwlist_temp} | grep -Ev '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$' | sed -E '\@^\.@! s@^(.*)$@.\1@g' | sort | uniq -i >> ${gfwlist_action}

## 处理完毕,删除临时文件
rm -fr ${gfwlist_txt} ${gfwlist_regex} ${gfwlist_scheme} ${gfwlist_begin} ${gfwlist_main} ${gfwlist_temp}

## 打印接下来要执行的命令,即:应用 gfwlist_action 文件
echo -e "\e[37m# Please execute the following command:\e[0m"
echo -e "\e[36mcp -af ${gfwlist_action} /etc/privoxy/\e[0m"
echo -e "\e[36mecho \"actionsfile ${gfwlist_action}\" >> /etc/privoxy/config\e[0m"

base64 on OS X should use `-D` instead of `-d`

因Readme中提到已经解决了参数不一致的问题,但实际上并没有完全解决。

Usage:	base64 [-hvD] [-b num] [-i in_file] [-o out_file]
  -h, --help     display this message
  -D, --decode   decodes input
  -b, --break    break encoded string into num character lines
  -i, --input    input file (default: "-" for stdin)
  -o, --output   output file (default: "-" for stdout)

当然了 gfwlist2privoxy-mac-zsh 是没有问题的

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.