Exemple #1
0
        protected override void Execute()
        {
            _Connection = new TcpConnection();
            if (_Connection.Listen(_Address, _Port))
            {
                RaiseBoundEvent();

                while (!_Stop)
                {
                    // Accept a new connection
                    if (_Connection.CanAccept(500)) // 1/2 of a second
                    {
                        TcpConnection NewConnection = _Connection.AcceptTCP();
                        if (NewConnection != null)
                        {
                            // Wait up to 5 seconds for the request string
                            string Request = NewConnection.ReadLn("\0", 5000);
                            if (Request.ToLower().Replace(" ", "") == "<policy-file-request/>")
                            {
                                ConnectionAcceptedEventArgs.Raise(this, ConnectionAcceptedEvent, _Address, _Port, NewConnection.GetRemoteIP(), NewConnection.GetRemotePort());
                                RaiseMessageEvent("Answered policy file request from " + NewConnection.GetRemoteIP() + ":" + NewConnection.GetRemotePort().ToString());

                                NewConnection.WriteLn("<?xml version=\"1.0\"?>");
                                NewConnection.WriteLn("<cross-domain-policy>");
                                NewConnection.WriteLn("   <allow-access-from domain=\"*\" to-ports=\"" + _AllowedPorts + "\"/>");
                                NewConnection.WriteLn("   <site-control permitted-cross-domain-policies=\"all\"/>"); // TODO Maybe add property to determine whether this should be all or master-only
                                NewConnection.WriteLn("</cross-domain-policy>");
                                NewConnection.Write("\0");
                            }
                            else
                            {
                                RaiseErrorMessageEvent("Invalid policy file request from " + NewConnection.GetRemoteIP() + ":" + NewConnection.GetRemotePort().ToString());
                            }
                            NewConnection.Close();
                        }
                    }
                }
                _Connection.Close();
            }
            else
            {
                RaiseErrorMessageEvent("Flash Socket Policy Thread: Unable to listen on " + _Address + ":" + _Port);
                RaiseBindFailedEvent();
            }
        }
Exemple #2
0
        // This part was taken from Rick Parrish TelnetDoor almost direct copy pase, with some stuff removed.
        private static void Connect()
        {
            _Server = new TelnetConnection();

            if (_Server.Connect(hostURL, _Port))
            {
                bool CanContinue = true;

                if (CanContinue)
                {
                    Door.PipeWrite = false;
                    bool UserAborted = false;
                    while (!UserAborted && Door.Carrier && _Server.Connected)
                    {
                        bool Yield = true;

                        // See if the server sent anything to the client
                        if (_Server.CanRead())
                        {
                            Door.Write(_Server.ReadString());
                            Yield = false;
                        }

                        // See if the client sent anything to the server
                        if (Door.KeyPressed())
                        {
                            string ToSend = "";
                            while (Door.KeyPressed())
                            {
                                byte B = (byte)Door.ReadByte();
                                ToSend += (char)B;
                            }
                            _Server.Write(ToSend);

                            Yield = false;
                        }

                        // See if we need to yield
                        if (Yield) Crt.Delay(1);
                    }
                    Door.PipeWrite = true;
                }
            }
            else
            {
                Door.WriteLn("Looks like the BBSLink server isn't online, please try back later.");
            }
        }
 public void SendCommand(string command)
 {
     _ClientConnection.Write(command + IPCSocketServerThread.EndStatement);
 }
Exemple #4
0
 public void SendMessage(string command)
 {
     _ClientConnection.Write(command.Replace(IPCSocketServerThread.EndStatement.ToString(), "") + IPCSocketServerThread.EndStatement);
 }