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

TProxy 下可以遇到的内存泄漏问题 #1341

Closed
MarksonHon opened this issue Oct 21, 2021 · 5 comments · Fixed by #1330
Closed

TProxy 下可以遇到的内存泄漏问题 #1341

MarksonHon opened this issue Oct 21, 2021 · 5 comments · Fixed by #1330
Labels

Comments

@MarksonHon
Copy link

你正在使用哪个版本的 V2Ray?

V2Ray 4.43.0 (V2Fly, a community-driven edition of V2Ray.) Custom (go1.17.1 linux/amd64)
A unified platform for anti-censorship.

你的使用场景是什么?

由 v2rayA 启动的透明代理与DNS分流,使用 nslookup 查询域名,使用 Telegram 上网聊天。

你看到的异常现象是什么?

在 DNS 域名查询缓慢的情况下,v2ray 会占用大量的 RAM。
图片

你期待看到的正常表现是怎样的?

内存不应该用这么多

请附上你的配置

{
"log": {
"access": "",
"error": "none",
"loglevel": "info"
},
"inbounds": [
{
"port": 20170,
"protocol": "socks",
"listen": "127.0.0.1",
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
],
"metadataOnly": false
},
"settings": {
"auth": "noauth",
"udp": true
},
"streamSettings": null,
"tag": "socks_ipv4"
},
{
"port": 20171,
"protocol": "http",
"listen": "127.0.0.1",
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
],
"metadataOnly": false
},
"streamSettings": null,
"tag": "http_ipv4"
},
{
"port": 20172,
"protocol": "http",
"listen": "127.0.0.1",
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
],
"metadataOnly": false
},
"streamSettings": null,
"tag": "rule_ipv4"
},
{
"port": 32345,
"protocol": "dokodemo-door",
"listen": "127.0.0.1",
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
],
"metadataOnly": false
},
"settings": {
"network": "tcp,udp",
"followRedirect": true
},
"streamSettings": {
"sockopt": {
"tproxy": "tproxy"
}
},
"tag": "transparent_ipv4"
},
{
"port": 46413,
"protocol": "dokodemo-door",
"listen": "127.0.0.1",
"sniffing": {
"enabled": false,
"metadataOnly": false
},
"settings": {
"address": "127.0.0.1"
},
"streamSettings": null,
"tag": "api-in_ipv4"
},
{
"port": 20170,
"protocol": "socks",
"listen": "::1",
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
],
"metadataOnly": false
},
"settings": {
"auth": "noauth",
"udp": true
},
"streamSettings": null,
"tag": "socks_ipv6"
},
{
"port": 20171,
"protocol": "http",
"listen": "::1",
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
],
"metadataOnly": false
},
"streamSettings": null,
"tag": "http_ipv6"
},
{
"port": 20172,
"protocol": "http",
"listen": "::1",
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
],
"metadataOnly": false
},
"streamSettings": null,
"tag": "rule_ipv6"
},
{
"port": 32345,
"protocol": "dokodemo-door",
"listen": "::1",
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
],
"metadataOnly": false
},
"settings": {
"network": "tcp,udp",
"followRedirect": true
},
"streamSettings": {
"sockopt": {
"tproxy": "tproxy"
}
},
"tag": "transparent_ipv6"
},
{
"port": 46413,
"protocol": "dokodemo-door",
"listen": "::1",
"sniffing": {
"enabled": false,
"metadataOnly": false
},
"settings": {
"address": "127.0.0.1"
},
"streamSettings": null,
"tag": "api-in_ipv6"
}
],
"outbounds": [
{
"tag": "proxy",
"protocol": "shadowsocks",
"settings": {
"servers": [
{
"address": "ServerIP",
"method": "aes-128-gcm",
"password": "ServerUUID",
"port": 10086
}
]
},
"streamSettings": {
"sockopt": {
"mark": 128
}
}
},
{
"tag": "direct",
"protocol": "freedom",
"settings": {
"domainStrategy": "UseIP"
},
"streamSettings": {
"sockopt": {
"mark": 128
}
}
},
{
"tag": "block",
"protocol": "blackhole",
"settings": {}
},
{
"tag": "dns-out",
"protocol": "dns",
"settings": {},
"streamSettings": {
"sockopt": {
"mark": 128
}
}
}
],
"routing": {
"domainStrategy": "IPOnDemand",
"domainMatcher": "mph",
"rules": [
{
"type": "field",
"outboundTag": "direct",
"ip": [
"ServerIP"
],
"port": "10086"
},
{
"type": "field",
"outboundTag": "proxy",
"inboundTag": [
"dns"
],
"domain": [
"dns.opendns.com"
],
"port": "5353"
},
{
"type": "field",
"outboundTag": "direct",
"inboundTag": [
"dns"
],
"domain": [
"dns.alidns.com"
],
"port": "443"
},
{
"type": "field",
"outboundTag": "direct",
"inboundTag": [
"dns"
],
"ip": [
"119.29.29.29"
],
"port": "53"
},
{
"type": "field",
"outboundTag": "direct",
"inboundTag": [
"dns"
],
"ip": [
"208.67.220.220"
],
"port": "5353"
},
{
"type": "field",
"outboundTag": "direct",
"inboundTag": [
"dns"
]
},
{
"type": "field",
"outboundTag": "dns-out",
"port": "53"
},
{
"type": "field",
"outboundTag": "direct",
"inboundTag": [
"transparent_ipv4",
"transparent_ipv6"
],
"ip": [
"geoip:private",
"127.0.0.1/8",
"192.168.10.195/24",
"::1/128",
"Local_IPv6::9e2/128",
"Local_Site_IPv6::9e2/128",
"Local_Site_IPv6::111/64",
"Local_IPv6:111/64",
"fe80::f85c:4c4e:b31e:ede4/64"
],
"port": "53"
},
{
"type": "field",
"outboundTag": "proxy",
"inboundTag": [
"rule_ipv4",
"rule_ipv6"
],
"domain": [
"ext:LoyalsoldierSite.dat:geolocation-!cn"
]
},
{
"type": "field",
"outboundTag": "direct",
"inboundTag": [
"rule_ipv4"
],
"domain": [
"geosite:cn"
]
},
{
"type": "field",
"outboundTag": "proxy",
"inboundTag": [
"rule_ipv4"
],
"ip": [
"geoip:hk",
"geoip:mo"
]
},
{
"type": "field",
"outboundTag": "direct",
"inboundTag": [
"rule_ipv4"
],
"ip": [
"geoip:private",
"geoip:cn",
"127.0.0.1/8",
"192.168.10.195/24",
"::1/128",
"Local_IPv6::9e2/128",
"Local_Site_IPv6::9e2/128",
"Local_Site_IPv6::111/64",
"Local_IPv6:111/64",
"fe80::f85c:4c4e:b31e:ede4/64"
]
},
{
"type": "field",
"outboundTag": "proxy",
"inboundTag": [
"transparent_ipv4",
"transparent_ipv6"
],
"domain": [
"ext:LoyalsoldierSite.dat:geolocation-!cn"
]
},
{
"type": "field",
"outboundTag": "direct",
"inboundTag": [
"transparent_ipv4"
],
"domain": [
"geosite:cn"
]
},
{
"type": "field",
"outboundTag": "proxy",
"inboundTag": [
"transparent_ipv4"
],
"ip": [
"geoip:hk",
"geoip:mo"
]
},
{
"type": "field",
"outboundTag": "direct",
"inboundTag": [
"transparent_ipv4"
],
"ip": [
"geoip:private",
"geoip:cn",
"127.0.0.1/8",
"192.168.10.195/24",
"::1/128",
"Local_IPv6::9e2/128",
"Local_Site_IPv6::9e2/128",
"Local_Site_IPv6:0:111/64",
"Local_IPv6:111/64",
"fe80::f85c:4c4e:b31e:ede4/64"
]
},
{
"type": "field",
"outboundTag": "api-out",
"inboundTag": [
"api-in_ipv4",
"api-in_ipv6"
]
}
]
},
"dns": {
"servers": [
"tcp://dns.opendns.com:5353",
{
"address": "https://dns.alidns.com:443/dns-query",
"domains": [
"geosite:cn"
]
},
{
"address": "119.29.29.29",
"port": 53,
"domains": [
"geosite:cn"
]
},
{
"address": "tcp://208.67.220.220:5353",
"domains": [
"dns.opendns.com",
"dns.alidns.com"
]
},
{
"address": "tcp://119.29.29.29:53",
"domains": [
"dns.opendns.com",
"dns.alidns.com"
]
}
],
"tag": "dns"
},
"api": {
"tag": "api-out",
"services": [
"LoggerService"
]
}
}⏎

服务端配置:

本地客户端故障,故而不上传服务器配置。


**客户端配置:**

如上

请附上出错时软件输出的错误日志

日志为 v2rayA 的进程附加,io.go 的是 v2rayA 记录的 v2ray 日志

10月 21 21:22:21 archlinux v2raya[2922]: [I] [io.go:425] 192.168.10.195:51387 accepted udp:192.168.10.1:53 [dns-out]
10月 21 21:22:22 archlinux v2raya[2922]: [I] [io.go:425] 192.168.10.195:43458 accepted udp:192.168.10.1:53 [dns-out]
10月 21 21:22:27 archlinux v2raya[2922]: [I] [io.go:425] 192.168.10.195:58265 accepted udp:192.168.10.1:53 [dns-out]
10月 21 21:22:28 archlinux v2raya[2922]: [I] [io.go:425] 192.168.10.195:33101 accepted udp:192.168.10.1:53 [dns-out]
10月 21 21:22:33 archlinux v2raya[2922]: [I] [io.go:425] 192.168.10.195:51499 accepted udp:192.168.10.1:53 [dns-out]
10月 21 21:22:40 archlinux v2raya[2922]: [I] [io.go:425] [fd63:1a46:cf::9e2]:47252 accepted udp:[fd63:1a46:cf::1]:53 [dns-out]
10月 21 21:22:44 archlinux v2raya[2922]: [I] [io.go:425] 192.168.10.195:42197 accepted udp:192.168.10.1:53 [dns-out]
10月 21 21:22:44 archlinux v2raya[2922]: [I] [io.go:425] [fd63:1a46:cf::9e2]:39116 accepted udp:[fd63:1a46:cf::1]:53 [dns-out]
10月 21 21:23:02 archlinux v2raya[2922]: [W] [asm_amd64.s:1581] v2ray-core: signal: killed

服务器端错误日志:

// 在这里附上服务器端日志

客户端错误日志:

// 在这里附上客户端日志

请附上访问日志

// 在这里附上服务器端日志

其它相关的配置文件(如 Nginx)和相关日志

如果 V2Ray 无法启动,请附上 --test 命令的输出

如果 V2Ray 服务运行异常,请附上 journal 日志

@kslr
Copy link
Contributor

kslr commented Oct 21, 2021

@nekohasekai
Copy link
Member

nekohasekai commented Oct 23, 2021

7b0699e 可能修复了这个

@nekohasekai nekohasekai linked a pull request Oct 23, 2021 that will close this issue
@ganli
Copy link

ganli commented Oct 25, 2021

7b0699e 可能修复了这个

Yes, I tried this commit, it fixed my issue.
Using 4.42.2 or 4.43.0, there are more than thousands of udp connections (dns query) in my router and seems not recycled.
Using this commit, there are only about 200 udp connections which is acceptable.

@ganli
Copy link

ganli commented Oct 26, 2021

After one day, the udp connections still increase to thousands, seems not fixed.

admin@RT-AC86U-F698:/tmp/home/root# netstat -anp|grep v2ray|grep udp|wc -l
3535

A lot of udp connections like below:
udp 0 0 :::40956 :::* 2275/v2ray
udp 0 0 :::49148 :::* 2275/v2ray
udp 0 0 :::54780 :::* 2275/v2ray
udp 0 0 :::33276 :::* 2275/v2ray
udp 0 0 :::40700 :::* 2275/v2ray

udp 0 0 180.168.255.118:53 10.0.0.88:41068 ESTABLISHED 2275/v2ray
udp 0 0 192.168.50.1:53 192.168.50.35:51115 ESTABLISHED 2275/v2ray
udp 0 0 180.168.255.118:53 10.0.0.88:51530 ESTABLISHED 2275/v2ray
udp 0 0 192.168.50.1:53 192.168.50.35:55965 ESTABLISHED 2275/v2ray
udp 0 0 180.168.255.118:53 10.0.0.88:28519 ESTABLISHED 2275/v2ray
udp 0 0 192.168.50.1:53 192.168.50.35:59954 ESTABLISHED 2275/v2ray

@github-actions
Copy link
Contributor

This issue is stale because it has been open 120 days with no activity. Remove stale label or comment or this will be closed in 5 days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants