sing-box icon indicating copy to clipboard operation
sing-box copied to clipboard

Implementing ListenPacket Function for SSH Outbound in Sing-box (关于Sing-box中SSH出站实现的ListenPacket功能的咨询与建议)

Open x1aoj1ang opened this issue 3 years ago • 0 comments

Operating system

Windows

System version

win11

Installation type

Original sing-box Command Line

If you are using a graphical client, please provide the version of the client.

No response

Version

1.6.6

Description

Hello Sing-box Developers,

I hope this message finds you well. I am writing to discuss an observation I've made regarding the SSH and Hysteria outbound implementations in Sing-box.

Upon reviewing the code, I noticed a disparity in the implementation of the ListenPacket function between the SSH and Hysteria outbounds. Specifically, for the SSH outbound, the function func (s *SSH) ListenPacket(ctx context.Context, destination M.Socksaddr) (net.PacketConn, error) currently returns nil, os.ErrInvalid, indicating a lack of specific implementation:

https://github.com/SagerNet/sing-box/blob/125691d59f607a7a76c5ac77e0894e2df5496d51/outbound/ssh.go#L200

func (s *SSH) ListenPacket(ctx context.Context, destination M.Socksaddr) (net.PacketConn, error) {
    return nil, os.ErrInvalid
}

In contrast, the Hysteria outbound has a detailed implementation of this function:

https://github.com/SagerNet/sing-box/blob/125691d59f607a7a76c5ac77e0894e2df5496d51/outbound/hysteria.go#L120

func (h *Hysteria) ListenPacket(ctx context.Context, destination M.Socksaddr) (net.PacketConn, error) {
    h.logger.InfoContext(ctx, "outbound packet connection to ", destination)
    return h.client.ListenPacket(ctx, destination)
}

Given that SSH tunnels are capable of supporting UDP forwarding, akin to SOCKS, I am curious about the rationale behind not including a similar implementation for the SSH outbound. Is this due to specific design choices or limitations inherent to the SSH protocol in this context?

I am interested in contributing to this project by potentially implementing this functionality for the SSH outbound, akin to what is done for Hysteria. Before proceeding, I wanted to check with you regarding the feasibility and your openness to such a contribution.

Would you be open to a Merge Request that addresses this functionality gap? If there are any specific guidelines or considerations I should be aware of while working on this, please let me know.

Thank you for your time and the effort you put into maintaining and developing Sing-box. I look forward to hearing your thoughts on this matter.

Best regards

尊敬的Sing-box开发团队,

您好!我在看Sing-box项目的代码时,注意到SSH和Hysteria出站实现在ListenPacket函数方面存在一些差异。

具体来说,在SSH出站的部分,函数func (s *SSH) ListenPacket(ctx context.Context, destination M.Socksaddr) (net.PacketConn, error)目前返回nil, os.ErrInvalid,暗示这一部分并没有具体实现:

go Copy code func (s *SSH) ListenPacket(ctx context.Context, destination M.Socksaddr) (net.PacketConn, error) { return nil, os.ErrInvalid } 与此相对照的是,Hysteria出站则对这个函数有详细的实现:

go Copy code func (h *Hysteria) ListenPacket(ctx context.Context, destination M.Socksaddr) (net.PacketConn, error) { h.logger.InfoContext(ctx, "outbound packet connection to ", destination) return h.client.ListenPacket(ctx, destination) } 考虑到SSH隧道也支持UDP转发(类似SOCKS),我很好奇为何没有在SSH出站部分加入类似的实现。这是出于什么样的设计考虑或是SSH协议在这一上下文中的特定限制吗?

我对为这个项目作出贡献表示出了兴趣,特别是可能为SSH出站实现这一功能。在开始工作之前,我想了解一下您对此类贡献的看法和接受度。

您是否欢迎一个针对此功能差异的合并请求(Merge Request)?如果在我进行这项工作时有任何特定的指导方针或考虑,烦请告知。

感谢您投入时间以及为维护和开发Sing-box所做的努力。期待您对此事的回复。

Reproduction

。

Logs

# Replace this line with logs

x1aoj1ang avatar Nov 22 '23 03:11 x1aoj1ang