
Security News
New Website “Is It Really FOSS?” Tracks Transparency in Open Source Distribution Models
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Leech is simple TCP client/server framework. Server is similar to rack, but is designed for asynchronously handling a short text commands. It can be used for some monitoring purposes or simple communication between few machines.
You can install Leach directly from rubygems:
gem install leach
Leech is using simple TCP client/server architecture. It's a simple processor for text commands passed through TCP socket.
Server can be created in two ways:
server = Leech::Server.new :port => 666
server.use :auth
server.run
...or using block style:
Leech::Server.new do
port 666
use :auth
run
end
You can pass frew configuration options when you are creating new server, eg:
Leech::Server.new(port => 666, :host => 'myhost.com', :timeout => 60)
For more information about allowed parameters visit This doc page.
Handlers are extending functionality of server by defining custom command handling callbacks or server instance methods.
For simple commands handling you can use inline handler, which is automatically used by server, eg.
Leech::Server.new do
handle(/^PRINT) (.*)$/ {|env,params| print params[0]}
handle(/^DELETE FILE (.*)$/) {|env,params| File.delete(params[0])}
end
For advanced tasks, you can write own handler, which will add new functionality to server instance.
class CustomHandler < Leech::Handler
# This method is automaticaaly called when server will use this handler
def self.used(server)
server.instance_eval { extend ServerMethods }
end
module ServerMethods
def say_hello
answer("Hello!")
end
end
handle /^Hello server!$/, :say_hello
handle /^Bye!$/ do |env,params|
env.answer("Take care!")
end
end
To enable this handler in the server you can simply type:
Leech::Server.new do
use CustomHandler
end
You should notice that block-style callbacks are passing two arguments: env - instance of server which is using this handler for processing, and params - array of strings fetched from matched command.
For sending answers to clients server have the #answer
method. It can be used
like here:
Leech::Server.new do
handle /^HELLO$/ do |env,params| env.answer("HELLO MY FRIEND!\n")
end
Server is partialy acting as Thread
. You can join it's instance so application
will be waiting to interrupt or some unhandled server error:
server = Leech::Server.new
server.run
server.join # on server.acceptor.join
You can also simple use:
server.run.join
Client will be implemented in 0.2.0 version.
Copyright (c) 2010 Kriss Kowalik. See LICENSE for details.
FAQs
Unknown package
We found that leech demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.