Skip to content

Commit

Permalink
libssh2 init
Browse files Browse the repository at this point in the history
  • Loading branch information
sshterm committed Sep 13, 2024
1 parent f03eea9 commit 0460957
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/SSH.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ public class SSH {
self.debug = debug
self.blocking = blocking
self.keepalive = keepalive
libssh2_init(0)
}

/// 关闭 SSH 会话和 Socket 连接。
Expand Down Expand Up @@ -155,15 +154,16 @@ public class SSH {
libssh2_session_disconnect_ex(rawSession, SSH_DISCONNECT_BY_APPLICATION, "SSH Term: Disconnect", "")
}
libssh2_session_free(rawSession)
libssh2_exit()
shutdown(.w)
close(.socket)
self.rawSession = nil
}
}
}

/// 析构函数,‌用于清理资源。‌

deinit {
libssh2_exit()

}
}
3 changes: 2 additions & 1 deletion src/Session.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ public extension SSH {
}
SSH.getSSH(from: sess)?.trace(message: message, messageLen: messageLen)
}


libssh2_init(0)
rawSession = libssh2_session_init_ex(nil, nil, nil, Unmanaged.passUnretained(self).toOpaque())

_ = methods.map { (key: SSHMethod, value: String) in
Expand Down

0 comments on commit 0460957

Please sign in to comment.