Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/dotnet-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0'
dotnet-version: '8.0'
- run: 'dotnet restore'
- run: 'dotnet publish -o publish/rfpproxy -c Release RfpProxy/RfpProxy.csproj'
- run: 'dotnet publish -o publish/rfpproxy.log -c Release RfpProxy.Log/RfpProxy.Log.csproj'
Expand Down
8 changes: 4 additions & 4 deletions AVM.Test/AVM.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion AVM/AVM.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>avm</AssemblyName>
<RootNamespace>RfpProxy.AVM</RootNamespace>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion BusyLed/BusyLed.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>busyled</AssemblyName>
<RootNamespace>RfpProxy.BusyLed</RootNamespace>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion CompressIPUI/CompressIPUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>compressipui</AssemblyName>
<RootNamespace>RfpProxy.CompressIPUI</RootNamespace>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion DoS/DoS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>dos</AssemblyName>
<RootNamespace>RfpProxy.Dos</RootNamespace>
</PropertyGroup>
Expand Down
8 changes: 4 additions & 4 deletions MediaTone.Test/MediaTone.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
4 changes: 2 additions & 2 deletions MediaTone/MediaTone.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>mediatone</AssemblyName>
<RootNamespace>RfpProxy.MediaTone</RootNamespace>
</PropertyGroup>
Expand All @@ -16,7 +16,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Melanchall.DryWetMidi.Nativeless" Version="6.1.3" />
<PackageReference Include="Melanchall.DryWetMidi.Nativeless" Version="6.1.4" />
<PackageReference Include="Mono.Options" Version="6.12.0.148" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion MorseLed/MorseLed.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>morseled</AssemblyName>
<RootNamespace>RfpProxy.MorseLed</RootNamespace>
</PropertyGroup>
Expand Down
6 changes: 3 additions & 3 deletions RfpProxy.AaMiDe/AaMiDe/Sys/SysInitMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,9 @@ public SysInitMessage(PhysicalAddress mac, RfpCapabilities capabilities) : base(
Hardware = RfpType.RFP35;
Mac2 = mac;
Magic = 0x00037a20000529d9;
Protocol = 0x080303u;
Protocol = 0x080500u;
Capabilities = capabilities;
SwVersion = "SIP-DECT 8.3-eventphone";
SwVersion = "SIP-DECT 9.2-eventphone";
}

public SysInitMessage(ReadOnlyMemory<byte> data):base(MsgType.SYS_INIT, data)
Expand Down Expand Up @@ -362,4 +362,4 @@ public override void Log(TextWriter writer)
writer.Write($"SW Version({SwVersion}) Signature({Signature.ToHex()}) ");
}
}
}
}
4 changes: 2 additions & 2 deletions RfpProxy.ChangeLed/RfpProxy.ChangeLed.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Mono.Options" Version="6.12.0.148" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion RfpProxy.Inject/RfpProxy.Inject.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>rfpproxyinject</AssemblyName>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
Expand Down
4 changes: 2 additions & 2 deletions RfpProxy.Log/RfpProxy.Log.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>rfpproxylog</AssemblyName>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Mono.Options" Version="6.12.0.148" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion RfpProxy.Pcap/RfpProxy.Pcap.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>rfpproxydump</AssemblyName>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
Expand Down
8 changes: 4 additions & 4 deletions RfpProxy.Test/RfpProxy.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand All @@ -18,9 +18,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion RfpProxy.Traffic/RfpProxy.Traffic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>rfpproxytraffic</AssemblyName>
</PropertyGroup>

