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

如何添加对“转发后的地址和端口”使用脚本进行输出? #79

Open
angel202422 opened this issue Aug 20, 2024 · 3 comments

Comments

@angel202422
Copy link

angel202422 commented Aug 20, 2024

通知脚本可以调用的参数有公网IP、公网端口、IP4P、协议、绑定端口等;目前可以实现输出方式为 “内网IP:绑定端口——打洞公网IP:端口”;比如使用脚本可以输出“100.125.136.199:13485——112.137.195.83:5957” ;但是100.125.136.199这个IP实际上是路由拨号后或得的移动宽带的内网IP,实际想要的是转发后的内网的IP的;最终实现类似于“192.168.10.123:80——112.137.195.83:5957”这种,请问如何实现?非常感谢
另一个求教事项:请AI写了一个脚本,想要通过webhook来通知变化后的公网IP和端口,但是不能实现
代码如下:
#!/bin/sh

发送HTTP GET请求

result=$(curl "http://www.baidu.com/tool/shownat.php?op=put&host=$1&port=$2" 2>/dev/null)

将$1和$2(用冒号分隔)写入文件

echo "$1:$2" > /etc/storage/ip3.txt

设置webhook的URL

webhook_url="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=12345678-1234-1234-1234-d95e12345678"

构造JSON格式的payload

payload="{"text": "IP: $1:$2"}"

发送POST请求到webhook

curl -X POST -H "Content-Type: application/json" -d "$payload" "$webhook_url" 2>/dev/null

curl -X POST -H "Content-Type: application/json" -d "$payload" "$webhook_url"

实际运行后只能输出 ip3.txt 这个文档(内含公网IP和端口),但不能实现通过webhook进行通知(webhook在另一项目上正常使用,排除webhook问题),现在不清楚是哪里出了问题了
请高手指教,不胜感激

@ysc3839
Copy link
Collaborator

ysc3839 commented Aug 20, 2024

“想要的是转发后的内网的IP”
这不是你自己设置的吗?比如说你想转发到 192.168.1.2:8000,那手动写上去就好了。

curl加参数 -vvv 同时去掉 2>/dev/null,看输出什么。

@lhongcai
Copy link

可以通过第三方短连接服务来跳转
natmap传递来的公网ipv4和端口号通过URL缩短器的API接口提交到短链接上,从而访问这个短链接来实现重定向到大内网web服务。
natmap利用缩短url网站重定向到大内网web
natmap利用缩短url网站(gg.gg)重定向功能来访问大内网web

@egg1234
Copy link

egg1234 commented Sep 28, 2024

#81

应该可以通过下面的项目解决向客户端或对端共享/报告打洞后的出口IP地址及端口的问题
https://github.com/Violet-sword/Exchange-Variable

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

4 participants