示例#1
0
 /// <summary>
 /// Creates a new Connection witht he given information
 /// </summary>
 /// <param name="dataStream">The Socket of the connection</param>
 /// <param name="connectionID">The id of the connection</param>
 public ClientSocketInformation(string address, int port, bool disableNaglesAlgorithm)
 {
     this.buffer = new byte[ConnectionSettings.BUFFER_SIZE];
     this.disableNaglesAlgorithm = disableNaglesAlgorithm;
     this.ip = address;
     this.port = port;
     this.isConnected = false;
     this.packetParser = new LicensePacketParser();
     this.RSAHandler = new RSAHandler();
     this.packetParser.onNewPacket += HandlePacket;
 }
示例#2
0
        public static ILicenseHolder CreateLicense(string license)
        {
#if DEBUG
            Console.ForegroundColor = ConsoleColor.Red;
            Logging.WriteLine("*************************************************************");
            Logging.WriteLine("*  The Butterfly server has been build in DEVELOPMENT mode  *");
            Logging.WriteLine("*                                         ^^^^^^^^^^^       *");
            Logging.WriteLine("*       In this mode only 9001 slots are available          *");
            Logging.WriteLine("*     Never publish any build build using >>DEVELOPMENT<<   *");
            Logging.WriteLine("*      The server will not use the licensing system in      *");
            Logging.WriteLine("*                         this mode                         *");
            Logging.WriteLine("*************************************************************");
            if (TestLicenseSystem)
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Logging.WriteLine("Server is testing license system, please change LicenseFactory.TestLicenseSystem to FALSE if you want to avoid using the licensesystem in debug mode");
            }
            else
            {

                Console.ForegroundColor = ConsoleColor.White;
                return new DevelopmentLicense();
            }

            Console.ForegroundColor = ConsoleColor.White;
            
           
#endif
            RSAHandler handler = new RSAHandler();
         
            string licenseString;
            try
            {
                string key = license.Substring(0, 4);
                string encodedLicense = license.Substring(4);
                licenseString = AESEncryption.Decrypt(encodedLicense, key, "lCtQe1god0b104Eq", key);
            }
            catch (Exception)
            {
                return new DummyLicense();
            }

            return new LicenseServerConnection(licenseString);
        }