احصائياتى

الردود
5

المشاهدات
556
 
ElSaher
.:: مشرف اقسام كونكر ::.

المشاركات
3,131

+التقييم
1.17

تاريخ التسجيل
Jun 2019

الاقامة
الزقازيق

نظام التشغيل
ويندوز 0

رقم العضوية
279
2020-07-07, 01:34 AM
المشاركة 1
2020-07-07, 01:34 AM
المشاركة 1
افتراضي سوكت سيرفر Matrix
اليوم معانا سوكت الخاص بي سيرفر متركس بتاع شمس نور

نبدا بي الاضافت

افتح كلاس ServerSocket
امسح كل الي فيه وضيف

كود:
namespace ElSaher.Network.Sockets
{
    
using System;
    
using System.Collections.Concurrent;
    
using System.Net;
    
using System.Net.Sockets;
    
using System.Runtime.InteropServices;
    
using System.Threading;
    
using ElSaher;

    public 
delegate void NetworkClientConnection(ClientWrapper client);
    public 
delegate void NetworkClientReceive(Byte[] buffer, Int32 length, ClientWrapper client);

    public class 
ServerSocket
    
{
        public 
Socket Socket { get; private set; }
        public 
IPEndPoint LocalEndPoint { get; private set; }
        public 
String Name { get; private set; }

        public 
NetworkClientConnection OnConnect;
        public 
NetworkClientReceive OnReceive;
        public 
NetworkClientConnection OnDisconnect;
        public 
BruteForceAttackProtection AttackProtector;

        public 
Int32 ClientBufferSize;

        public 
ServerSocket(String name, UInt32 maximum, UInt32 banTime)
        {
            
Name = name;
            
AttackProtector = new BruteForceAttackProtection(maximum, banTime);
        }

        
/*
         The Set IP Protection Level method enables restricting an a IPv6 or IP socket to listen on a specified scope, such as addresses with the same link local or site local prefix. This socket option enables applications to place access restrictions on IPv6 or IP sockets. Such restrictions enable an application running on a private LAN to simply and robustly harden itself against external attacks. This socket option can also be used to remove access restrictions if the level parameter is set to Unrestricted. This socket option widens or narrows the scope of a listening socket, enabling unrestricted access from public and private users when appropriate, or restricting access only to the same site, as required.

        This socket option has defined protection levels specified in the IPProtectionLevel enumeration.

        The SetIPProtectionLevel method is used to enable or disable Network Address Traversal (NAT) for a Socket instance. NAT traversal may be provided using Teredo, 6to4, or an ISATAP tunnel.

        When the level parameter is set to EdgeRestricted, or Restricted, this explicitly disables NAT traversal for a Socket instance.

        When the level parameter is set to EdgeRestricted, this may allow NAT traversal for a Socket depending on firewall rules in place on the system. 
        */
        
public void Prepare(int port, IPProtectionLevel protectionLevel)
        {
            
LocalEndPoint = new IPEndPoint(IPAddress.Any, port);
            
Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            
Socket.Bind(LocalEndPoint);
            
Socket.SetIPProtectionLevel(protectionLevel);
            
Socket.NoDelay = true;
            
Socket.Listen((int)SocketOptionName.MaxConnections);
        }

        public 
void BeginAccept()
        {
            
Socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, false);
            
Socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.DontLinger, true);
            
Socket.BeginAccept(Accept, null);
        }

        private 
void Accept(IAsyncResult result)
        {
            
Socket clientSocket;

            try
            {
                
clientSocket = Socket.EndAccept(result);
            }
            catch (
SocketException)
            {
                
BeginAccept();
                return;
            }

            if (
AttackProtector.Authenticate(clientSocket))
            {
                
clientSocket.ReceiveBufferSize = ClientBufferSize;
                var 
client = new ClientWrapper(this, clientSocket, ClientBufferSize);
                
InvokeOnConnect(client);
                
client.BeginReceive();
            }
            else
                
clientSocket.Disconnect(false);
            
BeginAccept();
        }

        public 
void InvokeOnConnect(ClientWrapper client)
        {
            if (
OnConnect != null) OnConnect(client);
        }

        public 
void InvokeOnReceive(Byte[] buffer, Int32 length, ClientWrapper client)
        {
            if (
OnReceive != null) OnReceive(buffer, length, client);
        }

        public 
void InvokeOnDisconnect(ClientWrapper client)
        {
            if (!
client.Alive) return;

            
//   client.Alive = false;

            
if (OnDisconnect != null) OnDisconnect(client);
        }
    }
} 

افتح كلاس
ClientWrapper
وامسح كل الي فيه وضيف

كود:
namespace ElSaher.Network.Sockets
{
    
using System;
    
using System.Collections.Generic;
    
using System.Net.Sockets;
    
using System.Runtime.InteropServices;
    
using System.Threading;
    
using ConquerDragonGate;
    
using System.Net;

