
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
rPatricia - A ruby wrapper of Net::Patricia
This is a ruby wrapper of Net::Patricia, which has been developed by Dave Plonka. The original Net::Patricia and its C API are available from: http://net.doit.wisc.edu/~plonka/Net-Patricia/
Net::Patricia is a module for fast IP address/prefix lookups. I have modified some interfaces for the Ruby wrapper version.
THE PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT
WITHOUT ANY WARRANTY. IT IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR
OR CORRECTION. 
This package extracts, builds, installs in the usual fashion, i.e.:
  $ tar xvfz rpatricia.tar.gz
  $ cd rpatricia
  $ ruby extconf.rb
  $ make
  $ ruby test.rb
  # make install
require 'rpatricia' pt = Patricia.new pt.add("192.168.1.0/24") pt.add("127.0.0.0/8", "user_data") node = pt.search_best("127.0.0.1") puts node.data puts node.prefix puts node.network puts node.prefixlen pt.remove("127.0.0.0/8") puts pt.num_nodes pt.show_nodes pt.clear
new:
  pt = Patricia.new
This is the class' constructor - it returns a Patricia object for
handling IPv4 addresses.  To handle IPv6 addresses (only),
Patricia.new may be called with an additional argument:
  pt = Patricia.new(:AF_INET6)
The Patricia object will be destroyed automatically when there are
no longer any references to it.
add: pt.add(key_string[,user_data])
The first argument, key_string, is a network or subnet
specification in canonical form, e.g. ``10.0.0.0/8'', where the
number after the slash represents the number of bits in the
netmask. If no mask width is specified, the longest possible mask
is assumed, i.e. 32 bits for AF_INET addresses and 128 bits for
AF_INET6 addresses.
The second argument, user_data, is optional. If supplied, it
should be a STRING object specifying the user data that will be 
stored in the Patricia Trie node. Subsequently, this value will
be returned by the match methods described below to indicate a 
successful search. 
If no second argument is passed, the key_string will be stored as
the user data and therfore will likewise be returned by the match
functions.
On success, this method returns the object of the Patricia Trie 
node.
family:
Returns either :AF_INET or :AF_INET6 symbol depending on how the
object was initialized.  A Patricia object may only handle IPv4 or
IPv6 addresses.
add_node: An alias of add.
search_best:
  pt.search_best(key_string);
This method searches the Patricia Trie to find a matching node,
according to normal subnetting rules for the address and mask
specified.
The key_string argument is a network or subnet specification in
canonical form, e.g. ``10.0.0.0/8'', where the number after the
slash represents the number of bits in the netmask. If no mask
width value is specified, the longest mask is assumed, i.e. 32
bits for AF_INET addresses and 128 bits for AF_INET6 addresses.
If a matching node is found in the Patricia Trie, this method
returns the object of the node. This method returns nil on
failure.
match_best: An alias of search_best.
search_exact:
  pt.search_exact(key_string);
This method searches the Patricia Trie to find a matching
node. Its semantics are exactly the same as those described for
search_best except that the key must match a node exactly. I.e.,
it is not sufficient that the address and mask specified merely
falls within the subnet specified by a particular node.
match_exact: An alias of search_exact.
include?:
  pt.include?(key_string);
This method behaves like match_best, but returns true on success
and false on failure.  This method is more efficient than match_best
as it does not allocate a new object.
remove:
  pt.remove(key_string);
This method removes the node which exactly matches the the address
and mask specified from the Patricia Trie.
If the matching node is found in the Patricia Trie, it is removed,
and this method returns the true. This method returns false on
failure. 
remove_node: An alias of remove
num_nodes:
   pt.num_nodes
 This method returns the number of nodes in the Patricia Trie.
show_nodes:
   pt.print_nodes
 This method prints all the nodes in the Patricia Trie.
nodes:
   pt.nodes
 This method returns all the nodes and values in the Patricia Trie
 as a Ruby Hash object.
data:
   node.data
 This method returns the user data of the Patricia Trie node.
network:
   node.network
 This method returns the network of the Patricia Trie node.
prefix:
   node.prefix
 This method returns the prefix of the Patricia Trie node.
prefixlen:
   node.prefixlen
 This method returns the prefix length of the Patricia Trie 
 node.
Tatsuya Mori mori.tatsuya@gmail.com Eric Wong normalperson@yhbt.net
FAQs
Unknown package
We found that rpatricia demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.