ARRRR ME HEARTY!
Sailing the Seas of DRb in a Shoe
Davy Stevenson
Eric Hodel
Rein Henrichs
@davystevenson
@drbrain
@reinh
RubyConf 2013
Slide 2
Slide 2 text
Spaceteam?
Who has played?
Pleiades by Jim Keller
Slide 3
Slide 3 text
Spaceteam trailer
Slide 4
Slide 4 text
Why DRb?
Easy Interprocess
Communication
Send and Get Data
Peer to Peer
Red Beach by alphadesigner
Slide 5
Slide 5 text
Why Rinda?
Flexible
Automatic
discovery
No explicit
destination?
Throw it in the
tuplespace
Farmhouse and Roosting Birds at Dusk
by Trey Ratcliff
Slide 6
Slide 6 text
Why Shoes?
Needs some love
and attention
Perfect showcase
for distributed
code
Support non-web
Ruby development!
Freestyle Converse by Daniele Margaroli
Preparation
Also in pirate_game README!
https://github.com/davy/pirate_game
Slide 10
Slide 10 text
DRb
RMI for Ruby
Written by
Masatoshi SEKI
require ‘drb’
Remote objects
act like local
objects
It’s “Ruby Throated” Tuesday!
by MrClean1982
Slide 11
Slide 11 text
Remote Array Server
array = []
# share the array
DRb::DRbServer.new nil, array
# print the URI (we let DRb pick)
puts DRb.uri
# wait for ^C
DRb.thread.join
Rinda
Linda for Ruby
Model for distributed
programming
require ‘rinda/
tuple_space’
Stores tuples with
arbitrary data
write, take, read
Quasicabinet by Aranda\Lasch
Slide 15
Slide 15 text
Tuple Space
# blocking operation with template
@ts.take
[:button, "Keel", (now...now + 30), nil]
# writing a matching tuple unblocks
@ts.write
[:button, "Keel", Time.now.to_i, DRb.uri]
Slide 16
Slide 16 text
Service Discovery
Rinda::RingFinger, Rinda::RingServer
TupleSpace for registry
Broadcast, unicast, multicast (Ruby 2.1)
Rinda::RingProvider
Wrapper for advertisement
Slide 17
Slide 17 text
Shoes
Created by _why
Simple cross-
platform GUI toolkit
for Ruby
Shoes4 is an all-
Ruby rewrite
Still under active
development
Blue Power! by Éole Wind
Display Issues
Not all movement methods have been
implemented on all types of objects
Can move, but not displace
Width/height =(
Show/hide/toggle missing =(
Slide 20
Slide 20 text
Animations
Animations run in parallel
Need to manually manage them
start, stop, remove
PROTIP™: Separate drawing from
animation
Slide 21
Slide 21 text
Give Back
Complicated Shoes app highlights
regressions
Use game to detect & fix issues
Slide 22
Slide 22 text
Open Source
Three Gems!
github.com/davy/
pirate_command
github.com/davy/
shuttlecraft
github.com/davy/
pirate_game
Coast Guard by Mike Baird
Networking
Theoretically this should work on
conference wifi
*But* for best results use a personal
access point
Slide 53
Slide 53 text
RingServer
Someone needs to run a ringserver
$ ring_server
But not too many
Try not to screw it up
We are working on it
Slide 54
Slide 54 text
Game Master
Only one needed per game
Pick a good name
If GM crashes, game is stranded =(
Slide 55
Slide 55 text
Pirate Game!
1* to 4 players
*Totally a ‘feature’
not a bug
Slide 56
Slide 56 text
Find Your Game
GMs are found
by Rinda
service
discovery
Slide 57
Slide 57 text
Find Your Game
ISSUE: If join fails you will not receive an
error message and will enter empty
disconnected pub =(
Slide 58
Slide 58 text
Pirate Pub
Chat with your
friends in the
Pirate Pub*
*Yes, you have to
click the ‘Send’
button. No
keybindings?!?
=(
Slide 59
Slide 59 text
Pirate Pub
ISSUE: At the moment the GM needs to
trigger each stage.
Future development should switch over to
Spaceteam-like mechanism where each
player indicates that they are ready to
proceed
Slide 60
Slide 60 text
Sail the High Seas
Keep the ship
afloat!
Work together
to man the ship
Beware of bad
weather!
Slide 61
Slide 61 text
Security
DRb Priorities:
Transparency
Easy of use
…
Security
Pirates by Adrien Sifre
Slide 62
Slide 62 text
Full Access
Clients can do anything
Get remote nil
instance_eval
github.com/drbrain/drb-worm
Slide 63
Slide 63 text
Message-level Security
DRb::DRbServer::INSECURE_METHOD
Opt-out
$SAFE
Relies on tainting
Slide 64
Slide 64 text
DRb over UNIX Socket
Restricted to one host
Filesystem permissions control access
No network access
Slide 65
Slide 65 text
Access Control List
Deny or allow by IP address and range
Difficult to manage
No privacy
Slide 66
Slide 66 text
DRb over SSL
X509 certificate
Full privacy
Difficult to manage
Slide 67
Slide 67 text
chroot
Filesystem sandbox
Can’t write outside
Can still consume CPU, create processes
Slide 68
Slide 68 text
Best Practices
Verify your peers
Limit accessibility
Use a private network
Slide 69
Slide 69 text
drbdump
tcpdump for DRb
Message sends
Message latency
Message
allocations
Colorful toy trucks parked together in rows
by Horia Varlan
Slide 70
Slide 70 text
Problems
Out-of-order TCP
mDNS
Ruby 2.1
No filtering
IPv6 (bug)
Slide 71
Slide 71 text
Running
Basic
drbdump
Summary of 10,000 messages
drbdump -q -n -c 10000
Listen only on loopback
drbdump -i lo0