GetLiveRadiationAndWeather: Retrieves live solar radiation and weather data.
GetLiveAdvancedPvPower: Retrieves advanced PV power live data.
GetLiveRooftopPvPower: Retrieves live rooftop PV power data based on location and other parameters.
ForecastClient
GetForecastRadiationAndWeather: Retrieves irradiance and weather forecasts for the requested location from the present up to 14 days ahead
GetForecastAdvancedPvPower: Retrieves advanced PV power forecasts with customizable options.
GetForecastRooftopPvPower: Retrieves rooftop PV power forecast data based on location and other parameters.
HistoricClient
GetHistoricRadiationAndWeather: Retrieves historic solar radiation and weather data for a specified time range.
GetHistoricAdvancedPvPower: Retrieves advanced PV power historical data.
GetHistoricRooftopPvPower: Retrieves rooftop PV power historical data.
TmyClient
GetTmyRadiationAndWeather: Retrieves TMY irradiance and weather data for a specified location.
GetTmyAdvancedPvPower: Retrieves advanced PV power TMY data.
GetTmyRooftopPvPower: Retrieves TMY rooftop PV power data.
AggregationClient
GetLiveAggregations: Retrieves live grid aggregation data for up to 7 days.
GetForecastAggregations: Retrieves forecast grid aggregation data for up to 7 days.
PvPowerSiteClient
GetPvPowerSites: Retrieves a list of all available PV power sites.
GetPvPowerSite: Retrieves metadata for a specific PV power site by its resource ID.
PostPvPowerSite: Creates a new PV Power Site for use with advanced PV power model.
PatchPvPowerSite: Partially updates the specifications of an existing PV power site.
PutPvPowerSite: Overwrites an existing PV power site specifications.
DeletePvPowerSite: Deletes an existing PV power site.
Optional: Enabling SDK Update Checks
By default, the SDK does not check for updates during runtime. To enable automatic update checking, you can pass true for the checkForUpdates parameter when creating client instances:
About 1/3 of food produced in the world is lost or wasted in the year. There are many reasons for this, including not being able to cook with said food, not having time to cook this food or cooking food that does not taste good. Albeit this, food waste is a serious problem that wastes money, wastes time and harms the environment.
Our Solution
Our web app, Recipe Nest is a chat bot deployed on Slack, the Web, through calls. (Messenger and Google Assistant are currently awaiting approval). Users simply enter in all the filters they would like their recipe to contain and Recipe Nest finds a recipe conforming to the users’ requests! We believe that making this application as accessible as possible reflects our goal of making it easy to get started with cooking at home and not wasting food!
How we did it
We used Python, Flask, for the backend. Our chat bot was built with Google Cloud’s Dialogflow in which we personally trained to be able to take user input. The front end was built with CSS, HTML, and Bootstrap.
Going forward
We hope to add user logins via Firebase. We would then add features such as 1. Saving food in your fridge 2. Having the app remind you of this food 3. Allow the user to save recipes that they like. Additionally, we would like to add more filters, such as nutrition, cost, and excluding certain foods, and finally, create a better UI/UX experience for the user.
About 1/3 of food produced in the world is lost or wasted in the year. There are many reasons for this, including not being able to cook with said food, not having time to cook this food or cooking food that does not taste good. Albeit this, food waste is a serious problem that wastes money, wastes time and harms the environment.
Our Solution
Our web app, Recipe Nest is a chat bot deployed on Slack, the Web, through calls. (Messenger and Google Assistant are currently awaiting approval). Users simply enter in all the filters they would like their recipe to contain and Recipe Nest finds a recipe conforming to the users’ requests! We believe that making this application as accessible as possible reflects our goal of making it easy to get started with cooking at home and not wasting food!
How we did it
We used Python, Flask, for the backend. Our chat bot was built with Google Cloud’s Dialogflow in which we personally trained to be able to take user input. The front end was built with CSS, HTML, and Bootstrap.
Going forward
We hope to add user logins via Firebase. We would then add features such as 1. Saving food in your fridge 2. Having the app remind you of this food 3. Allow the user to save recipes that they like. Additionally, we would like to add more filters, such as nutrition, cost, and excluding certain foods, and finally, create a better UI/UX experience for the user.
hrr_rb_ssh is a pure Ruby SSH 2.0 server and client implementation.
With hrr_rb_ssh, it is possible to write an SSH server easily, and also possible to write an original server side application on secure connection provided by SSH protocol. And it supports to write SSH client as well.
NOTE: ED25519 public key algorithm is now separated from hrr_rb_ssh. Please refer to hrr_rb_ssh-ed25519.
First of all, hrr_rb_ssh library needs to be loaded.
require'hrr_rb_ssh'
Logging
IMPORTANT: DEBUG log level outputs all communications between local and remote in human-readable plain-text including password and any secret. Be careful to use logging.
The library provides logging functionality. To enable logging in the library, you are to give a logger to Server.new or Client.new.
HrrRbSsh::Server.newoptions,logger: logger
or
HrrRbSsh::Client.newtarget,options,logger: logger
Where, the logger variable can be an instance of standard Logger class or user-defined logger class. What the library requires for logger variable is that the logger instance responds to #fatal, #error, #warn, #info and #debug with the following syntax.
For instance, logger variable can be prepared like below.
logger=Logger.newSTDOUTlogger.level=Logger::INFO
Writing standard SSH server
Starting server application
The library is to run on a socket IO. To start SSH server, running a server IO and accepting a connection are required. The 10022 port number is just an example.
Where, an options variable is an instance of Hash, which has optional (or sometimes almost necessary) values.
Registering pre-generated secret keys for server host key
By default, server host keys are generated everytime the gem is loaded. To use pre-generated keys, it is possible to register the keys in HrrRbSsh::Transport through options variable. The secret key value must be PEM or DER format string. The below is an example of registering ecdsa-sha2-nistp256 secret key. The supported server host key algorithms are listed later in this document.
By default, any authentications get failed. To allow users to login to the SSH service, at least one of the authentication methods must be defined and registered into the instance of HrrRbSsh::Authentication through options variable.
The library defines a sort of strategies to implement handling authentication.
Single authentication
Each authenticator returns true (or HrrRbSsh::Authentication::SUCCESS) or false (or HrrRbSsh::Authentication::FAILURE). When it is true, the user is accepted. When it is false, the user is not accepted and a subsequent authenticator is called.
Password authentication
Password authentication is the most simple way to allow users to login to the SSH service. Password authentication requires user-name and password.
To define a password authentication, the HrrRbSsh::Authentication::Authenticator.new { |context| ... } block is used. When the block returns true, then the authentication succeeded.
The context variable in password authentication context provides the followings.
#username : The username that a remote user tries to authenticate
#password : The password that a remote user tries to authenticate
#variables : A hash instance that is shared in each authenticator and subsequent session channel request handlers
#vars : The same object that #variables returns
#verify(username, password) : Returns true when username and password arguments match with the context’s username and password. Or returns false when username and password arguments don’t match.
Publickey authentication
The second one is public key authentication. Public key authentication requires user-name, public key algorithm name, and PEM or DER formed public key.
To define a public key authentication, the HrrRbSsh::Authentication::Authenticator.new { |context| ... } block is used as well. When the block returns true, then the authentication succeeded as well. However, context variable behaves differently.
The context variable in public key authentication context provides the #verify method. The #verify method takes three arguments; username, public key algorithm name and PEM or DER formed public key.
And public keys that is in OpenSSH public key format is now available. To use OpenSSH public keys, it is easy to use $USER_HOME/.ssh/authorized_keys file.
Keyboard-interactive authentication
The third one is keyboard-interactive authentication. This is also known as challenge-response authentication.
To define a keyboard-interactive authentication, the HrrRbSsh::Authentication::Authenticator.new { |context| ... } block is used as well. When the block returns true, then the authentication succeeded as well. However, context variable behaves differently.
The context variable in keyboard-interactive authentication context does NOT provides the #verify method. Instead, #info_request method is available. Since keyboard-interactive authentication has multiple times interactions between server and client, the values in responses needs to be verified respectively.
The #info_request method takes four arguments: name, instruction, language tag, and prompts. The name, instruction, and language tag can be empty string. The prompts needs to have at least one charactor for prompt message, and true or false value to specify whether echo back is enabled or not.
The responses are listed in the same order as request prompts.
None authentication (NOT recomended)
The last one is none authentication. None authentication is usually NOT used.
To define a none authentication, the HrrRbSsh::Authentication::Authenticator.new { |context| ... } block is used as well. When the block returns true, then the authentication succeeded as well. However, context variable behaves differently.
In none authentication context, context variable provides the #username method.
Multi-step authentication
In this strategy that conbines single authentications, it is possible to implement multi-step authentication. In case that the combination is a publickey authentication method and a password authentication method, it is so-called two-factor authentication.
A return value of each authentication handler can be HrrRbSsh::Authentication::PARTIAL_SUCCESS. The value means that the authentication method returns success and another authenticatoin method is requested (i.e. the authentication method is deleted from the list of authentication that can continue, and then the server sends USERAUTH_FAILURE message with the updated list of authentication that can continue and partial success true). When all preferred authentication methods returns PARTIAL_SUCCESS (i.e. there is no more authentication that can continue), then the user is treated as authenticated.
A context variable in an authenticator gives an access to remaining authentication methods that can continue. In this strategy, an implementer is able to control the order of authentication methods and to control which authentication methods are used for the user.
The below is an example. It is expected that any user must be verified by publickey and then another authentication is requested for the user accordingly.
auth_preferred_authentication_methods=['none']auth_none=HrrRbSsh::Authentication::Authenticator.new{ |context|
context.authentication_methods.push'publickey'HrrRbSsh::Authentication::PARTIAL_SUCCESS}auth_publickey=HrrRbSsh::Authentication::Authenticator.new{ |context|
ifsome_verification(context)casecontext.usernamewhen'user1'context.authentiation_methods.push'keyboard-interactive'HrrRbSsh::Authentication::PARTIAL_SUCCESSelsefalseendelsefalseend}auth_keyboard_interactive=HrrRbSsh::Authentication::Authenticator.new{ |context|
ifsome_verification(context)true# or HrrRbSsh::Authentication::PARTIAL_SUCCESS; both will accept the user because remaining authentication method is only 'keyboard-interactive' in this caseelsefalseend}options['authentication_preferred_authentication_methods']=auth_preferred_authentication_methodsoptions['authentication_none_authenticator']=auth_noneoptions['authentication_publickey_authenticator']=auth_publickeyoptions['authentication_keyboard_interactive_authenticator']=auth_keyboard_interactive
Handling session channel requests
By default, any channel requests belonging to session channel are implicitly ignored. To handle the requests, defining request handlers are required.
Reference request handlers
There are pre-implemented request handlers available for reference as below.
It is also possible to define customized request handlers. For instance, echo server can be implemented very easily as below. In this case, echo server works instead of shell and PTY-req and env requests are undefined.
conn_echo=HrrRbSsh::Connection::RequestHandler.new{ |context|
context.chain_proc{ |chain|
beginloopdobuf=context.io[0].readpartial(10240)breakifbuf.include?(0x04.chr)# break if ^Dcontext.io[1].writebufendexitstatus=0rescue=>elogger.error([e.backtrace[0],": ",e.message," (",e.class.to_s,")\n\t",e.backtrace[1..-1].join("\n\t")].join)exitstatus=1endexitstatus}}options['connection_channel_request_shell']=conn_echo
In HrrRbSsh::Connection::RequestHandler.new block, context variable basically provides the followings.
#io => [in, out, err] : in is readable and read data is sent by remote. out and err are writable. out is for standard output and written data is sent as channel data. err is for standard error and written data is sent as channel extended data.
#chain_proc => {|chain| ... } : When a session channel is opened, a background thread is started and is waitng for a chained block registered. This #chain_proc is used to define how to handle subsequent communications between local and remote. The chain variable provides #call_next method. In #proc_chain block, it is possible to call subsequent block that is defined in another request handler. For instance, shell request must called after pty-req request. The chain in pty-req request handler’s #chain_proc calls #next_proc and then subsequent shell request handler’s #chain_proc will be called.
#close_session : In most cases, input and output between a client and the server is handled in #chain_proc and closing the #chain_proc block will lead closing the underlying session channel. This means that to close the underlying session channel it is required to write at least one #chain_proc block. If it is not required to use #chain_proc block or is required to close the underlying session channel from outside of #chain_proc block, #close_session can be used. The #close_session will close the background thread that calls #chain_proc blocks.
#variables => Hash : A hash instance that is passed from authenticator and is shared in subsequent session channel request handlers
#vars : The same object that #variables returns
And request handler’s context variable also provides additional methods based on request type. See lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/<request type>/context.rb.
Defining preferred algorithms (optional)
Preferred encryption, server-host-key, KEX and compression algorithms can be selected and defined.
Supported algorithms can be got with each algorithm class’s #list_supported method, and default preferred algorithms can be got with each algorithm class’s #list_preferred method.
Outputs of #list_preferred method are ordered as preferred; i.e. the name listed at head is used as most preferred, and the name listed at tail is used as non-preferred.
By default, hrr_rb_ssh sends SSH-2.0-HrrRbSsh-#{VERSION} string at initial negotiation with remote peer. To address security concerns, it is possible to replace the version string.
# Hiding versionoptions['local_version']="SSH-2.0-HrrRbSsh"# Simulating OpenSSHoptions['local_version']="SSH-2.0-OpenSSH_x.x"# Simulating OpenSSH and hiding versionoptions['local_version']="SSH-2.0-OpenSSH"
Please note that the beginning of the string must be SSH-2.0-. Otherwise SSH 2.0 remote peer cannot continue negotiation with the local peer.
Writing SSH client (Experimental)
Starting SSH connection
The client mode can be started with HrrRbSsh::Client.start. The method takes target and options arguments. The target that the SSH client connects to can be one of:
(IO) An io that is open for input and output
(Array) An array of the target host address or host name and its service port number
(String) The target host address or host name; in this case the target service port number will be 22
And the options contains various parameters for the SSH connection. At least username key must be set in the options. Also at least one of password, publickey, or keyboard-interactive needs to be set for authentication instead of authenticators that are used in server mode. Also as similar to server mode, it is possible to specify preferred transport algorithms and preferred authentication methods with the same keywords.
target=['remotehost',22]options={username: 'user1',password: 'password1',publickey: ['ssh-rsa',"/home/user1/.ssh/id_rsa")],authentication_preferred_authentication_methods=['publickey','password'],}HrrRbSsh::Client.start(target,options)do |conn|
# Do something here# For instance: conn.exec "command"end
Executing remote commands
There are some methods supported in client mode. The methods works as a receiver of conn block variable.
exec method
The exec and exec! methods execute command on a remote host. Both takes a command argument that is executed in the remote host. And they can take optional pty and env arguments. When pty: true is set, then the command will be executed on a pseudo-TTY. When env: {'key' => 'value'} is set, then the environmental variables are set before the command is executed.
The exec! method returns [stdout, stderr] outputs. Once the command is executed and the outputs are completed, then the method returns the value.
conn.exec!"command"# => [stdout, stderr]
On the other hand, exec method takes block like the below example and returns exit status of the command. When the command is executed and the outputs and reading them are finished, then io_out and io_err return EOF.
conn.exec"command"do |io_in,io_out,io_err|
# Do something hereend
shell method
The shell method provides a shell access on a remote host. As similar to exec method, it takes block and its block variable is also io_in, io_out, io_err. shell is always on pseudo-TTY, so it doesn’t take pty optional argument. It takes env optional argument. Exiting shell will leads io_out and io_err EOF.
conn.shelldo |io_in,io_out,io_err|
# Do something hereend
subsystem method
The subsystem method is to start a subsystem on a remote host. The method takes a subsystem name argument and a block. Its block variable is also io_in, io_out, io_err. subsystem doesn’t take pty nor env optional argument.
conn.subsystem("echo")do |io_in,io_out,io_err|
# Do something hereend
Demo
The demo/server.rb shows a good example on how to use the hrr_rb_ssh library in SSH server mode. And the demo/client.rb shows an example on how to use the hrr_rb_ssh library in SSH client mode.
Bug reports and pull requests are welcome on GitHub at https://github.com/hirura/hrr_rb_ssh. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
Code of Conduct
Everyone interacting in the HrrRbSsh project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
License
The gem is available as open source under the terms of the Apache License 2.0.
hrr_rb_ssh is a pure Ruby SSH 2.0 server and client implementation.
With hrr_rb_ssh, it is possible to write an SSH server easily, and also possible to write an original server side application on secure connection provided by SSH protocol. And it supports to write SSH client as well.
NOTE: ED25519 public key algorithm is now separated from hrr_rb_ssh. Please refer to hrr_rb_ssh-ed25519.
First of all, hrr_rb_ssh library needs to be loaded.
require'hrr_rb_ssh'
Logging
IMPORTANT: DEBUG log level outputs all communications between local and remote in human-readable plain-text including password and any secret. Be careful to use logging.
The library provides logging functionality. To enable logging in the library, you are to give a logger to Server.new or Client.new.
HrrRbSsh::Server.newoptions,logger: logger
or
HrrRbSsh::Client.newtarget,options,logger: logger
Where, the logger variable can be an instance of standard Logger class or user-defined logger class. What the library requires for logger variable is that the logger instance responds to #fatal, #error, #warn, #info and #debug with the following syntax.
For instance, logger variable can be prepared like below.
logger=Logger.newSTDOUTlogger.level=Logger::INFO
Writing standard SSH server
Starting server application
The library is to run on a socket IO. To start SSH server, running a server IO and accepting a connection are required. The 10022 port number is just an example.
Where, an options variable is an instance of Hash, which has optional (or sometimes almost necessary) values.
Registering pre-generated secret keys for server host key
By default, server host keys are generated everytime the gem is loaded. To use pre-generated keys, it is possible to register the keys in HrrRbSsh::Transport through options variable. The secret key value must be PEM or DER format string. The below is an example of registering ecdsa-sha2-nistp256 secret key. The supported server host key algorithms are listed later in this document.
By default, any authentications get failed. To allow users to login to the SSH service, at least one of the authentication methods must be defined and registered into the instance of HrrRbSsh::Authentication through options variable.
The library defines a sort of strategies to implement handling authentication.
Single authentication
Each authenticator returns true (or HrrRbSsh::Authentication::SUCCESS) or false (or HrrRbSsh::Authentication::FAILURE). When it is true, the user is accepted. When it is false, the user is not accepted and a subsequent authenticator is called.
Password authentication
Password authentication is the most simple way to allow users to login to the SSH service. Password authentication requires user-name and password.
To define a password authentication, the HrrRbSsh::Authentication::Authenticator.new { |context| ... } block is used. When the block returns true, then the authentication succeeded.
The context variable in password authentication context provides the followings.
#username : The username that a remote user tries to authenticate
#password : The password that a remote user tries to authenticate
#variables : A hash instance that is shared in each authenticator and subsequent session channel request handlers
#vars : The same object that #variables returns
#verify(username, password) : Returns true when username and password arguments match with the context’s username and password. Or returns false when username and password arguments don’t match.
Publickey authentication
The second one is public key authentication. Public key authentication requires user-name, public key algorithm name, and PEM or DER formed public key.
To define a public key authentication, the HrrRbSsh::Authentication::Authenticator.new { |context| ... } block is used as well. When the block returns true, then the authentication succeeded as well. However, context variable behaves differently.
The context variable in public key authentication context provides the #verify method. The #verify method takes three arguments; username, public key algorithm name and PEM or DER formed public key.
And public keys that is in OpenSSH public key format is now available. To use OpenSSH public keys, it is easy to use $USER_HOME/.ssh/authorized_keys file.
Keyboard-interactive authentication
The third one is keyboard-interactive authentication. This is also known as challenge-response authentication.
To define a keyboard-interactive authentication, the HrrRbSsh::Authentication::Authenticator.new { |context| ... } block is used as well. When the block returns true, then the authentication succeeded as well. However, context variable behaves differently.
The context variable in keyboard-interactive authentication context does NOT provides the #verify method. Instead, #info_request method is available. Since keyboard-interactive authentication has multiple times interactions between server and client, the values in responses needs to be verified respectively.
The #info_request method takes four arguments: name, instruction, language tag, and prompts. The name, instruction, and language tag can be empty string. The prompts needs to have at least one charactor for prompt message, and true or false value to specify whether echo back is enabled or not.
The responses are listed in the same order as request prompts.
None authentication (NOT recomended)
The last one is none authentication. None authentication is usually NOT used.
To define a none authentication, the HrrRbSsh::Authentication::Authenticator.new { |context| ... } block is used as well. When the block returns true, then the authentication succeeded as well. However, context variable behaves differently.
In none authentication context, context variable provides the #username method.
Multi-step authentication
In this strategy that conbines single authentications, it is possible to implement multi-step authentication. In case that the combination is a publickey authentication method and a password authentication method, it is so-called two-factor authentication.
A return value of each authentication handler can be HrrRbSsh::Authentication::PARTIAL_SUCCESS. The value means that the authentication method returns success and another authenticatoin method is requested (i.e. the authentication method is deleted from the list of authentication that can continue, and then the server sends USERAUTH_FAILURE message with the updated list of authentication that can continue and partial success true). When all preferred authentication methods returns PARTIAL_SUCCESS (i.e. there is no more authentication that can continue), then the user is treated as authenticated.
A context variable in an authenticator gives an access to remaining authentication methods that can continue. In this strategy, an implementer is able to control the order of authentication methods and to control which authentication methods are used for the user.
The below is an example. It is expected that any user must be verified by publickey and then another authentication is requested for the user accordingly.
auth_preferred_authentication_methods=['none']auth_none=HrrRbSsh::Authentication::Authenticator.new{ |context|
context.authentication_methods.push'publickey'HrrRbSsh::Authentication::PARTIAL_SUCCESS}auth_publickey=HrrRbSsh::Authentication::Authenticator.new{ |context|
ifsome_verification(context)casecontext.usernamewhen'user1'context.authentiation_methods.push'keyboard-interactive'HrrRbSsh::Authentication::PARTIAL_SUCCESSelsefalseendelsefalseend}auth_keyboard_interactive=HrrRbSsh::Authentication::Authenticator.new{ |context|
ifsome_verification(context)true# or HrrRbSsh::Authentication::PARTIAL_SUCCESS; both will accept the user because remaining authentication method is only 'keyboard-interactive' in this caseelsefalseend}options['authentication_preferred_authentication_methods']=auth_preferred_authentication_methodsoptions['authentication_none_authenticator']=auth_noneoptions['authentication_publickey_authenticator']=auth_publickeyoptions['authentication_keyboard_interactive_authenticator']=auth_keyboard_interactive
Handling session channel requests
By default, any channel requests belonging to session channel are implicitly ignored. To handle the requests, defining request handlers are required.
Reference request handlers
There are pre-implemented request handlers available for reference as below.
It is also possible to define customized request handlers. For instance, echo server can be implemented very easily as below. In this case, echo server works instead of shell and PTY-req and env requests are undefined.
conn_echo=HrrRbSsh::Connection::RequestHandler.new{ |context|
context.chain_proc{ |chain|
beginloopdobuf=context.io[0].readpartial(10240)breakifbuf.include?(0x04.chr)# break if ^Dcontext.io[1].writebufendexitstatus=0rescue=>elogger.error([e.backtrace[0],": ",e.message," (",e.class.to_s,")\n\t",e.backtrace[1..-1].join("\n\t")].join)exitstatus=1endexitstatus}}options['connection_channel_request_shell']=conn_echo
In HrrRbSsh::Connection::RequestHandler.new block, context variable basically provides the followings.
#io => [in, out, err] : in is readable and read data is sent by remote. out and err are writable. out is for standard output and written data is sent as channel data. err is for standard error and written data is sent as channel extended data.
#chain_proc => {|chain| ... } : When a session channel is opened, a background thread is started and is waitng for a chained block registered. This #chain_proc is used to define how to handle subsequent communications between local and remote. The chain variable provides #call_next method. In #proc_chain block, it is possible to call subsequent block that is defined in another request handler. For instance, shell request must called after pty-req request. The chain in pty-req request handler’s #chain_proc calls #next_proc and then subsequent shell request handler’s #chain_proc will be called.
#close_session : In most cases, input and output between a client and the server is handled in #chain_proc and closing the #chain_proc block will lead closing the underlying session channel. This means that to close the underlying session channel it is required to write at least one #chain_proc block. If it is not required to use #chain_proc block or is required to close the underlying session channel from outside of #chain_proc block, #close_session can be used. The #close_session will close the background thread that calls #chain_proc blocks.
#variables => Hash : A hash instance that is passed from authenticator and is shared in subsequent session channel request handlers
#vars : The same object that #variables returns
And request handler’s context variable also provides additional methods based on request type. See lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/<request type>/context.rb.
Defining preferred algorithms (optional)
Preferred encryption, server-host-key, KEX and compression algorithms can be selected and defined.
Supported algorithms can be got with each algorithm class’s #list_supported method, and default preferred algorithms can be got with each algorithm class’s #list_preferred method.
Outputs of #list_preferred method are ordered as preferred; i.e. the name listed at head is used as most preferred, and the name listed at tail is used as non-preferred.
By default, hrr_rb_ssh sends SSH-2.0-HrrRbSsh-#{VERSION} string at initial negotiation with remote peer. To address security concerns, it is possible to replace the version string.
# Hiding versionoptions['local_version']="SSH-2.0-HrrRbSsh"# Simulating OpenSSHoptions['local_version']="SSH-2.0-OpenSSH_x.x"# Simulating OpenSSH and hiding versionoptions['local_version']="SSH-2.0-OpenSSH"
Please note that the beginning of the string must be SSH-2.0-. Otherwise SSH 2.0 remote peer cannot continue negotiation with the local peer.
Writing SSH client (Experimental)
Starting SSH connection
The client mode can be started with HrrRbSsh::Client.start. The method takes target and options arguments. The target that the SSH client connects to can be one of:
(IO) An io that is open for input and output
(Array) An array of the target host address or host name and its service port number
(String) The target host address or host name; in this case the target service port number will be 22
And the options contains various parameters for the SSH connection. At least username key must be set in the options. Also at least one of password, publickey, or keyboard-interactive needs to be set for authentication instead of authenticators that are used in server mode. Also as similar to server mode, it is possible to specify preferred transport algorithms and preferred authentication methods with the same keywords.
target=['remotehost',22]options={username: 'user1',password: 'password1',publickey: ['ssh-rsa',"/home/user1/.ssh/id_rsa")],authentication_preferred_authentication_methods=['publickey','password'],}HrrRbSsh::Client.start(target,options)do |conn|
# Do something here# For instance: conn.exec "command"end
Executing remote commands
There are some methods supported in client mode. The methods works as a receiver of conn block variable.
exec method
The exec and exec! methods execute command on a remote host. Both takes a command argument that is executed in the remote host. And they can take optional pty and env arguments. When pty: true is set, then the command will be executed on a pseudo-TTY. When env: {'key' => 'value'} is set, then the environmental variables are set before the command is executed.
The exec! method returns [stdout, stderr] outputs. Once the command is executed and the outputs are completed, then the method returns the value.
conn.exec!"command"# => [stdout, stderr]
On the other hand, exec method takes block like the below example and returns exit status of the command. When the command is executed and the outputs and reading them are finished, then io_out and io_err return EOF.
conn.exec"command"do |io_in,io_out,io_err|
# Do something hereend
shell method
The shell method provides a shell access on a remote host. As similar to exec method, it takes block and its block variable is also io_in, io_out, io_err. shell is always on pseudo-TTY, so it doesn’t take pty optional argument. It takes env optional argument. Exiting shell will leads io_out and io_err EOF.
conn.shelldo |io_in,io_out,io_err|
# Do something hereend
subsystem method
The subsystem method is to start a subsystem on a remote host. The method takes a subsystem name argument and a block. Its block variable is also io_in, io_out, io_err. subsystem doesn’t take pty nor env optional argument.
conn.subsystem("echo")do |io_in,io_out,io_err|
# Do something hereend
Demo
The demo/server.rb shows a good example on how to use the hrr_rb_ssh library in SSH server mode. And the demo/client.rb shows an example on how to use the hrr_rb_ssh library in SSH client mode.
Bug reports and pull requests are welcome on GitHub at https://github.com/hirura/hrr_rb_ssh. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
Code of Conduct
Everyone interacting in the HrrRbSsh project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
License
The gem is available as open source under the terms of the Apache License 2.0.
To download the mod, select the latest release version to the right and follow the instructions.
Description
This mod does random things to your game after a set interval. (30 seconds by default)
There are way over 400 different effects that can happen, and the list is only growing with each update! Anything from giving the player health, to teleporting them, changing the physics, removing car wheels, making the whole world spin and much more.
The mod is highly tweakable, allowing you to have the exact experience you want. Just press F7 at any time, and with the numpad, you will be able to configure any of these options to your heart’s content.
Main Options:
Toggle the mod on and off
Choose whether the mod automatically enables when the game starts
Recommended Features:
Autosaving, which makes the save menu appear after every passed mission
UI Options:
Change the scale and color pattern of the timer bar
Change the position, scale, color and style of the effects list on-screen
Behavior Options:
Change the amount of time between each new effect
Twitch voting
Trigger an effect when someone subscribes on Twitch
Synced effects, using a global timer to make multiple instances of the mod on different PCs have the same effects happen simultaneously
Bind a key to triggering an effect
Effect Options:
Preset filters to disable unstable, controversial or DMCA effects
Manual tweaks to effects, letting you change the length of and disable any effect
Audio Options:
Change the volume of effects that have sound
Difficulty Options:
Change the difficulty to change the available effects and the frequency of bad effects
Twitch Voting Options:
Choose whether the mod reconnects to Twitch automatically
Change the color scheme of the voting display
Choose between proportional and majority voting (Proportional: Votes are a percentage chance, Majority: The effect with the most votes always wins)
Change the command for voting (1 2 3 4 or c1 c2 c3 c4)
Change the amount of effects available to be voted on (any amount between 2 and 9)
Make the voting command alternate between 1 2 3 4 and 5 6 7 8 to prevent votes bleeding over, and to allow more than one identical vote per 30 seconds on Twitch
Change the method in which the voting display is drawn (Separate window, on-screen or in an .html file)
Mark Unpicked Effects (Off: The same effect will not be available again until every other effect has won the vote at least once, On: The same effect will not be available again until every other effect has appeared in the voting window)
To download the mod, select the latest release version to the right and follow the instructions.
Description
This mod does random things to your game after a set interval. (30 seconds by default)
There are way over 400 different effects that can happen, and the list is only growing with each update! Anything from giving the player health, to teleporting them, changing the physics, removing car wheels, making the whole world spin and much more.
The mod is highly tweakable, allowing you to have the exact experience you want. Just press F7 at any time, and with the numpad, you will be able to configure any of these options to your heart’s content.
Main Options:
Toggle the mod on and off
Choose whether the mod automatically enables when the game starts
Recommended Features:
Autosaving, which makes the save menu appear after every passed mission
UI Options:
Change the scale and color pattern of the timer bar
Change the position, scale, color and style of the effects list on-screen
Behavior Options:
Change the amount of time between each new effect
Twitch voting
Trigger an effect when someone subscribes on Twitch
Synced effects, using a global timer to make multiple instances of the mod on different PCs have the same effects happen simultaneously
Bind a key to triggering an effect
Effect Options:
Preset filters to disable unstable, controversial or DMCA effects
Manual tweaks to effects, letting you change the length of and disable any effect
Audio Options:
Change the volume of effects that have sound
Difficulty Options:
Change the difficulty to change the available effects and the frequency of bad effects
Twitch Voting Options:
Choose whether the mod reconnects to Twitch automatically
Change the color scheme of the voting display
Choose between proportional and majority voting (Proportional: Votes are a percentage chance, Majority: The effect with the most votes always wins)
Change the command for voting (1 2 3 4 or c1 c2 c3 c4)
Change the amount of effects available to be voted on (any amount between 2 and 9)
Make the voting command alternate between 1 2 3 4 and 5 6 7 8 to prevent votes bleeding over, and to allow more than one identical vote per 30 seconds on Twitch
Change the method in which the voting display is drawn (Separate window, on-screen or in an .html file)
Mark Unpicked Effects (Off: The same effect will not be available again until every other effect has won the vote at least once, On: The same effect will not be available again until every other effect has appeared in the voting window)
$ cargo hack --helpcargo-hackCargo subcommand to provide various options useful for testing and continuous integration.USAGE: cargo hack [OPTIONS] [SUBCOMMAND]Use -h for short descriptions and --help for more details.OPTIONS: -p, --package <SPEC>... Package(s) to check. --all Alias for --workspace. --workspace Perform command for all packages in the workspace. --exclude <SPEC>... Exclude packages from the check. --manifest-path <PATH> Path to Cargo.toml. --locked Require Cargo.lock is up to date. -F, --features <FEATURES>... Space or comma separated list of features to activate. --each-feature Perform for each feature of the package. This also includes runs with just --no-default-features flag, and default features. When this flag is not used together with --exclude-features (--skip) and --include-features and there are multiple features, this also includes runs with just --all-features flag. --feature-powerset Perform for the feature powerset of the package. This also includes runs with just --no-default-features flag, and default features. When this flag is used together with --depth or namespaced features (-Z namespaced-features) and not used together with --exclude-features (--skip) and --include-features and there are multiple features, this also includes runs with just --all-features flag. --optional-deps [DEPS]... Use optional dependencies as features. If DEPS are not specified, all optional dependencies are considered as features. This flag can only be used together with either --each-feature flag or --feature-powerset flag. --skip <FEATURES>... Alias for --exclude-features. --exclude-features <FEATURES>... Space or comma separated list of features to exclude. To exclude run of default feature, using value `--exclude-features default`. To exclude run of just --no-default-features flag, using --exclude-no-default-features flag. To exclude run of just --all-features flag, using --exclude-all-features flag. This flag can only be used together with either --each-feature flag or --feature-powerset flag. --exclude-no-default-features Exclude run of just --no-default-features flag. This flag can only be used together with either --each-feature flag or --feature-powerset flag. --exclude-all-features Exclude run of just --all-features flag. This flag can only be used together with either --each-feature flag or --feature-powerset flag. --depth <NUM> Specify a max number of simultaneous feature flags of --feature-powerset. If NUM is set to 1, --feature-powerset is equivalent to --each-feature. This flag can only be used together with --feature-powerset flag. --group-features <FEATURES>... Space or comma separated list of features to group. This treats the specified features as if it were a single feature. To specify multiple groups, use this option multiple times: `--group-features a,b --group-features c,d` This flag can only be used together with --feature-powerset flag. --target <TRIPLE> Build for specified target triple. Comma-separated lists of targets are not supported, but you can specify the whole --target option multiple times to do multiple targets. This is actually not a cargo-hack option, it is interpreted by Cargo itself. --mutually-exclusive-features <FEATURES>... Space or comma separated list of features to not use together. To specify multiple groups, use this option multiple times: `--mutually-exclusive-features a,b --mutually-exclusive-features c,d` This flag can only be used together with --feature-powerset flag. --at-least-one-of <FEATURES>... Space or comma separated list of features. Skips sets of features that don't enable any of the features listed. To specify multiple groups, use this option multiple times: `--at-least-one-of a,b --at-least-one-of c,d` This flag can only be used together with --feature-powerset flag. --include-features <FEATURES>... Include only the specified features in the feature combinations instead of package features. This flag can only be used together with either --each-feature flag or --feature-powerset flag. --no-dev-deps Perform without dev-dependencies. Note that this flag removes dev-dependencies from real `Cargo.toml` while cargo-hack is running and restores it when finished. --remove-dev-deps Equivalent to --no-dev-deps flag except for does not restore the original `Cargo.toml` after performed. --no-private Perform without `publish = false` crates. --ignore-private Skip to perform on `publish = false` packages. --ignore-unknown-features Skip passing --features flag to `cargo` if that feature does not exist in the package. This flag can be used with --features, --include-features, or --group-features. --rust-version Perform commands on `package.rust-version`. This cannot be used with --version-range. --version-range [START]..[=END] Perform commands on a specified (inclusive) range of Rust versions. If the upper bound of the range is omitted, the latest stable compiler is used as the upper bound. If the lower bound of the range is omitted, the value of the `rust-version` field in `Cargo.toml` is used as the lower bound. Note that ranges are always inclusive ranges. --version-step <NUM> Specify the version interval of --version-range (default to `1`). This flag can only be used together with --version-range flag. --clean-per-run Remove artifacts for that package before running the command. If used this flag with --workspace, --each-feature, or --feature-powerset, artifacts will be removed before each run. Note that dependencies artifacts will be preserved. --clean-per-version Remove artifacts per Rust version. Note that dependencies artifacts will also be removed. This flag can only be used together with --version-range flag. --keep-going Keep going on failure. --partition <M/N> Partition runs and execute only its subset according to M/N. --log-group <KIND> Log grouping: none, github-actions. If this option is not used, the environment will be automatically detected. --print-command-list Print commands without run (Unstable). --no-manifest-path Do not pass --manifest-path option to cargo (Unstable). -v, --verbose Use verbose output. --color <WHEN> Coloring: auto, always, never. This flag will be propagated to cargo. -h, --help Prints help information. -V, --version Prints version information.Some common cargo commands are (see all commands with --list): build Compile the current package check Analyze the current package and report errors, but don't build object files run Run a binary or example of the local package test Run the tests
cargo-hack is basically wrapper of cargo that propagates subcommand and most
of the passed flags to cargo, but provides additional flags and changes the
behavior of some existing flags.
–each-feature
Perform for each feature which includes default features and
--no-default-features of the package.
This is useful to check that each feature is working properly. (When used for
this purpose, it is recommended to use with --no-dev-deps to avoid
cargo#4866.)
Perform for the feature powerset which includes --no-default-features and
default features of the package.
This is useful to check that every combination of features is working
properly. (When used for this purpose, it is recommended to use with
--no-dev-deps to avoid cargo#4866.)
cargo hack check --feature-powerset --no-dev-deps
cargo-hack deduplicate any fully equivalent feature combinations based on how the cargo features work. Therefore, it may be more efficient than checking all feature combinations in other ways.
Tip
When using this flag results in a very large number of feature combinations, consider using --depth option.
Options for adjusting the behavior of –each-feature and –feature-powerset
The following flags can be used with --each-feature and --feature-powerset.
–optional-deps
Use optional dependencies as features.
This flag treats all option dependencies as features by default.
To treat only specific dependencies as features, pass a space or comma separated list.
Currently, using --no-dev-deps flag removes dev-dependencies from
real manifest while cargo-hack is running and restores it when finished.
Any changes you made to those files during running will not be preserved.
See cargo#4242 for why this is necessary.
Also, this behavior may change in the future on some subcommands. See also
#15.
–remove-dev-deps
Equivalent to --no-dev-deps except for does not restore the original
Cargo.toml after execution.
This is useful to know what Cargo.toml that cargo-hack is actually using
with --no-dev-deps.
This flag also works without subcommands.
–ignore-private
Skip to perform on publish = false crates.
–no-private
Perform without publish = false crates. This is similar to --ignore-private, but is more powerful because this also prevents private crates from affecting lockfile and metadata.
Note
--no-private flag modifies Cargo.toml while cargo-hack is running and restores it when finished. Any changes you made to those files during running will not be preserved.
–ignore-unknown-features
Skip passing --features to cargo if that feature does not exist.
–clean-per-run
Remove artifacts for that package before running the command.
Perform command for all packages in the workspace.
Unlike cargo, it does not compile all members at once.
For example, running cargo hack check --all in a workspace with members
foo and bar behaves almost the same as the following script:
# If you use cargo-hack, you don't need to maintain this list manually.
members=("foo""bar")
formemberin"${members[@]}";do
cargo check --manifest-path "${member}/Cargo.toml"done
Workspace members will be performed according to the order of the ‘packages’
fields of cargo metadata.
cargo-hack is usually runnable with Cargo versions older than the Rust version
required for installation (e.g., cargo +1.31 hack check). Currently, to run
cargo-hack requires Cargo 1.26+.
From prebuilt binaries
You can download prebuilt binaries from the Release page.
Prebuilt binaries are available for macOS, Linux (gnu and musl), Windows (static executable), FreeBSD, and illumos.
Example of script to install from the Release page (click to show)
# Get host target
host=$(rustc -vV | grep '^host:'| cut -d'' -f2)# Download binary and install to $HOME/.cargo/bin
curl --proto '=https' --tlsv1.2 -fsSL "https://github.com/taiki-e/cargo-hack/releases/latest/download/cargo-hack-$host.tar.gz" \
| tar xzf - -C "$HOME/.cargo/bin"
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall
be dual licensed as above, without any additional terms or conditions.
Must-read list and classic books of computational geometry and computer graphics
Some people say that computer graphics generally includes geometry, rendering and simulation. Others say that computer graphics mainly includes modeling, rendering, animation and human-computer interaction. In this book list, I want to summarize the books that can be read from two aspects: computational geometry and computer graphics. Computer graphics mainly summarizes the mathematical basis of graphics, rendering, animation, simulation, game engine design and development, graphics api, etc. Computational geometry mainly summarizes the basic geometry such as points, lines and planes and their relationships.
It is under continuous update. This update is on August 10, 2023. It is not finished yet to be continued.
This plugin allows you to automatically minify files when builting with Eleventy.
It currently supports css, html, json, xml, xsl and webmanifest files.
Why should you minify your files? Simply to reduce the data transfered between your hosting servers and your visitors,
even if some of them maybe some bots.
Under the hood, this plugin use the following plugins to minify code:
The plugin will automatically minify supported files, you don’t need to do anything except the installation!
Make sure that the files you want to minify are currently written by Eleventy. If not, you can easily rename it and add
Front matter options. For example, for the manifest.webmanifest file, I could rename it as manifest.webmanifest.njk
and add the following code at his top: