Class: LibSSH::Session
- Inherits:
-
Object
- Object
- LibSSH::Session
- Defined in:
- ext/libssh_ruby/session.c
Instance Method Summary collapse
- #add_identity(path) ⇒ Object
- #connect ⇒ Object
- #get_publickey ⇒ Object
- #host=(host) ⇒ Object
- #initialize ⇒ Object constructor
- #log_verbosity=(verbosity) ⇒ Object
- #parse_config(*args) ⇒ Object
- #server_known ⇒ Object
- #userauth_list ⇒ Object
- #userauth_none ⇒ Object
- #userauth_publickey_auto ⇒ Object
- #write_knownhost ⇒ Object
Constructor Details
#initialize ⇒ Object
52 53 54 55 56 57 58 |
# File 'ext/libssh_ruby/session.c', line 52 static VALUE m_initialize(VALUE self) { SessionHolder *holder; TypedData_Get_Struct(self, SessionHolder, &session_type, holder); holder->session = ssh_new(); return self; } |
Instance Method Details
#add_identity(path) ⇒ Object
120 121 122 123 124 125 126 127 128 |
# File 'ext/libssh_ruby/session.c', line 120 static VALUE m_add_identity(VALUE self, VALUE path) { SessionHolder *holder; TypedData_Get_Struct(self, SessionHolder, &session_type, holder); RAISE_IF_ERROR((holder->session, SSH_OPTIONS_ADD_IDENTITY, StringValueCStr(path))); return Qnil; } |
#connect ⇒ Object
141 142 143 144 145 146 147 148 149 150 151 |
# File 'ext/libssh_ruby/session.c', line 141 static VALUE m_connect(VALUE self) { SessionHolder *holder; struct nogvl_session_args args; TypedData_Get_Struct(self, SessionHolder, &session_type, holder); args.session = holder->session; rb_thread_call_without_gvl(nogvl_connect, &args, RUBY_UBF_IO, NULL); RAISE_IF_ERROR(args.rc); return Qnil; } |
#get_publickey ⇒ Object
221 222 223 224 225 226 227 228 229 230 231 |
# File 'ext/libssh_ruby/session.c', line 221 static VALUE m_get_publickey(VALUE self) { SessionHolder *holder; KeyHolder *key_holder; VALUE key; TypedData_Get_Struct(self, SessionHolder, &session_type, holder); key = rb_obj_alloc(rb_cLibSSHKey); key_holder = libssh_ruby_key_holder(key); RAISE_IF_ERROR(ssh_get_publickey(holder->session, &key_holder->key)); return key; } |
#host=(host) ⇒ Object
89 90 91 92 93 94 95 96 97 |
# File 'ext/libssh_ruby/session.c', line 89 static VALUE m_set_host(VALUE self, VALUE host) { SessionHolder *holder; TypedData_Get_Struct(self, SessionHolder, &session_type, holder); RAISE_IF_ERROR((holder->session, SSH_OPTIONS_HOST, StringValueCStr(host))); return Qnil; } |
#log_verbosity=(verbosity) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'ext/libssh_ruby/session.c', line 60 static VALUE m_set_log_verbosity(VALUE self, VALUE verbosity) { ID id_verbosity; int c_verbosity; SessionHolder *holder; Check_Type(verbosity, T_SYMBOL); id_verbosity = SYM2ID(verbosity); if (id_verbosity == id_none) { c_verbosity = SSH_LOG_NONE; } else if (id_verbosity == id_warn) { c_verbosity = SSH_LOG_WARN; } else if (id_verbosity == id_info) { c_verbosity = SSH_LOG_INFO; } else if (id_verbosity == id_debug) { c_verbosity = SSH_LOG_DEBUG; } else if (id_verbosity == id_trace) { c_verbosity = SSH_LOG_TRACE; } else { rb_raise(rb_eArgError, "invalid verbosity: %" PRIsVALUE, verbosity); } TypedData_Get_Struct(self, SessionHolder, &session_type, holder); RAISE_IF_ERROR((holder->session, SSH_OPTIONS_LOG_VERBOSITY, &c_verbosity)); return Qnil; } |
#parse_config(*args) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'ext/libssh_ruby/session.c', line 99 static VALUE m_parse_config(int argc, VALUE *argv, VALUE self) { SessionHolder *holder; VALUE path; char *c_path; rb_scan_args(argc, argv, "01", &path); if (NIL_P(path)) { c_path = NULL; } else { c_path = StringValueCStr(path); } TypedData_Get_Struct(self, SessionHolder, &session_type, holder); if ((holder->session, c_path) == 0) { return Qtrue; } else { return Qfalse; } } |
#server_known ⇒ Object
153 154 155 156 157 158 159 160 161 |
# File 'ext/libssh_ruby/session.c', line 153 static VALUE m_server_known(VALUE self) { SessionHolder *holder; int rc; TypedData_Get_Struct(self, SessionHolder, &session_type, holder); rc = ssh_is_server_known(holder->session); RAISE_IF_ERROR(rc); return INT2FIX(rc); } |
#userauth_list ⇒ Object
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'ext/libssh_ruby/session.c', line 173 static VALUE m_userauth_list(VALUE self) { SessionHolder *holder; int list; VALUE ary; TypedData_Get_Struct(self, SessionHolder, &session_type, holder); list = ssh_userauth_list(holder->session, NULL); RAISE_IF_ERROR(list); ary = rb_ary_new(); if (list & SSH_AUTH_METHOD_NONE) { rb_ary_push(ary, ID2SYM(id_none)); } if (list & SSH_AUTH_METHOD_PASSWORD) { rb_ary_push(ary, ID2SYM(id_password)); } if (list & SSH_AUTH_METHOD_PUBLICKEY) { rb_ary_push(ary, ID2SYM(id_publickey)); } if (list & SSH_AUTH_METHOD_HOSTBASED) { rb_ary_push(ary, ID2SYM(id_hostbased)); } if (list & SSH_AUTH_METHOD_INTERACTIVE) { rb_ary_push(ary, ID2SYM(id_interactive)); } if (list & SSH_AUTH_METHOD_GSSAPI_MIC) { rb_ary_push(ary, ID2SYM(id_gssapi_mic)); } return ary; } |
#userauth_none ⇒ Object
163 164 165 166 167 168 169 170 171 |
# File 'ext/libssh_ruby/session.c', line 163 static VALUE m_userauth_none(VALUE self) { SessionHolder *holder; int rc; TypedData_Get_Struct(self, SessionHolder, &session_type, holder); rc = ssh_userauth_none(holder->session, NULL); RAISE_IF_ERROR(rc); return INT2FIX(rc); } |
#userauth_publickey_auto ⇒ Object
210 211 212 213 214 215 216 217 218 219 |
# File 'ext/libssh_ruby/session.c', line 210 static VALUE m_userauth_publickey_auto(VALUE self) { SessionHolder *holder; struct nogvl_session_args args; TypedData_Get_Struct(self, SessionHolder, &session_type, holder); args.session = holder->session; rb_thread_call_without_gvl(nogvl_userauth_publickey_auto, &args, RUBY_UBF_IO, NULL); return INT2FIX(args.rc); } |
#write_knownhost ⇒ Object
233 234 235 236 237 238 239 |
# File 'ext/libssh_ruby/session.c', line 233 static VALUE m_write_knownhost(VALUE self) { SessionHolder *holder; holder = libssh_ruby_session_holder(self); RAISE_IF_ERROR(ssh_write_knownhost(holder->session)); return Qnil; } |