示例#1
0
 public pnAuthSession(pnAuthServer parent, Socket s, pnCli2Srv_Connect hdr)
     : base(s, hdr)
 {
     fParent = parent;
     fLog = plDebugLog.GetLog("AuthSrv");
     fChallenge = BitConverter.ToUInt32(RNG.Random(4), 0);
 }
示例#2
0
        private void IAcceptConnection(Socket cli)
        {
            hsStream s = new hsStream(new NetworkStream(cli, false));
            pnCli2Srv_Connect hdr = new pnCli2Srv_Connect();
            hdr.Read(s);
            s.Close();

            IAcceptConnection(cli, hdr);
        }
示例#3
0
        public void EatClient(Socket cli, pnCli2Srv_Connect hdr)
        {
            pnAuthSession ac = new pnAuthSession(this, cli, hdr);
            if (!ac.Initialize()) {
                cli.Close();
                return;
            }

            lock (fSessions)
                fSessions.Add(ac);
        }
示例#4
0
        public void EatClient(Socket cli, pnCli2Srv_Connect hdr)
        {
            pnVaultSession vc = new pnVaultSession(this, cli, hdr);
            if (!vc.Initialize()) {
                cli.Close();
                return;
            }

            lock (fSessions) {
                fSessions.Add(vc);
            }
        }
示例#5
0
        private void IAcceptConnection(Socket cli, pnCli2Srv_Connect hdr)
        {
            pnIniParser ini = pngIni.Ini;
            switch (hdr.fType) {
                case ENetProtocol.kConnTypeCliToAuth:
                    if (!ITestClientBranchID(hdr)) {
                        cli.Close();
                        break;
                    }

                    if (!ITestClientBuildID(hdr)) {
                        cli.Close();
                        break;
                    }

                    if (!ITestClientGuid(hdr)) {
                        cli.Close();
                        break;
                    }

                    fAuth.EatClient(cli, hdr);
                    break;
                case ENetProtocol.kConnTypeCliToFile:
                    throw new NotImplementedException();
                case ENetProtocol.kConnTypeCliToGame:
                    throw new NotImplementedException();
                case ENetProtocol.kConnTypeCliToGate:
                    throw new NotImplementedException();
                case ENetProtocol.kConnTypeSrvToLookup:
                    throw new NotImplementedException();
                case ENetProtocol.kConnTypeSrvToVault:
                    if (!ITestServerGuid(hdr)) {
                        cli.Close();
                        break;
                    }

                    fVault.EatClient(cli, hdr);
                    break;
                default:
                    // Unknown protocol, boot the client on principle.
                    cli.Close();
                    break;
            }
        }
示例#6
0
 public pnSynchSession(Socket s, pnCli2Srv_Connect hdr)
     : base(s, hdr)
 {
     fReceiveArgs.Completed +=new EventHandler<SocketAsyncEventArgs>(IReceive);
     fReceiveArgs.SetBuffer(new byte[0], 0, 0);
 }
示例#7
0
 public pnSession(Socket s, pnCli2Srv_Connect hdr)
     : base(s, hdr)
 {
 }
示例#8
0
 public pnVaultSession(pnVaultServer parent, Socket s, pnCli2Srv_Connect hdr)
     : base(s, hdr)
 {
     fParent = parent;
     fLog = plDebugLog.GetLog("VaultSrv");
 }
示例#9
0
 public plNetServer(Socket client, pnCli2Srv_Connect hdr)
 {
     fSocket = client;
     fConnHdr = hdr;
 }
示例#10
0
 private bool ITestServerGuid(pnCli2Srv_Connect hdr)
 {
     Guid product = pngIni.Ini.GetGuid("Server.ProductID");
     if (product != Guid.Empty)
         return hdr.fProductUuid == product;
     return true;
 }
示例#11
0
 private bool ITestClientBuildID(pnCli2Srv_Connect hdr)
 {
     int? buildID = pngIni.Ini.GetInteger("Client.BuildID");
     if (buildID.HasValue)
         return hdr.fBuildID == buildID.Value;
     return true;
 }