private static void ServePolicyFile(IAsyncResult ar) { try { TcpClient cli = ((TcpListener)ar.AsyncState).EndAcceptTcpClient(ar); ((TcpListener)ar.AsyncState)?.BeginAcceptTcpClient(ServePolicyFile, ar.AsyncState); NetworkStream s = cli.GetStream(); NReader rdr = new NReader(s); NWriter wtr = new NWriter(s); if (rdr.ReadNullTerminatedString() == "<policy-file-request/>") { wtr.WriteNullTerminatedString(@"<cross-domain-policy> <allow-access-from domain=""*"" to-ports=""*"" /> </cross-domain-policy>"); wtr.Write((byte)'\r'); wtr.Write((byte)'\n'); } cli.Close(); } catch (ObjectDisposedException) { } catch (Exception ex) { Console.WriteLine(ex); } }
private static void ServePolicyFile(IAsyncResult ar) { try { var cli = (ar.AsyncState as TcpListener).EndAcceptTcpClient(ar); (ar.AsyncState as TcpListener).BeginAcceptTcpClient(ServePolicyFile, ar.AsyncState); var s = cli.GetStream(); var rdr = new NReader(s); var wtr = new NWriter(s); if (rdr.ReadNullTerminatedString() == "<policy-file-request/>") { wtr.WriteNullTerminatedString( @"<cross-domain-policy>" + @"<allow-access-from domain=""*"" to-ports=""*"" />" + @"</cross-domain-policy>"); wtr.Write((byte)'\r'); wtr.Write((byte)'\n'); } cli.Close(); } catch { } }
private static void ServePolicyFile(IAsyncResult ar) { try { TcpClient cli = (ar.AsyncState as TcpListener).EndAcceptTcpClient(ar); (ar.AsyncState as TcpListener).BeginAcceptTcpClient(ServePolicyFile, ar.AsyncState); NetworkStream s = cli.GetStream(); NReader rdr = new NReader(s); NWriter wtr = new NWriter(s); if (rdr.ReadNullTerminatedString() == "<policy-file-request/>") { wtr.WriteNullTerminatedString(@"<cross-domain-policy> <allow-access-from domain=""*"" to-ports=""*"" /> </cross-domain-policy>"); wtr.Write((byte)'\r'); wtr.Write((byte)'\n'); } cli.Close(); } catch (ObjectDisposedException) { } catch (Exception ex) { logger.Error(ex); } }
static void ServePolicyFile(IAsyncResult ar) { TcpClient cli = (ar.AsyncState as TcpListener).EndAcceptTcpClient(ar); (ar.AsyncState as TcpListener).BeginAcceptTcpClient(ServePolicyFile, ar.AsyncState); try { var s = cli.GetStream(); NReader rdr = new NReader(s); NWriter wtr = new NWriter(s); if (rdr.ReadNullTerminatedString() == "<policy-file-request/>") { wtr.WriteNullTerminatedString(@"<cross-domain-policy> <allow-access-from domain=""*"" to-ports=""*"" /> </cross-domain-policy>"); wtr.Write((byte)'\r'); wtr.Write((byte)'\n'); } cli.Close(); } catch { } }
private static void ServePolicyFile(IAsyncResult ar) { TcpClient cli = (ar.AsyncState as TcpListener).EndAcceptTcpClient(ar); (ar.AsyncState as TcpListener).BeginAcceptTcpClient(ServePolicyFile, ar.AsyncState); try { NetworkStream s = cli.GetStream(); var rdr = new NReader(s); var wtr = new NWriter(s); if (rdr.ReadNullTerminatedString() == "<policy-file-request/>") { wtr.WriteNullTerminatedString(customDomains.enabled ? customDomains.custom : customDomains.local); wtr.Write((byte)'\r'); wtr.Write((byte)'\n'); } cli.Close(); } catch { } }
private static void ServePolicyFile(IAsyncResult ar) { try { TcpClient cli = (ar.AsyncState as TcpListener).EndAcceptTcpClient(ar); (ar.AsyncState as TcpListener).BeginAcceptTcpClient(ServePolicyFile, ar.AsyncState); NetworkStream s = cli.GetStream(); NReader rdr = new NReader(s); NWriter wtr = new NWriter(s); if (rdr.ReadNullTerminatedString() == "<policy-file-request/>") { wtr.WriteNullTerminatedString(Settings.IS_PRODUCTION ? Settings.NETWORKING.INTERNAL.SELECTED_DOMAINS : Settings.NETWORKING.INTERNAL.LOCALHOST_DOMAINS); wtr.Write((byte)'\r'); wtr.Write((byte)'\n'); } cli.Close(); } catch (ObjectDisposedException) { } catch (Exception ex) { log.Error(ex); } }