mirror of
https://github.com/SagerNet/sing-box.git
synced 2026-05-13 13:57:05 +00:00
ssh: Add cipher, MAC, and key exchange configuration
This commit is contained in:
parent
78f502d016
commit
610aa9432d
4 changed files with 72 additions and 0 deletions
|
|
@ -42,6 +42,9 @@ type Outbound struct {
|
|||
user string
|
||||
hostKey []ssh.PublicKey
|
||||
hostKeyAlgorithms []string
|
||||
cipher []string
|
||||
mac []string
|
||||
kexAlgorithm []string
|
||||
clientVersion string
|
||||
authMethod []ssh.AuthMethod
|
||||
clientAccess sync.Mutex
|
||||
|
|
@ -62,6 +65,9 @@ func NewOutbound(ctx context.Context, router adapter.Router, logger log.ContextL
|
|||
serverAddr: options.ServerOptions.Build(),
|
||||
user: options.User,
|
||||
hostKeyAlgorithms: options.HostKeyAlgorithms,
|
||||
cipher: options.Cipher,
|
||||
mac: options.MAC,
|
||||
kexAlgorithm: options.KexAlgorithm,
|
||||
clientVersion: options.ClientVersion,
|
||||
}
|
||||
if outbound.serverAddr.Port == 0 {
|
||||
|
|
@ -155,6 +161,15 @@ func (s *Outbound) connect() (*ssh.Client, error) {
|
|||
return E.New("host key mismatch, server send ", key.Type(), " ", base64.StdEncoding.EncodeToString(serverKey))
|
||||
},
|
||||
}
|
||||
if len(s.cipher) > 0 {
|
||||
config.Ciphers = s.cipher
|
||||
}
|
||||
if len(s.mac) > 0 {
|
||||
config.MACs = s.mac
|
||||
}
|
||||
if len(s.kexAlgorithm) > 0 {
|
||||
config.KeyExchanges = s.kexAlgorithm
|
||||
}
|
||||
clientConn, chans, reqs, err := ssh.NewClientConn(conn, s.serverAddr.Addr.String(), config)
|
||||
if err != nil {
|
||||
conn.Close()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue