Class: Netsoul::Message
- Inherits:
-
Object
- Object
- Netsoul::Message
- Defined in:
- lib/netsoul/message.rb
Class Method Summary collapse
- ._escape(str) ⇒ Object
- ._kerberos_auth_klog(config) ⇒ Object
-
._kerberos_get ⇒ Object
:nocov:.
- ._standard_auth_string(config) ⇒ Object
- ._unescape(str) ⇒ Object
- .attach ⇒ Object
-
.auth_ag ⇒ Object
:nocov:.
- .kerberos_auth(config) ⇒ Object
- .list_users(user_list) ⇒ Object
- .ns_exit ⇒ Object
- .ping ⇒ Object
- .send_message(user, msg) ⇒ Object
- .standard_auth(config) ⇒ Object
- .start_writing_to_user(user) ⇒ Object
- .stop_writing_to_user(user) ⇒ Object
- .user_data(data) ⇒ Object
- .user_state(state, timestamp) ⇒ Object
- .watch_users(user_list) ⇒ Object
- .who_users(user_list) ⇒ Object
- .xfer(user, id, filename, size, desc) ⇒ Object
- .xfer_accept(user, id) ⇒ Object
- .xfer_cancel(user, id) ⇒ Object
- .xfer_data(user, id, data) ⇒ Object
Class Method Details
._escape(str) ⇒ Object
112 113 114 115 |
# File 'lib/netsoul/message.rb', line 112 def _escape(str) str = URI.escape(str, Regexp.new("#{URI::PATTERN::ALNUM}[:graph:][:punct:][:cntrl:][:print:][:blank:]", false, 'N')) URI.escape(str, Regexp.new("[^#{URI::PATTERN::ALNUM}]", false, 'N')) end |
._kerberos_auth_klog(config) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/netsoul/message.rb', line 33 def _kerberos_auth_klog(config) location = Message._escape(config.location) user_group = Message._escape(config.user_group) client_name = Message._escape(config.client_name) "ext_user_klog #{_kerberos_get.token_base64.slice(0, 812)} #{Message._escape(RUBY_PLATFORM)} #{location} #{user_group} #{client_name}" end |
._kerberos_get ⇒ Object
:nocov:
25 26 27 28 29 30 31 |
# File 'lib/netsoul/message.rb', line 25 def _kerberos_get require 'netsoul_kerberos' @netsoul_kerberos ||= NetsoulKerberos.new rescue LoadError => e raise Netsoul::Error, "NetsoulKerberos library not found: #{e}." end |
._standard_auth_string(config) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/netsoul/message.rb', line 10 def _standard_auth_string(config) str = config.user_connection_info[:md5_hash].dup str << "-#{config.user_connection_info[:client_ip]}" str << "/#{config.user_connection_info[:client_port]}#{config.socks_password}" Digest::MD5.hexdigest(str) end |
._unescape(str) ⇒ Object
117 118 119 |
# File 'lib/netsoul/message.rb', line 117 def _unescape(str) URI.unescape str end |
.attach ⇒ Object
76 77 78 |
# File 'lib/netsoul/message.rb', line 76 def attach 'user_cmd attach' end |
.auth_ag ⇒ Object
:nocov:
48 49 50 |
# File 'lib/netsoul/message.rb', line 48 def auth_ag 'auth_ag ext_user none none' end |
.kerberos_auth(config) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/netsoul/message.rb', line 40 def kerberos_auth(config) unless _kerberos_get.build_token(config.login, config.unix_password) raise Netsoul::Error, 'Impossible to retrieve the kerberos token.' end _kerberos_auth_klog(config) end |
.list_users(user_list) ⇒ Object
64 65 66 |
# File 'lib/netsoul/message.rb', line 64 def list_users(user_list) "list_users {#{user_list}}" end |
.ns_exit ⇒ Object
108 109 110 |
# File 'lib/netsoul/message.rb', line 108 def ns_exit 'exit' end |
.ping ⇒ Object
104 105 106 |
# File 'lib/netsoul/message.rb', line 104 def ping 'pong' end |
.send_message(user, msg) ⇒ Object
52 53 54 |
# File 'lib/netsoul/message.rb', line 52 def (user, msg) "user_cmd msg_user #{user} msg #{Message._escape(msg.to_s)}" end |
.standard_auth(config) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/netsoul/message.rb', line 17 def standard_auth(config) client_ip = config.user_connection_info[:client_ip] location = Message._escape(Location.get(client_ip) == 'ext' ? config.location : Location.get(client_ip)) client_name = Message._escape(config.client_name) "ext_user_log #{config.login} #{_standard_auth_string(config)} #{client_name} #{location}" end |
.start_writing_to_user(user) ⇒ Object
56 57 58 |
# File 'lib/netsoul/message.rb', line 56 def start_writing_to_user(user) "user_cmd msg_user #{user} dotnetSoul_UserTyping null" end |
.stop_writing_to_user(user) ⇒ Object
60 61 62 |
# File 'lib/netsoul/message.rb', line 60 def stop_writing_to_user(user) "user_cmd msg_user #{user} dotnetSoul_UserCancelledTyping null" end |
.user_data(data) ⇒ Object
84 85 86 |
# File 'lib/netsoul/message.rb', line 84 def user_data(data) "user_cmd user_data #{Message._escape(data.to_s)}" end |
.user_state(state, timestamp) ⇒ Object
80 81 82 |
# File 'lib/netsoul/message.rb', line 80 def user_state(state, ) "user_cmd state #{state}:#{}" end |
.watch_users(user_list) ⇒ Object
72 73 74 |
# File 'lib/netsoul/message.rb', line 72 def watch_users(user_list) "user_cmd watch_log_user {#{user_list}}" end |
.who_users(user_list) ⇒ Object
68 69 70 |
# File 'lib/netsoul/message.rb', line 68 def who_users(user_list) "user_cmd who {#{user_list}}" end |
.xfer(user, id, filename, size, desc) ⇒ Object
88 89 90 |
# File 'lib/netsoul/message.rb', line 88 def xfer(user, id, filename, size, desc) "user_cmd msg_user #{user} xfer #{Message._escape("#{id} #{filename} #{size} #{desc}")}" end |
.xfer_accept(user, id) ⇒ Object
92 93 94 |
# File 'lib/netsoul/message.rb', line 92 def xfer_accept(user, id) "user_cmd msg_user #{user} xfer_accept #{id}" end |
.xfer_cancel(user, id) ⇒ Object
100 101 102 |
# File 'lib/netsoul/message.rb', line 100 def xfer_cancel(user, id) "user_cmd msg_user #{user} xfer_cancel #{id}" end |