Due on Feb 19 @ 05:00pm
Make a say server so your friends can make your computer talk to you
Objectives
Learning Objectives
After completing this assignment, you should…
Be able to write controllers to expose functionality to the local network
Make system calls based on user input
Appreciate the difficulty in securing anything doing the above
Performance Objectives
After completing this assignment, you be able to effectively use
Sinatra or Camping to build a web server in Ruby
Their respective DSLs for routing and handling an incoming request
Details
Deliverables
A repo containing at least:
app.rb
example.rb, based on the following:
require 'httparty'
url = "http://localhost:4567" # update this if needed
HTTParty.post "#{url}/cellos", body: { phrase: 'Droid' }
sleep 1
HTTParty.post "#{url}/badnews", body: { phrase: 'Daisy, Daisy, give me your answer do' }
sleep 1
# Add other examples here
puts HTTParty.get "#{url}/log?limit=5"
Requirements
Running ruby app.rb should start a server
Running ruby example.rb (with the server up) should play several phrases, and then log the most recent requests
Normal Mode
Implement endpoints POST /cellos and POST /badnews that take a phrase param and say that phrase with the associated voice.
Any call to say should be logged for auditing later. Record the time and ip address of the requester. GET /logs?limit=n should show the n most recent such requests.
You are encouraged to add more voices and examples as you see fit.
Hard Mode
Maintain a whitelist of ips allowed to use the service. Automatically block users if they make too many calls per minute.
Notes
Be very careful exposing system calls to the outside world. Think about how a malicious user could use them to attack your system.
Due on Feb 19 @ 05:00pm Make a
say
server so your friends can make your computer talk to youObjectives
Learning Objectives
After completing this assignment, you should…
Performance Objectives
After completing this assignment, you be able to effectively use
Details
Deliverables
app.rb
example.rb
, based on the following:Requirements
ruby app.rb
should start a serverruby example.rb
(with the server up) should play several phrases, and then log the most recent requestsNormal Mode
Implement endpoints
POST /cellos
andPOST /badnews
that take aphrase
param and say that phrase with the associated voice.Any call to
say
should be logged for auditing later. Record the time and ip address of the requester.GET /logs?limit=n
should show then
most recent such requests.You are encouraged to add more voices and examples as you see fit.
Hard Mode
Maintain a whitelist of ips allowed to use the service. Automatically block users if they make too many calls per minute.
Notes
Be very careful exposing system calls to the outside world. Think about how a malicious user could use them to attack your system.
Additional Resources
harder-better
from class, and note the commits exposing it to the local network on a port and fixing HTTParty requests.say
voices.