1
0
mirror of https://github.com/lidgren/lidgren-network-gen3.git synced 2026-05-15 22:56:30 +09:00

BREAKING CHANGE: NatIntroductionSuccess is now DISABLED by default; you must enable it using EnableMessageType

Added GarbageThrowerSample - a small library sample that sends random and semi-random data to detect problems
Made lots of changes that caused exceptions when malformed data was received
This commit is contained in:
lidgren
2014-07-31 14:55:50 +00:00
parent 04593ef00f
commit d2ae3cf41d
13 changed files with 336 additions and 18 deletions

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
</startup>
</configuration>

View File

@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using Lidgren.Network;
using System.Threading;
using System.Net;
namespace Client
{
class Program
{
static void Main(string[] args)
{
NetPeerConfiguration config = new NetPeerConfiguration("garbagethrower");
var client = new NetClient(config);
client.Start();
var target = new IPEndPoint(NetUtility.Resolve("localhost"), 14242);
var buffer = new byte[1024];
var rnd = new Random();
// use RawSend to throw poop at server
while(true)
{
rnd.NextBytes(buffer);
int length = rnd.Next(1, 1023);
switch (rnd.Next(2))
{
case 0:
// complete randomness
break;
case 1:
// semi-sensical
buffer[1] = 0; // not a fragment, sequence number 0
buffer[2] = 0; // not a fragment, sequence number 0
buffer[3] = (byte)length; // correct payload length
buffer[4] = (byte)(length >> 8); // correct payload length
break;
}
// fling teh poop
client.RawSend(buffer, 0, length, target);
Thread.Sleep(1);
}
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Client")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Client")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("0c9a409f-00cd-4b05-87f6-6f4a86d82987")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]