Skip to content

Commit

Permalink
fix sslv3 handshake failure.
Browse files Browse the repository at this point in the history
  • Loading branch information
kkkgo committed May 23, 2023
1 parent 5043808 commit 9eb8cb1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 38 deletions.
32 changes: 12 additions & 20 deletions FILES/usr/bin/ppg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ net_ready() {

fast_node_sel() {
if [ -f /tmp/ppgw.ini ]; then
. /tmp/ppgw.ini
. /tmp/ppgw.ini 2>/dev/tty0
fi
if [ -z "$clash_web_port" ]; then
clash_web_port="80"
Expand All @@ -46,7 +46,7 @@ fast_node_sel() {
start_clash() {
if [ -f /tmp/clash.yaml ]; then
if [ -f /tmp/ppgw.ini ]; then
. /tmp/ppgw.ini
. /tmp/ppgw.ini 2>/dev/tty0
fi
if [ -z "$test_node_url" ]; then
test_node_url="http://www.google.com"
Expand All @@ -59,7 +59,7 @@ start_clash() {
}
gen_hash() {
if [ -f /tmp/ppgw.ini ]; then
. /tmp/ppgw.ini
. /tmp/ppgw.ini 2>/dev/tty0
str="ppgw""$fake_cidr""$dns_ip""$dns_port""$openport""$sleeptime""$clash_web_port""$clash_web_password""$mode""$udp_enable""$socks5_ip""$socks5_port""$yamlfile""$suburl""$subtime""$fast_node""$test_node_url""$ext_node"
echo "$str" | md5sum | grep -Eo "[a-z0-9]{32}" | head -1
else
Expand Down Expand Up @@ -93,24 +93,16 @@ get_conf() {
rm "$file_down_tmp"
fi
if [ -f /tmp/ppgw.ini ]; then
. /tmp/ppgw.ini
. /tmp/ppgw.ini 2>/dev/tty0
fi
echo "127.0.0.1 localhost" >/etc/hosts
if [ "$down_sdns" = "yes" ]; then
rawURL=$(ppgw -server "$dns_ip" -port "$dns_port" -rawURL "$down_url")
genHost=$(ppgw -server "$dns_ip" -port "$dns_port" -rawURL "$down_url")
else
rawURL=$(ppgw -rawURL "$down_url")
fi
line_count=$(echo "$rawURL" | wc -l)
if [ "$line_count" -eq 1 ]; then
wget --header="User-Agent: ClashforWindows/0.20.23" --timeout=10 --tries=1 --no-check-certificate "$down_url" -O "$file_down_tmp" >/dev/tty0 2>&1
else
rawDomain=$(echo "$rawURL" | head -1)
rawSch=$(echo "$rawURL" | sed -n "2p")
rawIP=$(echo "$rawURL" | sed -n "3p")
rawReq=$(echo "$rawURL" | tail -1)
down_url="$rawSch"":""//""$rawIP""$rawReq"
wget --header="Host: ""$rawDomain" --header="User-Agent: ClashforWindows/0.20.23" --timeout=10 --no-check-certificate "$down_url" -O "$file_down_tmp" >/dev/tty0 2>&1
genHost=$(ppgw -rawURL "$down_url")
fi
echo "$genHost" >>/etc/hosts
wget --header="User-Agent: ClashforWindows/0.20.23" --timeout=10 --tries=1 --no-check-certificate "$down_url" -O "$file_down_tmp" >/dev/tty0 2>&1
if [ "$down_type" = "ini" ]; then
if head -1 "$file_down_tmp" | grep -q "#paopao-gateway"; then
cp "$file_down_tmp" "$file_down"
Expand Down Expand Up @@ -192,7 +184,7 @@ reload_gw() {
log "[SYSCTL] Turn on net.ipv4.conf.all.route_localnet..." warn
sysctl -w net.ipv4.conf.all.route_localnet=1 >/dev/null 2>&1
fi
. /tmp/ppgw.ini
. /tmp/ppgw.ini 2>/dev/tty0
if [ -z "$udp_enable" ]; then
udp_enable="yes"
fi
Expand Down Expand Up @@ -342,7 +334,7 @@ fi

if [ "$1" = "cron" ]; then
if [ -f /tmp/ppgw.ini ]; then
. /tmp/ppgw.ini
. /tmp/ppgw.ini 2>/dev/tty0
fi
get_conf "$suburl" "yaml" "yes"
exit
Expand All @@ -368,7 +360,7 @@ while true; do
fi
fi
if [ -f /tmp/ppgw.ini ]; then
. /tmp/ppgw.ini
. /tmp/ppgw.ini 2>/dev/tty0
fi
if [ "$mode" = "yaml" ]; then
try_conf "$yamlfile" "yaml"
Expand Down
2 changes: 1 addition & 1 deletion ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## PaoPao GateWay
![PaoPaoDNS](https://th.bing.com/th/id/OIG.0FtL40H4krRLeooEGFpu?w=220&h=220&c=6&r=0&o=5&pid=ImgGn)

PaoPao GateWay是一个体积小巧、稳定强大的FakeIP网关,系统由openwrt定制构建,核心由clash驱动,支持多种方式下发配置,支持多种出站方式,包括自定义socks5、自定义yaml节点、订阅模式和自由出站,支持节点测速自动选择、节点排除等功能,并附带web面板可供查看日志连接信息等。PaoPao GateWay可以和其他DNS服务器一起结合使用,比如配合[PaoPaoDNS](https://github.com/kkkgo/PaoPaoDNS)`CUSTOM_FORWARD`功能就可以完成简单精巧的分流。
PaoPao GateWay是一个体积小巧、稳定强大的FakeIP网关,系统由openwrt定制构建,核心由clash驱动,支持`Full Cone NAT`支持多种方式下发配置,支持多种出站方式,包括自定义socks5、自定义yaml节点、订阅模式和自由出站,支持节点测速自动选择、节点排除等功能,并附带web面板可供查看日志连接信息等。PaoPao GateWay可以和其他DNS服务器一起结合使用,比如配合[PaoPaoDNS](https://github.com/kkkgo/PaoPaoDNS)`CUSTOM_FORWARD`功能就可以完成简单精巧的分流。

你可以从Github Release下载到最新的镜像:[https://github.com/kkkgo/PaoPaoGateWay/releases](https://github.com/kkkgo/PaoPaoGateWay/releases)
## [→详细说明《FakeIP网关的工作原理》](https://blog.03k.org/post/paopaogateway.html)
Expand Down
18 changes: 1 addition & 17 deletions ppgw.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,26 +260,10 @@ func main() {
fmt.Printf("Failed to parse URL: %v\n", err)
os.Exit(0)
}

host := parsedURL.Hostname()
ip := net.ParseIP(host)
if ip != nil {
fmt.Println(rawURL)
os.Exit(0)
}
initDNS()
ipString := nslookup(host)
port := ""
if parsedURL.Port() != "" {
port = ":" + parsedURL.Port()
} else {
if parsedURL.Scheme == "http" {
port = ":80"
} else if parsedURL.Scheme == "https" {
port = ":443"
}
}
constructedURL := fmt.Sprintf("%s\n%s\n%s%s\n%s", host, parsedURL.Scheme, ipString, port, parsedURL.RequestURI())
constructedURL := fmt.Sprintf("%s %s", ipString, host)
fmt.Println(constructedURL)
os.Exit(0)
}
Expand Down

0 comments on commit 9eb8cb1

Please sign in to comment.