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); }
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(); }
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; } } } } } }
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); } } }
public static void TriggerOnUnLinkedSockets(Graph graph, AbstractSocket socket01, AbstractSocket socket02) { if (OnUnLinkedSockets != null) { OnUnLinkedSockets(graph, socket01, socket02); } }
/** * 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); }
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); } }
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; }
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(); }
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); }
/// <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); }
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(); }
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++; } } }
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(); }
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); } }
private void RemoveSocket(AbstractSocket socket) { Sockets.Remove(socket); UpdateSocketCounts(); TriggerChangeEvent(); }
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; }
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); }
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; }
public AuthenticationResult DoConnect(AbstractSocket target) { return GranadosRT.Routrek.SSHC.AuthenticationResult.Success; }
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); }
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); } }
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; }
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; } }
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)); }
/** * writes to plain stream */ public void WriteTo(AbstractSocket output) { byte[] image = BuildImage(); output.Write(image, 0, image.Length); }
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); }
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); }
/// <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)); }
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(); }
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); }
public AuthenticationResult DoConnect(AbstractSocket target) { return(GranadosRT.Routrek.SSHC.AuthenticationResult.Success); }
/** * 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); }