[GH-ISSUE #2934] [Feature Request] 希望加入对隐藏unix套接字支持 #2340

Closed
opened 2026-05-05 13:30:31 -06:00 by gitea-mirror · 8 comments
Owner

Originally created by @jaskle on GitHub (May 11, 2022).
Original GitHub issue: https://github.com/fatedier/frp/issues/2934

Originally assigned to: @blizard863 on GitHub.

Describe the feature request

如果使用隐藏的unix套接字,
plugin_unix_path=@webview_devtools_remote_25468
将无法访问

netstat -npla | grep @
能够看到这些隐藏的套接字(使用-a参数)

我需要将@改为0x00来使用它
我在源码中进行了修改,功能可用

Describe alternatives you've considered

源码上做了修改
`

func NewUnixDomainSocketPlugin(params map[string]string) (p Plugin, err error) {
unixPath, ok := params["plugin_unix_path"]
if !ok {
err = fmt.Errorf("plugin_unix_path not found")
return
}

// ++++++++++
unixPath = strings.Replace(unixPath, "@", "\x00", -1)
// ++++++++++

unixAddr, errRet := net.ResolveUnixAddr("unix", unixPath)
if errRet != nil {
	err = errRet
	return
}

p = &UnixDomainSocketPlugin{
	UnixAddr: unixAddr,
}
return

}
`

Affected area

  • Docs
  • Installation
  • Performance and Scalability
  • Security
  • User Experience
  • Test and Release
  • Developer Infrastructure
  • Client Plugin
  • Server Plugin
  • Extensions
  • Others
Originally created by @jaskle on GitHub (May 11, 2022). Original GitHub issue: https://github.com/fatedier/frp/issues/2934 Originally assigned to: @blizard863 on GitHub. ### Describe the feature request 如果使用隐藏的unix套接字, plugin_unix_path=@webview_devtools_remote_25468 将无法访问 netstat -npla | grep @ 能够看到这些隐藏的套接字(使用-a参数) 我需要将@改为0x00来使用它 我在源码中进行了修改,功能可用 ### Describe alternatives you've considered 源码上做了修改 ` func NewUnixDomainSocketPlugin(params map[string]string) (p Plugin, err error) { unixPath, ok := params["plugin_unix_path"] if !ok { err = fmt.Errorf("plugin_unix_path not found") return } // ++++++++++ unixPath = strings.Replace(unixPath, "@", "\x00", -1) // ++++++++++ unixAddr, errRet := net.ResolveUnixAddr("unix", unixPath) if errRet != nil { err = errRet return } p = &UnixDomainSocketPlugin{ UnixAddr: unixAddr, } return } ` ### Affected area - [ ] Docs - [ ] Installation - [ ] Performance and Scalability - [ ] Security - [ ] User Experience - [ ] Test and Release - [ ] Developer Infrastructure - [X] Client Plugin - [ ] Server Plugin - [ ] Extensions - [ ] Others
gitea-mirror 2026-05-05 13:30:31 -06:00
Author
Owner

@jaskle commented on GitHub (May 11, 2022):

提供一下相关的文献:
https://man7.org/linux/man-pages/man7/unix.7.html

sun_path[0] 部分

   *  abstract: an abstract socket address is distinguished (from a
      pathname socket) by the fact that sun_path[0] is a null byte
      ('\0').  The socket's address in this namespace is given by
      the additional bytes in sun_path that are covered by the
      specified length of the address structure.  (Null bytes in the
      name have no special significance.)  The name has no
      connection with filesystem pathnames.  When the address of an
      abstract socket is returned, the returned addrlen is greater
      than sizeof(sa_family_t) (i.e., greater than 2), and the name
      of the socket is contained in the first (addrlen -
      sizeof(sa_family_t)) bytes of sun_path.
<!-- gh-comment-id:1123450325 --> @jaskle commented on GitHub (May 11, 2022): 提供一下相关的文献: https://man7.org/linux/man-pages/man7/unix.7.html sun_path[0] 部分 * abstract: an abstract socket address is distinguished (from a pathname socket) by the fact that sun_path[0] is a null byte ('\0'). The socket's address in this namespace is given by the additional bytes in sun_path that are covered by the specified length of the address structure. (Null bytes in the name have no special significance.) The name has no connection with filesystem pathnames. When the address of an abstract socket is returned, the returned addrlen is greater than sizeof(sa_family_t) (i.e., greater than 2), and the name of the socket is contained in the first (addrlen - sizeof(sa_family_t)) bytes of sun_path.
Author
Owner

@koho commented on GitHub (May 11, 2022):

@ 应该只替换开头的

if strings.HasPrefix(unixPath, "@") {
    unixPath = "\x00" + unixPath[1:]
}
<!-- gh-comment-id:1123717552 --> @koho commented on GitHub (May 11, 2022): @ 应该只替换开头的 ```go if strings.HasPrefix(unixPath, "@") { unixPath = "\x00" + unixPath[1:] } ```
Author
Owner

@blizard863 commented on GitHub (May 12, 2022):

I cannot reproduce your problem.

I test in

Debian 9 linux 4.14
frp 0.42.0 version


[plugin_unix_domain_socket]
type = tcp
remote_port = 6003
plugin = unix_domain_socket
plugin_unix_path = @/tmp/frpc_plugin.sock

It just success.

I believe golang is compatible with this scenario

<!-- gh-comment-id:1125000268 --> @blizard863 commented on GitHub (May 12, 2022): I cannot reproduce your problem. I test in ``` Debian 9 linux 4.14 frp 0.42.0 version [plugin_unix_domain_socket] type = tcp remote_port = 6003 plugin = unix_domain_socket plugin_unix_path = @/tmp/frpc_plugin.sock ``` It just success. I believe golang is compatible with this scenario
Author
Owner

@jaskle commented on GitHub (May 12, 2022):

创建隐藏套接字也需要用0x00开头,netstat里会在开头显示@,
这个特性常被用到调试套接字,尤其在Android系统。
正常业务一般用不到。

<!-- gh-comment-id:1125010068 --> @jaskle commented on GitHub (May 12, 2022): 创建隐藏套接字也需要用0x00开头,netstat里会在开头显示@, 这个特性常被用到调试套接字,尤其在Android系统。 正常业务一般用不到。
Author
Owner

@blizard863 commented on GitHub (May 12, 2022):

Can you tell me how to reproduce this problem ? Such as your frpc & frps total config, and your testing os. @jaskle

<!-- gh-comment-id:1125026505 --> @blizard863 commented on GitHub (May 12, 2022): Can you tell me how to reproduce this problem ? Such as your frpc & frps total config, and your testing os. @jaskle
Author
Owner

@koho commented on GitHub (May 12, 2022):

It seems that this case has been covered by golang:

17371eea25/src/syscall/syscall_linux.go (L517)

<!-- gh-comment-id:1125046633 --> @koho commented on GitHub (May 12, 2022): It seems that this case has been covered by golang: https://github.com/golang/go/blob/17371eea25f203575389f85b33ddb58792d25e84/src/syscall/syscall_linux.go#L517
Author
Owner

@jaskle commented on GitHub (May 12, 2022):

看起来是个很有意思的话题,
我其实是为了调试4g手机用户web应用出现的bug,webview在调试模式将产生一个隐藏的域套接字,然后我通过frp映射到我的服务器。
你们不必在意,这个功能不重要。

<!-- gh-comment-id:1125057687 --> @jaskle commented on GitHub (May 12, 2022): 看起来是个很有意思的话题, 我其实是为了调试4g手机用户web应用出现的bug,webview在调试模式将产生一个隐藏的域套接字,然后我通过frp映射到我的服务器。 你们不必在意,这个功能不重要。
Author
Owner

@github-actions[bot] commented on GitHub (Jun 12, 2022):

Issues go stale after 30d of inactivity. Stale issues rot after an additional 7d of inactivity and eventually close.

<!-- gh-comment-id:1153030218 --> @github-actions[bot] commented on GitHub (Jun 12, 2022): Issues go stale after 30d of inactivity. Stale issues rot after an additional 7d of inactivity and eventually close.
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#2340
No description provided.