0

I'm trying to serve inline flash policy file on port 3000, but with no luck.

I can not catch any callback from flash policy call (<policy-file-request/>\0). And I don't know how to serve send policy file back to flash through the socket.

Somethig like this: Setting up a socket policy file server from Adobe

This is code from server:

var server   = require('http').createServer();
var io       = require('socket.io')(server);

var port = 3000;

var xml = '<?xml version="1.0"?>\n<!DOCTYPE cross-domain-policy SYSTEM \n"http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">\n<cross-domain-policy>\n';
    xml += '<site-control permitted-cross-domain-policies="master-only"/>\n';
    xml += '<allow-access-from domain="*" to-ports="*"/>\n';
    xml += '</cross-domain-policy>\n';

io.on('connection', function (socket) {
    socket.on('<policy-file-request/>\0', function (data, callback) {
        console.log('socket policy-file-request 0');
        callback(xml);
    });
});

server.listen(port, function () {
    info('Server listening at ' + port);
});

And from client:

Security.loadPolicyFile("xmlsocket://example.com:3000");

2 Answers2

0

You are doing the socket.io connections and communications incorrectly. You have to emit to the sockets instead of using a callback method, as such (a modification of your code):

Server:

var server   = require('http').createServer();
var io       = require('socket.io')(server);

var port = 3000;

var xml = '<?xml version="1.0"?>\n<!DOCTYPE cross-domain-policy SYSTEM \n"http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">\n<cross-domain-policy>\n';
    xml += '<site-control permitted-cross-domain-policies="master-only"/>\n';
    xml += '<allow-access-from domain="*" to-ports="*"/>\n';
    xml += '</cross-domain-policy>\n';

io.on('connection', function (socket) {
    socket.on('<policy-file-request/>\0', function (data) {
        console.log('socket policy-file-request 0');
        socket.emit('<policy-file-request/>\0', xml);
    });

    socket.on('<policy-file-request/>', function (data) {
        console.log('socket policy-file-request');
        socket.emit('<policy-file-request/>', xml);
    });
});

server.listen(port, function () {
    info('Server listening at ' + port);
});

Client:

//
//Existing code (socket setup)
//

socket.on('<policy-file-request/>\0', function(data){
    Security.loadPolicyFile(data);
});
socket.on('<policy-file-request/>', function(data){
    Security.loadPolicyFile(data);
});
Blubberguy22
  • 1,344
  • 1
  • 17
  • 29
  • I don't think that this solution will work because of crossdomain restrictions. I'm trying to implement [adobe socket policy](http://www.adobe.com/devnet/flashplayer/articles/socket_policy_files.html). – Maros Pixel Jun 24 '15 at 08:18
  • @MarosPixel Oh, thanks. Which part wouldn't work then? I noticed that the socket.io part was different from what I've worked with, so I thought that might be what was causing the problem (since the callbacks don't have a connection back to the client). I don't do much with Adobe, so I didn't know that it would conflict with crossdomain restrictions. I'm guessing I set up the xml parsing wrong. – Blubberguy22 Jun 24 '15 at 12:51
0

What about trying the npm crossdomain package which I recommended as a solution ( take look on the comments ) in this question ?

Hope that can help.

Community
  • 1
  • 1
akmozo
  • 9,829
  • 3
  • 28
  • 44
  • Thanks for your reply, but I think that this package is for **http** crossdomain, and i need to implement **socket** croosdomain policy. – Maros Pixel Jun 25 '15 at 07:54