Ejemplo n.º 1
0
        public void OnUnLinked(Graph graph, AbstractSocket s01, AbstractSocket s02)
        {
            Log.Info("OnUnLinked: Socket " + s02 + " and Socket " + s02);
            AbstractSocket input = s01.IsInput() ? s01 : s02;

            graph.UpdateDependingNodes(input.Parent);
        }
Ejemplo n.º 2
0
        public void Draw(EditorWindow window, Rect region, AbstractSocket currentDragingSocket)
        {
            if (centeredLabelStyle == null)
            {
                centeredLabelStyle = GUI.skin.GetStyle("Label");
            }
            centeredLabelStyle.alignment = TextAnchor.MiddleCenter;

            EditorZoomArea.Begin(Zoom, region);

            if (Style.normal.background == null)
            {
                Style.normal.background = CreateBackgroundTexture();
            }
            GUI.DrawTextureWithTexCoords(DrawArea, Style.normal.background, new Rect(0, 0, 1000, 1000));
            DrawArea.Set(Position.x, Position.y, CanvasSize, CanvasSize);
            GUILayout.BeginArea(DrawArea);
            DrawEdges();
            window.BeginWindows();
            DrawNodes();
            window.EndWindows();
            DrawDragEdge(currentDragingSocket);

            for (var i = 0; i < Graph.GetNodeCount(); i++)
            {
                Graph.GetNodeAt(i).GUIDrawSockets();
            }

            GUILayout.EndArea();
            EditorZoomArea.End();
        }
