Esempio n. 1
0
 public Config(SocketConfig SocketConfig, bool CheckCertificate, string Username, string Password)
 {
     this.SocketConfig     = SocketConfig;
     this.CheckCertificate = CheckCertificate;
     this.Username         = Username;
     this.Password         = Password;
 }
Esempio n. 2
0
        public static SocketConfig ParseSocketConfig(XmlNode Node)
        {
            string type = Node.Attributes["type"].Value.Trim().ToLower();

            switch (type)
            {
            case "unix":
            {
                var          socket         = new Socket(AddressFamily.Unix, SocketType.Stream, 0);
                var          endPoint       = new UnixEndPoint(Node.InnerText);
                XmlAttribute permsAttribute = Node.Attributes["perms"];
                SocketConfig sockConf       = new SocketConfig(socket, endPoint)
                {
                    UnixSocketPath = Node.InnerText
                };
                if (permsAttribute != null)
                {
                    sockConf.UnixSocketPerms = ParseUnixSocketPerms(permsAttribute.Value.Trim());
                }
                else
                {
                    sockConf.UnixSocketPerms = (FilePermissions)(0xC000 | 0x100 | 0x80 | 0x20 | 0x10);
                }
                return(sockConf);
            }

            case "tcp":
            {
                var    socket   = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                var    endPoint = Helper.GetIPEndPointFromString(Node.InnerText);
                string strTls   = Node.Attributes["tls"].Value.Trim();
                return(new SocketConfig(socket, endPoint)
                    {
                        UseTLS = Convert.ToBoolean(strTls)
                    });
            }

            default: throw new Exception("Unknown node '" + Node.Name + "'");
            }
        }