pax_global_header 0000666 0000000 0000000 00000000064 13711043772 0014517 g ustar 00root root 0000000 0000000 52 comment=60141e8d3942a88ba3de6a9b3aef9503bc1bb1e6 faye-1.4.0/ 0000775 0000000 0000000 00000000000 13711043772 0012445 5 ustar 00root root 0000000 0000000 faye-1.4.0/.gitignore 0000664 0000000 0000000 00000000137 13711043772 0014436 0 ustar 00root root 0000000 0000000 *.gem build Gemfile.lock lib/client node_modules package-lock.json spec/*_bundle.js spec/*.map faye-1.4.0/CHANGELOG.md 0000664 0000000 0000000 00000047215 13711043772 0014267 0 ustar 00root root 0000000 0000000 ### 1.4.0 / 2020-07-31 - Implement TLS certificate verification and enable it by default in the Ruby client class `Faye::Client` - Add a `:tls` option to the Ruby client with sub-field `:verify_peer` for configuring TLS verification - Officially support the `tls` option in the Node.js client, whose contents are forward to the `https` and `tls` modules as appropriate ### 1.3.0 / 2020-06-08 - Support `user:pass@` authorization in URIs and send `Authorization` headers from the Node HTTP transport - Support IPv6 hostnames in URIs - Allow credentials (cookies and `Authorization` headers) in cross-origin requests, by: - setting `Access-Control-Allow-Origin` to the value of the `Origin` header (not `*`) - enabling `Access-Control-Allow-Credentials` - Enable credentials when sending cross-origin requests - Don't disconnect WebSocket on page unload if `autodisconnect` is turned off - Catch errors when creating a WebSocket, which happens when Content Security Policy blocks it, allowing other transports to be tried - Fix a bug in the client where it handles messages from other clients as though they're the server's response to its own messages, based on the `id` field; now we only treat messages as server responses if they contain `successful: true` - Stop sending an empty message list `[]` from the WebSocket client as a keep-alive mechanism since CometD does not accept this message - Fix deprecation warnings for using the `new Buffer()` constructor - Switch to the Apache 2.0 license ### 1.2.5 / 2020-04-28 - Fix `/meta/*` channel recognition bug in the server that enables authentication bypass - https://blog.jcoglan.com/2020/04/28/authentication-bypass-in-faye/ ### 1.2.4 / 2017-01-28 - Fix `RackAdapter#get_client` that was failing due to a URI error - Define `Promise#catch` in a safe way for old browsers - Log errors in the Node HTTP transport ### 1.2.3 / 2016-10-11 - Return an error if the `data` field is missing on published messages - Fix errors that occur in the new `websocket` util when the browser does not support WebSocket ### 1.2.2 / 2016-07-18 - Mitigate the HTTPoxy vulnerability: https://httpoxy.org/ ### 1.2.1 / 2016-06-29 - Fix a missing variable error in `NodeAdapter` ### 1.2.0 / 2016-06-26 - Add `client.subscribe().withChannel()` to yield the message channel for wildcard subscriptions - Restructure the JavaScript codebase around Node modules (require/exports) rather than globals - Update the Promise shim to reflect the standard API, including `catch()` and `all()` - Support connecting to servers that use SNI in the Ruby client - Make the JavaScript client work inside React Native and Web Workers - Remove JSON2; you should import a JSON shim yourself if necessary - Handle errors that occur when a message is partially delivered via EventSource - Reject requests with invalid (non-array or -object) top-level JSON values - Make local client requests asynchronous to avoid re-entrant request handling errors - Remove `Connection: Close` from HTTP responses to allow use of keep-alive - Use `XMLHttpRequest` in preference to the ActiveX API in IE10 - Fix bug where flushing large message batches puts promises in an invalid state ### 1.1.3 / 2020-04-28 - Fix `/meta/*` channel recognition bug in the server that enables authentication bypass - https://blog.jcoglan.com/2020/04/28/authentication-bypass-in-faye/ ### 1.1.2 / 2015-07-19 - Allow the `Authorization` header to be used on CORS requests - Disallow unused methods like PUT and DELETE on CORS requests - Stop IE prematurely garbage-collecting `XDomainRequest` objects - Make sure messages can be sent if they overflow the request size limit and the outbox is empty - Don't send messages over WebSockets unless they are in the 'open' ready-state - Fix a bug preventing use of the in-process transport in Ruby ### 1.1.1 / 2015-02-25 - Make sure the client ID associated with a WebSocket is not dropped, so the socket can be closed properly - Handle cases where a JSON-P endpoint returns no response argument - Stop trying to retry messages after the client has been disconnected - Remove duplication of the client ID in EventSource URLs ### 1.1.0 / 2014-12-22 - Allow the server and client to use WebSocket extensions, for example permessage-deflate - Support the `HTTP_PROXY` and `HTTPS_PROXY` environment variables to send all client connections through an HTTP proxy - Introduce the `Scheduler` API to allow the user to control message retries - Add the `attempts` and `deadline` options to `Client#publish()` - Let `RackAdapter` take a block that yields the instance, so extensions can be added to middleware - Allow monitoring listeners to see the `clientId` on publishd messages but still avoid sending it to subscribers - Return a promise from `Client#disconnect()` - Fix client-side retry bugs causing the client to flood the server with duplicate messages - Send all transport types in the `supportedConnectionTypes` handshake parameter - Don't close WebSockets when the client recovers from an error and sends a new `clientId` - Replace `cookiejar` with `tough-cookie` to avoid global variable leaks ### 1.0.4 / 2020-04-28 - Fix `/meta/*` channel recognition bug in the server that enables authentication bypass - https://blog.jcoglan.com/2020/04/28/authentication-bypass-in-faye/ ### 1.0.3 / 2014-07-08 - Make some changes to JSON-P responses to mitigate the Rosetta Flash attack - http://miki.it/blog/2014/7/8/abusing-jsonp-with-rosetta-flash/ ### 1.0.2 -- removed due to error while publishing ### 1.0.1 / 2013-12-10 - Add `Adapter#close()` method for gracefully shutting down the server - Fix error recover bug in WebSocket that made transport cycle through `up`/`down` state - Update Promise implementation to pass `promises-aplus-tests 2.0` - Correct some incorrect variable names in the Ruby transports - Make logging methods public to fix a problem on Ruby 2.1 ### 1.0.0 / 2013-10-01 - Client changes: - Allow clients to be instantiated with URI objects rather than strings - Add a `ca` option to the Node `Client` class for passing in trusted server certificates - Objects supporting the `callback()` method in JavaScript are now Promises - Fix protocol-relative URI parsing in the client - Remove the `getClientId()` and `getState()` methods from the `Client` class - Transport changes: - Add request-size limiting to all batching transports - Make the WebSocket transport more robust against quiet network periods and clients going to sleep - Support cookies across all transports when using the client on Node.js or Ruby - Support custom headers in the `cross-origin-long-polling` and server-side `websocket` transports - Adapter changes: - Support the `rack.hijack` streaming API - Migrate to MultiJson for JSON handling on Ruby, allowing use of JRuby - Escape U+2028 and U+2029 in JSON-P output - Fix a bug stopping requests being routed when the mount point is `/` - Fix various bugs that cause errors to be thrown if we try to send a message over a closed socket - Remove the `listen()` method from `Adapter` in favour of using server-specific APIs - Server changes: - Use cryptographically secure random number generators to create client IDs - Allow extensions to access request properties by using 3-ary methods - Objects supporting the `bind()` method now implement the full `EventEmitter` API - Stop the server from forwarding the `clientId` property of published messages - Miscellaneous: - Support Browserify by returning the client module - `Faye.logger` can now be a logger object rather than a function ### 0.8.11 / 2014-07-08 - Make some changes to JSON-P responses to mitigate the Rosetta Flash attack - http://miki.it/blog/2014/7/8/abusing-jsonp-with-rosetta-flash/ ### 0.8.10 -- removed due to error while publishing ### 0.8.9 / 2013-02-26 - Specify ciphers for SSL on Node to mitigate the BEAST attack - Mitigate increased risk of socket hang-up errors in Node v0.8.20 - Fix race condition when processing outgoing extensions in the Node server - Fix problem loading the client script when using `{mount: '/'}` - Clean up connection objects when a WebSocket is re-used with a new clientId - All JavaScript code now runs in strict mode - Select transport on handshake, instead of on client creation to allow time for `disable()` calls - Do not speculatively open WebSocket/EventSource connections if they are disabled - Gracefully handle WebSocket messages with no data on the client side - Close and reconnect WebSocket when onerror is fired, not just when onclose is fired - Fix problem with caching of EventSource connections with stale clientIds - Don't parse query strings when checking if a URL is same-origin or not ### 0.8.8 / 2013-01-10 - Patch security hole allowing remote execution of arbitrary Server methods ### 0.8.7 -- removed due to error while publishing ### 0.8.6 / 2012-10-07 - Make sure messages pushed to the client over a socket pass through outgoing extensions ### 0.8.5 / 2012-09-30 - Fix a bug in `URI.parse()` that caused Faye endpoints to inherit search and hash from `window.location` ### 0.8.4 / 2012-09-29 - Optimise upgrade process so that WebSocket is tested earlier and the connection is cached - Check that EventSource actually works to work around broken Opera implementation - Emit `connection:open` and `connection:close` events from the Engine proxy - Increase size of client IDs from 128 to 160 bits - Fix bug with relative URL resolution in IE - Limit the JSON-P transport's message buffer so it doesn't create over-long URLs - Send `Pragma: no-cache` with XHR requests to guard against iOS 6 POST caching - Add `charset=utf-8` to response Content-Type headers ### 0.8.3 / 2012-07-15 - `Client#subscribe` returns an array of Subscriptions if given an array of channels - Allow different endpoints to be specified per-transport - Only use IE's `XDomainRequest` for same-protocol requests - Replace URL parser with one that treats relative URLs the same as the browser - Improve logging of malformed requests and detect problems earlier - Make sure socket connections are closed when a client session is timed out - Stop WebSocket reconnecting after `window.onbeforeunload` ### 0.8.2 / 2012-04-12 - Fix replacement of `null` with `{}` in `copyObject()` - Make EventSource transport trigger `transport:up/down` events - Supply source map for minified JavaScript client, and include source in gem - Return `Content-Length: 0` for 304 responses - Handle pre-flight CORS requests from old versions of Safari ### 0.8.1 / 2012-03-15 - Make `Publisher#trigger` safe for event listeners that modify the listener list - Make `Server#subscribe` return a response if the incoming message has an error - Fix edge case in code that identifies the `clientId` of socket connections - Return `Content-Length` headers for HTTP responses - Don't send empty lists of messages from the WebSocket transport - Stop client sending multiple `/meta/subscribe` messages for subscriptions made before handshaking - Stop client treating incoming published messages as responses to `/meta/*` messages ### 0.8.0 / 2012-02-26 - Extract the Redis engine into a separate library, `faye-redis` - Stabilize and document the Engine API so others can write backends - Extract WebSocket and EventSource tools into a separate library, `faye-websocket` - Improve use of WebSocket so messages are immediately pushed rather than polling - Introduce new EventSource-based transport, for proxies that block WebSocket - Support the Rainbows and Goliath web servers for Ruby, same as `faye-websocket` - Improve detection of network errors and switch to fixed-interval for reconnecting - Add `setHeader()` method to Client (e.g. for connecting to Salesforce API) - Add `timeout()` method to `Faye.Deferrable` to match `EventMachine::Deferrable` - Fix some bugs in client-side message handlers created with `subscribe()` - Improve speed and memory consumption of `copyObject()` - Switch from JSON to Yajl for JSON parsing in Ruby ### 0.7.2 / 2013-01-10 - Patch security hole allowing remote execution of arbitrary Server methods ### 0.7.1 / 2011-12-22 - Extension `added()` and `removed()` methods now receive the extended object - Detection of WebSockets in RackAdapter is more strict ### 0.7.0 / 2011-11-22 - Provide an event API for monitoring engine events on the server side - Implement server-side WebSocket connections for improved latency - Fix WebSocket protocol bugs and expose APIs for developers to use - Make server-side HTTP transports support SSL and cookies - Allow clients to disable selected transports and autodisconnection - Add callback/errback API to `Client#publish()` interface - Add `socket` setting for the Redis engine for connecting through a Unix socket ### 0.6.8 / 2013-01-10 - Patch security hole allowing remote execution of arbitrary Server methods ### 0.6.7 / 2011-10-20 - Cache client script in memory and add `ETag` and `Last-Modified` headers - Fix bug in Node Redis engine where `undefined` was used if no namespace given - Flush Redis message queues using a transaction to avoid re-delivery of messages - Fix race condition and timing errors present in Redis locking code - Use `Cache-Control: no-cache, no-store` on JSON-P responses - Improvements to the CORS and JSON-P transports - Prevent retry handlers in transports from being invoked multiple times - Use the current page protocol by default when parsing relative URIs ### 0.6.6 / 2011-09-12 - Add `:key` and `:cert` options to the `Adapter#listen` methods for setting up SSL - Fix error detection of CORS transport in IE9 running IE8 compatibility mode - Fix dependency versions so that Rubygems lets Faye install ### 0.6.5 / 2011-08-29 - Fix UTF-8 encoding bugs in draft-75/76 and protocol-8 WebSocket parsers - Switch to streaming parser for WebSocket protocol-8 - Remove an `SREM` operation that shouldn't have been in the Redis engine - Move `thin_extensions.rb` so it's not on the Rubygems load path ### 0.6.4 / 2011-08-18 - Support WebSocket protocol used by Chrome 14 and Firefox 6 - Fix handling of multibyte characters in WebSocket messages on Node - Improve message routing in Node memory engine to avoid false duplicates ### 0.6.3 / 2011-07-10 - Use sequential message IDs to reduce memory usage on the client side - Only send advice with handshake and connect responses - Stop trying to publish `/meta/*` messages - no-one is listening and it breaks `/**` - Fix bug causing invalid listeners to appear after a client reconnection - Stop loading `rubygems` within our library code - Make sure we only queue a message for each client once in the Redis engine - Use lists instead of sets for message queues in Redis - Improve clean-up of expired clients in Redis engine ### 0.6.2 / 2011-06-19 - Add authentication, database selection and namespacing to Redis engine - Clean up all client data when removing clients from Redis - Fix `cross-origin-long-polling` for `OPTIONS`-aware browsers - Update secure WebSocket detection for recent Node versions - Reinstate `faye.client` field in Rack environment ### 0.6.1 / 2011-06-06 - Fix `cross-origin-long-polling` support in `RackAdapter` - Plug some potential memory leaks in `Memory` engine ### 0.6.0 / 2011-05-21 - Extract core logic into the `Engine` class to support swappable backends - Introduce a Redis-backed engine to support clustered web front-ends - Use CORS for `cross-domain long-polling` - Make server more resilient against bad requests, including empty message lists - Perform subscription validation on the server and use errbacks to signal errors - Prohibit publishing to wildcard channels - Unsubscribing from a channel is now O(1) instead of O(N) - Much more thorough and consistent unit test coverage of both versions - Automatic integration tests using Terminus and TestSwarm ### 0.5.5 / 2011-01-16 - Open a real socket to check for WebSocket usability, not just object detection - Catch server-side errors when handshaking with WebSockets ### 0.5.4 / 2010-12-19 - Add a `#callback` method to `Subscriptions` to detect when they become active - Add `:extensions` option to `RackAdapter` to make it easier to extend middleware - Detect secure WebSocket requests through the `HTTP_X_FORWARDED_PROTO` header - Handle socket errors when sending WebSocket messages from `NodeAdapter` - Use exponential backoff to reconnect client-side WebSockets to reduce CPU load ### 0.5.3 / 2010-10-21 - Improve detection of `wss:` requirement for secure WebSocket connections - Correctly use default ports (80,443) for server-side HTTP connections - Support legacy `application/x-www-form-urlencoded` POST requests - Delete unused Channel objects that have all their subscribers removed - Fix resend/reconnect logic in WebSocket transport - Keep client script in memory rather than reading it from disk every time - Prevent error-adding extensions from breaking the core protocol ### 0.5.2 / 2010-08-12 - Support draft-76 of the WebSocket protocol (FF4, Chrome 6) - Reduce `Connection::MAX_DELAY` to improve latency ### 0.5.1 / 2010-07-21 - Fix a publishing problem in Ruby `LocalTransport` ### 0.5.0 / 2010-07-17 - Handle multiple event listeners bound to a channel - Add extension system for adding domain-specific logic to the protocol - Improve handling of client reconnections if the server goes down - Change default polling interval to 0 (immediate reconnect) - Add support for WebSockets (draft75 only) as a network transport - Remove support for Ruby servers other than Thin - Make client and server compatible with CometD (1.x and 2.0) components - Improve clean-up of unused server-side connections - Change Node API for adding Faye service to an HTTP server ### 0.3.4 / 2010-06-20 - Stop local clients going into an infinite loop if a subscription block causes a reconnect ### 0.3.3 / 2010-06-07 - Bring Node APIs up to date with 0.1.97 - Catch `ECONNREFUSED` errors in Node clients to withstand server outages - Refactor the `Server` internals ### 0.3.2 / 2010-04-04 - Fix problems with JSON serialization when Prototype, MooTools present - Make the client reconnect if it doesn't hear from the server after a timeout - Stop JavaScript server returning `NaN` for `advice.interval` - Make Ruby server return an integer for `advice.interval` - Ensure EventMachine is running before handling messages - Handle `data` and `end` events properly in Node HTTP API - Switch to `application/json` for content types and stop using querystring format in POST bodies - Respond to any URL path under the mount point, not just the exact match ### 0.3.1 / 2010-03-09 - Pass client down through Rack stack as `env['faye.client']` - Refactor some JavaScript internals to mirror Ruby codebase ### 0.3.0 / 2010-03-01 - Add server-side clients for Node.js and Ruby environments - Clients support both HTTP and in-process transports - Fix ID generation in JavaScript version to 128-bit IDs - Fix bug in interpretation of `**` channel wildcard - Users don't have to call `#connect()` on clients any more - Fix timeout race conditions that were killing active connections - Support new Node APIs from 0.1.29. ### 0.2.2 / 2010-02-10 - Kick out requests with malformed JSON as 400s ### 0.2.1 / 2010-02-04 - Fix server-side flushing of callback-polling connections - Backend can be used cross-domain if running on Node or Thin ### 0.2.0 / 2010-02-02 - Port server to JavaScript with an adapter for Node.js - Support Thin's async responses in the Ruby version for complete non-blocking - Fix some minor client-side bugs in transport choice ### 0.1.1 / 2009-07-26 - Fix a broken client build ### 0.1.0 / 2009-06-15 - Ruby Bayeux server and Rack adapter - Internally evented using EventMachine, web frontend blocks - JavaScript client with `long-polling` and `callback-polling` faye-1.4.0/CODE_OF_CONDUCT.md 0000664 0000000 0000000 00000000242 13711043772 0015242 0 ustar 00root root 0000000 0000000 # Code of Conduct All projects under the [Faye](https://github.com/faye) umbrella are covered by the [Code of Conduct](https://github.com/faye/code-of-conduct). faye-1.4.0/CONTRIBUTING.md 0000664 0000000 0000000 00000001762 13711043772 0014704 0 ustar 00root root 0000000 0000000 # Contributing to Faye Faye is implemented in both JavaScript and Ruby. You should be able to hack on each implementation independently, although since both implementations include a build of the JS client, you will need Node if you want to build the Ruby gem. To get the code: git clone git://github.com/faye/faye.git cd faye ## Working on the JavaScript codebase To install the dependencies (you will need to do this if you need to build the Ruby gem as well): npm install To run the tests on Node: npm test To run the tests in the browser, you should run make test which starts a process to continuously rebuild the source code and tests as you edit them. Open `spec/index.html` to run the tests. To build the package that we release to npm, run: make ## Working on the Ruby codebase To install the dependencies: bundle install To run the tests: bundle exec rspec To build the gem (you will need to install the Node dependencies for this): make gem faye-1.4.0/Gemfile 0000664 0000000 0000000 00000000046 13711043772 0013740 0 ustar 00root root 0000000 0000000 source 'https://rubygems.org' gemspec faye-1.4.0/LICENSE.md 0000664 0000000 0000000 00000001056 13711043772 0014053 0 ustar 00root root 0000000 0000000 Copyright 2009-2020 James Coglan Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. faye-1.4.0/Makefile 0000664 0000000 0000000 00000001550 13711043772 0014106 0 ustar 00root root 0000000 0000000 PATH := node_modules/.bin:$(PATH) SHELL := /bin/bash source_files := $(shell find src -name '*.js') spec_files := $(shell find spec -name '*_spec.js') webpack_config := webpack.config.js name := faye-browser bundles := $(name).js $(name)-min.js client_dir := build/client client_bundles := $(bundles:%=$(client_dir)/%) top_files := CHANGELOG.md LICENSE.md README.md package.json src top_level := $(top_files:%=build/%) .PHONY: all gem clean all: $(client_bundles) $(top_level) gem: all gem build faye.gemspec clean: rm -rf build *.gem spec/*_bundle.js{,.map} $(client_dir)/$(name).js: $(webpack_config) $(source_files) webpack $(client_dir)/$(name)-min.js: $(webpack_config) $(source_files) NODE_ENV=production webpack build/src: $(source_files) build rsync -a src/ $@/ build/%: % build cp $< $@ build: mkdir -p $@ faye-1.4.0/README.md 0000664 0000000 0000000 00000000660 13711043772 0013726 0 ustar 00root root 0000000 0000000 # Faye Faye is a set of tools for simple publish-subscribe messaging between web clients. It ships with easy-to-use message routing servers for Node.js and Rack applications, and clients that can be used on the server and in the browser. - Documentation: http://faye.jcoglan.com - Mailing list: http://groups.google.com/group/faye-users - Bug tracker: http://github.com/faye/faye/issues - Source code: http://github.com/faye/faye faye-1.4.0/Rakefile 0000664 0000000 0000000 00000001126 13711043772 0014112 0 ustar 00root root 0000000 0000000 require 'rubygems' require './lib/faye' task :example, :port, :ssl do |t, args| exec "ruby examples/ruby/server.rb #{args[:port]} #{args[:ssl] && 'ssl'}" end task :handshake, :port, :n, :c do |t, args| require 'cgi' require 'json' message = {:channel => '/meta/handshake', :version => '1.0', :supportedConnectionTypes => ['long-polling']} message = CGI.escape(JSON.dump message) url = "http://127.0.0.1:#{args[:port]}/bayeux?jsonp=callback&message=#{message}" puts "Request URL:\n#{url}\n\n" exec "ab -n #{args[:n]} -c #{args[:c]} '#{url}'" end faye-1.4.0/examples/ 0000775 0000000 0000000 00000000000 13711043772 0014263 5 ustar 00root root 0000000 0000000 faye-1.4.0/examples/automate.rb 0000664 0000000 0000000 00000002336 13711043772 0016433 0 ustar 00root root 0000000 0000000 # Load and configure Capybara require 'capybara/dsl' require 'terminus' Capybara.current_driver = :terminus Capybara.app_host = 'http://localhost:9292' extend Capybara::DSL # Acquire some browsers and log into each with a username NAMES = %w[alice bob carol dan erica frank gemma harold ingrid james] BROWSERS = {} Terminus.ensure_browsers 5 Terminus.browsers.each_with_index do |browser, i| name = NAMES[i] puts "#{ name } is using #{ browser }" BROWSERS[name] = browser Terminus.browser = browser visit '/' fill_in 'username', :with => name click_button 'Go' end # Send a message from each browser to every other browser, and check that it # arrived. If it doesn't arrive, send all the browsers back to the dock and # raise an exception BROWSERS.each do |name, sender| BROWSERS.each do |at, target| next if at == name Terminus.browser = sender fill_in 'message', :with => "@#{ at } Hello, world!" click_button 'Send' Terminus.browser = target unless page.has_content?("#{ name }: @#{ at } Hello, world!") Terminus.return_to_dock raise "Message did not make it from #{ sender } to #{ target }" end end end # Re-dock all the browsers when we're finished Terminus.return_to_dock faye-1.4.0/examples/haproxy.conf 0000664 0000000 0000000 00000000513 13711043772 0016623 0 ustar 00root root 0000000 0000000 listen stats 127.0.0.1:7000 option httpchk mode http stats uri / listen soapbox 127.0.0.1:3000 option httpchk GET / server soapbox1 127.0.0.1:7070 weight 1 maxconn 1000 check port 7070 server soapbox2 127.0.0.1:8080 weight 1 maxconn 1000 check port 8080 server soapbox3 127.0.0.1:9090 weight 1 maxconn 1000 check port 9090 faye-1.4.0/examples/node/ 0000775 0000000 0000000 00000000000 13711043772 0015210 5 ustar 00root root 0000000 0000000 faye-1.4.0/examples/node/benchmark.js 0000664 0000000 0000000 00000001722 13711043772 0017502 0 ustar 00root root 0000000 0000000 var faye = require('../../build'), port = process.argv[2] || 8000, path = process.argv[3] || 'bayeux', scheme = process.argv[4] === 'tls' ? 'https' : 'http'; var A = new faye.Client(scheme + '://localhost:' + port + '/' + path), B = new faye.Client(scheme + '://localhost:' + port + '/' + path); A.connect(function() { B.connect(function() { var time = new Date().getTime(), MAX = 1000; var stop = function() { console.log(new Date().getTime() - time); process.exit(); }; var handle = function(client, channel) { return function(n) { if (n === MAX) return stop(); client.publish(channel, n + 1); }; }; var subA = A.subscribe('/chat/a', handle(A, '/chat/b')), subB = B.subscribe('/chat/b', handle(B, '/chat/a')); subA.callback(function() { subB.callback(function() { console.log('START'); A.publish('/chat/b', 0); }); }); }); }); faye-1.4.0/examples/node/client.js 0000664 0000000 0000000 00000003176 13711043772 0017033 0 ustar 00root root 0000000 0000000 // This script demonstrates a logger for the chat app. First, start the chat // server in one terminal then run this in another: // // $ node examples/node/server.js // $ node examples/node/client.js // // The client connects to the chat server and logs all messages sent by all // connected users. var fs = require('fs'), deflate = require('permessage-deflate'), faye = require('../../build'), port = process.argv[2] || 8000, path = process.argv[3] || 'bayeux', scheme = process.argv[4] === 'tls' ? 'https' : 'http', endpoint = scheme + '://localhost:' + port + '/' + path, cert = fs.readFileSync(__dirname + '/../server.crt'), proxy = { headers: { 'User-Agent': 'Faye' }, tls: { ca: cert }}; console.log('Connecting to ' + endpoint); var client = new faye.Client(endpoint, { proxy: proxy, tls: { ca: cert }}); client.addWebsocketExtension(deflate); var subscription = client.subscribe('/chat/*', function(message) { var user = message.user; var publication = client.publish('/members/' + user, { user: 'node-logger', message: ' Got your message, ' + user + '!' }); publication.callback(function() { console.log('[PUBLISH SUCCEEDED]'); }); publication.errback(function(error) { console.log('[PUBLISH FAILED]', error); }); }); subscription.callback(function() { console.log('[SUBSCRIBE SUCCEEDED]'); }); subscription.errback(function(error) { console.log('[SUBSCRIBE FAILED]', error); }); client.bind('transport:down', function() { console.log('[CONNECTION DOWN]'); }); client.bind('transport:up', function() { console.log('[CONNECTION UP]'); }); faye-1.4.0/examples/node/pingpong.js 0000664 0000000 0000000 00000000777 13711043772 0017402 0 ustar 00root root 0000000 0000000 var faye = require('../../build'); ENDPOINT = 'http://localhost:8000/bayeux'; console.log('Connecting to ' + ENDPOINT); var ping = new faye.Client(ENDPOINT); ping.subscribe('/ping', function() { console.log('PING'); setTimeout(function() { ping.publish('/pong', {}) }, 1000); }); var pong = new faye.Client(ENDPOINT); pong.subscribe('/pong', function() { console.log('PONG'); setTimeout(function() { pong.publish('/ping', {}) }, 1000); }); setTimeout(function() { ping.publish('/pong', {}) }, 500); faye-1.4.0/examples/node/server.js 0000664 0000000 0000000 00000003303 13711043772 0017053 0 ustar 00root root 0000000 0000000 var fs = require('fs'), path = require('path'), http = require('http'), https = require('https'), mime = require('mime'), deflate = require('permessage-deflate'), faye = require('../../build'); var SHARED_DIR = __dirname + '/..', PUBLIC_DIR = SHARED_DIR + '/public', bayeux = new faye.NodeAdapter({ mount: '/bayeux', timeout: 20 }), port = process.argv[2] || '8000', secure = process.argv[3] === 'tls', key = fs.readFileSync(SHARED_DIR + '/server.key'), cert = fs.readFileSync(SHARED_DIR + '/server.crt'); bayeux.addWebsocketExtension(deflate); var handleRequest = function(request, response) { var path = (request.url === '/') ? '/index.html' : request.url; fs.readFile(PUBLIC_DIR + path, function(err, content) { var status = err ? 404 : 200; try { response.writeHead(status, { 'Content-Type': mime.lookup(path) }); response.end(content || 'Not found'); } catch (e) {} }); }; var server = secure ? https.createServer({ cert: cert, key: key }, handleRequest) : http.createServer(handleRequest); bayeux.attach(server); server.listen(Number(port)); bayeux.getClient().subscribe('/chat/*', function(message) { console.log('[' + message.user + ']: ' + message.message); }); bayeux.on('subscribe', function(clientId, channel) { console.log('[ SUBSCRIBE] ' + clientId + ' -> ' + channel); }); bayeux.on('unsubscribe', function(clientId, channel) { console.log('[UNSUBSCRIBE] ' + clientId + ' -> ' + channel); }); bayeux.on('disconnect', function(clientId) { console.log('[ DISCONNECT] ' + clientId); }); console.log('Listening on ' + port + (secure? ' (https)' : '')); faye-1.4.0/examples/node/ticker.js 0000664 0000000 0000000 00000000362 13711043772 0017030 0 ustar 00root root 0000000 0000000 var faye = require('../../build'); var endpoint = process.argv[2] || 'http://localhost:8000/bayeux', client = new faye.Client(endpoint), n = 0; setInterval(function() { client.publish('/chat/tick', { n: ++n }); }, 1000); faye-1.4.0/examples/public/ 0000775 0000000 0000000 00000000000 13711043772 0015541 5 ustar 00root root 0000000 0000000 faye-1.4.0/examples/public/index.html 0000664 0000000 0000000 00000002530 13711043772 0017536 0 ustar 00root root 0000000 0000000