Module: Pssh
- Defined in:
- lib/pssh.rb,
lib/pssh/cli.rb,
lib/pssh/pty.rb,
lib/pssh/web.rb,
lib/pssh/client.rb,
lib/pssh/socket.rb,
lib/pssh/console.rb,
lib/pssh/version.rb
Defined Under Namespace
Classes: CLI, Client, Console, Pty, Socket, Web
Constant Summary collapse
- DEFAULT_IO_MODE =
'rw'
- DEFAULT_SOCKET_PREFIX =
'pssh'
- DEFAULT_PORT =
8022
- DEFAULT_CACHE_LENGTH =
4096
- PSSH_DOMAIN =
'pssh.herokuapp.com'
- VERSION =
"0.3.3"
Class Attribute Summary collapse
-
.cache_length ⇒ Object
Public: This sets the amount of data that will be stored to show new connections when they join.
-
.client ⇒ Object
Returns the value of attribute client.
-
.command ⇒ Object
Public: This is the tool which we are going to use for our multiplexing.
-
.io_mode ⇒ Object
Public: This sets whether the connecting user can just view or can also write to the screen.
- .open_sessions ⇒ Object
- .port ⇒ Object
-
.prompt ⇒ Object
Public: This is the prompt character that shows up at the beginning of Pssh’s console.
-
.pty ⇒ Object
Returns the value of attribute pty.
-
.socket ⇒ Object
Returns the value of attribute socket.
-
.socket_path ⇒ Object
Returns the value of attribute socket_path.
-
.socket_prefix ⇒ Object
Public: This is the prefix that will be used to set up the socket for tmux or screen.
-
.web ⇒ Object
Returns the value of attribute web.
Class Method Summary collapse
- .base_path ⇒ Object
-
.configure {|_self| ... } ⇒ Object
Public: Allow configuring details of Pssh by making use of a block.
-
.create_session(username = nil) ⇒ Object
Public: Generates a random id for a session and stores it to a list.
-
.default_socket_path ⇒ Object
Public: This is the default socket path that will be used if one is not provided in the command line arguments.
-
.share_url ⇒ Object
Public: This method retrieves the current IP address and compresses it into a short url that can be shared to redirect to your site.
Class Attribute Details
.cache_length ⇒ Object
Public: This sets the amount of data that will be stored to show new connections when they join.
76 77 78 |
# File 'lib/pssh.rb', line 76 def cache_length @cache_length end |
.client ⇒ Object
Returns the value of attribute client.
38 39 40 |
# File 'lib/pssh.rb', line 38 def client @client end |
.command ⇒ Object
Public: This is the tool which we are going to use for our multiplexing. If we’re currently in a tmux or screen session, that is the first option, then it checks if tmux or screen is installed, and then it resorts to a plain old shell.
Returns a Symbol.
101 102 103 104 105 106 107 108 |
# File 'lib/pssh.rb', line 101 def command @command ||= (ENV['TMUX'] && :tmux) || (ENV['STY'] && :screen) || :shell #(`which tmux` && :tmux) || #(`which screen` && :screen) || end |
.io_mode ⇒ Object
Public: This sets whether the connecting user can just view or can also write to the screen. Values are ‘rw, ’r’, and ‘w’.
Returns a String.
59 60 61 |
# File 'lib/pssh.rb', line 59 def io_mode @io_mode ||= DEFAULT_IO_MODE end |
.open_sessions ⇒ Object
51 52 53 |
# File 'lib/pssh.rb', line 51 def open_sessions @open_sessions ||= {} end |
.port ⇒ Object
47 48 49 |
# File 'lib/pssh.rb', line 47 def port @port ||= DEFAULT_PORT end |
.prompt ⇒ Object
Public: This is the prompt character that shows up at the beginning of Pssh’s console.
Returns a String.
122 123 124 |
# File 'lib/pssh.rb', line 122 def prompt @prompt ||= "\u26a1 " end |
.pty ⇒ Object
Returns the value of attribute pty.
40 41 42 |
# File 'lib/pssh.rb', line 40 def pty @pty end |
.socket ⇒ Object
Returns the value of attribute socket.
39 40 41 |
# File 'lib/pssh.rb', line 39 def socket @socket end |
.socket_path ⇒ Object
Returns the value of attribute socket_path.
36 37 38 |
# File 'lib/pssh.rb', line 36 def socket_path @socket_path end |
.socket_prefix ⇒ Object
Public: This is the prefix that will be used to set up the socket for tmux or screen.
Returns a String.
83 84 85 |
# File 'lib/pssh.rb', line 83 def socket_prefix @socket_prefix ||= DEFAULT_SOCKET_PREFIX end |
.web ⇒ Object
Returns the value of attribute web.
41 42 43 |
# File 'lib/pssh.rb', line 41 def web @web end |
Class Method Details
.base_path ⇒ Object
43 44 45 |
# File 'lib/pssh.rb', line 43 def base_path File.dirname(__FILE__) + "/.." end |
.configure {|_self| ... } ⇒ Object
Public: Allow configuring details of Pssh by making use of a block.
Returns True.
113 114 115 116 |
# File 'lib/pssh.rb', line 113 def configure yield self true end |
.create_session(username = nil) ⇒ Object
Public: Generates a random id for a session and stores it to a list.
Returns a String.
129 130 131 132 133 |
# File 'lib/pssh.rb', line 129 def create_session(username=nil) id = SecureRandom.uuid self.open_sessions[id] = username id end |
.default_socket_path ⇒ Object
Public: This is the default socket path that will be used if one is not provided in the command line arguments.
Returns a String.
91 92 93 |
# File 'lib/pssh.rb', line 91 def default_socket_path @socket_path ||= "#{socket_prefix}-#{SecureRandom.uuid}" end |
.share_url ⇒ Object
Public: This method retrieves the current IP address and compresses it into a short url that can be shared to redirect to your site.
65 66 67 68 69 70 71 72 |
# File 'lib/pssh.rb', line 65 def share_url return @share_url if @share_url ip = open("http://#{PSSH_DOMAIN}/ip").read .split('.') .map { |x| x.to_i.to_s(36).rjust(2,'0') } .join('') @share_url = "http://#{PSSH_DOMAIN}/#{ip}#{port.to_i.to_s(36)}" end |