1
Vote

Hello,I increased some safe of the handling at flash

description

cssdomain.xml
 
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<site-control permitted-cross-domain-policies="master-only"/>
<allow-access-from domain="localhost" to-ports="5432" />
<allow-access-from domain="127.0.0.1" to-ports="5432" />
</cross-domain-policy>
 
 
public class NetStringStream : NetBaseStream<string>
{
    public NetStringStream(NetworkStream stream, EndPoint endpoint)
        : base(stream, endpoint)
    {
    }
 
    public override void Send(string data)
    {
        base.SendRaw(System.Text.Encoding.UTF8.GetBytes(data));
    }
 
    protected override void ReceivedRaw(byte[] bytes)
    {
        String data = System.Text.Encoding.UTF8.GetString(bytes);
        if (data.Equals("<policy-file-request/>\0"))
        {
            Send(Security);
            Stop(NetStoppedReason.Remote);
        }
        else
        {
            base.RaiseOnReceived(data);
        }
    }
 
    public String Security { get; set; }
}
 
 
static NetStringServer server = new NetStringServer();
    static void Main(string[] args)
    {
        if (!server.IsOnline)
        {
            server.Security = File.ReadAllText("cssdomain.xml");
            server.EchoMode = NetEchoMode.None;
 
            server.OnClientConnected += new NetClientConnectedEventHandler(server_OnClientConnected);
            server.OnClientDisconnected += new NetClientDisconnectedEventHandler(server_OnClientDisconnected);
            server.OnReceived += new NetClientReceivedEventHandler<String>(server_OnReceived);
            server.OnStarted += new NetStartedEventHandler(server_OnStarted);
            server.OnStopped += new NetStoppedEventHandler(server_OnStopped);
 
            server.Start(Dns.GetHostAddresses("127.0.0.1")[0], 5432);
        }
        Console.Read();
    }

comments