Skip to content

Commit

Permalink
Moved committer delay logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
krisdb2009 committed Mar 7, 2024
1 parent 66e97d9 commit b7a2a31
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions Tikhole.Engine/Committer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ private void Login()
private void Matcher_ResponseMatched(object? sender, ResponseMatchedEventArgs e)
{
if (ResponsesRecieved++ % TotalInstances != InstanceID) return;
bool added = false;
if (!TcpClientSemephore.Wait((int)ComitterTimeoutMS))
{
Logger.Warning("Committer queued for more than a " + ComitterTimeoutMS + "ms. Commit canceled.");
Expand Down Expand Up @@ -161,11 +160,6 @@ private void Matcher_ResponseMatched(object? sender, ResponseMatchedEventArgs e)
finally
{
TcpClientSemephore.Release();
if (added)
{
if (Logger.VerboseMode) Logger.Verbose("New entry in IP list, sleeping for " + ComitterDelayMS + "ms for RouterOS to catch up.");
Thread.Sleep((int)ComitterDelayMS);
}
}
}
private void TrackListSet(CommitterTrackKey Key, CommitterTrackValue Value)
Expand Down Expand Up @@ -205,13 +199,17 @@ private bool TrackListContains(CommitterTrackKey Key)
private string[] ListAdd(IPAddress IPAddress, string List, string Comment)
{
(string v6, string cidr) = AddressBits(IPAddress);
return TcpClient.SendSentence([
string[] result = TcpClient.SendSentence([
"/ip" + v6 + "/firewall/address-list/add",
"=list=" + List,
"=comment=" + Comment,
"=address=" + IPAddress.ToString() + cidr,
"=timeout=" + ListTTL.ToString()
]);
if (Logger.VerboseMode) Logger.Verbose("New entry in IP list, sleeping for " + ComitterDelayMS + "ms for RouterOS to catch up.");
Thread.Sleep((int)ComitterDelayMS);
return result;

}
private string[] ListSet(string ID, IPAddress IPAddress, string Comment)
{
Expand Down

0 comments on commit b7a2a31

Please sign in to comment.