From d3d35387b7b8674f0f79fdb9943e5c73b6da53fd Mon Sep 17 00:00:00 2001 From: voidint Date: Tue, 30 Jul 2024 12:08:31 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=B8=BA=E6=B7=BB=E5=8A=A0=E6=B3=A8?= =?UTF-8?q?=E9=87=8A=E5=AF=BC=E8=87=B4lint=E6=9C=AA=E9=80=9A=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cache/redis.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cache/redis.go b/cache/redis.go index 9bb4323..3187569 100644 --- a/cache/redis.go +++ b/cache/redis.go @@ -120,6 +120,7 @@ const ( PwdAuth SSHAuthMethod = 2 ) +// OverSSH SSH 代理配置 type OverSSH struct { Host string `yml:"host" json:"host"` Port int `yml:"port" json:"port"` @@ -129,6 +130,7 @@ type OverSSH struct { KeyFile string `yml:"key_file" json:"key_file"` } +// DialWithPassword 返回密码方式认证的 SSH 客户端 func (s *OverSSH) DialWithPassword() (*ssh.Client, error) { return ssh.Dial( "tcp", @@ -143,6 +145,7 @@ func (s *OverSSH) DialWithPassword() (*ssh.Client, error) { ) } +// DialWithKeyFile 返回公钥方式认证的 SSH 客户端 func (s *OverSSH) DialWithKeyFile() (*ssh.Client, error) { k, err := os.ReadFile(s.KeyFile) if err != nil { @@ -166,6 +169,7 @@ func (s *OverSSH) DialWithKeyFile() (*ssh.Client, error) { ) } +// MakeDialer 创建 SSH 代理拨号器 func (s *OverSSH) MakeDialer() func(ctx context.Context, network, addr string) (net.Conn, error) { return func(ctx context.Context, network, addr string) (net.Conn, error) { var err error