Permalink
Browse files

Created separate flash socket policy server for Node

Signed-off-by: Jonas Pfenniger <jonas@pfenniger.name>
  • Loading branch information...
1 parent 29dc7e6 commit ca2c68a1e72b090833a78aead66843afd6b2e5d5 @tautologistics tautologistics committed with Jan 4, 2010
Showing with 25 additions and 0 deletions.
  1. +25 −0 example/socketpolicy.js
View
@@ -0,0 +1,25 @@
+var sys = require("sys");
+var tcp = require("tcp");
+
+var server = tcp.createServer(function (socket) {
+ socket.setEncoding("utf8");
+ socket.inBuffer = "";
+ socket.addListener("connect", function () {
+ sys.debug("Connection to policy server from " + socket.remoteAddress);
+ }).addListener("receive", function (data) {
+ socket.inBuffer += data;
+ if (socket.inBuffer.length > 32) {
+ socket.close();
+ return;
+ }
+ if (server.policyReqRegex.test(socket.inBuffer)) {
+ socket.send(server.policyRes);
+ socket.close();
+ }
+ });
+})
+server.policyReqRegex = /<\s*policy\-file\-request\s*\/>/i;
+server.policyRes = "<cross-domain-policy><allow-access-from domain=\"*\" to-ports=\"*\" /></cross-domain-policy>";
+server.listen(843);
+sys.puts("Listening for Flash policy requests on port 843");
+

0 comments on commit ca2c68a

Please sign in to comment.