Hashtable unsafepackethandlers = new Hashtable(); // packets which dont have correct sharedsecret, or sharedsecret not yet validated #endregion Fields #region Constructors public NetworkLevel2Connection( NetworkLevel2Controller parent, ConnectionInfo connectioninfo, bool isserver ) { LogFile.WriteLine("NetworkLevel2Connection()"); networkimplementation = parent.networkimplementation; this.connectioninfo = connectioninfo; this.parent = parent; //this.connection = connectioninfo.Connection; this.isserver = isserver; lasttimestamp = DateTime.Now; packetreferencecontroller = new NetPacketReferenceController( this, isserver ); sharedsecretexchange = new NetSharedSecretExchange( this, isserver ); //sharedsecretexchange.Tick(); }
void network_NewConnection(NetworkLevel2Connection net2con, ConnectionInfo connectioninfo) { LogFile.WriteLine("Server: client disconnected: " + net2con.connectioninfo); }
void network_Disconnection(NetworkLevel2Connection net2con, ConnectionInfo connectioninfo) { remoteclientdirtyqueues.Remove(net2con.connectioninfo.Connection); }
void network_NewConnection(NetworkLevel2Connection net2con, ConnectionInfo connectioninfo) { LogFile.WriteLine( "isserver: " + net2con.isserver ); LogFile.WriteLine( "net2con: " + net2con ); LogFile.WriteLine( "connectioninfo: " + net2con.connectioninfo ); LogFile.WriteLine( "connection: " + net2con.connectioninfo.Connection ); remoteclientdirtyqueues.Add( net2con.connectioninfo.Connection, new DirtyObjectQueueSingleClient( this, net2con.connectioninfo.Connection ) ); }
void net_NewConnection(NetworkLevel2Connection net2con, ConnectionInfo connectioninfo) { LogFile.WriteLine("TestLevel2Client: connected to server " + connectioninfo.IPAddress.ToString() + " " + connectioninfo.Port); net.Send( net2con.connectioninfo.Connection, 'Z', Encoding.UTF8.GetBytes("Hello server!") ); }
void net_NewConnection(NetworkLevel2Connection net2con, ConnectionInfo connectioninfo) { LogFile.WriteLine("TestLevel2Server: Client connected " + connectioninfo.IPAddress.ToString() + " " + connectioninfo.Port); }
public void ReceivedPacketHandler( ConnectionInfo connection, byte[]packet, int nextposition, int length ) { //object connection = e.Connection; //byte[] packet = e.Data; //int nextposition = e.DataStartIndex; lasttimestamp = DateTime.Now; if( packet.Length >= 4 + 2 + 1 ) { int packetkey = (int)binarypacker.ReadValueFromBuffer(packet, ref nextposition, typeof(int)); short packetref = (short)binarypacker.ReadValueFromBuffer(packet, ref nextposition, typeof(short)); char packetcode = (char)binarypacker.ReadValueFromBuffer(packet, ref nextposition, typeof(char)); //LogFile.WriteLine( "Packet key: " + packetkey.ToString() + " packetref: " + packetref.ToString() + " packetcode: " + packetcode ); if( unsafepackethandlers.Contains( packetcode ) ) { //LogFile.WriteLine("calling unsafepackethandler..."); if( packetreferencecontroller.ValidateIncomingReference( packetref ) ) { //LogFile.WriteLine("Incoming reference validated"); ((PacketHandler)unsafepackethandlers[packetcode])(this, new PacketHandlerArgs( packetkey, packetcode, packetref, packet, nextposition ) ); } } else { if( sharedsecretexchange.ValidateIncomingPacketKey( packetkey ) ) { if( packetreferencecontroller.ValidateIncomingReference( packetref ) ) { if( packethandlers.Contains( packetcode ) ) { ((PacketHandler)packethandlers[ packetcode ])( this, new PacketHandlerArgs( packetkey, packetcode, packetref, packet, nextposition ) ); } else if (parent.packetconsumers.ContainsKey(packetcode)) { parent.packetconsumers[packetcode](this, packet, nextposition, length - nextposition); } else { LogFile.WriteLine("Warning: unknown packet code " + packetcode.ToString() + " " + Encoding.ASCII.GetString(packet, 0, packet.Length)); } }// else silently ignore duplicate packet } else { if (isserver) { LogFile.WriteLine("WARNING: server received potentially spoofed packet allegedly from " + connection.ToString() + " " + Encoding.ASCII.GetString(packet, 0, packet.Length)); } else { LogFile.WriteLine("WARNING: client received potentially spoofed packet allegedly from " + connection.ToString() + " " + Encoding.ASCII.GetString(packet, 0, packet.Length)); } } } } }
void network_ReceivedPacket( INetworkImplementation source, ConnectionInfo connectioninfo, byte[] data, int offset, int length ) { try { //LogFile.WriteLine("STUN network receivedpacket"); if (length > 2 && data[0] == 1 && data[0] == 1) // bindingresponse { LogFile.WriteLine( this.GetType() + "could be binding reponse"); Message responsemessage = Message.Decode(data, 0, data.Length); MappedAddressAttribute mappedaddress = (MappedAddressAttribute)responsemessage.GetAttribute( net.voxx.stun4cs.Attribute.MAPPED_ADDRESS ); IPAddress ipaddress = new IPAddress( mappedaddress.GetAddressBytes() ); int port = mappedaddress.GetAddress().GetPort(); Console.WriteLine( ipaddress + " " + port ); network.ReceivedPacket -= packethandler; callback( ipaddress, port ); } else if (length > 2 && data[0] == 1 && data[0] == 0x11) // bindingerror response { LogFile.WriteLine( this.GetType() + " could be binding error"); } } catch( Exception e ) { //LogFile.WriteLine( "STUN networkreceivedpacket " + e); } }
void network_NewConnection(NetworkLevel2Connection net2con, ConnectionInfo connectioninfo) { LogFile.WriteLine("TestNetRpcServer, new connection: " + net2con.connectioninfo); }
void network_NewConnection(NetworkLevel2Connection net2con, ConnectionInfo connectioninfo) { LogFile.WriteLine("Testnetrpc , new connection " + connectioninfo); RpcController rpc = new RpcController(network); TestController.GetInstance().rpc = rpc; Testing.TestInterface_ClientProxy testinterface_clientproxy = new OSMP.Testing.TestInterface_ClientProxy(rpc, null); testinterface_clientproxy.SayHello(); }
void net_ReceivedPacket( INetworkImplementation source, ConnectionInfo connectioninfo, byte[] data, int offset, int length ) { LogFile.WriteLine( "Received packet: " + Encoding.UTF8.GetString( data ) ); }
void net_ReceivedPacket( INetworkImplementation source, ConnectionInfo connectioninfo, byte[] data, int offset, int length ) { LogFile.WriteLine("Received packet: " + Encoding.UTF8.GetString(data)); net.Send(connectioninfo.Connection, Encoding.UTF8.GetBytes( "Hello from server!" ) ); }
void network_NewConnection( NetworkLevel2Connection net2con, ConnectionInfo connectioninfo ) { LogFile.WriteLine( "showserverdialog.network_newconnection()" ); new STUN( net2con.networkimplementation, new STUN.GotExternalAddress( STUNResponseForOwnInterface ) ); }
void net_Disconnection(NetworkLevel2Connection net2con, ConnectionInfo connectioninfo) { LogFile.WriteLine("TestLevel2Client: Disconnected from server " + connectioninfo.IPAddress.ToString() + " " + connectioninfo.Port); }
public Level1ConnectionInfo( IPEndPoint EndPoint, ConnectionInfo connectioninfo ) { this.EndPoint = EndPoint; this.connectioninfo = connectioninfo; LastTimestamp = DateTime.Now; LastOutgoingPacketTime = DateTime.Now; }
public void ReceivedPacketHandler( INetworkImplementation source, ConnectionInfo connectioninfo, byte[] data, int offset, int length ) { object connection = connectioninfo.Connection; //LogFile.WriteLine("Connection: " + connection); if (IsServer) { if (!connections.ContainsKey(connection)) { NetworkLevel2Connection networklevel2connection = new NetworkLevel2Connection(this, connectioninfo, IsServer); connections.Add(connection, networklevel2connection); } connections[connection].ReceivedPacketHandler(connectioninfo, data, offset, length); } else { connectiontoserver.ReceivedPacketHandler(connectioninfo, data, offset, length); } }
void network_NewConnection(NetworkLevel2Connection net2con, ConnectionInfo connectioninfo) { LogFile.WriteLine("client connected to server"); waitingforserverconnection = false; InitializePlayermovement(); myavatar = new Avatar(); worldstorage.AddEntity(myavatar); new NetworkInterfaces.WorldControl_ClientProxy(rpc, connectioninfo.Connection) .RequestResendWorld(); }
void net_NewConnection(NetworkLevel2Connection net2con, ConnectionInfo connectioninfo) { LogFile.WriteLine("TestLevel2Client: connected to server " + connectioninfo.IPAddress.ToString() + " " + connectioninfo.Port); net.Send(net2con.connectioninfo.Connection, 'Z', Encoding.UTF8.GetBytes("Hello server!")); }