mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-14 02:42:40 +01:00
86040227b0
Summary: - Move to port 22280 by default. - Warn when running as non-root. - Allow subscription and publish/admin ports to be configured. - Allow server to drop root after binding to 843. - Allow log path to be configured. - Add /status/ admin URI which shows server status. - Return HTTP 400 Bad Request for other requests, instead of hanging. - Minor formatting cleanup. Test Plan: Ran without root: $ node aphlict_server.js ...got a good error message. Ran with --user: $ sudo node aphlict_server.js --user=epriestley ...verified server dropped permissions. Ran with --port / --admin. Hit /status/ with GET, got status. Hit other URLs with GET, got 400. Reviewers: allenjohnashton, ddfisher, keebuhm Reviewed By: ddfisher CC: aran Differential Revision: https://secure.phabricator.com/D2737
74 lines
1.8 KiB
JavaScript
74 lines
1.8 KiB
JavaScript
/**
|
|
* @provides javelin-aphlict
|
|
* @requires javelin-install
|
|
* javelin-util
|
|
*/
|
|
|
|
/**
|
|
* Simple JS API for the Flash Aphlict client. Example usage:
|
|
*
|
|
* var aphlict = new JX.Aphlict('aphlict_swf', '127.0.0.1', 22280)
|
|
* .setHandler(function(type, message) {
|
|
* JX.log("Got " + type + " event!")
|
|
* })
|
|
* .start();
|
|
*
|
|
* Your handler will receive these events:
|
|
*
|
|
* - `connect` The client initiated a connection to the server.
|
|
* - `connected` The client completed a connection to the server.
|
|
* - `close` The client disconnected from the server.
|
|
* - `error` There was an error.
|
|
* - `receive` Received a message from the server.
|
|
*
|
|
* You do not have to handle any of them in any specific way.
|
|
*/
|
|
JX.install('Aphlict', {
|
|
|
|
construct : function(id, server, port) {
|
|
if (__DEV__) {
|
|
if (JX.Aphlict._instance) {
|
|
JX.$E('Aphlict object is sort of a singleton..!');
|
|
}
|
|
}
|
|
|
|
JX.Aphlict._instance = this;
|
|
|
|
this._server = server;
|
|
this._port = port;
|
|
|
|
// Flash puts its "objects" into global scope in an inconsistent way,
|
|
// because it was written in like 1816 when globals were awesome and IE4
|
|
// didn't support other scopes since global scope is the best anyway.
|
|
var container = document[id] || window[id];
|
|
|
|
this._flashContainer = container;
|
|
},
|
|
|
|
members : {
|
|
_server : null,
|
|
_port : null,
|
|
start : function() {
|
|
this._flashContainer.connect(this._server, this._port);
|
|
}
|
|
},
|
|
|
|
properties : {
|
|
handler : null
|
|
},
|
|
|
|
statics : {
|
|
_instance : null,
|
|
didReceiveEvent : function(type, message) {
|
|
if (!JX.Aphlict._instance) {
|
|
return;
|
|
}
|
|
|
|
var handler = JX.Aphlict._instance.getHandler();
|
|
if (handler) {
|
|
handler(type, message);
|
|
}
|
|
}
|
|
}
|
|
|
|
});
|