[GH-ISSUE #450] 商业版goproxy使用--auth-file出现异常问题 #356

Open
opened 2026-02-27 23:16:37 +03:00 by kerem · 5 comments
Owner

Originally created by @nginxzzz on GitHub (Aug 25, 2021).
Original GitHub issue: https://github.com/snail007/goproxy/issues/450

商业版goproxy sps模式使用--auth-file认证, 接口根据文档返回upstream字段,日志提示functions.go:178: bind crashed runtime error: invalid memory address or nil pointer dereference,无法正常工作。 接口不中不返回upstream则可正常使用,不会报错

Expected Behavior

二级代理模式,goproxy部署为一级代理(sps模式,上级为其他http代理), 接受客户端(proxifier)连接

Current Behavior

1,使用curl -x hello:test@192.168.2.1:10000 时, goproxy日志中提示" functions.go:178: bind crashed runtime error: invalid memory address or nil pointer dereference"
2, 使用proxifier工具也同样有此提示(附上proxifier日志), 并且提示错误
3, 客户端连gorpoxy的上级可以正常工作,说明goproxy上级配置没有问题
4, 测试了baidu等网址,同样错误

// 这是proxifier日志
[41:21] 测试已开始。
代理服务器
地址: 192.168.2.1:10000
协议: HTTPS
验证: 基础
用户名: hello
[41:21] 正在开始: 测试 1: 连接到代理服务器
[41:21] IP 地址: 192.168.2.1
[41:21] 已建立连接
[41:21] 测试已通过。
[41:21] 正在开始: 测试 2: 通过代理服务器连接
[41:21] 已通过代理服务器与 www.google.com:80 建立了连接。
[41:22] 错误: 代理服务器的连接被意外关闭。
请确保目标主机是 Web 服务器。
此错误也可能表示代理服务器不能正常运行。
[41:22] 测试已失败。
[41:22] 测试已完成。

// 这是goproxy 日志
2021/08/25 03:41:21.797050 sps.go:1091: user hello rate, current: 1/s, max: 20/s, ip:192.168.2.1
2021/08/25 03:41:22.847175 sps.go:1325: rate limit 3000 bytes/s ,192.168.2.1 , www.google.com:80
2021/08/25 03:41:22.847175 sps.go:1394: conn 192.168.2.1:53720 - 192.168.3.1:1234 connected [www.google.com:80]
2021/08/25 03:41:22.861951 sps.go:1355: conn 192.168.2.1:53720 - 192.168.3.1:1234 released [www.google.com:80]
2021/08/25 03:41:22.861951 functions.go:178: bind crashed runtime error: invalid memory address or nil pointer dereference

Possible Solution

可能是--auth-file校验有问题, 单独测试了命令行使用-T -P连接上级代理时可以正常工作

Steps to Reproduce

Context (Environment)

  1. proxy version is : commercial_11.0
  2. full command is :?
  3. system is : winserver 2019 (vesion1809)
  4. full log is:
    2021/08/25 03:41:21.797050 sps.go:1091: user hello rate, current: 1/s, max: 20/s, ip:192.168.2.1
    2021/08/25 03:41:22.847175 sps.go:1325: rate limit 3000 bytes/s ,192.168.2.1 , www.google.com:80
    2021/08/25 03:41:22.847175 sps.go:1394: conn 192.168.2.1:53720 - 192.168.3.1:1234 connected [www.google.com:80]
    2021/08/25 03:41:22.861951 sps.go:1355: conn 192.168.2.1:53720 - 192.168.3.1:1234 released [www.google.com:80]
    2021/08/25 03:41:22.861951 functions.go:178: bind crashed runtime error: invalid memory address or nil pointer dereference

Detailed Description

// goproxy配置
sps
-p :10000
--forever
--log proxy.log
--auth-url http://192.168.1.10/auth.php

// auth.php
$alluser=[
"hello"=>"test",
"user2"=>"pass2",
"user3"=>"pass3",
"user4"=>"pass4",
];
$proxy_ip=$_GET['local_addr'];
$user_ip=$_GET['client_addr'];
$service=$_GET['service'];
$is_sps=$_GET['sps']=='1';
$user=$_GET['user'];
$pass=$_GET['pass'];
$target=$_GET['target'];
//业务逻辑判断
//....
$ok=true;

//设置认证结果
if($ok){
header("userconns:1000");
header("ipconns:2000");
header("userrate:3000");
header("iprate:8000");
header("UPSTREAM:http://admin:test@192.168.3.1:1234?parent-type=tcp");
header("HTTP/1.1 204 No Content");
}

Possible Implementation

Originally created by @nginxzzz on GitHub (Aug 25, 2021). Original GitHub issue: https://github.com/snail007/goproxy/issues/450 <!--- Provide a general summary of the issue in the Title above --> 商业版goproxy sps模式使用--auth-file认证, 接口根据文档返回upstream字段,日志提示functions.go:178: bind crashed runtime error: invalid memory address or nil pointer dereference,无法正常工作。 接口不中不返回upstream则可正常使用,不会报错 ## Expected Behavior <!--- Tell us what should happen --> 二级代理模式,goproxy部署为一级代理(sps模式,上级为其他http代理), 接受客户端(proxifier)连接 ## Current Behavior <!--- Tell us what happens instead of the expected behavior --> 1,使用curl -x hello:test@192.168.2.1:10000 时, goproxy日志中提示" functions.go:178: bind crashed runtime error: invalid memory address or nil pointer dereference" 2, 使用proxifier工具也同样有此提示(附上proxifier日志), 并且提示错误 3, 客户端连gorpoxy的上级可以正常工作,说明goproxy上级配置没有问题 4, 测试了baidu等网址,同样错误 // 这是proxifier日志 [41:21] 测试已开始。 代理服务器 地址: 192.168.2.1:10000 协议: HTTPS 验证: 基础 用户名: hello [41:21] 正在开始: 测试 1: 连接到代理服务器 [41:21] IP 地址: 192.168.2.1 [41:21] 已建立连接 [41:21] 测试已通过。 [41:21] 正在开始: 测试 2: 通过代理服务器连接 [41:21] 已通过代理服务器与 www.google.com:80 建立了连接。 [41:22] 错误: 代理服务器的连接被意外关闭。 请确保目标主机是 Web 服务器。 此错误也可能表示代理服务器不能正常运行。 [41:22] 测试已失败。 [41:22] 测试已完成。 // 这是goproxy 日志 2021/08/25 03:41:21.797050 sps.go:1091: user hello rate, current: 1/s, max: 20/s, ip:192.168.2.1 2021/08/25 03:41:22.847175 sps.go:1325: rate limit 3000 bytes/s ,192.168.2.1 , www.google.com:80 2021/08/25 03:41:22.847175 sps.go:1394: conn 192.168.2.1:53720 - 192.168.3.1:1234 connected [www.google.com:80] 2021/08/25 03:41:22.861951 sps.go:1355: conn 192.168.2.1:53720 - 192.168.3.1:1234 released [www.google.com:80] 2021/08/25 03:41:22.861951 functions.go:178: bind crashed runtime error: invalid memory address or nil pointer dereference ## Possible Solution <!--- Not obligatory, but suggest a fix/reason for the bug, --> 可能是--auth-file校验有问题, 单独测试了命令行使用-T -P连接上级代理时可以正常工作 ## Steps to Reproduce <!--- Provide a link to a live example, or an unambiguous set of steps to --> <!--- reproduce this bug. Include code to reproduce, if relevant --> 1. 1. 1. 1. ## Context (Environment) <!--- How has this issue affected you? What are you trying to accomplish? --> <!--- Providing context helps us come up with a solution that is most useful in the real world --> 1. proxy version is : commercial_11.0 1. full command is :? 1. system is : winserver 2019 (vesion1809) 1. full log is: 2021/08/25 03:41:21.797050 sps.go:1091: user hello rate, current: 1/s, max: 20/s, ip:192.168.2.1 2021/08/25 03:41:22.847175 sps.go:1325: rate limit 3000 bytes/s ,192.168.2.1 , www.google.com:80 2021/08/25 03:41:22.847175 sps.go:1394: conn 192.168.2.1:53720 - 192.168.3.1:1234 connected [www.google.com:80] 2021/08/25 03:41:22.861951 sps.go:1355: conn 192.168.2.1:53720 - 192.168.3.1:1234 released [www.google.com:80] 2021/08/25 03:41:22.861951 functions.go:178: bind crashed runtime error: invalid memory address or nil pointer dereference <!--- Provide a general summary of the issue in the Title above --> ## Detailed Description <!--- Provide a detailed description of the change or addition you are proposing --> // goproxy配置 sps -p :10000 --forever --log proxy.log --auth-url http://192.168.1.10/auth.php // auth.php $alluser=[ "hello"=>"test", "user2"=>"pass2", "user3"=>"pass3", "user4"=>"pass4", ]; $proxy_ip=$_GET['local_addr']; $user_ip=$_GET['client_addr']; $service=$_GET['service']; $is_sps=$_GET['sps']=='1'; $user=$_GET['user']; $pass=$_GET['pass']; $target=$_GET['target']; //业务逻辑判断 //.... $ok=true; //设置认证结果 if($ok){ header("userconns:1000"); header("ipconns:2000"); header("userrate:3000"); header("iprate:8000"); header("UPSTREAM:http://admin:test@192.168.3.1:1234?parent-type=tcp"); header("HTTP/1.1 204 No Content"); } ## Possible Implementation <!--- Not obligatory, but suggest an idea for implementing addition or change -->
Author
Owner

@snail007 commented on GitHub (Aug 25, 2021):

你这是api认证,并不是--auth-file认证。

<!-- gh-comment-id:905229003 --> @snail007 commented on GitHub (Aug 25, 2021): 你这是api认证,并不是--auth-file认证。
Author
Owner

@snail007 commented on GitHub (Aug 25, 2021):

问题已经复现和定位,下个版本会修复。

<!-- gh-comment-id:905247279 --> @snail007 commented on GitHub (Aug 25, 2021): 问题已经复现和定位,下个版本会修复。
Author
Owner

@nginxzzz commented on GitHub (Aug 25, 2021):

感谢处理, 是auth-url, 是我写错了

<!-- gh-comment-id:905250278 --> @nginxzzz commented on GitHub (Aug 25, 2021): 感谢处理, 是auth-url, 是我写错了
Author
Owner

@aa1008611 commented on GitHub (Apr 9, 2022):

老板 api可以付费对接你的吗

<!-- gh-comment-id:1094130903 --> @aa1008611 commented on GitHub (Apr 9, 2022): 老板 api可以付费对接你的吗
Author
Owner

@snail007 commented on GitHub (Apr 10, 2022):

商业版可以对接你自己写的API。

<!-- gh-comment-id:1094155136 --> @snail007 commented on GitHub (Apr 10, 2022): 商业版可以对接你自己写的API。
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/goproxy#356
No description provided.