Example #1
0
        public override void HandleSelectionChanged(string protocol, bool isEditing)
        {
            if (DefaultProtocolName != protocol.ToUpper() && !ProtocolName.Contains(protocol.ToUpper()))
            {
                return;
            }

            // if we are either dealing with a new or an existing connection and have more than one
            // FavoritePanel per connection defined -> hide this option, because the user won't be
            // able to use it.
            if (DefaultProtocolName == protocol.ToUpper())
            {
                chkShowTinyMceInConnectionMode.Visible = true;
            }
            else
            {
                chkShowTinyMceInConnectionMode.Checked = false;
            }

            // we are dealing with a new connection
            if (!isEditing)
            {
                chkShowTinyMceInEditMode.Checked = tinyMce.IsTextEditable = true;
                tinyMce.Render();
            }
        }
Example #2
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Protocol != 0)
            {
                hash ^= Protocol.GetHashCode();
            }
            if (ProtocolName.Length != 0)
            {
                hash ^= ProtocolName.GetHashCode();
            }
            hash ^= transportSettings_.GetHashCode();
            if (SecurityType.Length != 0)
            {
                hash ^= SecurityType.GetHashCode();
            }
            hash ^= securitySettings_.GetHashCode();
            if (socketSettings_ != null)
            {
                hash ^= SocketSettings.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Example #3
0
        private byte[] GetDataBytes()
        {
            if (ProtocolName?.Equals("sc500", StringComparison.OrdinalIgnoreCase) == true)
            {
                return(Encoding.UTF8.GetBytes(DataHexOrXml));
            }

            return(ToByteArray(DataHexOrXml));
        }
        public IdentificationDescriptor(byte[] buffer, int offset)
        {
            ProtocolIdentifier = (ProtocolName)((buffer[offset + 0] >> 4) & 0x0F);
            CodeSet            = (CodeSetName)(buffer[offset + 0] & 0x0F);
            PIV            = (buffer[offset + 1] & 0x80) != 0;
            Association    = (AssociationName)((buffer[offset + 1] >> 4) & 0x03);
            IdentifierType = (IdentifierTypeName)(buffer[offset + 1] & 0x0F);

            IdentifierLength = buffer[offset + 3];
            Identifier       = new byte[IdentifierLength];
            Array.Copy(buffer, offset + 4, Identifier, 0, IdentifierLength);
        }
Example #5
0
    private string Set_ProtocalError(ProtocolName ptName)
    {
        //팝업

        string errorMsg = string.Empty;
        string msg2     = TextDataManager.Dic_TranslateText[433];    //"네트워크가 불안정 합니다.";
        string msg1     = "네트워크 오류 발생하엿습니다. \n다시 시도해주세요";



        switch (ptName)
        {
        case ProtocolName.CheckServer:
        case ProtocolName.GetVersion:
        case ProtocolName.SetMemberLogin:
        case ProtocolName.SetMemberJoin:
        case ProtocolName.SetMemberChange:
        case ProtocolName.GetAuthentication:
        case ProtocolName.GetReferenceDB:
        case ProtocolName.GetUserInfos:
        case ProtocolName.ClanInfo:
        case ProtocolName.FriendList:
        case ProtocolName.GetServerList:
        case ProtocolName.GetServerTime:
            UI_Popup_Notice popup3 = UI_Manager.Getsingleton.CreatAndGetPopup <UI_Popup_Notice>(UIPOPUP.POPUPNOTICE);
            popup3.Set_PopupTitleMessage(TextDataManager.Dic_TranslateText[145]);                     //알림
            errorMsg = string.Format("{1}\n {0}", ptName, msg1);
            popup3.SetPopupMessage(errorMsg);
            if (UI_Manager.Getsingleton.Dic_UILst.ContainsKey(UI.TITLE))
            {
                popup3.Set_addEventButton(exeption_gotoTitleUI);
            }
            else
            {
                popup3.Set_addEventButton(exeption_Stay);
            }
            break;



        default:
            UI_Popup_Notice popup2 = UI_Manager.Getsingleton.CreatAndGetPopup <UI_Popup_Notice>(UIPOPUP.POPUPNOTICE);
            popup2.Set_PopupTitleMessage(TextDataManager.Dic_TranslateText[145]);                     //알림
            errorMsg = string.Format("{1}\n {0}", ptName, msg1);
            popup2.Set_addEventButton(exeption_Stay);
            popup2.SetPopupMessage(errorMsg);
            break;
        }



        return(errorMsg);
    }
Example #6
0
        public override int GetHashCode()
        {
            int hc = ProtocolVersion.ToLowerInvariant().GetHashCode();

            hc ^= ReceivedBy.ToLowerInvariant().GetHashCode();

            if (!string.IsNullOrEmpty(ProtocolName))
            {
                hc ^= ProtocolName.ToLowerInvariant().GetHashCode();
            }

            if (!string.IsNullOrEmpty(Comment))
            {
                hc ^= Comment.GetHashCode();
            }

            return(hc);
        }
        public static GPRSProtocol CreateGPRSProtocol(ProtocolName Name)
        {
            switch (Name)
            {
            case ProtocolName.AutecAory5000:
                return(new AutecAory5000());

            case ProtocolName.AutecNewModbusRtu:
                return(new AutecNewModbusRtu());

            case ProtocolName.AutecOldModbusRtu:
                return(new AutecOldModbusRtu());

            case ProtocolName.HuiZhongSCL_61D:
                return(new HuiZhongSCL_61D());

            default:
                return(new GPRSProtocol());
            }
        }
Example #8
0
        public override byte[] Serialize()
        {
            var data = new List <byte>();

            data.AddRange(ProtocolName.Serialize());
            data.Add(ProtocolVersion);

            byte flags = 0;

            if (CleanSession)
            {
                flags |= (byte)(1 << 1);
            }

            if (Will)
            {
                flags |= (byte)(1 << 2);              // will
                flags |= (byte)(((int)WillQoS) << 3); // will qos
                if (WillRetain)
                {
                    flags |= (byte)(1 << 5); // will retain
                }
            }

            if (HasPassword)
            {
                flags |= (byte)(1 << 6);
            }

            if (HasUserName)
            {
                flags |= (byte)(1 << 7);
            }

            data.Add(flags);

            data.AddRange(BitConverter.GetBytes(IPAddress.HostToNetworkOrder(KeepAliveSeconds)));

            return(data.ToArray());
        }
Example #9
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Protocol != 0)
            {
                hash ^= Protocol.GetHashCode();
            }
            if (ProtocolName.Length != 0)
            {
                hash ^= ProtocolName.GetHashCode();
            }
            if (settings_ != null)
            {
                hash ^= Settings.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Example #10
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Protocol != global::V2Ray.Core.Transport.Internet.TransportProtocol.Tcp)
            {
                hash ^= Protocol.GetHashCode();
            }
            if (ProtocolName.Length != 0)
            {
                hash ^= ProtocolName.GetHashCode();
            }
            if (settings_ != null)
            {
                hash ^= Settings.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Example #11
0
        protected override CodeTypeDeclaration BeginClass()
        {
            soapBinding = (SoapBinding)Binding.Extensions.Find(typeof(SoapBinding));

            CodeTypeDeclaration codeClass = new CodeTypeDeclaration(ClassName);

#if NET_2_0
            codeClass.IsPartial = true;
#endif

            string location = null;

            if (Port != null)
            {
                SoapAddressBinding sab = (SoapAddressBinding)Port.Extensions.Find(typeof(SoapAddressBinding));
                if (sab != null)
                {
                    location = sab.Location;
                }
            }

            string namspace = (Port != null ? Port.Binding.Namespace : Binding.ServiceDescription.TargetNamespace);
            string name     = (Port != null ? Port.Name : Binding.Name);

            if (Style == ServiceDescriptionImportStyle.Client)
            {
                CodeTypeReference ctr = new CodeTypeReference("System.Web.Services.Protocols.SoapHttpClientProtocol");
                codeClass.BaseTypes.Add(ctr);
            }
            else
            {
                CodeTypeReference ctr = new CodeTypeReference("System.Web.Services.WebService");
                codeClass.BaseTypes.Add(ctr);
                CodeAttributeDeclaration attws = new CodeAttributeDeclaration("System.Web.Services.WebServiceAttribute");
                attws.Arguments.Add(GetArg("Namespace", namspace));
                AddCustomAttribute(codeClass, attws, true);
            }

            CodeAttributeDeclaration att = new CodeAttributeDeclaration("System.Web.Services.WebServiceBinding");
            att.Arguments.Add(GetArg("Name", name));
            att.Arguments.Add(GetArg("Namespace", namspace));
            AddCustomAttribute(codeClass, att, true);

            if (Style == ServiceDescriptionImportStyle.Client)
            {
                CodeConstructor cc = new CodeConstructor();
                cc.Attributes = MemberAttributes.Public;
                GenerateServiceUrl(location, cc.Statements);

#if NET_2_0
                if (ProtocolName.ToUpper() == "SOAP12")
                {
                    CodeExpression thisSoapVer = new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "SoapVersion");
                    CodeFieldReferenceExpression soap12Enum =
                        new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(typeof(SoapProtocolVersion)), "Soap12");
                    cc.Statements.Add(new CodeAssignStatement(thisSoapVer, soap12Enum));
                }
#endif
                codeClass.Members.Add(cc);
            }

            memberIds       = new CodeIdentifiers();
            headerVariables = new Hashtable();
            return(codeClass);
        }
Example #12
0
        /// <summary>
        /// Create a new http request header based on the given string representation.
        /// </summary>
        /// <param name="RemoteSocket">The remote TCP/IP socket.</param>
        /// <param name="LocalSocket">The local TCP/IP socket.</param>
        /// <param name="HTTPServer">The HTTP server of the request.</param>
        /// <param name="HTTPHeader">A valid string representation of a http request header.</param>
        /// <param name="HTTPBody">The HTTP body as an array of bytes.</param>
        /// <param name="HTTPBodyStream">The HTTP body as an stream of bytes.</param>
        /// <param name="CancellationToken">A token to cancel the HTTP request processing.</param>
        /// <param name="EventTrackingId">An unique event tracking identification for correlating this request with other events.</param>
        private HTTPRequest(IPSocket RemoteSocket,
                            IPSocket LocalSocket,
                            HTTPServer HTTPServer,
                            String HTTPHeader,
                            Byte[]              HTTPBody        = null,
                            Stream HTTPBodyStream               = null,
                            CancellationToken?CancellationToken = null,
                            EventTracking_Id EventTrackingId    = null)

            : base(RemoteSocket,
                   LocalSocket,
                   HTTPHeader,
                   HTTPBody,
                   HTTPBodyStream,
                   CancellationToken,
                   EventTrackingId)

        {
            this._HTTPServer = HTTPServer;

            #region Parse HTTPMethod (first line of the http request)

            var _HTTPMethodHeader = FirstPDULine.Split(_SpaceSeparator, StringSplitOptions.RemoveEmptyEntries);

            // e.g: PROPFIND /file/file Name HTTP/1.1
            if (_HTTPMethodHeader.Length != 3)
            {
                throw new Exception("Bad request");
            }

            // Parse HTTP method
            // Propably not usefull to define here, as we can not send a response having an "Allow-header" here!
            this._HTTPMethod = (HTTPMethod.TryParseString(_HTTPMethodHeader[0], out _HTTPMethod))
                                   ? _HTTPMethod
                                   : HTTPMethod.Create(_HTTPMethodHeader[0]);

            #endregion

            #region Parse URL and QueryString (first line of the http request)

            var RawUrl     = _HTTPMethodHeader[1];
            var _ParsedURL = RawUrl.Split(_URLSeparator, 2, StringSplitOptions.None);
            this.URI = HttpUtility.UrlDecode(_ParsedURL[0]);

            if (URI.StartsWith("http", StringComparison.Ordinal) || URI.StartsWith("https", StringComparison.Ordinal))
            {
                URI = URI.Substring(URI.IndexOf("://", StringComparison.Ordinal) + 3);
                URI = URI.Substring(URI.IndexOf("/", StringComparison.Ordinal) + 1);
            }

            if (URI == "" || URI == null)
            {
                URI = "/";
            }

            // Parse QueryString after '?'
            if (RawUrl.IndexOf('?') > -1 && _ParsedURL[1].IsNeitherNullNorEmpty())
            {
                this._QueryString = QueryString.Parse(_ParsedURL[1]);
            }
            else
            {
                this._QueryString = QueryString.Empty;
            }

            #endregion

            #region Parse protocol name and -version (first line of the http request)

            var _ProtocolArray = _HTTPMethodHeader[2].Split(_SlashSeparator, 2, StringSplitOptions.RemoveEmptyEntries);
            this._ProtocolName = _ProtocolArray[0].ToUpper();

            if (ProtocolName.ToUpper() != "HTTP")
            {
                throw new Exception("Bad request");
            }

            HTTPVersion _HTTPVersion = null;

            if (HTTPVersion.TryParseVersionString(_ProtocolArray[1], out _HTTPVersion))
            {
                this._ProtocolVersion = _HTTPVersion;
            }

            if (ProtocolVersion != HTTPVersion.HTTP_1_0 && ProtocolVersion != HTTPVersion.HTTP_1_1)
            {
                throw new Exception("HTTP version not supported");
            }

            #endregion


            #region Check Host header

            // rfc 2616 - Section 19.6.1.1
            // A client that sends an HTTP/1.1 request MUST send a Host header.

            // rfc 2616 - Section 14.23
            // All Internet-based HTTP/1.1 servers MUST respond with a 400 (Bad Request)
            // status code to any HTTP/1.1 request message which lacks a Host header field.

            // rfc 2616 - Section 5.2 The Resource Identified by a Request
            // 1. If Request-URI is an absoluteURI, the host is part of the Request-URI.
            //    Any Host header field value in the request MUST be ignored.
            // 2. If the Request-URI is not an absoluteURI, and the request includes a
            //    Host header field, the host is determined by the Host header field value.
            // 3. If the host as determined by rule 1 or 2 is not a valid host on the server,
            //    the response MUST be a 400 (Bad Request) error message. (Not valid for proxies?!)
            if (!_HeaderFields.ContainsKey(HTTPHeaderField.Host.Name))
            {
                throw new Exception("The HTTP PDU does not have a HOST header!");
            }

            // rfc 2616 - 3.2.2
            // If the port is empty or not given, port 80 is assumed.
            var HostHeader = _HeaderFields[HTTPHeaderField.Host.Name].ToString().
                             Split(_ColonSeparator, StringSplitOptions.RemoveEmptyEntries).
                             Select(v => v.Trim()).
                             ToArray();

            UInt16 HostPort = 80;

            if (HostHeader.Length == 1)
            {
                _HeaderFields[HTTPHeaderField.Host.Name] = _HeaderFields[HTTPHeaderField.Host.Name].ToString();// + ":80"; ":80" will cause side effects!
            }
            else if ((HostHeader.Length == 2 && !UInt16.TryParse(HostHeader[1], out HostPort)) || HostHeader.Length > 2)
            {
                throw new Exception("Bad request");
            }

            #endregion
        }
Example #13
0
 public netData(ProtocolName _protocolName)
 {
     Seq++;
     SendData.Add("Seq", Seq);
 }
 /// <summary>
 /// 将当前的地址信息组合成URL地址
 /// </summary>
 /// <returns></returns>
 protected virtual void GenerateUrl(System.Text.StringBuilder sb)
 {
     sb.Append(ProtocolName.ToLower());
     sb.Append("://");
 }