Ejemplo n.º 3
0
        public void DrawEdges(Rect canvasAreaInWindow)
        {
            if (_draggingPathPointIndex == -1)
            {
                _hoveringEdge = null;
            }

            for (var i = 0; i < Graph.GetNodeCount(); i++)
            {
                Node node = Graph.GetNodeAt(i);


                for (var iu = 0; iu < node.Sockets.Count; iu++)
                {
                    AbstractSocket socket = node.Sockets[iu];
                    if (socket.IsInput() && socket.IsConnected())                     // draw only input sockets to avoid double drawing of edges
                    {
                        InputSocket inputSocket = (InputSocket)socket;
                        if (CanvasOverlapsWindow(inputSocket.Edge.Bounds, canvasAreaInWindow))
                        {
                            bool highlight = _selectedNodes.Contains(node) ||
                                             _selectedNodes.Contains(inputSocket.Edge.Output.Parent);
                            int  segmentIndex = inputSocket.Edge.IntersectsPathSegment(Event.current.mousePosition);
                            bool hover        = segmentIndex > -1;
                            node.GUIDrawEdge(inputSocket, highlight, hover);
                            if (hover && _draggingPathPointIndex == -1)
                            {
                                HandleEdgeHover(inputSocket.Edge, segmentIndex);
                                _hoveringEdge = inputSocket.Edge;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public void UnLink(AbstractSocket socket)
        {
            if (socket == null || !socket.IsConnected())
            {
                return;
            }


            if (socket.IsInput())
            {
                InputSocket inputSocket = (InputSocket)socket;
                if (inputSocket.Edge != null)
                {
                    UnLink(inputSocket, inputSocket.Edge.Output);
                }
            }

            if (socket.IsOutput())
            {
                OutputSocket outputSocket = (OutputSocket)socket;
                Edge[]       edgeCopy     = new Edge[outputSocket.Edges.Count];
                outputSocket.Edges.CopyTo(edgeCopy);
                for (int index = 0; index < edgeCopy.Length; index++)
                {
                    var edge = edgeCopy[index];
                    UnLink(edge.Input, outputSocket);
                }
            }
        }
Ejemplo n.º 5
0
 public static void TriggerOnUnLinkedSockets(Graph graph, AbstractSocket socket01, AbstractSocket socket02)
 {
     if (OnUnLinkedSockets != null)
     {
         OnUnLinkedSockets(graph, socket01, socket02);
     }
 }
Ejemplo n.º 6
0
        /**
         * writes to encrypted stream
         */
        public void WriteTo(AbstractSocket output, Cipher cipher)
        {
            byte[] image = BuildImage();
            //dumpBA(image);
            byte[] encrypted = new byte[image.Length - 4];
            cipher.Encrypt(image, 4, image.Length - 4, encrypted, 0);           //length field must not be encrypted

            Array.Copy(encrypted, 0, image, 4, encrypted.Length);
            output.Write(image, 0, image.Length);
        }
Ejemplo n.º 7
0
 private void DrawDragEdge(AbstractSocket currentDragingSocket)
 {
     if (currentDragingSocket != null)
     {
         _tmpVector01 = Edge.GetEdgeSocketPosition(currentDragingSocket, _tmpVector01);
         _tmpVector02 = Edge.GetSocketTangentPosition(currentDragingSocket, _tmpVector01);
         Edge.DrawEdgeSegment(_tmpVector01, _tmpVector02, Event.current.mousePosition, Event.current.mousePosition,
                              currentDragingSocket.Type, true, false);
     }
 }
Ejemplo n.º 8
0
        protected override void OnGUI()
        {
            GUI.skin.label.alignment = TextAnchor.MiddleLeft;
            Height = SocketTopOffsetInput + (_entitiesCount + _landscapeCount) * 20 + 25;

            _tmpRect.Set(3, 0, 120, 20);
            if (GUI.Button(_tmpRect, "add landscape"))
            {
                AddLandscapeSocket();
                TriggerChangeEvent();
            }

            _tmpRect.Set(3, 20, 120, 20);
            if (GUI.Button(_tmpRect, "add entities"))
            {
                AddGameObjectsSocket();
                TriggerChangeEvent();
            }

            float topOffset = SocketTopOffsetInput;

            InputSocket removeSocket = null;

            for (int i = 0; i < Sockets.Count; i++)
            {
                AbstractSocket socket = Sockets[i];
                if (socket.Type == typeof(ILandscapeConnection) || socket.Type == typeof(IEntitiesConnection) && socket.IsInput())
                {
                    InputSocket s = socket as InputSocket;
                    if (s.IsConnected())
                    {
                        _tmpRect.Set(3, topOffset, 100, 20);
                        Node connectedNode = s.Edge.GetOtherSocket(s).Parent;
                        GUI.Label(_tmpRect, connectedNode.Name + " (" + connectedNode.Id + ")");
                    }
                    else
                    {
                        _tmpRect.Set(3, topOffset, 20, 20);
                        if (GUI.Button(_tmpRect, "x"))
                        {
                            removeSocket = s;
                        }
                    }
                    topOffset += 20;
                }
            }

            if (removeSocket != null)
            {
                RemoveSocket(removeSocket);
            }
            GUI.skin.label.alignment = TextAnchor.MiddleCenter;
        }
Ejemplo n.º 9
0
 private void HandleSocketDrop(AbstractSocket dropTarget)
 {
     if (dropTarget != null && dropTarget.GetType() != _dragSourceSocket.GetType())
     {
         if (dropTarget.IsInput())
         {
             _currentCanvas.Graph.Link((InputSocket)dropTarget, (OutputSocket)_dragSourceSocket);
         }
         Event.current.Use();
     }
     _dragSourceSocket = null;
     Repaint();
 }
Ejemplo n.º 10
0
        private static void SendMyVersion(AbstractSocket stream, SSHConnectionParameter param)
        {
            string cv = SSHUtil.ClientVersionString(param.Protocol);

            if (param.Protocol == SSHProtocol.SSH1)
            {
                cv += param.SSH1VersionEOL;
            }
            else
            {
                cv += "\r\n";
            }
            byte[] data = Encoding.UTF8.GetBytes(cv);
            stream.Write(data, 0, data.Length);
        }
Ejemplo n.º 11
0
        /// <summary> Returns the socket at the window position.</summary>
        /// <param name="windowPosition"> The position to get the Socket from in window coordinates</param>
        /// <returns>The socket at the posiiton or null or null.</returns>
        public AbstractSocket GetSocketAt(Vector2 windowPosition)
        {
            Vector2 projectedPosition = ProjectToGDICanvas(windowPosition);

            for (var i = 0; i < Graph.GetNodeCount(); i++)
            {
                Node           node   = Graph.GetNodeAt(i);
                AbstractSocket socket = node.SearchSocketAt(projectedPosition);
                if (socket != null)
                {
                    return(socket);
                }
            }
            return(null);
        }
        internal override AuthenticationResult Connect(AbstractSocket s)
        {
            _stream = s;

            // Phase2 receives server keys
            ReceiveServerKeys();
            if (_param.KeyCheck != null && !_param.KeyCheck(_cInfo))
            {
                _stream.Close();
                return(AuthenticationResult.Failure);
            }

            // Phase3 generates session key
            byte[] session_key = GenerateSessionKey();

            // Phase4 establishes the session key
            try {
                _packetBuilder.SetSignal(false);
                SendSessionKey(session_key);
                InitCipher(session_key);
            }
            finally {
                _packetBuilder.SetSignal(true);
            }
            ReceiveKeyConfirmation();

            // Phase5 user authentication
            SendUserName(_param.UserName);
            if (ReceiveAuthenticationRequirement() == AUTH_REQUIRED)
            {
                if (_param.AuthenticationType == AuthenticationType.Password)
                {
                    SendPlainPassword();
                }
                else if (_param.AuthenticationType == AuthenticationType.PublicKey)
                {
                    DoRSAChallengeResponse();
                }
                bool auth = ReceiveAuthenticationResult();
                if (!auth)
                {
                    throw new SSHException(Strings.GetString("AuthenticationFailed"));
                }
            }

            _packetBuilder.Handler = new CallbackSSH1PacketHandler(this);
            return(AuthenticationResult.Success);
        }
Ejemplo n.º 13
0
 private void HandleSocketDrag(AbstractSocket dragSource)
 {
     if (dragSource != null)
     {
         if (dragSource.IsInput() && dragSource.IsConnected())
         {
             _dragSourceSocket = ((InputSocket)dragSource).Edge.GetOtherSocket(dragSource);
             _currentCanvas.Graph.UnLink((InputSocket)dragSource, (OutputSocket)_dragSourceSocket);
         }
         if (dragSource.IsOutput())
         {
             _dragSourceSocket = dragSource;
         }
         Event.current.Use();
     }
     Repaint();
 }
Ejemplo n.º 14
0
 private void UpdateSocketCounts()
 {
     _landscapeCount = 0;
     _entitiesCount  = 0;
     for (int i = 0; i < Sockets.Count; i++)
     {
         AbstractSocket s = Sockets[i];
         if (s.Type == typeof(ILandscapeConnection))
         {
             _landscapeCount++;
         }
         if (s.Type == typeof(IEntitiesConnection))
         {
             _entitiesCount++;
         }
     }
 }
Ejemplo n.º 15
0
        public void WriteTo(AbstractSocket strm, Cipher cipher)
        {
            int bodylen = 4 + _packetLength;

            byte[] buf = new byte[bodylen + (_mac == null? 0 : _mac.Length)];
            WriteTo(buf, 0, false);

            if (cipher != null)
            {
                cipher.Encrypt(buf, 0, bodylen, buf, 0);
            }

            if (_mac != null)
            {
                Array.Copy(_mac, 0, buf, bodylen, _mac.Length);
            }

            strm.Write(buf, 0, buf.Length);
            strm.Flush();
        }
Ejemplo n.º 16
0
        private void DrawSocketTooltip(Node node)
        {
            Vector2        m      = Event.current.mousePosition;
            AbstractSocket socket = node.SearchSocketAt(m);

            if (socket != null)
            {
                string text      = socket.Type + "";
                int    lastIndex = text.LastIndexOf(".");
                if (lastIndex > -1)
                {
                    text = text.Substring(lastIndex + 1);
                }
                float width   = GUI.skin.label.CalcSize(new GUIContent(text)).x + 8;
                float xOffset = -width - 10;
                if (socket.IsOutput())
                {
                    xOffset = 10;
                }
                _tmpRect.Set(m.x + xOffset, m.y - 10, width, 20);
                DrawTooltip(_tmpRect, text);
            }
        }
Ejemplo n.º 17
0
 private void RemoveSocket(AbstractSocket socket)
 {
     Sockets.Remove(socket);
     UpdateSocketCounts();
     TriggerChangeEvent();
 }
Ejemplo n.º 18
0
        public AuthenticationResult DoConnect(AbstractSocket target)
        {
            _stream = target;

            // Phase2 receives server keys
            ReceiveServerKeys();
            if(_param.KeyCheck!=null && !_param.KeyCheck(_cInfo)) {
                _stream.Close();
                return GranadosRT.Routrek.SSHC.AuthenticationResult.Failure;
            }

            // Phase3 generates session key
            byte[] session_key = GenerateSessionKey();

            // Phase4 establishes the session key
            try {
                _packetBuilder.SetSignal(false);
                SendSessionKey(session_key);
                InitCipher(session_key);
            }
            finally {
                _packetBuilder.SetSignal(true);
            }
            ReceiveKeyConfirmation();

            // Phase5 user authentication
            SendUserName(_param.UserName);
            if(ReceiveAuthenticationRequirement()==AUTH_REQUIRED) {
                if(_param.AuthenticationType==AuthenticationType.Password) {
                    SendPlainPassword();
                } else if(_param.AuthenticationType==AuthenticationType.PublicKey) {
                    DoRSAChallengeResponse();
                }
                bool auth = ReceiveAuthenticationResult();
                if(!auth) throw new Exception(Strings.GetString("AuthenticationFailed"));

            }

            _packetBuilder.Handler = new CallbackSSH1PacketHandler(this);
            return GranadosRT.Routrek.SSHC.AuthenticationResult.Success;
        }
Ejemplo n.º 19
0
        public static SSHConnection Connect(SSHConnectionParameter param, ISSHConnectionEventReceiver receiver, ProtocolNegotiationHandler pnh, AbstractSocket s)
        {
            if (param.UserName == null) throw new InvalidOperationException("UserName property is not set");
            if (param.Password == null) throw new InvalidOperationException("Password property is not set");

            return ConnectMain(param, receiver, pnh, s);
        }
Ejemplo n.º 20
0
        public void Draw(EditorWindow window, Rect region, AbstractSocket currentDragingSocket)
        {
            Event e = Event.current;

            InitWindowStyles();

            if (e.type == EventType.MouseUp)
            {
                if (_draggingPathPointIndex != -1)
                {
                    _draggingPathPointIndex = -1;
                    Event.current.Use();
                    OnEdgePointDragEnd();
                }
            }

            if (e.type == EventType.MouseDown)
            {
                _currentHelpText = null;
                _renamingNodeId  = -1;
            }

            if (_centeredLabelStyle == null)
            {
                _centeredLabelStyle = GUI.skin.GetStyle("Label");
            }
            _centeredLabelStyle.alignment = TextAnchor.MiddleCenter;

            EditorZoomArea.Begin(Zoom, region);

            if (Style.normal.background == null)
            {
                Style.normal.background = CreateBackgroundTexture();
            }
            GUI.DrawTextureWithTexCoords(DrawArea, Style.normal.background, new Rect(0, 0, 1000, 1000));
            DrawArea.Set(Position.x, Position.y, GDICanvasSize, GDICanvasSize);
            GUILayout.BeginArea(DrawArea);
            DrawEdges(region);
            window.BeginWindows();
            DrawNodes(region);
            window.EndWindows();
            DrawDragEdge(currentDragingSocket);

            GUILayout.EndArea();
            EditorZoomArea.End();


            if (e.type == EventType.MouseDrag)
            {
                if (e.button == 0)
                {
                    if (_draggingPathPointIndex > -1 && _hoveringEdge != null)
                    {
                        Vector2 pos = ProjectToGDICanvas(e.mousePosition);
                        pos.y += Config.PathPointSize;
                        _hoveringEdge.SetPathPointAtIndex(_draggingPathPointIndex, pos);
                        Event.current.Use();
                    }
                }
            }

            if (_hoveringEdge != null && Config.ShowEdgeHover)
            {
                string tooltipText = _hoveringEdge.Output.Parent.Name + "-> " + _hoveringEdge.Input.Parent.Name;
                float  width       = GUI.skin.textField.CalcSize(new GUIContent(tooltipText)).x;
                _tmpRect.Set(Event.current.mousePosition.x - width / 2f, e.mousePosition.y - 30, width, 20);
                DrawTooltip(_tmpRect, tooltipText);
            }


            HandleSelectionBox();
            DrawHelpText();


            if (!_initialEdgeCalcDone)
            {
                _initialEdgeCalcDone = true;
                Graph.UpdateEdgeBounds();
            }

            GUI.SetNextControlName(Config.NullControlName);
            GUI.TextField(new Rect(0, 0, 0, 0), "");
            if (GUI.GetNameOfFocusedControl().Equals(Config.NullControlName))
            {
                if (e.keyCode == KeyCode.Delete)
                {
                    DeleteSelectedNodes(null);
                }
                if ((e.control || e.command) && e.keyCode == KeyCode.C && _lastKeyCode != KeyCode.C)
                {
                    CopySelection();
                }
                if ((e.control || e.command) && e.keyCode == KeyCode.V && _lastKeyCode != KeyCode.V)
                {
                    PasteFromClipboard();
                }
            }

            _lastKeyCode = e.keyCode;
        }
Ejemplo n.º 21
0
 public AuthenticationResult DoConnect(AbstractSocket target)
 {
     return GranadosRT.Routrek.SSHC.AuthenticationResult.Success;
 }
Ejemplo n.º 22
0
        public static SSHConnection Connect(SSHConnectionParameter param, ISSHConnectionEventReceiver receiver, ProtocolNegotiationHandler pnh, AbstractSocket s)
        {
            if (param.UserName == null) throw new InvalidOperationException(resLoader.GetString("UsernameUnset"));
            if (param.Password == null) throw new InvalidOperationException(resLoader.GetString("PasswordUnset"));

            return ConnectMain(param, receiver, pnh, s);
        }
Ejemplo n.º 23
0
        private static SSHConnection ConnectMain(SSHConnectionParameter param, ISSHConnectionEventReceiver receiver, ProtocolNegotiationHandler pnh, AbstractSocket s)
        {
            pnh.Wait();

            if (pnh.State != ReceiverState.Ready)
            {
                throw new Exception(pnh.ErrorMessage);
            }

            string sv = pnh.ServerVersion;

            SSHConnection con = null;

            //if (param.Protocol == SSHProtocol.SSH1)
            con = new SSH1Connection(param, receiver, sv, SSHUtil.ClientVersionString(param.Protocol));
            //else
            //    con = new SSH2Connection(param, receiver, sv, SSHUtil.ClientVersionString(param.Protocol));

            s.SetHandler(con.PacketBuilder());
            SendMyVersion(s, param);

            if (con.DoConnect(s) != GranadosRT.Routrek.SSHC.AuthenticationResult.Failure)
            {
                return(con);
            }
            else
            {
                s.Close();
                return(null);
            }
        }
Ejemplo n.º 24
0
        public AuthenticationResult DoConnect(AbstractSocket target)
        {
            _stream = target;

            KeyExchanger kex = new KeyExchanger(this, null);
            if(!kex.SynchronousKexExchange()) {
                _stream.Close();
                return GranadosRT.Routrek.SSHC.AuthenticationResult.Failure;
            }
            //Step3 user authentication
            ServiceRequest("ssh-userauth");
            _authenticationResult = UserAuth();
            return _authenticationResult;
        }
Ejemplo n.º 25
0
        private static SSHConnection ConnectMain(SSHConnectionParameter param, ISSHConnectionEventReceiver receiver, ProtocolNegotiationHandler pnh, AbstractSocket s)
        {
            pnh.Wait();

            if (pnh.State != ReceiverState.Ready) throw new Exception(pnh.ErrorMessage);

            string sv = pnh.ServerVersion;

            SSHConnection con = null;
            //if (param.Protocol == SSHProtocol.SSH1)
            //    con = new SSH1Connection(param, receiver, sv, SSHUtil.ClientVersionString(param.Protocol));
            //else
                con = new SSH2Connection(param, receiver, sv, SSHUtil.ClientVersionString(param.Protocol));

            s.SetHandler(con.PacketBuilder());
            SendMyVersion(s, param);

            if (con.DoConnect(s) != GranadosRT.Routrek.SSHC.AuthenticationResult.Failure)
                return con;
            else
            {
                s.Close();
                throw new Exception(Strings.GetString("AuthenticationFailed"));
                //return null;
            }
        }
Ejemplo n.º 26
0
        public static SSHConnection Connect(SSHConnectionParameter param, ISSHConnectionEventReceiver receiver, ProtocolNegotiationHandler pnh, AbstractSocket s)
        {
            if (param.UserName == null)
            {
                throw new InvalidOperationException("UserName property is not set");
            }
            if (param.Password == null)
            {
                throw new InvalidOperationException("Password property is not set");
            }

            return(ConnectMain(param, receiver, pnh, s));
        }
Ejemplo n.º 27
0
 /**
  * writes to plain stream
  */
 public void WriteTo(AbstractSocket output)
 {
     byte[] image = BuildImage();
     output.Write(image, 0, image.Length);
 }
Ejemplo n.º 28
0
 private static void SendMyVersion(AbstractSocket stream, SSHConnectionParameter param)
 {
     string cv = SSHUtil.ClientVersionString(param.Protocol);
     if (param.Protocol == SSHProtocol.SSH1)
         cv += param.SSH1VersionEOL;
     else
         cv += "\r\n";
     byte[] data = Encoding.UTF8.GetBytes(cv);
     stream.Write(data, 0, data.Length);
 }
Ejemplo n.º 29
0
 public void OnUnLink(Graph graph, AbstractSocket s01, AbstractSocket s02)
 {
     // Log.Info("OnUnLink: Node " + s01.Connection.Output.Parent.Id + " from Node " + s02.Connection.Input.Parent.Id);
 }
Ejemplo n.º 30
0
 /// <summary> Returns true if this node contains the assigned socket.</summary>
 /// <param name="socket"> The socket to use.</param>
 /// <returns>True if this node contains the assigned socket.</returns>
 public bool ContainsSocket(AbstractSocket socket)
 {
     return(Sockets.Contains(socket));
 }
Ejemplo n.º 31
0
        public void WriteTo(AbstractSocket strm, Cipher cipher)
        {
            int bodylen = 4+_packetLength;
            byte[] buf = new byte[bodylen + (_mac==null? 0 : _mac.Length)];
            WriteTo(buf, 0, false);

            if(cipher!=null)
                cipher.Encrypt(buf, 0, bodylen, buf, 0);

            if(_mac!=null)
                Array.Copy(_mac, 0, buf, bodylen, _mac.Length);

            strm.Write(buf, 0, buf.Length);
            strm.Flush();
        }
Ejemplo n.º 32
0
 /**
 * writes to plain stream
 */
 public void WriteTo(AbstractSocket output)
 {
     byte[] image = BuildImage();
     output.Write(image, 0, image.Length);
 }
Ejemplo n.º 33
0
 public void OnUnLink(Assets.GDI.Code.Graph.Graph graph, AbstractSocket s01, AbstractSocket s02)
 {
     // Log.Info("OnUnLink: Node " + s01.Edge.Output.Parent.Id + " from Node " + s02.Edge.Input.Parent.Id);
 }
Ejemplo n.º 34
0
 public AuthenticationResult DoConnect(AbstractSocket target)
 {
     return(GranadosRT.Routrek.SSHC.AuthenticationResult.Success);
 }
Ejemplo n.º 35
0
        /**
        * writes to encrypted stream
        */
        public void WriteTo(AbstractSocket output, Cipher cipher)
        {
            byte[] image = BuildImage();
            //dumpBA(image);
            byte[] encrypted = new byte[image.Length-4];
            cipher.Encrypt(image, 4, image.Length-4, encrypted, 0); //length field must not be encrypted

            Array.Copy(encrypted, 0, image, 4, encrypted.Length);
            output.Write(image, 0, image.Length);
        }