قديم 2020-02-15, 06:35 PM
المشاركة 2
MRonlineGvrix
.:: عضو مميز ::.
  • غير متواجد
افتراضي رد: طلب بخصوص سورس متركس
شغل الفى بى اس دا ممكن تكون شغال با بتش ميجو ودا مربوط بسحب الفى بى اس و البنج ممكن يكون العيب فى السورس
عاوز سوكت ولا حاجا خد سوكت نضيف فى السورس ركبو اهو


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

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

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

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

        public 
void BeginReceive()
        {
            try
            {
                
Socket.BeginReceive(_buffer0_buffer.LengthSocketFlags.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(resultout error);
                    if (
IsAlive && error == SocketError.Success)
                    {
                        if (
length 0)
                        {
                            try
                            {
                                
Server.InvokeOnReceive(_bufferlengththis);
                            }
                            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 (
IsAlive)
            {
                try
                {
                    
Socket.BeginSend(packet0packet.LengthSocketFlags.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();
        }
    }



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

    public 
delegate void NetworkClientConnection(ClientWrapper client);
    public 
delegate void NetworkClientReceive(Byte[] bufferInt32 lengthClientWrapper 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 nameUInt32 maximumUInt32 banTime)
        {
            
Name name;
            
AttackProtector = new BruteForceAttackProtection(maximumbanTime);
        }

        
/*
         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 portIPProtectionLevel protectionLevel)
        {
            
LocalEndPoint = new IPEndPoint(IPAddress.Anyport);
            
Socket = new Socket(AddressFamily.InterNetworkSocketType.StreamProtocolType.Tcp);
            
Socket.Bind(LocalEndPoint);
            
Socket.SetIPProtectionLevel(protectionLevel);
            
Socket.NoDelay true;
            
Socket.Listen((int)SocketOptionName.MaxConnections);
        }

        public 
void BeginAccept()
        {
            
Socket.SetSocketOption(SocketOptionLevel.SocketSocketOptionName.KeepAlivefalse);
            
Socket.SetSocketOption(SocketOptionLevel.SocketSocketOptionName.DontLingertrue);
            
Socket.BeginAccept(Acceptnull);
        }

        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(thisclientSocketClientBufferSize);
                
InvokeOnConnect(client);
                
client.BeginReceive();
            }
            else
                
clientSocket.Disconnect(false);
            
BeginAccept();
        }

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

        public 
void InvokeOnReceive(Byte[] bufferInt32 lengthClientWrapper client)
        {
            if (
OnReceive != nullOnReceive(bufferlengthclient);
        }

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

            
//   client.IsAlive = false;

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



قديم 2020-02-15, 08:45 PM
المشاركة 3
Hassan Emprator
.:: عضو خبير ::.
  • غير متواجد
افتراضي رد: طلب بخصوص سورس متركس
جرب حل سوكت دا ولو مش ظبطت شيل الحجات الي مش مهمه في سورس

قديم 2020-02-15, 08:48 PM
المشاركة 4
محمودمحمدسالم
.:: عضو مميز ::.
  • غير متواجد
افتراضي رد: طلب بخصوص سورس متركس
جرب حل سوكت دا ولو مش ظبطت شيل الحجات الي مش مهمه في سورس
في عندي مشكلة اكبر من كده دلواتي في واحد نزل جاب 2 مليار سببس انا كل يومين بلاقي حد عمل الحوار ده و ادور و الغي انبسي و الغي مش عارف اي و احل المشكلة و بعد كده واحد تاني ينزل يعمل ثغره تاني عايز اعرف اعمل اي الغي كل الانبسهات لاني منزل اتشي و جيانج و اصطف و تغير الاسم و كل الانبسهات موجود ولا في طريقه تاني اظبط الموضوع ده بيها

قديم 2020-02-15, 08:49 PM
المشاركة 5
محمودمحمدسالم
.:: عضو مميز ::.
  • غير متواجد
افتراضي رد: طلب بخصوص سورس متركس
شغل الفى بى اس دا ممكن تكون شغال با بتش ميجو ودا مربوط بسحب الفى بى اس و البنج ممكن يكون العيب فى السورس
عاوز سوكت ولا حاجا خد سوكت نضيف فى السورس ركبو اهو


كود:
namespace khaledmohamed.network.sockets
{
    
using system;
    
using system.collections.generic;
    
using system.net.sockets;
    
using system.runtime.interopservices;
    
using system.threading;
    
using khaledmohamed;
    
using system.net;

    public class 
clientwrapper
    
{
        public 
socket socket get; private set; }
        public 
serversocket server get; private set; }
        public 
ipendpoint remoteendpoint get; private set; }
        private 
readonly byte[] _buffer;
        public 
object owner;
        public 
boolean isalive get { return socket.connected; } }

        public 
string ip
        
{
            
get
            
{
                if (
socket != null)
                    return (
socket.remoteendpoint as ipendpoint).address.tostring();
                else
                    return 
null;
            }
        }

        public 
clientwrapper(serversocket serversocket socketint32 bufferlength)
        {
            
//isalive = true;
            
server server;
            
socket socket;
            
_buffer = new byte[bufferlength];
            
remoteendpoint = (ipendpoint)socket.remoteendpoint;
            
socket.nodelay true;
        }

        public 
void beginreceive()
        {
            try
            {
                
socket.beginreceive(_buffer0_buffer.lengthsocketflags.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(resultout error);
                    if (
isalive && error == socketerror.success)
                    {
                        if (
length 0)
                        {
                            try
                            {
                                
server.invokeonreceive(_bufferlengththis);
                            }
                            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 (
isalive)
            {
                try
                {
                    
socket.beginsend(packet0packet.lengthsocketflags.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();
        }
    }



كود:
namespace khaledmohamed.network.sockets
{
    
using system;
    
using system.collections.concurrent;
    
using system.net;
    
using system.net.sockets;
    
using system.runtime.interopservices;
    
using system.threading;
    
using khaledmohamed;

    public 
delegate void networkclientconnection(clientwrapper client);
    public 
delegate void networkclientreceive(byte[] bufferint32 lengthclientwrapper 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 nameuint32 maximumuint32 bantime)
        {
            
name name;
            
attackprotector = new bruteforceattackprotection(maximumbantime);
        }

        
/*
         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 portipprotectionlevel protectionlevel)
        {
            
localendpoint = new ipendpoint(ipaddress.anyport);
            
socket = new socket(addressfamily.internetworksockettype.streamprotocoltype.tcp);
            
socket.bind(localendpoint);
            
socket.setipprotectionlevel(protectionlevel);
            
socket.nodelay true;
            
socket.listen((int)socketoptionname.maxconnections);
        }

        public 
void beginaccept()
        {
            
socket.setsocketoption(socketoptionlevel.socketsocketoptionname.keepalivefalse);
            
socket.setsocketoption(socketoptionlevel.socketsocketoptionname.dontlingertrue);
            
socket.beginaccept(acceptnull);
        }

        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(thisclientsocketclientbuffersize);
                
invokeonconnect(client);
                
client.beginreceive();
            }
            else
                
clientsocket.disconnect(false);
            
beginaccept();
        }

        public 
void invokeonconnect(clientwrapper client)
        {
            if (
onconnect != nullonconnect(client);
        }

        public 
void invokeonreceive(byte[] bufferint32 lengthclientwrapper client)
        {
            if (
onreceive != nullonreceive(bufferlengthclient);
        }

        public 
void invokeondisconnect(clientwrapper client)
        {
            if (!
client.isalive) return;

            
//   client.isalive = false;

            
if (ondisconnect != nullondisconnect(client);
        }
    }

هجرب و هرود عليك شكرا


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



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

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

المواضيع المتشابهه للموضوع: طلب بخصوص سورس متركس
الموضوع كاتب الموضوع المنتدى مشاركات آخر مشاركة
ثغره في سورس متركس محمودمحمدسالم تطوير سيرفرات كونكر 4 2020-05-16 11:53 AM
مشاكل سورس متركس محمودمحمدسالم مشكلات السيرفيرات كونكر الشخصيه 3 2020-02-18 12:46 PM
مشكله الكلام في سورس متركس taha مشكلات السيرفيرات كونكر الشخصيه 1 2020-01-22 10:37 PM
ايرور في سورس متركس Mawdo3jded مشكلات السيرفيرات كونكر الشخصيه 2 2019-12-24 09:53 PM
فاعل خير سورس متركس بعد ما تسرق ahmedfathy سورسات كونكر 5 2019-12-19 02:33 AM


الساعة الآن 06:46 PM

Powered by vBulletin® Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.