    public class 
ClientWrapper
    
{
        public 
Socket Socket { get; private set; }
        public 
ServerSocket Server { get; private set; }
        public 
bool OverrideTiming;
        public 
IPEndPoint RemoteEndPoint { get; private set; }
        private 
readonly byte[] _buffer;
        public 
object Connector;
        public 
object Owner;
        public 
Boolean Alive { get { return Socket.Connected; } }

        public 
String IP
        
{
            
get
            
{
                if (
Socket != null)
                    return (
Socket.RemoteEndPoint as IPEndPoint).Address.ToString();
                else
                    return 
null;
            }
        }

        public 
ClientWrapper(ServerSocket server, Socket socket, Int32 bufferLength)
        {
            
//Alive = true;
            
Server = server;
            
Socket = socket;
            
_buffer = new byte[bufferLength];
            
RemoteEndPoint = (IPEndPoint)Socket.RemoteEndPoint;
            
Socket.NoDelay = true;
        }

        public 
void BeginReceive()
        {
            try
            {
                
Socket.BeginReceive(_buffer, 0, _buffer.Length, SocketFlags.None, new AsyncCallback(Receive), null);
            }
            catch (
SocketException)
            {
                
Server.InvokeOnDisconnect(this);
            }
        }

        private 
void Receive(IAsyncResult result)
        {
            if (
Socket != null)
            {
                try
                {
                    
SocketError error;
                    
Int32 length = Socket.EndReceive(result, out error);
                    if (
Alive && error == SocketError.Success)
                    {
                        if (
length > 0)
                        {
                            try
                            {
                                
Server.InvokeOnReceive(_buffer, length, this);
                            }
                            catch (
Exception e)
                            {
                                
System.Console.WriteLine(e.ToString());
                            }
                            finally
                            {
                                
BeginReceive();
                            }
                        }
                        else
                        {
                            
Server.InvokeOnDisconnect(this);
                        }
                    }
                }
                catch (
SocketException)
                {
                    
Server.InvokeOnDisconnect(this);
                }
            }
        }
        public 
void Send(byte[] packet)
        {
            if (
Alive)
            {
                try
                {
                    
Socket.BeginSend(packet, 0, packet.Length, SocketFlags.None, new AsyncCallback(EndSend), null);
                }
                catch (
SocketException)
                {
                    
Server.InvokeOnDisconnect(this);
                }
            }
        }

        private 
void EndSend(IAsyncResult result)
        {
            try
            {
                
Socket.EndSend(result);
            }
            catch (
SocketException)
            {
                
Server.InvokeOnDisconnect(this);
            }
        }

        public 
void Disconnect()
        {
            try
            {
                
Socket.Disconnect(false);
            }
            catch (
SocketException)
            {
            }
            
Server.InvokeOnDisconnect(this);
        }

        public 
override string ToString()
        {
            return 
RemoteEndPoint.ToString();
        }
    }
} 

بدل ElSaher بي اسم البروجكت بتاعك


قديم 2020-07-07, 04:15 AM
المشاركة 2
SourceDanger
.:: مشرف قسم السورسات ::.
  • غير متواجد
افتراضي رد: سوكت سيرفر Matrix
مساء البرشم ؟

دة اي دة سوكت اي يحج صبح الفل دة ناقص علفكره يعني حتها لو الناس ضفت الاتنين دول بس هيطلع ايرورات قد كدا فيه حاجت تني هتتغير لو اخدت السوكت دة وضفتو فى اي سورس عمتنا !!

قديم 2020-07-07, 04:34 AM
المشاركة 3
ElSaher
.:: مشرف اقسام كونكر ::.
  • غير متواجد
افتراضي رد: سوكت سيرفر Matrix
عفواً لايمكن عرض الرابط إلا بعد الرد على الموضوع
مساء البرشم ؟

دة اي دة سوكت اي يحج صبح الفل دة ناقص علفكره يعني حتها لو الناس ضفت الاتنين دول بس هيطلع ايرورات قد كدا فيه حاجت تني هتتغير لو اخدت السوكت دة وضفتو فى اي سورس عمتنا !!
الايرور الي هيجي هنديلو الحل

متصعبشي الامور يا خلوده

قديم 2020-07-07, 12:25 PM
المشاركة 4
abuhaneen
.:: عضو مميز ::.
  • غير متواجد
افتراضي رد: سوكت سيرفر Matrix
عفواً لايمكن عرض الرابط إلا بعد الرد على الموضوع
مساء البرشم ؟

دة اي دة سوكت اي يحج صبح الفل دة ناقص علفكره يعني حتها لو الناس ضفت الاتنين دول بس هيطلع ايرورات قد كدا فيه حاجت تني هتتغير لو اخدت السوكت دة وضفتو فى اي سورس عمتنا !!
نقولو عاش :]

قديم 2020-07-08, 07:57 PM
المشاركة 5
Diga
.:: عضو نشيط ::.
  • غير متواجد
افتراضي رد: سوكت سيرفر Matrix
مساء الهبد

قديم 2020-07-08, 09:34 PM
المشاركة 6
ElSaher
.:: مشرف اقسام كونكر ::.
  • غير متواجد
افتراضي رد: سوكت سيرفر Matrix
دي اخرت الواحد لما ينزل حاجا

سوفا يتم مسح الموضوع


العلامات المرجعية



الذين يشاهدون محتوى الموضوع الآن : 1 ( الأعضاء 0 والزوار 1)
 

الانتقال السريع

المواضيع المتشابهه للموضوع: سوكت سيرفر Matrix
الموضوع كاتب الموضوع المنتدى مشاركات آخر مشاركة
New Source Matrix[Proto] By MaZzGanGy MaZzGanGYy سورسات كونكر 125 2021-09-03 02:33 AM
ثغره في سورس Matrix 3d V1 محمودمحمدسالم تطوير سيرفرات كونكر 6 2020-05-07 11:38 PM
حل بسرعه يا شباب سورس matrix V1 محمودمحمدسالم مشكلات السيرفيرات كونكر الشخصيه 1 2020-02-13 04:47 AM


الساعة الآن 03:56 AM