Skip to content
This repository has been archived by the owner on Apr 7, 2021. It is now read-only.

Commit

Permalink
Merge branch 'atmos'
Browse files Browse the repository at this point in the history
Conflicts:
	server.coffee
  • Loading branch information
mpd committed Dec 6, 2010
2 parents 98b080a + c8761eb commit d61867a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 13 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
tmp/camouflage.pid
server.js
tmp/camo.pid
5 changes: 5 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
namespace :test do
desc "Run the tests against localhost"
task :check do |t|
system("ruby test/proxy_test.rb")
end
end
task :default => "test:check"

Dir["tasks/*.rake"].each do |f|
load f
end
21 changes: 12 additions & 9 deletions server.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ Http = require 'http'
Crypto = require 'crypto'
QueryString = require 'querystring'

port = process.env.PORT || 8081
version = "0.2.2"
shared_key = process.env.CAMO_KEY || '0x24FEEDFACEDEADBEEFCAFE'
port = process.env.PORT || 8081
version = "0.3.0"
shared_key = process.env.CAMO_KEY || '0x24FEEDFACEDEADBEEFCAFE'
logging_enabled = process.env.CAMO_LOGGING_ENABLED || "disabled"
pidfile = process.env.PIDFILE || 'tmp/camo.pid'

log = (msg) ->
console.log("--------------------------------------------")
console.log(msg)
console.log("--------------------------------------------")
unless logging_enabled == "disabled"
console.log("--------------------------------------------")
console.log(msg)
console.log("--------------------------------------------")

server = Http.createServer (req, resp) ->
if req.method != 'GET' || req.url == '/'
Expand Down Expand Up @@ -102,7 +105,7 @@ server = Http.createServer (req, resp) ->
resp.writeHead srcResp.statusCode, newHeaders

else
four_oh_four("Responded with #{srcResp.statusCode}")
four_oh_four("Responded with #{srcResp.statusCode}:#{srcResp.headers}")

srcReq.on 'error', ->
resp.end()
Expand All @@ -112,14 +115,14 @@ server = Http.createServer (req, resp) ->
else
four_oh_four("No host found")
else
four_oh_four("checksum mismatch")
four_oh_four("checksum mismatch #{hmac_digest}:#{query_digest}")
else
four_oh_four("No pathname provided on the server")

console.log "SSL-Proxy running on #{port} with pid:#{process.pid}."
console.log "Using the secret key #{shared_key}"

Fs.open (process.env.PIDFILE || "tmp/camo.pid"), "w", 0600, (err, fd) ->
Fs.open (pidfile), "w", 0600, (err, fd) ->
Fs.writeSync fd, process.pid

server.listen port
Empty file added tasks/.gitignore
Empty file.
6 changes: 3 additions & 3 deletions test/proxy_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

require 'test/unit'

class AssetProxyTest < Test::Unit::TestCase
class CamoProxyTest < Test::Unit::TestCase
def config
{ 'key' => "0x24FEEDFACEDEADBEEFCAFE",
'host' => "http://localhost:8081" }
{ 'key' => ENV['CAMO_KEY'] || "0x24FEEDFACEDEADBEEFCAFE",
'host' => ENV['CAMO_HOST'] || "http://localhost:8081" }
end

def request(image_url)
Expand Down

0 comments on commit d61867a

Please sign in to comment.