Expand Down
26 changes: 24 additions & 2 deletions RfpProxy/AbstractRfpProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public AbstractRfpProxy(int listenPort, string ommHost, int ommPort)
protected override async Task ReadFromClientAsync(CryptedRfpConnection connection, PipeReader client, CancellationToken cancellationToken)
{
var sysInit = await ReadPacketAsync(0x0120, 0, client, cancellationToken).ConfigureAwait(false);

Console.WriteLine($"[{connection.TraceId}] SYS_INIT");
var iv = connection.RfpToOmmIv;
connection.RfpToOmmIv = ReadOnlyMemory<byte>.Empty;

Expand All @@ -37,6 +37,7 @@ protected override async Task ReadFromClientAsync(CryptedRfpConnection connectio
protected override async Task ReadFromServerAsync(CryptedRfpConnection connection, PipeReader server, CancellationToken cancellationToken)
{
var sysAuthenticate = await ReadPacketAsync(0x012d, 0x20, server, cancellationToken).ConfigureAwait(false);
Console.WriteLine($"[{connection.TraceId}] SYS_AUTHENTICATE");
connection.InitRfpToOmmIv(sysAuthenticate.Slice(11, 8).Span);

await OnServerMessageAsync(connection, sysAuthenticate, cancellationToken).ConfigureAwait(false);
Expand All @@ -49,11 +50,13 @@ protected override async Task ReadFromServerAsync(CryptedRfpConnection connectio
if (type.Span[1] == 0x24)
{
//SYS_RFP_AUTH_KEY
Console.WriteLine($"[{connection.TraceId}] SYS_RFP_AUTH_KEY");
key = packet.Slice(4);
}
else if (type.Span[1] == 0x25)
{
//SYS_RFP_RE_ENROLEMENT
Console.WriteLine($"[{connection.TraceId}] SYS_RFP_RE_ENROLEMENT");
var checksum = packet.Slice(0x44);
var crypted = packet.Slice(4, 0x40);
var pw = await GetRootPasswordHashAsync(cancellationToken).ConfigureAwait(false);
Expand Down Expand Up @@ -94,9 +97,28 @@ protected override async Task ReadFromServerAsync(CryptedRfpConnection connectio
await OnServerMessageAsync(connection, packet, cancellationToken).ConfigureAwait(false);
packet = await ReadPacketAsync(0x01, 0x08, server, cancellationToken).ConfigureAwait(false);
}
else
{
Console.WriteLine($"[{connection.TraceId}] PACKET 0x{type.Span[0]:X2}{type.Span[1]:X2}");
}
var ack = packet;
await OnServerMessageAsync(connection, ack, cancellationToken).ConfigureAwait(false);

//check if we have another unencrypted SYS_OMM_CONTROL
//this may happen if the RFP requires a firmware update
var next = await server.ReadAsync(cancellationToken).ConfigureAwait(false);
server.AdvanceTo(next.Buffer.Start, next.Buffer.Start);
if (next.Buffer.Length > 2 && next.Buffer.FirstSpan[0] == 0x01 && next.Buffer.Slice(1).FirstSpan[0] == 0x0c)
{
packet = await ReadPacketAsync(0x010c, 0, server, cancellationToken).ConfigureAwait(false);
Console.WriteLine($"[{connection.TraceId}] SYS_OMM_CONTROL");
await OnServerMessageAsync(connection, packet, cancellationToken).ConfigureAwait(false);

packet = await ReadPacketAsync(0x0121, 0, server, cancellationToken).ConfigureAwait(false);
Console.WriteLine($"[{connection.TraceId}] SYS_RESET");
await OnServerMessageAsync(connection, packet, cancellationToken).ConfigureAwait(false);
}

connection.InitOmmToRfpIv(sysAuthenticate.Slice(27, 8).Span);

await ReadAsync(connection, server, OnServerMessageAsync, connection.OmmToRfpIv, connection.DecryptOmmToRfp, cancellationToken).ConfigureAwait(false);
Expand Down Expand Up @@ -146,7 +168,7 @@ private static async Task ReadAsync(CryptedRfpConnection connection, PipeReader
}
catch (OperationCanceledException ex)
{
Console.WriteLine("cancelled in AbstractRfpProxy.ReadAsync");
Console.WriteLine($"[{connection.TraceId}] cancelled in AbstractRfpProxy.ReadAsync");
reader.Complete(ex);
}
}
Expand Down
6 changes: 6 additions & 0 deletions RfpProxy/RfpConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public RfpConnection(TcpClient client, TcpClient server)
}

public RfpIdentifier Identifier { get; set; }
public Guid TraceId { get; } = Guid.NewGuid();

public virtual ValueTask<int> SendToServerAsync(ReadOnlyMemory<byte> data, CancellationToken cancellationToken)
{
Expand All @@ -30,5 +31,10 @@ public virtual ValueTask<int> SendToClientAsync(ReadOnlyMemory<byte> data, Cance
if (data.IsEmpty) return new ValueTask<int>(0);
return Client.Client.SendAsync(data, SocketFlags.None, cancellationToken);
}

public override string ToString()
{
return TraceId.ToString();
}
}
}
6 changes: 3 additions & 3 deletions RfpProxy/RfpProxy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>rfpproxy</AssemblyName>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Mono.Options" Version="6.12.0.148" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="System.IO.Pipelines" Version="6.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.IO.Pipelines" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
27 changes: 21 additions & 6 deletions RfpProxy/TcpProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,28 +95,43 @@ private async Task HandleClientAsync(TcpClient client, CancellationToken cancell
{
await server.ConnectAsync(_server, _port, cts.Token).ConfigureAwait(false);
var clientData = OnClientConnected(client, server);
var tasks = new List<Task>();
try
{
var clientPipe = new Pipe();
var fillClientPipe = PipeHelper.FillPipeAsync(client.Client, clientPipe.Writer, cts.Token);
tasks.Add(fillClientPipe);
var readClientPipe = ReadFromClientAsync(clientData, clientPipe.Reader, cts.Token);
tasks.Add(readClientPipe);

var serverPipe = new Pipe();
var fillServerPipe = PipeHelper.FillPipeAsync(server.Client, serverPipe.Writer, cts.Token);
tasks.Add(fillServerPipe);
var readServerPipe = ReadFromServerAsync(clientData, serverPipe.Reader, cts.Token);

var t = await Task.WhenAny(fillClientPipe, readClientPipe, fillServerPipe, readServerPipe).ConfigureAwait(false);
tasks.Add(readServerPipe);
var t = await Task.WhenAny(tasks).ConfigureAwait(false);
await t;
}
catch (Exception ex)
{
Console.WriteLine("HandleClient failed");
Console.WriteLine(ex);
Console.WriteLine($"[{clientData}] HandleClient failed\n{ex}");
}
finally
{
cts.Cancel();
OnClientDisconnected(clientData);
//delay cancellation to allow processing of pending packets
cts.CancelAfter(100);
try
{
await Task.WhenAll(tasks);
}
catch(Exception ex)
{
Console.WriteLine($"[{clientData}] Exception during teardown\n{ex}");
}
finally
{
OnClientDisconnected(clientData);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion RfpProxyLib/RfpProxyLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions SoftRfp/SoftRfp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>virtualrfp</AssemblyName>
<RootNamespace>RfpProxy.Virtual</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Mono.Options" Version="6.12.0.148" />
<PackageReference Include="System.IO.Pipelines" Version="6.0.3" />
<PackageReference Include="System.IO.Pipelines" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading