[GH-ISSUE #5121] [Feature Request] frpc api 可以获取 xtcp是否p2p成功吗?现在好像只能看日志确认visitor结果 #4007

Closed
opened 2026-05-05 14:32:48 -06:00 by gitea-mirror · 3 comments
Owner

Originally created by @litrycn on GitHub (Jan 10, 2026).
Original GitHub issue: https://github.com/fatedier/frp/issues/5121

Describe the feature request

frpc api 可以知道 xtcp是否p2p成功吗?现在好像只能看日志确认visitor结果
http://xxx.com/api/status 看不到xtcp、stcp、sudp的相关数据

Describe alternatives you've considered

No response

Affected area

  • Docs
  • Installation
  • Performance and Scalability
  • Security
  • User Experience
  • Test and Release
  • Developer Infrastructure
  • Client Plugin
  • Server Plugin
  • Extensions
  • Others
Originally created by @litrycn on GitHub (Jan 10, 2026). Original GitHub issue: https://github.com/fatedier/frp/issues/5121 ### Describe the feature request frpc api 可以知道 xtcp是否p2p成功吗?现在好像只能看日志确认visitor结果 http://xxx.com/api/status 看不到xtcp、stcp、sudp的相关数据 ### Describe alternatives you've considered _No response_ ### Affected area - [ ] Docs - [ ] Installation - [ ] Performance and Scalability - [ ] Security - [ ] User Experience - [ ] Test and Release - [ ] Developer Infrastructure - [ ] Client Plugin - [ ] Server Plugin - [ ] Extensions - [ ] Others
Author
Owner

@litrycn commented on GitHub (Jan 10, 2026):

cli status 也看不到p2p结果
./frpc_linux_amd64 status -c ./frpc.json

<!-- gh-comment-id:3732502908 --> @litrycn commented on GitHub (Jan 10, 2026): cli status 也看不到p2p结果 ./frpc_linux_amd64 status -c ./frpc.json
Author
Owner

@litrycn commented on GitHub (Jan 14, 2026):

使用场景:vps是1M的小水管,目前在多地部署了frpc,检查发现 p2p打洞都是部分能打通。
比如:A、B、C三个,AC点对点失败,但是 AB、BC可以点对点成功,

目前可以通过 xtcp将A的3389端口转发到B的13389端口,B再通过13389端口转发到C13389端口,实现 在C地访问A的windows电脑

现在要获取结果比较麻烦,需要单独部署日志检查服务

cat /opt/frp/xtcp.php
<?php
$cmd = "/usr/bin/tail -100 /tmp/frpc.log | /bin/grep 'xtcp.go:154' | /bin/grep success | /usr/bin/awk '{gsub(/[\\[\\]]/,\"\",$6);print $6}' | /usr/bin/sort -u";
$com="tail -100 /tmp/frpc.log | grep 'xtcp' | grep success | awk '{print $6}' | sort -u| tr -d '[]'";
exec($cmd, $out);
exit(implode(",",$out));
?>

在vps 用php调用每一个节点的成功记录,聚合结果

$r=[];
foreach (explode(',', implode(',', array_map(fn($u)=>trim(@file_get_contents($u))?:'', [
    'http://xxx1.com/',
    'http://xxx2.com/',
    'http://xxx3.com/',
])) ) as $v)
    if (($a=explode('_',$v)) && count($a)>=5)
        $r[$a[0]][]=$a[2];
echo json_encode($r, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);

最终获取到点对点的结果:
{
"nat-1": [
"nat-2",
"nat-4",
],
"nat-2": [
"nat-1",
"nat-4",
"nat-aoc"
],
"nat-4": [
"nat-1"
]
}

在nat-4家里 访问nat-aoc,可以通过 nat-4 -> nat-1 -> nat-2 -> nat-aoc ,结合frpc webServer 加载proxies 实现 p2p访问

nat-aoc与nat-1实际上也可以点对点连接的,只是nat-aoc是windwos不好获取log结果,现在使用nat-4 -> nat-1 -> nat-aoc 不通过frps服务器节点实现 点对点对点 中继访问

<!-- gh-comment-id:3747464471 --> @litrycn commented on GitHub (Jan 14, 2026): 使用场景:vps是1M的小水管,目前在多地部署了frpc,检查发现 p2p打洞都是部分能打通。 比如:A、B、C三个,AC点对点失败,但是 AB、BC可以点对点成功, 目前可以通过 xtcp将A的3389端口转发到B的13389端口,B再通过13389端口转发到C13389端口,实现 在C地访问A的windows电脑 现在要获取结果比较麻烦,需要单独部署日志检查服务 ``` cat /opt/frp/xtcp.php <?php $cmd = "/usr/bin/tail -100 /tmp/frpc.log | /bin/grep 'xtcp.go:154' | /bin/grep success | /usr/bin/awk '{gsub(/[\\[\\]]/,\"\",$6);print $6}' | /usr/bin/sort -u"; $com="tail -100 /tmp/frpc.log | grep 'xtcp' | grep success | awk '{print $6}' | sort -u| tr -d '[]'"; exec($cmd, $out); exit(implode(",",$out)); ?> ``` 在vps 用php调用每一个节点的成功记录,聚合结果 ``` $r=[]; foreach (explode(',', implode(',', array_map(fn($u)=>trim(@file_get_contents($u))?:'', [ 'http://xxx1.com/', 'http://xxx2.com/', 'http://xxx3.com/', ])) ) as $v) if (($a=explode('_',$v)) && count($a)>=5) $r[$a[0]][]=$a[2]; echo json_encode($r, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); ``` 最终获取到点对点的结果: { "nat-1": [ "nat-2", "nat-4", ], "nat-2": [ "nat-1", "nat-4", "nat-aoc" ], "nat-4": [ "nat-1" ] } 在nat-4家里 访问nat-aoc,可以通过 nat-4 -> nat-1 -> nat-2 -> nat-aoc ,结合frpc webServer 加载proxies 实现 p2p访问 nat-aoc与nat-1实际上也可以点对点连接的,只是nat-aoc是windwos不好获取log结果,现在使用nat-4 -> nat-1 -> nat-aoc 不通过frps服务器节点实现 点对点对点 中继访问
Author
Owner

@litrycn commented on GitHub (Jan 19, 2026):

用ai自行优化了

curl 'http://frpc.xxxx.com/api/xtcp' -H "Host: test" -u "test:1!p@s5" -s | jq
{
  "test-nat_xtcp_nat-1_22_35601": 1768788481,
  "test-nat_xtcp_nat-2_22_35602": 1768788481,
  "test-nat_xtcp_nat-4_22_35604": 1768788481,
  "test-nat_xtcp_nat-aoc_3389_33890": 1768788481
}
<!-- gh-comment-id:3766091653 --> @litrycn commented on GitHub (Jan 19, 2026): 用ai自行优化了 ``` curl 'http://frpc.xxxx.com/api/xtcp' -H "Host: test" -u "test:1!p@s5" -s | jq { "test-nat_xtcp_nat-1_22_35601": 1768788481, "test-nat_xtcp_nat-2_22_35602": 1768788481, "test-nat_xtcp_nat-4_22_35604": 1768788481, "test-nat_xtcp_nat-aoc_3389_33890": 1768788481 } ```
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: github-starred/frp#4007
No description provided.