public override void SetServerInfo(ServerInfo serverInfo)
 {
     if (subObfs == null && serverInfo.param != null && serverInfo.param.Length > 0)
     {
         try
         {
             string[] paramsList = serverInfo.param.Split(",".ToCharArray(), 2);
             string   subParam   = "";
             if (paramsList.Length > 1)
             {
                 subObfs  = ObfsFactory.GetObfs(paramsList[0]);
                 subParam = paramsList[1];
             }
             else
             {
                 subObfs = ObfsFactory.GetObfs(serverInfo.param);
             }
             if (((SubEncodeObfs)serverInfo.data).subObfs == null)
             {
                 ((SubEncodeObfs)serverInfo.data).subObfs = subObfs.InitData();
             }
             subObfs.SetServerInfo(new ServerInfo(serverInfo.host, serverInfo.port, serverInfo.tcp_mss, subParam, ((SubEncodeObfs)serverInfo.data).subObfs));
         }
         catch (Exception)
         {
             // do nothing
         }
         serverInfo.param = null;
     }
     base.SetServerInfo(serverInfo);
 }
        public override byte[] ClientPreEncrypt(byte[] plaindata, int datalength, out int outlength)
        {
            byte[] outdata  = new byte[datalength + datalength / 10 + 32];
            byte[] packdata = new byte[32768];
            byte[] data     = plaindata;
            outlength = 0;
            const int unit_len = 32700;

            while (datalength > unit_len)
            {
                int outlen;
                PackData(data, unit_len, packdata, out outlen);
                if (outdata.Length < outlength + outlen)
                {
                    Array.Resize(ref outdata, (outlength + outlen) * 2);
                }
                Array.Copy(packdata, 0, outdata, outlength, outlen);
                outlength  += outlen;
                datalength -= unit_len;
                byte[] newdata = new byte[datalength];
                Array.Copy(data, unit_len, newdata, 0, newdata.Length);
                data = newdata;
            }
            if (datalength > 0)
            {
                int outlen;
                PackData(data, datalength, packdata, out outlen);
                if (outdata.Length < outlength + outlen)
                {
                    Array.Resize(ref outdata, (outlength + outlen) * 2);
                }
                Array.Copy(packdata, 0, outdata, outlength, outlen);
                outlength += outlen;
            }
            if (subObfs == null && Server.param != null && Server.param.Length > 0)
            {
                try
                {
                    subObfs = ObfsFactory.GetObfs(Server.param);
                }
                catch (Exception)
                {
                    // do nothing
                }
                Server.param = null;
            }
            return(outdata);
        }