diff --git a/DHCPLease.cs b/DHCPLease.cs
index f8b52a7..aab5d9a 100644
--- a/DHCPLease.cs
+++ b/DHCPLease.cs
@@ -1,8 +1,11 @@
using System;
using ln.types.net;
using ln.types.odb.attributes;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
namespace ln.dhcp
{
+ [JsonConverter(typeof(StringEnumConverter))]
public enum DHCPLeaseState
{
RELEASED,
diff --git a/DHCPServer.cs b/DHCPServer.cs
index 7267796..8ffd8d2 100644
--- a/DHCPServer.cs
+++ b/DHCPServer.cs
@@ -288,6 +288,7 @@ namespace ln.dhcp
lease.ValidThrough = validThrough;
}
lease.LeaseState = DHCPLeaseState.BOUND;
+ lease.LastUpdate = DateTimeOffset.Now;
Commit(lease);
logLease.Log(LogLevel.INFO, "[ACK ] {0} {1} {2}", lease.ClientMAC, lease.ClientIP, lease.ClientName);
@@ -328,10 +329,11 @@ namespace ln.dhcp
IPv4 test = start;
while (leasesAPI.FindLease(test) != null)
{
- test = ippool.NextIP;
+ test = ippool.GetNextIP();
if (test.Equals(start))
return null;
}
+ Commit(ippool);
return test;
}
}
diff --git a/IPPool.cs b/IPPool.cs
index fbae4ed..794ccaa 100644
--- a/IPPool.cs
+++ b/IPPool.cs
@@ -13,20 +13,24 @@ namespace ln.dhcp
public IPv4 LastIP { get; set; }
IPv4 nextIP;
- public IPv4 NextIP
+ public IPv4 NextIP
{
- get
+ get => nextIP;
+ set => nextIP = value;
+ }
+
+ public TimeSpan DefaultLeaseTime { get; set; }
+
+ public IPv4 GetNextIP()
+ {
+ lock (this)
{
IPv4 next = nextIP++;
if (nextIP > LastIP)
nextIP = FirstIP;
return next;
}
- set => nextIP = value;
}
-
- public TimeSpan DefaultLeaseTime { get; set; }
-
private IPPool()
{
DefaultLeaseTime = TimeSpan.FromHours(1);
diff --git a/bin/Debug/Newtonsoft.Json.dll b/bin/Debug/Newtonsoft.Json.dll
index d0aaed9..4395f61 100755
Binary files a/bin/Debug/Newtonsoft.Json.dll and b/bin/Debug/Newtonsoft.Json.dll differ
diff --git a/bin/Debug/Newtonsoft.Json.pdb b/bin/Debug/Newtonsoft.Json.pdb
deleted file mode 100755
index 0cfd893..0000000
Binary files a/bin/Debug/Newtonsoft.Json.pdb and /dev/null differ
diff --git a/bin/Debug/Newtonsoft.Json.xml b/bin/Debug/Newtonsoft.Json.xml
index b2810a0..9e42a41 100755
--- a/bin/Debug/Newtonsoft.Json.xml
+++ b/bin/Debug/Newtonsoft.Json.xml
@@ -1514,7 +1514,7 @@
Converts the to its JSON string representation.
The value to convert.
- A JSON string representation of the .
+ A JSON string representation of the .
@@ -2162,6 +2162,12 @@
The member serialization.
+
+
+ Gets or sets the missing member handling used when deserializing this object.
+
+ The missing member handling.
+
Gets or sets how the object's properties with null values are handled during serialization and deserialization.
@@ -8103,6 +8109,13 @@
The token to read from.
+
+
+ Initializes a new instance of the class.
+
+ The token to read from.
+ The initial path of the token. It is prepended to the returned .
+
Reads the next JSON token from the underlying .
@@ -10199,6 +10212,13 @@
The converter.
+
+
+ Gets the internally resolved for the contract's type.
+ This converter is used as a fallback converter when no other converter is resolved.
+ Setting will always override this converter.
+
+
Gets or sets all methods called immediately after deserialization of the object.
@@ -10344,6 +10364,12 @@
The member object serialization.
+
+
+ Gets or sets the missing member handling used when deserializing this object.
+
+ The missing member handling.
+
Gets or sets a value that indicates whether the object's properties are required.
@@ -10510,6 +10536,11 @@
A value indicating whether this is required.
+
+
+ Gets a value indicating whether has a value specified.
+
+
Gets or sets a value indicating whether this property preserves object references.
@@ -10760,6 +10791,26 @@
The property name to resolve.
The resolved property name.
+
+
+ Hash code calculation
+
+
+
+
+
+ Object equality implementation
+
+
+
+
+
+
+ Compare to another NamingStrategy
+
+
+
+
Represents a method that constructs an object.
diff --git a/bin/Debug/ln.dhcp.dll b/bin/Debug/ln.dhcp.dll
index 3cb0a67..f212fae 100644
Binary files a/bin/Debug/ln.dhcp.dll and b/bin/Debug/ln.dhcp.dll differ
diff --git a/bin/Debug/ln.dhcp.pdb b/bin/Debug/ln.dhcp.pdb
index cda7738..1d5f917 100644
Binary files a/bin/Debug/ln.dhcp.pdb and b/bin/Debug/ln.dhcp.pdb differ
diff --git a/bin/Debug/ln.types.dll b/bin/Debug/ln.types.dll
index 650415c..a9fe7c0 100644
Binary files a/bin/Debug/ln.types.dll and b/bin/Debug/ln.types.dll differ
diff --git a/bin/Debug/sharp.logging.dll b/bin/Debug/sharp.logging.dll
index 3b6b9a5..0f2a906 100644
Binary files a/bin/Debug/sharp.logging.dll and b/bin/Debug/sharp.logging.dll differ
diff --git a/ln.dhcp.csproj b/ln.dhcp.csproj
index 87ee592..27895b4 100644
--- a/ln.dhcp.csproj
+++ b/ln.dhcp.csproj
@@ -29,6 +29,9 @@
+
+ ..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll
+
@@ -51,5 +54,8 @@
ln.logging
+
+
+
\ No newline at end of file
diff --git a/obj/Debug/ln.dhcp.csproj.CoreCompileInputs.cache b/obj/Debug/ln.dhcp.csproj.CoreCompileInputs.cache
index a039c52..c1d016e 100644
--- a/obj/Debug/ln.dhcp.csproj.CoreCompileInputs.cache
+++ b/obj/Debug/ln.dhcp.csproj.CoreCompileInputs.cache
@@ -1 +1 @@
-62f8061fbf7e671ceaa150fc217748d6af510370
+52f74c261979b87de87fda0ff386127bee4e9aa4
diff --git a/obj/Debug/ln.dhcp.csproj.FileListAbsolute.txt b/obj/Debug/ln.dhcp.csproj.FileListAbsolute.txt
index 66a348f..979c095 100644
--- a/obj/Debug/ln.dhcp.csproj.FileListAbsolute.txt
+++ b/obj/Debug/ln.dhcp.csproj.FileListAbsolute.txt
@@ -25,4 +25,3 @@
/home/haraldwolff/src/ln.skyspot/ln.dhcp/bin/Debug/sharp.logging.pdb
/home/haraldwolff/src/ln.skyspot/ln.dhcp/bin/Debug/Newtonsoft.Json.xml
/home/haraldwolff/src/ln.skyspot/ln.dhcp/obj/Debug/ln.dhcp.csproj.CopyComplete
-/home/haraldwolff/src/ln.skyspot/ln.dhcp/bin/Debug/Newtonsoft.Json.pdb
diff --git a/obj/Debug/ln.dhcp.csprojAssemblyReference.cache b/obj/Debug/ln.dhcp.csprojAssemblyReference.cache
index 31d7b7e..8e98121 100644
Binary files a/obj/Debug/ln.dhcp.csprojAssemblyReference.cache and b/obj/Debug/ln.dhcp.csprojAssemblyReference.cache differ
diff --git a/obj/Debug/ln.dhcp.dll b/obj/Debug/ln.dhcp.dll
index 3cb0a67..f212fae 100644
Binary files a/obj/Debug/ln.dhcp.dll and b/obj/Debug/ln.dhcp.dll differ
diff --git a/obj/Debug/ln.dhcp.pdb b/obj/Debug/ln.dhcp.pdb
index cda7738..1d5f917 100644
Binary files a/obj/Debug/ln.dhcp.pdb and b/obj/Debug/ln.dhcp.pdb differ
diff --git a/packages.config b/packages.config
new file mode 100644
index 0000000..39d1cce
--- /dev/null
+++ b/packages.config
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file