Added CI build
This commit is contained in:
155
.gitlab-ci.yml
Normal file
155
.gitlab-ci.yml
Normal file
@@ -0,0 +1,155 @@
|
|||||||
|
image: mcr.microsoft.com/dotnet/sdk:8.0
|
||||||
|
|
||||||
|
variables:
|
||||||
|
TZ: "Europe/Berlin"
|
||||||
|
LANG: "de"
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- build
|
||||||
|
- test
|
||||||
|
- deploy
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
debug-build:
|
||||||
|
stage: build
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- lnx
|
||||||
|
- 64bit
|
||||||
|
rules:
|
||||||
|
- if: $CI_COMMIT_TAG == null
|
||||||
|
script:
|
||||||
|
- dotnet build -c Debug --nologo
|
||||||
|
- mkdir ./artifacts
|
||||||
|
- shopt -s globstar
|
||||||
|
- mv ./**/*.nupkg ./artifacts/ || true
|
||||||
|
- mv ./**/*.snupkg ./artifacts/ || true
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- artifacts/*.nupkg
|
||||||
|
- artifacts/*.snupkg
|
||||||
|
expire_in: 1 days
|
||||||
|
|
||||||
|
debug-test:
|
||||||
|
stage: test
|
||||||
|
dependencies:
|
||||||
|
- debug-build
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- lnx
|
||||||
|
- 64bit
|
||||||
|
rules:
|
||||||
|
- if: $CI_COMMIT_TAG == null
|
||||||
|
coverage: /Branch coverage[\s\S].+%/
|
||||||
|
before_script:
|
||||||
|
- dotnet tool install dotnet-reportgenerator-globaltool --tool-path /dotnet-tools
|
||||||
|
script:
|
||||||
|
- dotnet test -c Debug --nologo /p:CoverletOutputFormat=Cobertura
|
||||||
|
- /dotnet-tools/reportgenerator "-reports:${CI_PROJECT_DIR}/**/coverage.cobertura.xml" "-targetdir:/reports" -reportType:TextSummary
|
||||||
|
- cat /reports/Summary.txt
|
||||||
|
artifacts:
|
||||||
|
when: always
|
||||||
|
reports:
|
||||||
|
coverage_report:
|
||||||
|
coverage_format: cobertura
|
||||||
|
path: ./**/coverage.cobertura.xml
|
||||||
|
|
||||||
|
debug-deploy:
|
||||||
|
stage: deploy
|
||||||
|
dependencies:
|
||||||
|
- debug-build
|
||||||
|
- debug-test
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- lnx
|
||||||
|
- server
|
||||||
|
rules:
|
||||||
|
- if: $CI_COMMIT_TAG == null
|
||||||
|
script:
|
||||||
|
- dotnet nuget push -k $BAGET_APIKEY -s https://nuget.am-wd.de/v3/index.json --skip-duplicate artifacts/*.nupkg || true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
release-build:
|
||||||
|
stage: build
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- lnx
|
||||||
|
- 64bit
|
||||||
|
rules:
|
||||||
|
- if: $CI_COMMIT_TAG != null
|
||||||
|
script:
|
||||||
|
- dotnet build -c Release --nologo
|
||||||
|
- mkdir ./artifacts
|
||||||
|
- shopt -s globstar
|
||||||
|
- mv ./**/*.nupkg ./artifacts/ || true
|
||||||
|
- mv ./**/*.snupkg ./artifacts/ || true
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- artifacts/*.nupkg
|
||||||
|
- artifacts/*.snupkg
|
||||||
|
expire_in: 1 days
|
||||||
|
|
||||||
|
release-test:
|
||||||
|
stage: test
|
||||||
|
dependencies:
|
||||||
|
- release-build
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- lnx
|
||||||
|
- 64bit
|
||||||
|
rules:
|
||||||
|
- if: $CI_COMMIT_TAG != null
|
||||||
|
before_script:
|
||||||
|
- dotnet tool install dotnet-reportgenerator-globaltool --tool-path /dotnet-tools
|
||||||
|
script:
|
||||||
|
- dotnet test -c Release --nologo /p:CoverletOutputFormat=Cobertura
|
||||||
|
- /dotnet-tools/reportgenerator "-reports:${CI_PROJECT_DIR}/**/coverage.cobertura.xml" "-targetdir:/reports" -reportType:TextSummary
|
||||||
|
- cat /reports/Summary.txt
|
||||||
|
artifacts:
|
||||||
|
when: always
|
||||||
|
reports:
|
||||||
|
coverage_report:
|
||||||
|
coverage_format: cobertura
|
||||||
|
path: ./**/coverage.cobertura.xml
|
||||||
|
|
||||||
|
release-deploy:
|
||||||
|
stage: deploy
|
||||||
|
dependencies:
|
||||||
|
- release-build
|
||||||
|
- release-test
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- lnx
|
||||||
|
- server
|
||||||
|
rules:
|
||||||
|
- if: $CI_COMMIT_TAG != null
|
||||||
|
script:
|
||||||
|
- dotnet nuget push -k $NUGET_APIKEY -s https://api.nuget.org/v3/index.json --skip-duplicate artifacts/*.nupkg || true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
publish-docs:
|
||||||
|
variables:
|
||||||
|
DOCFX_SOURCE_REPOSITORY_URL: "https://github.com/AM-WD/FritzCallMonitor"
|
||||||
|
stage: deploy
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- lnx
|
||||||
|
- server
|
||||||
|
rules:
|
||||||
|
- if: $CI_COMMIT_TAG != null
|
||||||
|
before_script:
|
||||||
|
- apt-get update
|
||||||
|
- apt-get -y install zip unzip
|
||||||
|
- dotnet tool install docfx --tool-path /dotnet-tools
|
||||||
|
script:
|
||||||
|
# Build the docs
|
||||||
|
- dotnet build -c Release --nologo
|
||||||
|
- /dotnet-tools/docfx metadata docs/docfx.json
|
||||||
|
- /dotnet-tools/docfx build docs/docfx.json
|
||||||
|
# Deploy the docs
|
||||||
|
- cd docs/_site
|
||||||
|
- zip -r ../docs.zip *
|
||||||
|
- curl --user "$DOCS_DEPLOY_USER:$DOCS_DEPLOY_PASS" -F docs=fritzcallmonitor -F dump=@../docs.zip "$DOCS_DEPLOY_URL"
|
||||||
@@ -21,6 +21,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FritzCallMonitor.Tests", "t
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{3DF1F30A-77F3-4F24-8739-CB89EE07BB8B}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{3DF1F30A-77F3-4F24-8739-CB89EE07BB8B}"
|
||||||
ProjectSection(SolutionItems) = preProject
|
ProjectSection(SolutionItems) = preProject
|
||||||
|
.gitlab-ci.yml = .gitlab-ci.yml
|
||||||
Directory.Build.props = Directory.Build.props
|
Directory.Build.props = Directory.Build.props
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
|
|||||||
14
README.md
14
README.md
@@ -1,12 +1,24 @@
|
|||||||
# FRITZ!Box CallMonitor
|
# FRITZ!Box CallMonitor
|
||||||
|
|
||||||
|
The call monitor is a custom endpoint, which can be enabled in the FRITZ!Box using specific phone codes.
|
||||||
|
|
||||||
|
When the endpoint is enabled, a raw TCP stream is opened on port 1012 of the FRITZ!Box, which sends information about incoming and outgoing calls in real-time.
|
||||||
|
|
||||||
|
This can be used to integrate the FRITZ!Box call signaling into other applications or systems.
|
||||||
|
|
||||||
|
## Enabling the Call Monitor
|
||||||
|
|
||||||
|
To enable the call monitor, you need to dial the following code on a connected telephone: `#96*5*`.
|
||||||
|
|
||||||
|
To disable the call monitor, dial: `#96*4*`.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
Published under [MIT License] (see [choose a license]).
|
Published under [MIT License] (see [choose a license]).
|
||||||
|
|
||||||
[](https://link.am-wd.de/donate)
|
[](https://link.am-wd.de/donate)
|
||||||
|
|
||||||
|
|
||||||
[MIT License]: LICENSE.txt
|
[MIT License]: LICENSE.txt
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace AMWD.Net.Api.Fritz.CallMonitor
|
|||||||
private bool _isDisposed;
|
private bool _isDisposed;
|
||||||
|
|
||||||
private ILogger? _logger;
|
private ILogger? _logger;
|
||||||
private readonly ReconnectTcpClient _client;
|
private readonly ReconnectTcpClient _tcpClient;
|
||||||
private readonly CancellationTokenSource _disposeCts;
|
private readonly CancellationTokenSource _disposeCts;
|
||||||
|
|
||||||
private Task _monitorTask = Task.CompletedTask;
|
private Task _monitorTask = Task.CompletedTask;
|
||||||
@@ -39,10 +39,10 @@ namespace AMWD.Net.Api.Fritz.CallMonitor
|
|||||||
throw new ArgumentOutOfRangeException(nameof(port));
|
throw new ArgumentOutOfRangeException(nameof(port));
|
||||||
|
|
||||||
_disposeCts = new CancellationTokenSource();
|
_disposeCts = new CancellationTokenSource();
|
||||||
_client = new ReconnectTcpClient(host, port) { OnConnected = OnConnected };
|
_tcpClient = new ReconnectTcpClient(host, port) { OnConnected = OnConnected };
|
||||||
|
|
||||||
// Start the client in the background
|
// Start the client in the background
|
||||||
_client.StartAsync(_disposeCts.Token).Forget();
|
_tcpClient.StartAsync(_disposeCts.Token).Forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -62,7 +62,7 @@ namespace AMWD.Net.Api.Fritz.CallMonitor
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
_logger = value;
|
_logger = value;
|
||||||
_client.Logger = value;
|
_tcpClient.Logger = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ namespace AMWD.Net.Api.Fritz.CallMonitor
|
|||||||
catch
|
catch
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
_client.Dispose();
|
_tcpClient.Dispose();
|
||||||
_disposeCts.Dispose();
|
_disposeCts.Dispose();
|
||||||
|
|
||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);
|
||||||
@@ -93,6 +93,8 @@ namespace AMWD.Net.Api.Fritz.CallMonitor
|
|||||||
|
|
||||||
private Task OnConnected(ReconnectTcpClient client)
|
private Task OnConnected(ReconnectTcpClient client)
|
||||||
{
|
{
|
||||||
|
Logger?.LogTrace($"Client connected");
|
||||||
|
|
||||||
_monitorTask = Task.Run(async () =>
|
_monitorTask = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -1,10 +1,51 @@
|
|||||||
# FRITZ!Box Call Monitor
|
# FRITZ!Box Call Monitor
|
||||||
|
|
||||||
|
You can use this small library to connect to the FRITZ!Box Call Monitor and receive live call events.
|
||||||
|
|
||||||
|
|
||||||
|
## Router preparation
|
||||||
|
|
||||||
|
Call `#96*5*` to enable the endpoint in your FRITZ!Box.
|
||||||
|
Call `#96*4*` to disable it again.
|
||||||
|
|
||||||
|
|
||||||
|
## In your code
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
using (var client = new CallMonitorClient(host, port))
|
||||||
|
{
|
||||||
|
client.OnEvent += (sender, e) =>
|
||||||
|
{
|
||||||
|
switch (e.Event)
|
||||||
|
{
|
||||||
|
case EventType.Ring:
|
||||||
|
Console.WriteLine($"{e.Timestamp:yyyy-MM-dd HH:mm:ss} | #{e.ConnectionId} | Incoming Call from {e.CallerNumber} to {e.CalleeNumber}");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EventType.Connect:
|
||||||
|
Console.WriteLine($"{e.Timestamp:yyyy-MM-dd HH:mm:ss} | #{e.ConnectionId} | Call connected to {e.CallerNumber}");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EventType.Disconnect:
|
||||||
|
Console.WriteLine($"{e.Timestamp:yyyy-MM-dd HH:mm:ss} | #{e.ConnectionId} | Call disconnected after {e.Duration}");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EventType.Call:
|
||||||
|
Console.WriteLine($"{e.Timestamp:yyyy-MM-dd HH:mm:ss} | #{e.ConnectionId} | Outgoing Call from {e.CalleeNumber} to {e.CallerNumber}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Wait to terminate.
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
Published under MIT License (see [choose a license]).
|
Published under MIT License (see [choose a license]).
|
||||||
|
|
||||||
[](https://link.am-wd.de/donate)
|
[](https://link.am-wd.de/donate)
|
||||||
|
|
||||||
[choose a license]: https://choosealicense.com/licenses/mit/
|
[choose a license]: https://choosealicense.com/licenses/mit/
|
||||||
|
|||||||
Reference in New Issue
Block a user