lib/envoy/server/trunk.rb in envoy-proxy-0.1.5 vs lib/envoy/server/trunk.rb in envoy-proxy-0.2.0

- old
+ new

@@ -75,39 +75,40 @@ if version? "~> 0.1" receive_pong end if version? "< #{Envoy::VERSION}" send_object :message, "Your client is out of date. Please upgrade to #{Envoy::VERSION}." + elsif version? "> #{Envoy::VERSION}" + send_object :message, "Your client is from the future. The server is expecting #{Envoy::VERSION}." end if @key and @key != @options[:key] halt "Key is invalid" return end hosts = @options[:hosts] || [] hosts.any? do |label| if label == "s" - send_object :message, "#{label}: label is reserved" + send_object :message, "label is reserved: `#{label}'" true elsif label =~ /\./ - send_object :message, "#{label}: labels may not contain dots" + send_object :message, "label is invalid: `#{label}'" true elsif other_trunk = Trunk.trunks[label][0] unless other_trunk.key == key - send_object :message, "#{label}: label in use, and you don't have the key" + send_object :message, "label is protected with a key: `#{label}'" true end end end && halt hosts << SecureRandom.random_number(36 ** 4).to_s(36) if hosts.empty? m = ["#{options[:local_host]}:#{options[:local_port]} now available at:"] @hosts = hosts.each do |host| Trunk.trunks[host] << self - m << "http://#{host}.#{$zone}/" + send_object :message, "host: #{host}.#{$zone}" end - send_object :message, m.join(" ") unless @options[:key] @options[:key] ||= SecureRandom.hex(8) - send_object :message, "Your key is #{@options[:key]}" + send_object :message, "key: #{@options[:key]}" end end def unbind hosts.each do |host|