├── .config
└── dotnet-tools.json
├── .editorconfig
├── .gitattributes
├── .github
├── dependabot.yml
└── workflows
│ ├── release.yml
│ └── test.yml
├── .gitignore
├── .gitmodules
├── .vscode
├── launch.json
└── tasks.json
├── Directory.Build.props
├── Directory.Build.targets
├── LICENSE.txt
├── Makefile
├── Packages.props
├── README.md
├── axus.sln
├── build-linux.sh
├── build-win.ps1
├── demo
├── 0
│ └── .gitkeep
├── 1
│ ├── run-daemon.ps1
│ ├── run-daemon.sh
│ ├── run-ui-desktop.ps1
│ └── run-ui-desktop.sh
├── 2
│ ├── run-daemon.ps1
│ ├── run-daemon.sh
│ ├── run-ui-desktop.ps1
│ └── run-ui-desktop.sh
├── 3
│ ├── run-daemon.ps1
│ ├── run-daemon.sh
│ ├── run-ui-desktop.ps1
│ └── run-ui-desktop.sh
├── run-1.ps1
├── run-2.ps1
└── run-3.ps1
├── docs
├── faq.md
├── requirements
│ ├── index.adoc
│ └── requirements.puml
└── specifications
│ ├── index.adoc
│ └── models.puml
├── eng
├── coverage.ps1
├── coverage.sh
├── export-diff.sh
├── gen-code.sh
├── gen-envfile.sh
├── import-diff.sh
├── update-dotnet-tool.sh
├── update-sln.ps1
└── update-sln.sh
├── lock
├── Omnius.Axus.Daemon.json
├── Omnius.Axus.Engines.Tests.json
├── Omnius.Axus.Engines.json
├── Omnius.Axus.Intaractors.json
├── Omnius.Axus.IntegrationTests.json
├── Omnius.Axus.Interactors.Tests.json
├── Omnius.Axus.Interactors.json
├── Omnius.Axus.Launcher.json
├── Omnius.Axus.Messages.json
├── Omnius.Axus.Models.json
├── Omnius.Axus.Remoting.json
├── Omnius.Axus.Ui.Desktop.json
├── Omnius.Axus.Utils.json
├── linux-x64
│ ├── Omnius.Axus.Daemon.json
│ ├── Omnius.Axus.Engines.json
│ ├── Omnius.Axus.Intaractors.json
│ ├── Omnius.Axus.Interactors.json
│ ├── Omnius.Axus.Launcher.json
│ ├── Omnius.Axus.Messages.json
│ ├── Omnius.Axus.Models.json
│ ├── Omnius.Axus.Remoting.json
│ ├── Omnius.Axus.Ui.Desktop.json
│ └── Omnius.Axus.Utils.json
└── win-x64
│ ├── Omnius.Axus.Daemon.json
│ ├── Omnius.Axus.Engines.json
│ ├── Omnius.Axus.Intaractors.json
│ ├── Omnius.Axus.Interactors.json
│ ├── Omnius.Axus.Launcher.json
│ ├── Omnius.Axus.Messages.json
│ ├── Omnius.Axus.Models.json
│ ├── Omnius.Axus.Remoting.json
│ ├── Omnius.Axus.Ui.Desktop.json
│ └── Omnius.Axus.Utils.json
├── nuget.config
├── rpfs
├── Omnius.Axus.Engines
│ ├── Omnius.Axus.Engines.Internal.Models.rpf
│ └── Omnius.Axus.Engines.Models.rpf
├── Omnius.Axus.Interactors
│ ├── Omnius.Axus.Interactors.Internal.Models.rpf
│ └── Omnius.Axus.Interactors.Models.rpf
├── Omnius.Axus.Messages
│ └── Omnius.Axus.Messages.rpf
├── Omnius.Axus.Remoting
│ └── Omnius.Axus.Remoting.rpf
└── config.yml
├── src
├── Directory.Build.props
├── Omnius.Axus.Daemon
│ ├── AssemblyInfo.cs
│ ├── AxusService.cs
│ ├── NLog.config
│ ├── Omnius.Axus.Daemon.csproj
│ ├── Program.cs
│ ├── Properties
│ │ └── launchSettings.json
│ ├── Runner.TcpListenerManager.cs
│ └── Runner.cs
├── Omnius.Axus.Engines
│ ├── Implementations
│ │ ├── ConnectionI2pAccepter.cs
│ │ ├── ConnectionI2pAccepterOptions.cs
│ │ ├── ConnectionI2pConnector.cs
│ │ ├── ConnectionI2pConnectorOptions.cs
│ │ ├── ConnectionTcpAccepter.TcpListenerManager.cs
│ │ ├── ConnectionTcpAccepter.cs
│ │ ├── ConnectionTcpAccepterOptions.cs
│ │ ├── ConnectionTcpConnector.cs
│ │ ├── ConnectionTcpConnectorOptions.cs
│ │ ├── FileExchanger.SessionStatus.cs
│ │ ├── FileExchanger.cs
│ │ ├── FileExchangerException.cs
│ │ ├── FileExchangerOptions.cs
│ │ ├── FilePublisherStorage.cs
│ │ ├── FilePublisherStorageOptions.cs
│ │ ├── FileSubscriberStorage.cs
│ │ ├── FileSubscriberStorageOptions.cs
│ │ ├── Internal
│ │ │ ├── ContentClueConverter.cs
│ │ │ ├── Entities
│ │ │ │ ├── BlockPublishedExternalItemEntity.cs
│ │ │ │ ├── BlockPublishedInternalItemEntity.cs
│ │ │ │ ├── BlockSubscribedItemEntity.cs
│ │ │ │ ├── CachedNodeLocationEntry.cs
│ │ │ │ ├── FilePublishedItemEntity.cs
│ │ │ │ ├── FileSubscribedItemEntity.cs
│ │ │ │ ├── NodeLocationEntity.cs
│ │ │ │ ├── OmniHashEntity.cs
│ │ │ │ ├── OmniSignatureEntity.cs
│ │ │ │ ├── ShoutPublishedItemEntity.cs
│ │ │ │ └── ShoutSubscribedItemEntity.cs
│ │ │ ├── IpAddressHelper.cs
│ │ │ ├── Kademlia.cs
│ │ │ ├── Models
│ │ │ │ ├── BlockPublishedExternalItem.cs
│ │ │ │ ├── BlockPublishedInternalItem.cs
│ │ │ │ ├── BlockSubscribedItem.cs
│ │ │ │ ├── CachedNodeLocation.cs
│ │ │ │ ├── FilePublishedItem.cs
│ │ │ │ ├── FileSubscribedItem.cs
│ │ │ │ ├── ShoutPublishedItem.cs
│ │ │ │ ├── ShoutSubscribedItem.cs
│ │ │ │ └── _RocketPack
│ │ │ │ │ └── _Generated.cs
│ │ │ ├── Repositories
│ │ │ │ ├── CachedNodeLocationRepository.cs
│ │ │ │ ├── FilePublisherStorageRepository.cs
│ │ │ │ ├── FileSubscriberStorageRepository.cs
│ │ │ │ ├── ShoutPublisherStorageRepository.cs
│ │ │ │ └── ShoutSubscriberStorageRepository.cs
│ │ │ ├── Session.cs
│ │ │ └── StringConverter.cs
│ │ ├── NodeFinder.SessionStatus.cs
│ │ ├── NodeFinder.cs
│ │ ├── NodeFinderException.cs
│ │ ├── NodeFinderOptions.cs
│ │ ├── NodeLocationsFetcher.cs
│ │ ├── NodeLocationsFetcherOptions.cs
│ │ ├── SessionAccepter.SessionChannels.cs
│ │ ├── SessionAccepter.cs
│ │ ├── SessionAccepterOptions.cs
│ │ ├── SessionConnector.cs
│ │ ├── SessionConnectorOptions.cs
│ │ ├── ShoutExchanger.SessionStatus.cs
│ │ ├── ShoutExchanger.cs
│ │ ├── ShoutExchangerException.cs
│ │ ├── ShoutExchangerOptions.cs
│ │ ├── ShoutPublisherStorage.cs
│ │ ├── ShoutPublisherStorageOptions.cs
│ │ ├── ShoutSubscriberStorage.cs
│ │ └── ShoutSubscriberStorageOptions.cs
│ ├── Interfaces
│ │ ├── IConnectionAcceptor.cs
│ │ ├── IConnectionConnector.cs
│ │ ├── IFileExchanger.cs
│ │ ├── IFilePublisherStorage.cs
│ │ ├── IFileSubscriberStorage.cs
│ │ ├── INodeFinder.cs
│ │ ├── INodeLocationsFetcher.cs
│ │ ├── ISession.cs
│ │ ├── ISessionAccepter.cs
│ │ ├── ISessionConnector.cs
│ │ ├── IShoutExchanger.cs
│ │ ├── IShoutPublisherStorage.cs
│ │ ├── IShoutSubscriberStorage.cs
│ │ └── Primitives
│ │ │ ├── IReadOnlyFileStorage.cs
│ │ │ ├── IReadOnlyShoutStorage.cs
│ │ │ ├── IWritableFileStorage.cs
│ │ │ └── IWritableShoutStorage.cs
│ ├── Models
│ │ ├── ConnectionAcceptedResult.cs
│ │ └── _RocketPack
│ │ │ └── _Generated.cs
│ └── Omnius.Axus.Engines.csproj
├── Omnius.Axus.Interactors
│ ├── Extensions
│ │ └── AxusUriConverterSeedExtensions.cs
│ ├── Implementations
│ │ ├── AxusServiceMediator.cs
│ │ ├── AxusServiceProvider.cs
│ │ ├── FileDownloader.cs
│ │ ├── FileDownloaderOptions.cs
│ │ ├── FileUploader.cs
│ │ ├── FileUploaderOptions.cs
│ │ ├── IntaractorProvider.cs
│ │ ├── Internal
│ │ │ ├── Entities
│ │ │ │ ├── CaskDownloadingItemEntity.cs
│ │ │ │ ├── FileDownloadingItemEntity.cs
│ │ │ │ ├── FileUploadingItemEntity.cs
│ │ │ │ ├── NoteDownloadingItemEntity.cs
│ │ │ │ ├── NoteUploadingItemEntity.cs
│ │ │ │ ├── OmniHashEntity.cs
│ │ │ │ ├── OmniSignatureEntity.cs
│ │ │ │ ├── ProfileDownloadingItemEntity.cs
│ │ │ │ ├── ProfileUploadingItemEntity.cs
│ │ │ │ ├── SeedEntity.cs
│ │ │ │ └── SeedUploadingItemEntity.cs
│ │ │ ├── Models
│ │ │ │ ├── CaskDownloadingItem.cs
│ │ │ │ ├── CaskUploadingItem.cs
│ │ │ │ ├── FileDownloadingItem.cs
│ │ │ │ ├── FileUploadingItem.cs
│ │ │ │ ├── NoteDownloadingItem.cs
│ │ │ │ ├── NoteUploadingItem.cs
│ │ │ │ ├── ProfileDownloadingItem.cs
│ │ │ │ ├── ProfileUploadingItem.cs
│ │ │ │ └── _RocketPack
│ │ │ │ │ ├── CachedCaskContent.cs
│ │ │ │ │ ├── CachedMemo.cs
│ │ │ │ │ ├── CachedNoteContent.cs
│ │ │ │ │ ├── CachedSeed.cs
│ │ │ │ │ └── _Generated.cs
│ │ │ ├── Repositories
│ │ │ │ ├── CachedMemoRepository.cs
│ │ │ │ ├── CachedProfileRepository.cs
│ │ │ │ ├── CachedSeedRepository.cs
│ │ │ │ ├── CaskDownloaderRepository.cs
│ │ │ │ ├── FileDownloaderRepository.cs
│ │ │ │ ├── FileUploaderRepository.cs
│ │ │ │ ├── NoteDownloaderRepository.cs
│ │ │ │ ├── NoteUploaderRepository.cs
│ │ │ │ ├── ProfileDownloaderRepository.cs
│ │ │ │ ├── ProfileUploaderRepository.cs
│ │ │ │ └── SeedUploaderRepository.cs
│ │ │ └── StringConverter.cs
│ │ ├── MemoDownloader.cs
│ │ ├── MemoDownloaderOptions.cs
│ │ ├── MemoUploader.cs
│ │ ├── MemoUploaderOptions.cs
│ │ ├── ProfileDownloader.cs
│ │ ├── ProfileDownloaderOptions.cs
│ │ ├── ProfileUploader.cs
│ │ ├── ProfileUploaderOptions.cs
│ │ ├── SeedUploader.cs
│ │ └── SeedUploaderOptions.cs
│ ├── Interfaces
│ │ ├── IAxusServiceMediator.cs
│ │ ├── IAxusServiceProvider.cs
│ │ ├── IFileDownloader.cs
│ │ ├── IFileUploader.cs
│ │ ├── IInteractorProvider.cs
│ │ ├── IMemoDownloader.cs
│ │ ├── IMemoUploader.cs
│ │ ├── IProfileDownloader.cs
│ │ ├── IProfileUploader.cs
│ │ ├── ISeedDownloader.cs
│ │ └── ISeedUploader.cs
│ ├── Models
│ │ ├── ConditionRange.cs
│ │ ├── FileDownloadReport.cs
│ │ ├── FileUploadingReport.cs
│ │ ├── FindSeedsCondition.cs
│ │ ├── FindSeedsResult.cs
│ │ ├── MemoReport.cs
│ │ ├── ProfileReport.cs
│ │ ├── SeedReport.cs
│ │ └── _RocketPack
│ │ │ └── _Generated.cs
│ └── Omnius.Axus.Interactors.csproj
├── Omnius.Axus.Launcher
│ ├── AssemblyInfo.cs
│ ├── Helpers
│ │ ├── DirectoryHelper.cs
│ │ └── FileLock.cs
│ ├── NLog.config
│ ├── Omnius.Axus.Launcher.csproj
│ ├── Options.cs
│ ├── Program.cs
│ ├── Runner.cs
│ └── Updater.cs
├── Omnius.Axus.Messages
│ ├── AxusUriConverter.cs
│ ├── Extensions
│ │ └── AxusUriConverterNodeLocationExtensions.cs
│ ├── Omnius.Axus.Messages.csproj
│ └── _RocketPack
│ │ ├── NodeLocation.cs
│ │ ├── Shout.cs
│ │ └── _Generated.cs
├── Omnius.Axus.Remoting
│ ├── Internal
│ │ └── Entities
│ │ │ └── ServiceConfigEntity.cs
│ ├── Omnius.Axus.Remoting.csproj
│ └── _RocketPack
│ │ ├── ServiceConfig.cs
│ │ └── _Generated.cs
├── Omnius.Axus.Ui.Desktop
│ ├── App.xaml
│ ├── App.xaml.cs
│ ├── AssemblyInfo.cs
│ ├── Assets
│ │ ├── axus.svg
│ │ ├── chat.svg
│ │ ├── download.svg
│ │ ├── menu.svg
│ │ ├── peers.svg
│ │ ├── search.svg
│ │ ├── settings.svg
│ │ ├── status.svg
│ │ └── upload.svg
│ ├── Configuration
│ │ ├── AxusEnvironment.cs
│ │ └── UiStatus.cs
│ ├── Converters
│ │ └── OmniDigitalSignatureToStringConverter.cs
│ ├── Helpers
│ │ └── ConvertHelper.cs
│ ├── Internal
│ │ ├── Bootstrapper.cs
│ │ └── DialogService.cs
│ ├── NLog.config
│ ├── Omnius.Axus.Ui.Desktop.csproj
│ ├── Options.cs
│ ├── Program.cs
│ ├── Properties
│ │ └── launchSettings.json
│ ├── Styles
│ │ ├── Base.xaml
│ │ ├── OptionMenu.xaml
│ │ └── SideBar.xaml
│ ├── Windows
│ │ ├── DIalogs
│ │ │ ├── MultilineTextEdit
│ │ │ │ ├── MultilineTextEditWindow.xaml
│ │ │ │ ├── MultilineTextEditWindow.xaml.cs
│ │ │ │ └── MultilineTextEditWindowModel.cs
│ │ │ └── SinglelineTextEdit
│ │ │ │ ├── SinglelineTextEditWindow.xaml
│ │ │ │ ├── SinglelineTextEditWindow.xaml.cs
│ │ │ │ └── SinglelineTextEditWindowModel.cs
│ │ ├── Main
│ │ │ ├── MainWindow.xaml
│ │ │ ├── MainWindow.xaml.cs
│ │ │ ├── MainWindowDesignModel.cs
│ │ │ ├── MainWindowModel.cs
│ │ │ └── Views
│ │ │ │ ├── Download
│ │ │ │ ├── DownloadView.xaml
│ │ │ │ ├── DownloadView.xaml.cs
│ │ │ │ ├── DownloadViewModel.cs
│ │ │ │ └── Models
│ │ │ │ │ └── DownloadingFileModel.cs
│ │ │ │ ├── Peers
│ │ │ │ ├── Models
│ │ │ │ │ └── SessionModel.cs
│ │ │ │ ├── PeersView.xaml
│ │ │ │ ├── PeersView.xaml.cs
│ │ │ │ ├── PeersViewDesignModel.cs
│ │ │ │ └── PeersViewModel.cs
│ │ │ │ ├── Search
│ │ │ │ ├── Models
│ │ │ │ │ ├── IFileSearchCondition.cs
│ │ │ │ │ ├── RangeCondition.cs
│ │ │ │ │ └── RegexCondition.cs
│ │ │ │ ├── SearchView.xaml
│ │ │ │ ├── SearchView.xaml.cs
│ │ │ │ └── SearchViewModel.cs
│ │ │ │ ├── Status
│ │ │ │ ├── StatusView.xaml
│ │ │ │ ├── StatusView.xaml.cs
│ │ │ │ └── StatusViewModel.cs
│ │ │ │ └── Upload
│ │ │ │ ├── Models
│ │ │ │ └── UploadingFileModel.cs
│ │ │ │ ├── UploadVew.xaml.cs
│ │ │ │ ├── UploadView.xaml
│ │ │ │ └── UploadViewModel.cs
│ │ └── Settings
│ │ │ ├── SettingsWindow.xaml
│ │ │ ├── SettingsWindow.xaml.cs
│ │ │ ├── SettingsWindowDesignModel.cs
│ │ │ ├── SettingsWindowModel.cs
│ │ │ └── Views
│ │ │ └── Signatures
│ │ │ ├── SignaturesView.xaml
│ │ │ ├── SignaturesView.xaml.cs
│ │ │ ├── SignaturesViewDesignModel.cs
│ │ │ └── SignaturesViewModel.cs
│ └── nuget.config
└── Omnius.Axus.Utils
│ ├── Extentions
│ └── LiteDatabaseExtensions.cs
│ └── Omnius.Axus.Utils.csproj
├── style.ruleset
└── test
├── Directory.Build.props
├── Omnius.Axus.Engines.Tests
├── FileExchangerTest.cs
├── Internal
│ ├── FileExchangerNode.cs
│ └── ShoutExchangerNode.cs
├── NLog.config
├── Omnius.Axus.Engines.Tests.csproj
└── ShoutExchangerTest.cs
└── Omnius.Axus.IntegrationTests
├── AxusServiceTest.cs
├── NLog.config
└── Omnius.Axus.IntegrationTests.csproj
/.config/dotnet-tools.json:
--------------------------------------------------------------------------------
1 | {
2 | "isRoot": true,
3 | "tools": {
4 | "coverlet.console": {
5 | "commands": ["coverlet"],
6 | "version": "3.1.0"
7 | },
8 | "dotnet-reportgenerator-globaltool": {
9 | "commands": ["reportgenerator"],
10 | "version": "4.8.13"
11 | }
12 | },
13 | "version": 1
14 | }
15 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.json text eol=lf
2 | *.sh text eol=lf
3 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: nuget
4 | directory: "/"
5 | schedule:
6 | interval: "daily"
7 | labels:
8 | - "dependabot"
9 | groups:
10 | dependencies:
11 | patterns:
12 | - "*"
13 | - package-ecosystem: github-actions
14 | directory: "/"
15 | schedule:
16 | interval: "daily"
17 | labels:
18 | - "dependabot"
19 | groups:
20 | dependencies:
21 | patterns:
22 | - "*"
23 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: release
2 |
3 | on:
4 | push:
5 | tags:
6 | - "v*.*.*"
7 |
8 | jobs:
9 | linux:
10 | runs-on: ubuntu-latest
11 | env:
12 | ContinuousIntegrationBuild: true
13 | steps:
14 | - name: Checkout branch
15 | uses: actions/checkout@v4
16 | with:
17 | submodules: "recursive"
18 | - name: Set env
19 | run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
20 | - name: Setup dotnet
21 | uses: actions/setup-dotnet@v3
22 | with:
23 | dotnet-version: 7.0.x
24 | include-prerelease: true
25 | - name: Setup dotnet tool
26 | run: dotnet tool restore
27 | - name: Install dependencies
28 | run: dotnet restore
29 | - name: Build
30 | run: bash build-linux.sh
31 | - name: Zip
32 | run: |
33 | cd ./pub/linux-x64 && zip -r ../../axus-linux-x64-${{ env.RELEASE_VERSION }}.zip ./*
34 | - name: Release
35 | uses: softprops/action-gh-release@v1
36 | with:
37 | files: |
38 | axus-linux-x64-${{ env.RELEASE_VERSION }}.zip
39 | windows:
40 | runs-on: windows-latest
41 | env:
42 | ContinuousIntegrationBuild: true
43 | steps:
44 | - name: Checkout branch
45 | uses: actions/checkout@v4
46 | with:
47 | submodules: "recursive"
48 | - name: Set env
49 | run: |
50 | chcp 65001 #set code page to utf-8
51 | echo ("RELEASE_VERSION=" + $env:GITHUB_REF.replace('refs/tags/', '')) >> $env:GITHUB_ENV
52 | - name: Setup dotnet
53 | uses: actions/setup-dotnet@v3
54 | with:
55 | dotnet-version: 7.0.x
56 | include-prerelease: true
57 | - name: Setup dotnet tool
58 | run: dotnet tool restore
59 | - name: Install dependencies
60 | run: dotnet restore
61 | - name: Build
62 | run: pwsh build-win.ps1
63 | - name: Zip
64 | uses: vimtor/action-zip@v1
65 | with:
66 | files: ./pub/win-x64
67 | dest: axus-win-x64-${{ env.RELEASE_VERSION }}.zip
68 | - name: Release
69 | uses: softprops/action-gh-release@v1
70 | with:
71 | files: |
72 | axus-win-x64-${{ env.RELEASE_VERSION }}.zip
73 |
--------------------------------------------------------------------------------
/.github/workflows/test.yml:
--------------------------------------------------------------------------------
1 | name: test
2 |
3 | on:
4 | push:
5 | branches:
6 | - "**"
7 | paths:
8 | - "**"
9 | - "!/docs/**"
10 |
11 | jobs:
12 | linux:
13 | runs-on: ubuntu-latest
14 | env:
15 | ContinuousIntegrationBuild: true
16 | steps:
17 | - name: Checkout branch
18 | uses: actions/checkout@v4
19 | with:
20 | submodules: "recursive"
21 | - name: Setup dotnet
22 | uses: actions/setup-dotnet@v3
23 | with:
24 | dotnet-version: 7.0.x
25 | - name: Setup dotnet tool
26 | run: dotnet tool restore
27 | - name: Install dependencies
28 | run: dotnet restore
29 | - name: format check
30 | run: dotnet format --verify-no-changes
31 | - name: Test
32 | run: dotnet test --filter "FullyQualifiedName~Omnius.Axus"
33 | windows:
34 | runs-on: windows-latest
35 | env:
36 | ContinuousIntegrationBuild: true
37 | steps:
38 | - name: Checkout branch
39 | uses: actions/checkout@v4
40 | with:
41 | submodules: "recursive"
42 | - name: Setup dotnet
43 | uses: actions/setup-dotnet@v3
44 | with:
45 | dotnet-version: 7.0.x
46 | - name: Install dependencies
47 | run: dotnet restore
48 | - name: Test
49 | run: dotnet test --filter "FullyQualifiedName~Omnius.Axus"
50 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "refs/core"]
2 | path = refs/core
3 | url = git@github.com:omnius-labs/core-cs.git
4 | branch = main
5 |
--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0.0",
3 | "tasks": [
4 | {
5 | "label": "gen-envfile",
6 | "type": "shell",
7 | "linux": {
8 | "command": "bash ${workspaceFolder}/eng/gen-envfile.sh"
9 | }
10 | },
11 | {
12 | "label": "design-build (Omnius.Axus.Ui.Desktop)",
13 | "command": "dotnet",
14 | "type": "process",
15 | "args": [
16 | "build",
17 | "${workspaceFolder}/src/Omnius.Axus.Ui.Desktop/Omnius.Axus.Ui.Desktop.csproj",
18 | "/property:GenerateFullPaths=true",
19 | "/consoleloggerparameters:NoSummary"
20 | ],
21 | "options": {
22 | "env": {
23 | "BuildTargetName": "vscode-design-ui-desktop",
24 | "DesignMode": "true"
25 | }
26 | },
27 | "problemMatcher": "$msCompile",
28 | "dependsOn": "gen-envfile"
29 | },
30 | {
31 | "label": "build (Omnius.Axus.Daemon)",
32 | "command": "dotnet",
33 | "type": "process",
34 | "args": [
35 | "build",
36 | "${workspaceFolder}/src/Omnius.Axus.Daemon/Omnius.Axus.Daemon.csproj",
37 | "/property:GenerateFullPaths=true",
38 | "/consoleloggerparameters:NoSummary"
39 | ],
40 | "options": {
41 | "env": {
42 | "BuildTargetName": "vscode-daemon"
43 | }
44 | },
45 | "problemMatcher": "$msCompile"
46 | },
47 | {
48 | "label": "build (Omnius.Axus.Ui.Desktop)",
49 | "command": "dotnet",
50 | "type": "process",
51 | "args": [
52 | "build",
53 | "${workspaceFolder}/src/Omnius.Axus.Ui.Desktop/Omnius.Axus.Ui.Desktop.csproj",
54 | "/property:GenerateFullPaths=true",
55 | "/consoleloggerparameters:NoSummary"
56 | ],
57 | "options": {
58 | "env": {
59 | "BuildTargetName": "vscode-ui-desktop"
60 | }
61 | },
62 | "problemMatcher": "$msCompile",
63 | "dependsOn": "gen-envfile"
64 | }
65 | ]
66 | }
67 |
--------------------------------------------------------------------------------
/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 - 2023 Lyrise
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | PreviewXamlFile := Views/Windows/Main/MainWindow.axaml
2 |
3 | gen-code:
4 | bash ./eng/gen-code.sh
5 |
6 | test:
7 | dotnet test --no-restore --filter "FullyQualifiedName~Omnius.Axus"
8 |
9 | build:
10 | dotnet build
11 |
12 | run-designer: build
13 | dotnet msbuild ./src/Omnius.Axus.Ui.Desktop/ /t:Preview /p:XamlFile=$(PreviewXamlFile)
14 |
15 | update-dotnet-tool:
16 | bash ./eng/update-dotnet-tool.sh
17 |
18 | update-sln:
19 | bash ./eng/update-sln.sh
20 |
21 | clean:
22 | rm -rf ./bin
23 | rm -rf ./tmp
24 | rm -rf ./pub
25 |
26 | .PHONY: test build
27 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Axus - Omnius File Exchanger
2 |
3 | [](https://github.com/omnius-labs/axus/actions/workflows/test.yml)
4 | [](https://gitter.im/omnius-labs/community)
5 |
6 | ## Installing Required Dependencies
7 |
8 | ### Linux
9 |
10 | ```sh
11 | sudo apt-get install -y libsnappy-dev
12 | ```
13 |
14 | ## Docs
15 | - [Requirements](./docs/requirements/index.adoc)
16 | - [Specifications](./docs/specifications/index.adoc)
17 | - [FAQ](./docs/faq.md)
18 |
19 | ## Links
20 |
21 | - docs: https://docs.omnius-labs.com/
22 | - icons: https://icooon-mono.com/
23 |
--------------------------------------------------------------------------------
/build-linux.sh:
--------------------------------------------------------------------------------
1 | #!/usr/env bash
2 | set -euo pipefail
3 |
4 | rm -rf ./pub/linux-x64/*
5 |
6 | export NativeDepsPlatform=linux
7 | export PlatformTarget=x64
8 |
9 | dotnet publish ./src/Omnius.Axus.Daemon -p:PublishSingleFile=true --runtime linux-x64 --configuration Release --self-contained true --output ./pub/linux-x64/bin/daemon
10 | dotnet publish ./src/Omnius.Axus.Ui.Desktop -p:PublishSingleFile=true --runtime linux-x64 --configuration Release --self-contained true --output ./pub/linux-x64/bin/ui-desktop
11 | dotnet publish ./src/Omnius.Axus.Launcher -p:PublishSingleFile=true -p:PublishTrimmed=true --runtime linux-x64 --configuration Release --self-contained true --output ./pub/linux-x64/
12 |
--------------------------------------------------------------------------------
/build-win.ps1:
--------------------------------------------------------------------------------
1 | Remove-Item ./pub/win-x64/* -Recurse
2 |
3 | $Env:NativeDepsPlatform="Windows"
4 | $Env:PlatformTarget="x64"
5 |
6 | dotnet publish ./src/Omnius.Axus.Daemon -p:PublishSingleFile=true --runtime win-x64 --configuration Release --self-contained true --output ./pub/win-x64/bin/daemon
7 | dotnet publish ./src/Omnius.Axus.Ui.Desktop -p:PublishSingleFile=true --runtime win-x64 --configuration Release --self-contained true --output ./pub/win-x64/bin/ui-desktop
8 | dotnet publish ./src/Omnius.Axus.Launcher -p:PublishSingleFile=true -p:PublishTrimmed=true --runtime win-x64 --configuration Release --self-contained true --output ./pub/win-x64/
9 |
--------------------------------------------------------------------------------
/demo/0/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/omnius-labs/axus-cs/91e21cb5dd9103923ffa1122167b34a48b0b2944/demo/0/.gitkeep
--------------------------------------------------------------------------------
/demo/1/run-daemon.ps1:
--------------------------------------------------------------------------------
1 | Set-Location $PSScriptRoot
2 |
3 | $Env:BuildTargetName = "daemon-1"
4 | dotnet run --project ../../src/Omnius.Axus.Daemon/ -- -s ./storage/daemon -l "tcp(ip4(127.0.0.1),43201)" -v true
5 |
--------------------------------------------------------------------------------
/demo/1/run-daemon.sh:
--------------------------------------------------------------------------------
1 | #!/usr/env bash
2 | set -euo pipefail
3 |
4 | cd $(dirname $0)
5 |
6 | export BuildTargetName=daemon-1
7 | dotnet run --project ../../src/Omnius.Axus.Daemon/ -- -s ./storage/daemon -l "tcp(ip4(127.0.0.1),43201)" -v true
8 |
--------------------------------------------------------------------------------
/demo/1/run-ui-desktop.ps1:
--------------------------------------------------------------------------------
1 | Set-Location $PSScriptRoot
2 |
3 | $Env:BuildTargetName = "ui-desktop-1"
4 | dotnet run --project ../../src/Omnius.Axus.Ui.Desktop/ -- -s ./storage/ui-desktop -l "tcp(ip4(127.0.0.1),43201)" -v true
5 |
--------------------------------------------------------------------------------
/demo/1/run-ui-desktop.sh:
--------------------------------------------------------------------------------
1 | #!/usr/env bash
2 | set -euo pipefail
3 |
4 | cd $(dirname $0)
5 |
6 | export BuildTargetName=ui-desktop-1
7 | dotnet run --project ../../src/Omnius.Axus.Ui.Desktop/ -- -s ./storage/ui-desktop -l "tcp(ip4(127.0.0.1),43201)" -v true
8 |
--------------------------------------------------------------------------------
/demo/2/run-daemon.ps1:
--------------------------------------------------------------------------------
1 | Set-Location $PSScriptRoot
2 |
3 | $Env:BuildTargetName = "daemon-2"
4 | dotnet run --project ../../src/Omnius.Axus.Daemon/ -- -s ./storage/daemon -l "tcp(ip4(127.0.0.1),43202)" -v true
5 |
--------------------------------------------------------------------------------
/demo/2/run-daemon.sh:
--------------------------------------------------------------------------------
1 | #!/usr/env bash
2 | set -euo pipefail
3 |
4 | cd $(dirname $0)
5 |
6 | export BuildTargetName=daemon-2
7 | dotnet run --project ../../src/Omnius.Axus.Daemon/ -- -s ./storage/daemon -l "tcp(ip4(127.0.0.1),43202)" -v true
8 |
--------------------------------------------------------------------------------
/demo/2/run-ui-desktop.ps1:
--------------------------------------------------------------------------------
1 | Set-Location $PSScriptRoot
2 |
3 | $Env:BuildTargetName = "ui-desktop-2"
4 | dotnet run --project ../../src/Omnius.Axus.Ui.Desktop/ -- -s ./storage/ui-desktop -l "tcp(ip4(127.0.0.1),43202)" -v true
5 |
--------------------------------------------------------------------------------
/demo/2/run-ui-desktop.sh:
--------------------------------------------------------------------------------
1 | #!/usr/env bash
2 | set -euo pipefail
3 |
4 | cd $(dirname $0)
5 |
6 | export BuildTargetName=ui-desktop-2
7 | dotnet run --project ../../src/Omnius.Axus.Ui.Desktop/ -- -s ./storage/ui-desktop -l "tcp(ip4(127.0.0.1),43202)" -v true
8 |
--------------------------------------------------------------------------------
/demo/3/run-daemon.ps1:
--------------------------------------------------------------------------------
1 | Set-Location $PSScriptRoot
2 |
3 | $Env:BuildTargetName = "daemon-3"
4 | dotnet run --project ../../src/Omnius.Axus.Daemon/ -- -s ./storage/daemon -l "tcp(ip4(127.0.0.1),43203)" -v true
5 |
--------------------------------------------------------------------------------
/demo/3/run-daemon.sh:
--------------------------------------------------------------------------------
1 | #!/usr/env bash
2 | set -euo pipefail
3 |
4 | cd $(dirname $0)
5 |
6 | export BuildTargetName=daemon-3
7 | dotnet run --project ../../src/Omnius.Axus.Daemon/ -- -s ./storage/daemon -l "tcp(ip4(127.0.0.1),43203)" -v true
8 |
--------------------------------------------------------------------------------
/demo/3/run-ui-desktop.ps1:
--------------------------------------------------------------------------------
1 | Set-Location $PSScriptRoot
2 |
3 | $Env:BuildTargetName = "ui-desktop-3"
4 | dotnet run --project ../../src/Omnius.Axus.Ui.Desktop/ -- -s ./storage/ui-desktop -l "tcp(ip4(127.0.0.1),43203)" -v true
5 |
--------------------------------------------------------------------------------
/demo/3/run-ui-desktop.sh:
--------------------------------------------------------------------------------
1 | #!/usr/env bash
2 | set -euo pipefail
3 |
4 | cd $(dirname $0)
5 |
6 | export BuildTargetName=ui-desktop-3
7 | dotnet run --project ../../src/Omnius.Axus.Ui.Desktop/ -- -s ./storage/ui-desktop -l "tcp(ip4(127.0.0.1),43203)" -v true
8 |
--------------------------------------------------------------------------------
/demo/run-1.ps1:
--------------------------------------------------------------------------------
1 | Start-Process -FilePath pwsh -ArgumentList ./1/run-daemon.ps1
2 | Start-Process -FilePath pwsh -ArgumentList ./1/run-ui-desktop.ps1
3 |
--------------------------------------------------------------------------------
/demo/run-2.ps1:
--------------------------------------------------------------------------------
1 | Start-Process -FilePath pwsh -ArgumentList ./2/run-daemon.ps1
2 | Start-Process -FilePath pwsh -ArgumentList ./2/run-ui-desktop.ps1
3 |
--------------------------------------------------------------------------------
/demo/run-3.ps1:
--------------------------------------------------------------------------------
1 | Start-Process -FilePath pwsh -ArgumentList ./3/run-daemon.ps1
2 | Start-Process -FilePath pwsh -ArgumentList ./3/run-ui-desktop.ps1
3 |
--------------------------------------------------------------------------------
/docs/faq.md:
--------------------------------------------------------------------------------
1 | ## UI scaling is wrong on Linux
2 |
3 | You need to set the AVALONIA_SCREEN_SCALE_FACTORS environment variable.
4 |
5 | For debugging, you can set environment variables in the .env file with the following command.
6 |
7 | ```sh
8 | SCALE=2 bash ./eng/gen-envfile.sh
9 | ```
10 |
11 | ### Refs
12 | - https://github.com/AvaloniaUI/Avalonia/issues/4826
13 | - https://github.com/AvaloniaUI/Avalonia/issues/6923
14 |
15 | ## System.InvalidOperationException: Default font family name can't be null or empty.
16 |
17 | You need to set the LANG=en_US.UTF-8 environment variable.
18 |
19 | For debugging, you can set environment variables in the .env file with the following command.
20 |
21 | ```sh
22 | SCALE=2 bash ./eng/gen-envfile.sh
23 | ```
24 |
25 | ### Refs
26 | - https://github.com/AvaloniaUI/Avalonia/issues/4427
27 |
--------------------------------------------------------------------------------
/docs/requirements/index.adoc:
--------------------------------------------------------------------------------
1 | == Requirements
2 |
3 | [plantuml]
4 | ----
5 | include::requirements.puml[]
6 | ----
7 |
--------------------------------------------------------------------------------
/docs/requirements/requirements.puml:
--------------------------------------------------------------------------------
1 | @startmindmap requirements
2 | * Chat
3 | ** View
4 | ** Post
5 | * FileShare
6 | ** Find
7 | ** Download
8 | ** Upload
9 | @endmindmap
10 |
--------------------------------------------------------------------------------
/docs/specifications/index.adoc:
--------------------------------------------------------------------------------
1 | == Models
2 |
3 | [plantuml]
4 | ----
5 | include::models.puml[]
6 | ----
7 |
--------------------------------------------------------------------------------
/docs/specifications/models.puml:
--------------------------------------------------------------------------------
1 | @startmindmap models
2 | * File
3 | @endmindmap
4 |
--------------------------------------------------------------------------------
/eng/coverage.ps1:
--------------------------------------------------------------------------------
1 | $Env:ContinuousIntegrationBuild = "true"
2 |
3 | $output = "../../tmp/test/win/opencover.xml";
4 | dotnet test --no-restore --filter "FullyQualifiedName~Omnius.Axus" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput="$output" /p:Exclude="[xunit*]*%2c[*.Tests]*%2c[Omnius.Core*]*";
5 |
6 | if (!$?) {
7 | exit 1
8 | }
9 |
10 | dotnet tool run reportgenerator "-reports:tmp/test/win/opencover.xml" "-targetdir:pub/code-coverage/win"
11 |
--------------------------------------------------------------------------------
/eng/coverage.sh:
--------------------------------------------------------------------------------
1 | #!/usr/env bash
2 | set -euo pipefail
3 |
4 | export ContinuousIntegrationBuild=true
5 |
6 | output="../../tmp/test/linux/opencover.xml"
7 | dotnet test --no-restore --filter "FullyQualifiedName~Omnius.Axus" -p:CollectCoverage=true -p:CoverletOutputFormat=opencover -p:CoverletOutput="$output" -p:Exclude="[xunit*]*%2c[*.Tests]*%2c[Omnius.Core*]*"
8 |
9 | ret=$?
10 | if [ $ret -gt 0 ]; then
11 | exit $ret
12 | fi
13 |
14 | dotnet tool run reportgenerator "-reports:tmp/test/linux/opencover.xml" "-targetdir:pub/code-coverage/linux"
15 |
--------------------------------------------------------------------------------
/eng/export-diff.sh:
--------------------------------------------------------------------------------
1 | #!/usr/env bash
2 | set -euo pipefail
3 |
4 | git diff --diff-filter=AMCRD HEAD | gzip -c | base64 > patch.txt
5 |
--------------------------------------------------------------------------------
/eng/gen-code.sh:
--------------------------------------------------------------------------------
1 | #!/usr/env bash
2 | set -euo pipefail
3 |
4 | DOTNET_CLI_TELEMETRY_OPTOUT=1
5 |
6 | # *.rpf
7 | RPFC_PATH="$PWD/refs/core/src/Omnius.Core.RocketPack.DefinitionCompiler"
8 | dotnet run --project $RPFC_PATH -- -c "$PWD/rpfs/config.yml"
9 |
--------------------------------------------------------------------------------
/eng/gen-envfile.sh:
--------------------------------------------------------------------------------
1 | #!/usr/env bash
2 | set -euo pipefail
3 |
4 | rm -f .env
5 |
6 | echo "LANG=en_US.UTF-8" >> .env
7 |
8 | SCREEN=$(xrandr --listactivemonitors | awk -F " " '{ printf("%s", $4) }')
9 | echo "AVALONIA_SCREEN_SCALE_FACTORS='$SCREEN=${SCREEN_SCALE:-1}'" >> .env
10 |
--------------------------------------------------------------------------------
/eng/import-diff.sh:
--------------------------------------------------------------------------------
1 | #!/usr/env bash
2 | set -euo pipefail
3 |
4 | cat patch.txt | base64 -d | gzip -d | git apply
5 |
--------------------------------------------------------------------------------
/eng/update-dotnet-tool.sh:
--------------------------------------------------------------------------------
1 | #!/usr/env bash
2 | set -euo pipefail
3 |
4 | for name in $(dotnet tool list | awk 'NR>2{print $1}'); do
5 | dotnet tool update $name
6 | done
7 |
--------------------------------------------------------------------------------
/eng/update-sln.ps1:
--------------------------------------------------------------------------------
1 | dotnet new sln --force -n axus
2 | dotnet sln axus.sln add (ls -r ./refs/core/src/**/*.csproj)
3 | dotnet sln axus.sln add (ls -r ./refs/core/test/**/*.csproj)
4 | dotnet sln axus.sln add (ls -r ./src/**/*.csproj)
5 | dotnet sln axus.sln add (ls -r ./test/**/*.csproj)
6 |
--------------------------------------------------------------------------------
/eng/update-sln.sh:
--------------------------------------------------------------------------------
1 | #!/usr/env bash
2 | set -euo pipefail
3 |
4 | dotnet new sln --force -n axus
5 | dotnet sln axus.sln add ./refs/core/src/**/*.csproj
6 | dotnet sln axus.sln add ./refs/core/test/**/*.csproj
7 | dotnet sln axus.sln add ./src/**/*.csproj
8 | dotnet sln axus.sln add ./test/**/*.csproj
9 |
--------------------------------------------------------------------------------
/lock/Omnius.Axus.Launcher.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": 1,
3 | "dependencies": {
4 | "net7.0": {
5 | "CommandLineParser": {
6 | "type": "Direct",
7 | "requested": "[2.8.0, )",
8 | "resolved": "2.8.0",
9 | "contentHash": "eco2HlKQBY4Joz9odHigzGpVzv6pjsXnY5lziioMveQxr+i2Z7xYcIOMeZTgYiqnMtMAbXMXsVhrNfWO5vJS8Q=="
10 | },
11 | "GitInfo": {
12 | "type": "Direct",
13 | "requested": "[2.2.0, )",
14 | "resolved": "2.2.0",
15 | "contentHash": "SKTmjt40sYqoDB3S7HFVUToUN/vl6Zrt+PuSHdjbQDlcBx0JAZBdS7BXVbVKyy+0iaaF3FBd4ZxspIlKQCC9Lw=="
16 | },
17 | "NLog": {
18 | "type": "Direct",
19 | "requested": "[4.7.15, )",
20 | "resolved": "4.7.15",
21 | "contentHash": "vXMmsK17hXnMsKd8BdCrJzvb8JMT0+cPgBGRfnqcXIb6y8b6RMIZexO4hMhQgifcTHgU7dbubvCR5A5wX6Ne+A=="
22 | },
23 | "NLog.Config": {
24 | "type": "Direct",
25 | "requested": "[4.7.15, )",
26 | "resolved": "4.7.15",
27 | "contentHash": "njc2NvwgAzEuH609TGO4yqpokcxXFdypHwG3I8hyLYIE4pr+j4KJB4ZhsyODVwkP/n2F2V4uJ24VW4icNyJMcA==",
28 | "dependencies": {
29 | "NLog": "4.7.15",
30 | "NLog.Schema": "4.7.15"
31 | }
32 | },
33 | "NLog.Schema": {
34 | "type": "Transitive",
35 | "resolved": "4.7.15",
36 | "contentHash": "cBzca2abS5Qz8e40vIPZNWBiDAQaRY7PKWffBbazMAzvxGBM6/ZWgaAEmqHUOluhV41cuyXnHOzo485JPLeChg=="
37 | }
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/lock/Omnius.Axus.Utils.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": 1,
3 | "dependencies": {
4 | "net7.0": {
5 | "LiteDB": {
6 | "type": "Direct",
7 | "requested": "[5.0.15, )",
8 | "resolved": "5.0.15",
9 | "contentHash": "nucyfCOGSATH553BxplxExP3BOqEwmHt0B57426EIaQjD3CC1Odb52VVCGgTxyYaD2oe3B/cJk8jDo6XiBJqPg=="
10 | },
11 | "NLog": {
12 | "type": "Direct",
13 | "requested": "[4.7.15, )",
14 | "resolved": "4.7.15",
15 | "contentHash": "vXMmsK17hXnMsKd8BdCrJzvb8JMT0+cPgBGRfnqcXIb6y8b6RMIZexO4hMhQgifcTHgU7dbubvCR5A5wX6Ne+A=="
16 | }
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/lock/linux-x64/Omnius.Axus.Launcher.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": 1,
3 | "dependencies": {
4 | "net7.0": {
5 | "CommandLineParser": {
6 | "type": "Direct",
7 | "requested": "[2.8.0, )",
8 | "resolved": "2.8.0",
9 | "contentHash": "eco2HlKQBY4Joz9odHigzGpVzv6pjsXnY5lziioMveQxr+i2Z7xYcIOMeZTgYiqnMtMAbXMXsVhrNfWO5vJS8Q=="
10 | },
11 | "GitInfo": {
12 | "type": "Direct",
13 | "requested": "[2.2.0, )",
14 | "resolved": "2.2.0",
15 | "contentHash": "SKTmjt40sYqoDB3S7HFVUToUN/vl6Zrt+PuSHdjbQDlcBx0JAZBdS7BXVbVKyy+0iaaF3FBd4ZxspIlKQCC9Lw=="
16 | },
17 | "NLog": {
18 | "type": "Direct",
19 | "requested": "[4.7.15, )",
20 | "resolved": "4.7.15",
21 | "contentHash": "vXMmsK17hXnMsKd8BdCrJzvb8JMT0+cPgBGRfnqcXIb6y8b6RMIZexO4hMhQgifcTHgU7dbubvCR5A5wX6Ne+A=="
22 | },
23 | "NLog.Config": {
24 | "type": "Direct",
25 | "requested": "[4.7.15, )",
26 | "resolved": "4.7.15",
27 | "contentHash": "njc2NvwgAzEuH609TGO4yqpokcxXFdypHwG3I8hyLYIE4pr+j4KJB4ZhsyODVwkP/n2F2V4uJ24VW4icNyJMcA==",
28 | "dependencies": {
29 | "NLog": "4.7.15",
30 | "NLog.Schema": "4.7.15"
31 | }
32 | },
33 | "NLog.Schema": {
34 | "type": "Transitive",
35 | "resolved": "4.7.15",
36 | "contentHash": "cBzca2abS5Qz8e40vIPZNWBiDAQaRY7PKWffBbazMAzvxGBM6/ZWgaAEmqHUOluhV41cuyXnHOzo485JPLeChg=="
37 | }
38 | },
39 | "net7.0/linux-x64": {}
40 | }
41 | }
--------------------------------------------------------------------------------
/lock/linux-x64/Omnius.Axus.Utils.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": 1,
3 | "dependencies": {
4 | "net7.0": {
5 | "LiteDB": {
6 | "type": "Direct",
7 | "requested": "[5.0.11, )",
8 | "resolved": "5.0.11",
9 | "contentHash": "6cL4bOmVCUB0gIK+6qIr68HeqjjHZicPDGQjvJ87mIOvkFsEsJWkIps3yoKNeLpHhJQur++yoQ9Q8gxsdos0xQ=="
10 | },
11 | "NLog": {
12 | "type": "Direct",
13 | "requested": "[4.7.15, )",
14 | "resolved": "4.7.15",
15 | "contentHash": "vXMmsK17hXnMsKd8BdCrJzvb8JMT0+cPgBGRfnqcXIb6y8b6RMIZexO4hMhQgifcTHgU7dbubvCR5A5wX6Ne+A=="
16 | }
17 | },
18 | "net7.0/linux-x64": {}
19 | }
20 | }
--------------------------------------------------------------------------------
/lock/win-x64/Omnius.Axus.Launcher.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": 1,
3 | "dependencies": {
4 | "net7.0": {
5 | "CommandLineParser": {
6 | "type": "Direct",
7 | "requested": "[2.8.0, )",
8 | "resolved": "2.8.0",
9 | "contentHash": "eco2HlKQBY4Joz9odHigzGpVzv6pjsXnY5lziioMveQxr+i2Z7xYcIOMeZTgYiqnMtMAbXMXsVhrNfWO5vJS8Q=="
10 | },
11 | "GitInfo": {
12 | "type": "Direct",
13 | "requested": "[2.2.0, )",
14 | "resolved": "2.2.0",
15 | "contentHash": "SKTmjt40sYqoDB3S7HFVUToUN/vl6Zrt+PuSHdjbQDlcBx0JAZBdS7BXVbVKyy+0iaaF3FBd4ZxspIlKQCC9Lw=="
16 | },
17 | "NLog": {
18 | "type": "Direct",
19 | "requested": "[4.7.15, )",
20 | "resolved": "4.7.15",
21 | "contentHash": "vXMmsK17hXnMsKd8BdCrJzvb8JMT0+cPgBGRfnqcXIb6y8b6RMIZexO4hMhQgifcTHgU7dbubvCR5A5wX6Ne+A=="
22 | },
23 | "NLog.Config": {
24 | "type": "Direct",
25 | "requested": "[4.7.15, )",
26 | "resolved": "4.7.15",
27 | "contentHash": "njc2NvwgAzEuH609TGO4yqpokcxXFdypHwG3I8hyLYIE4pr+j4KJB4ZhsyODVwkP/n2F2V4uJ24VW4icNyJMcA==",
28 | "dependencies": {
29 | "NLog": "4.7.15",
30 | "NLog.Schema": "4.7.15"
31 | }
32 | },
33 | "NLog.Schema": {
34 | "type": "Transitive",
35 | "resolved": "4.7.15",
36 | "contentHash": "cBzca2abS5Qz8e40vIPZNWBiDAQaRY7PKWffBbazMAzvxGBM6/ZWgaAEmqHUOluhV41cuyXnHOzo485JPLeChg=="
37 | }
38 | },
39 | "net7.0/win-x64": {}
40 | }
41 | }
--------------------------------------------------------------------------------
/lock/win-x64/Omnius.Axus.Utils.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": 1,
3 | "dependencies": {
4 | "net7.0": {
5 | "LiteDB": {
6 | "type": "Direct",
7 | "requested": "[5.0.11, )",
8 | "resolved": "5.0.11",
9 | "contentHash": "6cL4bOmVCUB0gIK+6qIr68HeqjjHZicPDGQjvJ87mIOvkFsEsJWkIps3yoKNeLpHhJQur++yoQ9Q8gxsdos0xQ=="
10 | },
11 | "NLog": {
12 | "type": "Direct",
13 | "requested": "[4.7.15, )",
14 | "resolved": "4.7.15",
15 | "contentHash": "vXMmsK17hXnMsKd8BdCrJzvb8JMT0+cPgBGRfnqcXIb6y8b6RMIZexO4hMhQgifcTHgU7dbubvCR5A5wX6Ne+A=="
16 | }
17 | },
18 | "net7.0/win-x64": {}
19 | }
20 | }
--------------------------------------------------------------------------------
/nuget.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/rpfs/Omnius.Axus.Engines/Omnius.Axus.Engines.Models.rpf:
--------------------------------------------------------------------------------
1 | syntax v1.0;
2 |
3 | using "Omnius.Core.Cryptography";
4 | using "Omnius.Core.Net";
5 | using "Omnius.Axus.Messages";
6 |
7 | namespace "Omnius.Axus.Engines.Models";
8 |
9 | // Common
10 |
11 | message ContentClue {
12 | Scheme: string(capacity: 256),
13 | RootHash: OmniHash,
14 | }
15 |
--------------------------------------------------------------------------------
/rpfs/Omnius.Axus.Interactors/Omnius.Axus.Interactors.Internal.Models.rpf:
--------------------------------------------------------------------------------
1 | syntax v1.0;
2 |
3 | using "Omnius.Core.Cryptography";
4 | using "Omnius.Core.Net";
5 | using "Omnius.Axus.Messages";
6 | using "Omnius.Axus.Interactors.Models";
7 |
8 | namespace "Omnius.Axus.Interactors.Internal.Models";
9 |
10 | // Profile
11 |
12 | message CachedProfile {
13 | Signature: OmniSignature,
14 | ShoutUpdatedTime: timestamp64,
15 | Value: Profile,
16 | }
17 |
18 | // Note
19 |
20 | message CachedNoteContent {
21 | Signature: OmniSignature,
22 | ShoutUpdatedTime: timestamp64,
23 | Value: NoteContent,
24 | }
25 |
26 | message NoteContent {
27 | Memos: vector(capacity: 8 * 1024),
28 | }
29 |
30 | message CachedMemo {
31 | Signature: OmniSignature,
32 | Value: Memo,
33 | }
34 |
35 | // Cask
36 |
37 | message CachedCaskContent {
38 | Signature: OmniSignature,
39 | ShoutUpdatedTime: timestamp64,
40 | Value: CaskContent,
41 | }
42 |
43 | message CaskContent {
44 | Seeds: vector(capacity: 1024 * 32),
45 | }
46 |
47 | message CachedSeed {
48 | Signature: OmniSignature,
49 | Value: Seed,
50 | }
51 |
--------------------------------------------------------------------------------
/rpfs/Omnius.Axus.Interactors/Omnius.Axus.Interactors.Models.rpf:
--------------------------------------------------------------------------------
1 | syntax v1.0;
2 |
3 | using "Omnius.Core.Cryptography";
4 | using "Omnius.Core.Net";
5 | using "Omnius.Axus.Messages";
6 |
7 | namespace "Omnius.Axus.Interactors.Models";
8 |
9 | // Common
10 |
11 | message Profile {
12 | TrustedSignatures: vector(capacity: 1024),
13 | BlockedSignatures: vector(capacity: 1024),
14 | }
15 |
16 | message Seed {
17 | RootHash: OmniHash,
18 | Name: string(capacity: 256),
19 | Size: uint64,
20 | CreatedTime: timestamp64,
21 | }
22 |
23 | message Memo {
24 | Comment: string(capacity: 1024),
25 | Tag: string(capacity: 256),
26 | AnchorHash: OmniHash,
27 | CreatedTime: timestamp64,
28 | }
29 |
30 | // Profile
31 |
32 | message ProfileUploaderConfig {
33 | DigitalSignature: OmniDigitalSignature,
34 | TrustedSignatures: vector(capacity: 1024),
35 | BlockedSignatures: vector(capacity: 1024),
36 | }
37 |
38 | message ProfileDownloaderConfig {
39 | TrustedSignatures: vector(capacity: 1024),
40 | BlockedSignatures: vector(capacity: 1024),
41 | SearchDepth: uint32,
42 | MaxProfileCount: uint32,
43 | }
44 |
45 | // Memo
46 |
47 | message MemoUploaderConfig {
48 | DigitalSignature: OmniDigitalSignature,
49 | Memos: vector(capacity: 8 * 1024),
50 | }
51 |
52 | message MemoDownloaderConfig {
53 | Tags: vector(capacity: 256),
54 | MaxMemoCount: uint32,
55 | }
56 |
57 | // Seed
58 |
59 | message SeedUploaderConfig {
60 | DigitalSignature: OmniDigitalSignature,
61 | }
62 |
63 | message SeedDownloaderConfig {
64 | MaxSeedCount: uint32,
65 | }
66 |
67 | // File
68 |
69 | message FileDownloaderConfig {
70 | DestinationDirectory: string,
71 | }
72 |
--------------------------------------------------------------------------------
/rpfs/Omnius.Axus.Messages/Omnius.Axus.Messages.rpf:
--------------------------------------------------------------------------------
1 | syntax v1.0;
2 |
3 | using "Omnius.Core.Cryptography";
4 | using "Omnius.Core.Net";
5 |
6 | namespace "Omnius.Axus.Messages";
7 |
8 | // Common
9 |
10 | message NodeLocation {
11 | Addresses: vector(capacity: 32),
12 | }
13 |
14 | message Shout {
15 | Channel: string(capacity: 256),
16 | UpdatedTime: timestamp64,
17 | Value: bytes(capacity: 32 * 1024 * 1024, recyclable: true),
18 | Certificate: OmniCertificate?,
19 | }
20 |
21 | message ConsistencyReport {
22 | BadBlockCount: uint32,
23 | CheckedBlockCount: uint32,
24 | TotalBlockCount: uint32,
25 | }
26 |
27 | message SessionReport {
28 | Scheme: string(capacity: 256),
29 | HandshakeType: SessionHandshakeType,
30 | Address: OmniAddress,
31 | }
32 |
33 | enum SessionHandshakeType : uint8 {
34 | Unknown = 0,
35 | Connected = 1,
36 | Accepted = 2,
37 | }
38 |
39 | // Report
40 |
41 | message PublishedFileReport {
42 | FilePath: string?,
43 | RootHash: OmniHash?,
44 | }
45 |
46 | message SubscribedFileReport {
47 | RootHash: OmniHash,
48 | Status: SubscribedFileStatus,
49 | }
50 |
51 | message SubscribedFileStatus {
52 | CurrentDepth: int32,
53 | DownloadedBlockCount: uint32,
54 | TotalBlockCount: uint32,
55 | State: SubscribedFileState,
56 | }
57 |
58 | enum SubscribedFileState : uint8 {
59 | Unknown = 0,
60 | Downloading = 1,
61 | Downloaded = 2,
62 | Failed = 3,
63 | }
64 |
65 | message PublishedShoutReport {
66 | Signature: OmniSignature,
67 | Channel: string,
68 | }
69 |
70 | message SubscribedShoutReport {
71 | Signature: OmniSignature,
72 | Channel: string,
73 | }
74 |
--------------------------------------------------------------------------------
/rpfs/config.yml:
--------------------------------------------------------------------------------
1 | - Includes:
2 | - ./refs/core/rpfs/**/*.rpf
3 | - ./rpfs/**/*.rpf
4 | CompileTargets:
5 | - Input: ./rpfs/Omnius.Axus.Messages/Omnius.Axus.Messages.rpf
6 | Output: ./src/Omnius.Axus.Messages/_RocketPack/_Generated.cs
7 | - Input: ./rpfs/Omnius.Axus.Engines/Omnius.Axus.Engines.Models.rpf
8 | Output: ./src/Omnius.Axus.Engines/Models/_RocketPack/_Generated.cs
9 | - Input: ./rpfs/Omnius.Axus.Engines/Omnius.Axus.Engines.Internal.Models.rpf
10 | Output: ./src/Omnius.Axus.Engines/Implementations/Internal/Models/_RocketPack/_Generated.cs
11 | - Input: ./rpfs/Omnius.Axus.Remoting/Omnius.Axus.Remoting.rpf
12 | Output: ./src/Omnius.Axus.Remoting/_RocketPack/_Generated.cs
13 | - Input: ./rpfs/Omnius.Axus.Interactors/Omnius.Axus.Interactors.Models.rpf
14 | Output: ./src/Omnius.Axus.Interactors/Models/_RocketPack/_Generated.cs
15 | - Input: ./rpfs/Omnius.Axus.Interactors/Omnius.Axus.Interactors.Internal.Models.rpf
16 | Output: ./src/Omnius.Axus.Interactors/Implementations/Internal/Models/_RocketPack/_Generated.cs
17 |
--------------------------------------------------------------------------------
/src/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | <_Parameter1>$(MSBuildProjectName).Tests
7 |
8 |
9 |
10 | ../../style.ruleset
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Daemon/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | [assembly: AssemblyVersion(ThisAssembly.Git.BaseVersion.Major + "." + ThisAssembly.Git.BaseVersion.Minor + "." + ThisAssembly.Git.BaseVersion.Patch)]
4 | [assembly: AssemblyFileVersion(ThisAssembly.Git.SemVer.Major + "." + ThisAssembly.Git.SemVer.Minor + "." + ThisAssembly.Git.SemVer.Patch)]
5 | [assembly: AssemblyInformationalVersion(ThisAssembly.Git.SemVer.Major + "." + ThisAssembly.Git.SemVer.Minor + "." + ThisAssembly.Git.SemVer.Patch + "-" + ThisAssembly.Git.Branch + "+" + ThisAssembly.Git.Commit)]
6 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Daemon/NLog.config:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
18 |
22 |
23 |
24 |
25 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Daemon/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "Omnius.Axus.Ui.Desktop": {
4 | "commandLineArgs": "\"-s\" \"./storage/daemon\" \"-l\" \"tcp(ip4(127.0.0.1),43200)\" \"-v\" \"true\"",
5 | "commandName": "Project",
6 | "workingDirectory": "../../demo/0"
7 | }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Daemon/Runner.TcpListenerManager.cs:
--------------------------------------------------------------------------------
1 | using System.Net.Sockets;
2 | using Omnius.Core;
3 | using Omnius.Core.Net;
4 |
5 | namespace Omnius.Axus.Daemon;
6 |
7 | public static partial class Runner
8 | {
9 | private sealed class TcpListenerManager : DisposableBase
10 | {
11 | private readonly TcpListener _tcpListener;
12 | private readonly CancellationTokenRegistration _registration;
13 |
14 | public TcpListenerManager(OmniAddress listenAddress, CancellationToken cancellationToken = default)
15 | {
16 | if (!listenAddress.TryParseTcpEndpoint(out var ipAddress, out var port)) throw new Exception("listenAddress is invalid format.");
17 |
18 | _tcpListener = new TcpListener(ipAddress!, port);
19 | _tcpListener.Start();
20 | _registration = cancellationToken.Register(() => _tcpListener.Stop());
21 | }
22 |
23 | public async ValueTask AcceptSocketAsync()
24 | {
25 | return await _tcpListener.AcceptSocketAsync();
26 | }
27 |
28 | protected override void OnDispose(bool disposing)
29 | {
30 | _registration.Dispose();
31 |
32 | if (_tcpListener is not null)
33 | {
34 | _tcpListener.Stop();
35 | _tcpListener.Server.Dispose();
36 | }
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/ConnectionI2pAccepterOptions.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core.Net;
2 |
3 | namespace Omnius.Axus.Engines;
4 |
5 | public record ConnectionI2pAccepterOptions
6 | {
7 | public required OmniAddress SamBridgeAddress { get; init; }
8 | }
9 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/ConnectionI2pConnectorOptions.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core.Net;
2 |
3 | namespace Omnius.Axus.Engines;
4 |
5 | public record ConnectionI2pConnectorOptions
6 | {
7 | public required OmniAddress SamBridgeAddress { get; init; }
8 | }
9 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/ConnectionTcpAccepterOptions.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core.Net;
2 |
3 | namespace Omnius.Axus.Engines;
4 |
5 | public record ConnectionTcpAccepterOptions
6 | {
7 | public required bool UseUpnp { get; init; }
8 | public required OmniAddress ListenAddress { get; init; }
9 | }
10 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/ConnectionTcpConnectorOptions.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core.Net;
2 |
3 | namespace Omnius.Axus.Engines;
4 |
5 | public record ConnectionTcpConnectorOptions
6 | {
7 | public required TcpProxyOptions Proxy { get; init; }
8 | }
9 |
10 | public record TcpProxyOptions
11 | {
12 | public required TcpProxyType Type { get; init; }
13 | public required OmniAddress Address { get; init; }
14 | }
15 |
16 | public enum TcpProxyType : byte
17 | {
18 | None = 0,
19 | HttpProxy = 1,
20 | Socks5Proxy = 2,
21 | }
22 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/FileExchanger.SessionStatus.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Engines.Internal.Models;
2 | using Omnius.Core;
3 | using Omnius.Core.Collections;
4 | using Omnius.Core.Cryptography;
5 | using Omnius.Core.Tasks;
6 |
7 | namespace Omnius.Axus.Engines;
8 |
9 | public sealed partial class FileExchanger
10 | {
11 | private sealed class SessionStatus : AsyncDisposableBase
12 | {
13 | public SessionStatus(ISession session, ExchangeType exchangeType, OmniHash rootHash, IBatchActionDispatcher batchActionDispatcher)
14 | {
15 | this.Session = session;
16 | this.ExchangeType = exchangeType;
17 | this.RootHash = rootHash;
18 | this.BatchActionDispatcher = batchActionDispatcher;
19 | this.LastReceivedTime = DateTime.UtcNow;
20 |
21 | this.SentBlockHashes = new(TimeSpan.FromMinutes(3), TimeSpan.FromSeconds(30), batchActionDispatcher);
22 | this.ReceivedWantBlockHashes = new(TimeSpan.FromMinutes(3), TimeSpan.FromSeconds(30), batchActionDispatcher);
23 | }
24 |
25 | protected override async ValueTask OnDisposeAsync()
26 | {
27 | await this.Session.DisposeAsync();
28 |
29 | this.SentBlockHashes.Dispose();
30 | this.ReceivedWantBlockHashes.Dispose();
31 | }
32 |
33 | public ISession Session { get; }
34 | public ExchangeType ExchangeType { get; }
35 | public OmniHash RootHash { get; }
36 | public IBatchActionDispatcher BatchActionDispatcher { get; }
37 | public DateTime LastReceivedTime { get; set; }
38 |
39 | public FileExchangerDataMessage? SendingDataMessage { get; set; }
40 |
41 | public VolatileHashSet SentBlockHashes { get; }
42 |
43 | public VolatileHashSet ReceivedWantBlockHashes { get; }
44 | }
45 |
46 | private enum ExchangeType
47 | {
48 | Unknown,
49 | Published,
50 | Subscribed,
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/FileExchangerException.cs:
--------------------------------------------------------------------------------
1 | namespace Omnius.Axus.Engines;
2 |
3 | public sealed class FileExchangerException : Exception
4 | {
5 | public FileExchangerException()
6 | : base()
7 | {
8 | }
9 |
10 | public FileExchangerException(string? message)
11 | : base(message)
12 | {
13 | }
14 |
15 | public FileExchangerException(string? message, Exception? innerException)
16 | : base(message, innerException)
17 | {
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/FileExchangerOptions.cs:
--------------------------------------------------------------------------------
1 | namespace Omnius.Axus.Engines;
2 |
3 | public record FileExchangerOptions
4 | {
5 | public required uint MaxSessionCount { get; init; }
6 | }
7 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/FilePublisherStorageOptions.cs:
--------------------------------------------------------------------------------
1 | namespace Omnius.Axus.Engines;
2 |
3 | public record FilePublisherStorageOptions
4 | {
5 | public required string ConfigDirectoryPath { get; init; }
6 | }
7 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/FileSubscriberStorageOptions.cs:
--------------------------------------------------------------------------------
1 | namespace Omnius.Axus.Engines;
2 |
3 | public record FileSubscriberStorageOptions
4 | {
5 | public required string ConfigDirectoryPath { get; init; }
6 | }
7 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/Internal/ContentClueConverter.cs:
--------------------------------------------------------------------------------
1 | using System.Text;
2 | using Omnius.Axus.Engines.Models;
3 | using Omnius.Core;
4 | using Omnius.Core.Cryptography;
5 | using Omnius.Core.Cryptography.Functions;
6 | using Omnius.Core.Pipelines;
7 |
8 | namespace Omnius.Axus.Engines.Internal;
9 |
10 | internal static class ContentClueConverter
11 | {
12 | private static readonly Lazy _encoding = new Lazy(() => new UTF8Encoding(false));
13 |
14 | public static ContentClue ToContentClue(string schema, OmniHash hash)
15 | {
16 | return new ContentClue(schema, hash);
17 | }
18 |
19 | public static ContentClue ToContentClue(string schema, OmniSignature signature, string channel)
20 | {
21 | using var bytesPipe = new BytesPipe(BytesPool.Shared);
22 | _encoding.Value.GetBytes(signature.ToString(), bytesPipe.Writer);
23 | _encoding.Value.GetBytes("/", bytesPipe.Writer);
24 | _encoding.Value.GetBytes(channel, bytesPipe.Writer);
25 |
26 | var hash = new OmniHash(OmniHashAlgorithmType.Sha2_256, Sha2_256.ComputeHash(bytesPipe.Reader.GetSequence()));
27 | return new ContentClue(schema, hash);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/Internal/Entities/BlockPublishedExternalItemEntity.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Engines.Internal.Models;
2 | using Omnius.Core.Cryptography;
3 |
4 | namespace Omnius.Axus.Engines.Internal.Entities;
5 |
6 | internal record BlockPublishedExternalItemEntity
7 | {
8 | public string? FilePath { get; set; }
9 | public OmniHashEntity? RootHash { get; set; }
10 | public OmniHashEntity? BlockHash { get; set; }
11 | public int Order { get; set; }
12 | public long Offset { get; set; }
13 | public int Count { get; set; }
14 |
15 | public static BlockPublishedExternalItemEntity Import(BlockPublishedExternalItem item)
16 | {
17 | return new BlockPublishedExternalItemEntity()
18 | {
19 | FilePath = item.FilePath,
20 | RootHash = OmniHashEntity.Import(item.RootHash),
21 | BlockHash = OmniHashEntity.Import(item.BlockHash),
22 | Order = item.Order,
23 | Offset = item.Offset,
24 | Count = item.Count,
25 | };
26 | }
27 |
28 | public BlockPublishedExternalItem Export()
29 | {
30 | return new BlockPublishedExternalItem()
31 | {
32 | FilePath = this.FilePath ?? string.Empty,
33 | RootHash = this.RootHash?.Export() ?? OmniHash.Empty,
34 | BlockHash = this.BlockHash?.Export() ?? OmniHash.Empty,
35 | Order = this.Order,
36 | Offset = this.Offset,
37 | Count = this.Count,
38 | };
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/Internal/Entities/BlockPublishedInternalItemEntity.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Engines.Internal.Models;
2 | using Omnius.Core.Cryptography;
3 |
4 | namespace Omnius.Axus.Engines.Internal.Entities;
5 |
6 | internal record BlockPublishedInternalItemEntity
7 | {
8 | public OmniHashEntity? RootHash { get; set; }
9 | public OmniHashEntity? BlockHash { get; set; }
10 | public int Depth { get; set; }
11 | public int Order { get; set; }
12 |
13 | public static BlockPublishedInternalItemEntity Import(BlockPublishedInternalItem item)
14 | {
15 | return new BlockPublishedInternalItemEntity()
16 | {
17 | RootHash = OmniHashEntity.Import(item.RootHash),
18 | BlockHash = OmniHashEntity.Import(item.BlockHash),
19 | Depth = item.Depth,
20 | Order = item.Order,
21 | };
22 | }
23 |
24 | public BlockPublishedInternalItem Export()
25 | {
26 | return new BlockPublishedInternalItem()
27 | {
28 | RootHash = this.RootHash?.Export() ?? OmniHash.Empty,
29 | BlockHash = this.BlockHash?.Export() ?? OmniHash.Empty,
30 | Depth = this.Depth,
31 | Order = this.Order,
32 | };
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/Internal/Entities/BlockSubscribedItemEntity.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Engines.Internal.Models;
2 | using Omnius.Core.Cryptography;
3 |
4 | namespace Omnius.Axus.Engines.Internal.Entities;
5 |
6 | internal record BlockSubscribedItemEntity
7 | {
8 | public OmniHashEntity? RootHash { get; set; }
9 | public OmniHashEntity? BlockHash { get; set; }
10 | public int Depth { get; set; }
11 | public int Order { get; set; }
12 | public bool IsDownloaded { get; set; }
13 |
14 | public static BlockSubscribedItemEntity Import(BlockSubscribedItem item)
15 | {
16 | return new BlockSubscribedItemEntity()
17 | {
18 | RootHash = OmniHashEntity.Import(item.RootHash),
19 | BlockHash = OmniHashEntity.Import(item.BlockHash),
20 | Depth = item.Depth,
21 | Order = item.Order,
22 | IsDownloaded = item.IsDownloaded,
23 | };
24 | }
25 |
26 | public BlockSubscribedItem Export()
27 | {
28 | return new BlockSubscribedItem()
29 | {
30 | RootHash = this.RootHash?.Export() ?? OmniHash.Empty,
31 | BlockHash = this.BlockHash?.Export() ?? OmniHash.Empty,
32 | Depth = this.Depth,
33 | Order = this.Order,
34 | IsDownloaded = this.IsDownloaded,
35 | };
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/Internal/Entities/CachedNodeLocationEntry.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Engines.Internal.Models;
2 | using Omnius.Axus.Messages;
3 |
4 | namespace Omnius.Axus.Engines.Internal.Entities;
5 |
6 | internal record CachedNodeLocationEntity
7 | {
8 | public NodeLocationEntity? Value { get; set; }
9 | public DateTime LastConnectedTime { get; set; }
10 | public DateTime UpdatedTime { get; set; }
11 |
12 | public static CachedNodeLocationEntity Import(CachedNodeLocation item)
13 | {
14 | return new CachedNodeLocationEntity()
15 | {
16 | Value = NodeLocationEntity.Import(item.Value),
17 | LastConnectedTime = item.LastConnectedTime,
18 | UpdatedTime = item.UpdatedTime,
19 | };
20 | }
21 |
22 | public CachedNodeLocation Export()
23 | {
24 | return new CachedNodeLocation
25 | {
26 | Value = this.Value?.Export() ?? NodeLocation.Empty,
27 | LastConnectedTime = this.LastConnectedTime,
28 | UpdatedTime = this.UpdatedTime,
29 | };
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/Internal/Entities/FilePublishedItemEntity.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Engines.Internal.Models;
2 | using Omnius.Core.Cryptography;
3 |
4 | namespace Omnius.Axus.Engines.Internal.Entities;
5 |
6 | internal record FilePublishedItemEntity
7 | {
8 | public OmniHashEntity? RootHash { get; set; }
9 | public string? FilePath { get; set; }
10 | public int MaxBlockSize { get; set; }
11 | public IReadOnlyList? Authors { get; set; }
12 |
13 | public static FilePublishedItemEntity Import(FilePublishedItem item)
14 | {
15 | return new FilePublishedItemEntity()
16 | {
17 | RootHash = OmniHashEntity.Import(item.RootHash),
18 | FilePath = item.FilePath,
19 | MaxBlockSize = item.MaxBlockSize,
20 | Authors = item.Authors,
21 | };
22 | }
23 |
24 | public FilePublishedItem Export()
25 | {
26 | return new FilePublishedItem()
27 | {
28 | RootHash = this.RootHash?.Export() ?? OmniHash.Empty,
29 | FilePath = this.FilePath,
30 | MaxBlockSize = this.MaxBlockSize,
31 | Authors = this.Authors ?? Array.Empty(),
32 | };
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/Internal/Entities/FileSubscribedItemEntity.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Engines.Internal.Models;
2 | using Omnius.Axus.Messages;
3 | using Omnius.Core.Cryptography;
4 |
5 | namespace Omnius.Axus.Engines.Internal.Entities;
6 |
7 | internal record FileSubscribedItemEntity
8 | {
9 | public OmniHashEntity? RootHash { get; set; }
10 | public IReadOnlyList? Authors { get; set; }
11 | public SubscribedFileItemStatusEntity? Status { get; init; }
12 |
13 | public static FileSubscribedItemEntity Import(FileSubscribedItem item)
14 | {
15 | return new FileSubscribedItemEntity()
16 | {
17 | RootHash = OmniHashEntity.Import(item.RootHash),
18 | Authors = item.Authors,
19 | Status = SubscribedFileItemStatusEntity.Import(item.Status),
20 | };
21 | }
22 |
23 | public FileSubscribedItem Export()
24 | {
25 | return new FileSubscribedItem()
26 | {
27 | RootHash = this.RootHash?.Export() ?? OmniHash.Empty,
28 | Authors = this.Authors ?? Array.Empty(),
29 | Status = this.Status?.Export() ?? new FileSubscribedItemStatus
30 | {
31 | CurrentDepth = 0,
32 | TotalBlockCount = 0,
33 | DownloadedBlockCount = 0,
34 | State = SubscribedFileState.Unknown
35 | },
36 | };
37 | }
38 | }
39 |
40 | internal record SubscribedFileItemStatusEntity
41 | {
42 | public int CurrentDepth { get; init; }
43 | public int TotalBlockCount { get; init; }
44 | public int DownloadedBlockCount { get; init; }
45 | public int State { get; init; }
46 |
47 | public static SubscribedFileItemStatusEntity Import(FileSubscribedItemStatus item)
48 | {
49 | return new SubscribedFileItemStatusEntity()
50 | {
51 | CurrentDepth = item.CurrentDepth,
52 | TotalBlockCount = item.TotalBlockCount,
53 | DownloadedBlockCount = item.DownloadedBlockCount,
54 | State = (int)item.State,
55 | };
56 | }
57 |
58 | public FileSubscribedItemStatus Export()
59 | {
60 | return new FileSubscribedItemStatus()
61 | {
62 | CurrentDepth = this.CurrentDepth,
63 | TotalBlockCount = this.TotalBlockCount,
64 | DownloadedBlockCount = this.DownloadedBlockCount,
65 | State = (SubscribedFileState)this.State
66 | };
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/Internal/Entities/NodeLocationEntity.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Messages;
2 | using Omnius.Core.Net;
3 |
4 | namespace Omnius.Axus.Engines.Internal.Entities;
5 |
6 | internal record NodeLocationEntity
7 | {
8 | public string[]? Addresses { get; set; }
9 |
10 | public static NodeLocationEntity Import(NodeLocation item)
11 | {
12 | return new NodeLocationEntity()
13 | {
14 | Addresses = item.Addresses.Select(n => n.ToString()).ToArray()
15 | };
16 | }
17 |
18 | public NodeLocation Export()
19 | {
20 | return new NodeLocation(this.Addresses?.Select(n => new OmniAddress(n))?.ToArray() ?? Array.Empty());
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/Internal/Entities/OmniHashEntity.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core.Cryptography;
2 |
3 | namespace Omnius.Axus.Engines.Internal.Entities;
4 |
5 | internal record OmniHashEntity
6 | {
7 | public int AlgorithmType { get; set; }
8 | public byte[]? Value { get; set; }
9 |
10 | public static OmniHashEntity Import(OmniHash item)
11 | {
12 | return new OmniHashEntity()
13 | {
14 | AlgorithmType = (int)item.AlgorithmType,
15 | Value = item.Value.ToArray(),
16 | };
17 | }
18 |
19 | public OmniHash Export()
20 | {
21 | return new OmniHash((OmniHashAlgorithmType)this.AlgorithmType, this.Value);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/Internal/Entities/OmniSignatureEntity.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core.Cryptography;
2 |
3 | namespace Omnius.Axus.Engines.Internal.Entities;
4 |
5 | internal record OmniSignatureEntity
6 | {
7 | public string? Name { get; set; }
8 | public OmniHashEntity? Hash { get; set; }
9 |
10 | public static OmniSignatureEntity Import(OmniSignature item)
11 | {
12 | return new OmniSignatureEntity()
13 | {
14 | Name = item.Name,
15 | Hash = OmniHashEntity.Import(item.Hash),
16 | };
17 | }
18 |
19 | public OmniSignature Export()
20 | {
21 | return new OmniSignature(this.Name!, this.Hash!.Export());
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/Internal/Entities/ShoutPublishedItemEntity.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Engines.Internal.Models;
2 | using Omnius.Core.Cryptography;
3 |
4 | namespace Omnius.Axus.Engines.Internal.Entities;
5 |
6 | internal record ShoutPublishedItemEntity
7 | {
8 | public OmniSignatureEntity? Signature { get; set; }
9 | public string? Channel { get; set; }
10 | public IReadOnlyList? Authors { get; set; }
11 | public DateTime ShoutUpdatedTime { get; set; }
12 |
13 | public static ShoutPublishedItemEntity Import(ShoutPublishedItem item)
14 | {
15 | return new ShoutPublishedItemEntity()
16 | {
17 | Signature = OmniSignatureEntity.Import(item.Signature),
18 | Channel = item.Channel,
19 | Authors = item.Authors,
20 | ShoutUpdatedTime = item.ShoutUpdatedTime,
21 | };
22 | }
23 |
24 | public ShoutPublishedItem Export()
25 | {
26 | return new ShoutPublishedItem()
27 | {
28 | Signature = this.Signature?.Export() ?? OmniSignature.Empty,
29 | Channel = this.Channel ?? string.Empty,
30 | Authors = this.Authors ?? Array.Empty(),
31 | ShoutUpdatedTime = this.ShoutUpdatedTime,
32 | };
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/Internal/Entities/ShoutSubscribedItemEntity.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Engines.Internal.Models;
2 | using Omnius.Core.Cryptography;
3 |
4 | namespace Omnius.Axus.Engines.Internal.Entities;
5 |
6 | internal record ShoutSubscribedItemEntity
7 | {
8 | public OmniSignatureEntity? Signature { get; set; }
9 | public string? Channel { get; set; }
10 | public IReadOnlyList? Authors { get; set; }
11 | public DateTime ShoutUpdatedTime { get; set; }
12 |
13 | public static ShoutSubscribedItemEntity Import(ShoutSubscribedItem item)
14 | {
15 | return new ShoutSubscribedItemEntity()
16 | {
17 | Signature = OmniSignatureEntity.Import(item.Signature),
18 | Channel = item.Channel,
19 | Authors = item.Authors,
20 | ShoutUpdatedTime = item.ShoutUpdatedTime,
21 | };
22 | }
23 |
24 | public ShoutSubscribedItem Export()
25 | {
26 | return new ShoutSubscribedItem()
27 | {
28 | Signature = this.Signature?.Export() ?? OmniSignature.Empty,
29 | Channel = this.Channel ?? string.Empty,
30 | Authors = this.Authors ?? Array.Empty(),
31 | ShoutUpdatedTime = this.ShoutUpdatedTime,
32 | };
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/Internal/Models/BlockPublishedExternalItem.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core.Cryptography;
2 |
3 | namespace Omnius.Axus.Engines.Internal.Models;
4 |
5 | internal record BlockPublishedExternalItem
6 | {
7 | public required string FilePath { get; init; }
8 | public required OmniHash RootHash { get; init; }
9 | public required OmniHash BlockHash { get; init; }
10 | public required int Order { get; init; }
11 | public required long Offset { get; init; }
12 | public required int Count { get; init; }
13 | }
14 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/Internal/Models/BlockPublishedInternalItem.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core.Cryptography;
2 |
3 | namespace Omnius.Axus.Engines.Internal.Models;
4 |
5 | internal record BlockPublishedInternalItem
6 | {
7 | public required OmniHash RootHash { get; init; }
8 | public required OmniHash BlockHash { get; init; }
9 | public required int Depth { get; init; }
10 | public required int Order { get; init; }
11 | }
12 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/Internal/Models/BlockSubscribedItem.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core.Cryptography;
2 |
3 | namespace Omnius.Axus.Engines.Internal.Models;
4 |
5 | internal record BlockSubscribedItem
6 | {
7 | public required OmniHash RootHash { get; init; }
8 | public required OmniHash BlockHash { get; init; }
9 | public required int Depth { get; init; }
10 | public required int Order { get; init; }
11 | public required bool IsDownloaded { get; init; }
12 | }
13 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/Internal/Models/CachedNodeLocation.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Messages;
2 |
3 | namespace Omnius.Axus.Engines.Internal.Models;
4 |
5 | internal record CachedNodeLocation
6 | {
7 | public required NodeLocation Value { get; init; }
8 | public required DateTime LastConnectedTime { get; init; }
9 | public required DateTime UpdatedTime { get; init; }
10 | }
11 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/Internal/Models/FilePublishedItem.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core.Cryptography;
2 |
3 | namespace Omnius.Axus.Engines.Internal.Models;
4 |
5 | internal record FilePublishedItem
6 | {
7 | public required OmniHash RootHash { get; init; }
8 | public required string? FilePath { get; init; }
9 | public required int MaxBlockSize { get; init; }
10 | public required IReadOnlyList Authors { get; init; }
11 | }
12 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/Internal/Models/FileSubscribedItem.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Messages;
2 | using Omnius.Core.Cryptography;
3 |
4 | namespace Omnius.Axus.Engines.Internal.Models;
5 |
6 | internal record FileSubscribedItem
7 | {
8 | public required OmniHash RootHash { get; init; }
9 | public required IReadOnlyList Authors { get; init; }
10 | public required FileSubscribedItemStatus Status { get; init; }
11 | }
12 |
13 | internal record FileSubscribedItemStatus
14 | {
15 | public required int CurrentDepth { get; init; }
16 | public required int TotalBlockCount { get; init; }
17 | public required int DownloadedBlockCount { get; init; }
18 | public required SubscribedFileState State { get; init; }
19 | }
20 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/Internal/Models/ShoutPublishedItem.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core.Cryptography;
2 |
3 | namespace Omnius.Axus.Engines.Internal.Models;
4 |
5 | internal record ShoutPublishedItem
6 | {
7 | public required OmniSignature Signature { get; init; }
8 | public required string Channel { get; init; }
9 | public required IReadOnlyList Authors { get; init; }
10 | public required DateTime ShoutUpdatedTime { get; init; }
11 | }
12 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/Internal/Models/ShoutSubscribedItem.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core.Cryptography;
2 |
3 | namespace Omnius.Axus.Engines.Internal.Models;
4 |
5 | internal record ShoutSubscribedItem
6 | {
7 | public required OmniSignature Signature { get; init; }
8 | public required string Channel { get; init; }
9 | public required IReadOnlyList Authors { get; init; }
10 | public required DateTime ShoutUpdatedTime { get; init; }
11 | }
12 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/Internal/Session.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Messages;
2 | using Omnius.Core;
3 | using Omnius.Core.Cryptography;
4 | using Omnius.Core.Net;
5 | using Omnius.Core.Net.Connections;
6 |
7 | namespace Omnius.Axus.Engines.Internal;
8 |
9 | internal class Session : AsyncDisposableBase, ISession
10 | {
11 | public Session(IConnection connection, OmniAddress address, SessionHandshakeType handshakeType, OmniSignature signature, string scheme)
12 | {
13 | this.Connection = connection;
14 | this.Address = address;
15 | this.HandshakeType = handshakeType;
16 | this.Signature = signature;
17 | this.Scheme = scheme;
18 | }
19 |
20 | protected override async ValueTask OnDisposeAsync()
21 | {
22 | await this.Connection.DisposeAsync();
23 | }
24 |
25 | public IConnection Connection { get; }
26 |
27 | public OmniAddress Address { get; }
28 |
29 | public SessionHandshakeType HandshakeType { get; }
30 |
31 | public OmniSignature Signature { get; }
32 |
33 | public string Scheme { get; }
34 | }
35 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/Internal/StringConverter.cs:
--------------------------------------------------------------------------------
1 | using System.Text;
2 | using Omnius.Core;
3 | using Omnius.Core.Cryptography;
4 | using Omnius.Core.Cryptography.Functions;
5 | using Omnius.Core.Pipelines;
6 | using Omnius.Core.Serialization;
7 |
8 | namespace Omnius.Axus.Engines.Internal;
9 |
10 | internal static class StringConverter
11 | {
12 | private static readonly Lazy _encoding = new Lazy(() => new UTF8Encoding(false));
13 |
14 | public static string ToString(OmniHash hash)
15 | {
16 | return hash.ToString(ConvertStringType.Base16);
17 | }
18 |
19 | public static string ToString(OmniSignature signature, string channel)
20 | {
21 | using var bytesPipe = new BytesPipe(BytesPool.Shared);
22 | _encoding.Value.GetBytes(signature.ToString(), bytesPipe.Writer);
23 | _encoding.Value.GetBytes("/", bytesPipe.Writer);
24 | _encoding.Value.GetBytes(channel, bytesPipe.Writer);
25 |
26 | var hash = new OmniHash(OmniHashAlgorithmType.Sha2_256, Sha2_256.ComputeHash(bytesPipe.Reader.GetSequence()));
27 | return hash.ToString(ConvertStringType.Base16);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/NodeFinder.SessionStatus.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Engines.Internal.Models;
2 | using Omnius.Axus.Engines.Models;
3 | using Omnius.Axus.Messages;
4 | using Omnius.Core;
5 | using Omnius.Core.Collections;
6 | using Omnius.Core.Tasks;
7 |
8 | namespace Omnius.Axus.Engines;
9 |
10 | public sealed partial class NodeFinder
11 | {
12 | private sealed class SessionStatus : AsyncDisposableBase
13 | {
14 | public SessionStatus(ISession session, ReadOnlyMemory id, NodeLocation nodeLocation, IBatchActionDispatcher batchActionDispatcher)
15 | {
16 | this.Session = session;
17 | this.Id = id;
18 | this.NodeLocation = nodeLocation;
19 | this.LastReceivedTime = DateTime.UtcNow;
20 |
21 | this.ReceivedWantContentClues = new VolatileHashSet(TimeSpan.FromMinutes(3), TimeSpan.FromSeconds(30), batchActionDispatcher);
22 | }
23 |
24 | protected override async ValueTask OnDisposeAsync()
25 | {
26 | await this.Session.DisposeAsync();
27 |
28 | this.ReceivedWantContentClues.Dispose();
29 | }
30 |
31 | public ISession Session { get; }
32 |
33 | public ReadOnlyMemory Id { get; }
34 |
35 | public NodeLocation NodeLocation { get; }
36 |
37 | public DateTime LastReceivedTime { get; set; }
38 |
39 | public NodeFinderDataMessage? SendingDataMessage { get; set; } = null;
40 |
41 | public VolatileHashSet ReceivedWantContentClues { get; }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/NodeFinderException.cs:
--------------------------------------------------------------------------------
1 | public sealed class NodeFinderException : Exception
2 | {
3 | public NodeFinderException()
4 | : base()
5 | {
6 | }
7 |
8 | public NodeFinderException(string? message)
9 | : base(message)
10 | {
11 | }
12 |
13 | public NodeFinderException(string? message, Exception? innerException)
14 | : base(message, innerException)
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/NodeFinderOptions.cs:
--------------------------------------------------------------------------------
1 | namespace Omnius.Axus.Engines;
2 |
3 | public record NodeFinderOptions
4 | {
5 | public required string ConfigDirectoryPath { get; init; }
6 | public required uint MaxSessionCount { get; init; }
7 | }
8 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/NodeLocationsFetcher.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Messages;
2 |
3 | namespace Omnius.Axus.Engines;
4 |
5 | public class NodeLocationsFetcher : INodeLocationsFetcher
6 | {
7 | private static readonly NLog.Logger _logger = NLog.LogManager.GetCurrentClassLogger();
8 |
9 | private readonly string? _uri;
10 | private readonly NodeLocationsFetcherOperationType _operationType;
11 |
12 | public static NodeLocationsFetcher Create(NodeLocationsFetcherOptions options)
13 | {
14 | var nodeLocationsFetcher = new NodeLocationsFetcher(options);
15 | return nodeLocationsFetcher;
16 | }
17 |
18 | private NodeLocationsFetcher(NodeLocationsFetcherOptions options)
19 | {
20 | _uri = options.Uri;
21 | _operationType = options.OperationType;
22 | }
23 |
24 | public async ValueTask> FetchAsync(CancellationToken cancellationToken = default)
25 | {
26 | if (_operationType == NodeLocationsFetcherOperationType.HttpGet && _uri is not null)
27 | {
28 | await Task.Delay(1, cancellationToken).ConfigureAwait(false);
29 |
30 | try
31 | {
32 | using var client = new HttpClient();
33 | var text = await client.GetStringAsync(_uri, cancellationToken);
34 |
35 | var results = new List();
36 |
37 | foreach (var line in text.Split(new string[] { "\n", "\r" }, StringSplitOptions.RemoveEmptyEntries))
38 | {
39 | if (!AxusUriConverter.Instance.TryStringToNodeLocation(line, out var nodeLocation)) continue;
40 | results.Add(nodeLocation);
41 | }
42 |
43 | return results.ToArray();
44 | }
45 | catch (Exception e)
46 | {
47 | _logger.Warn(e, "Failed to fetch node locations");
48 | }
49 | }
50 |
51 | return Enumerable.Empty();
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/NodeLocationsFetcherOptions.cs:
--------------------------------------------------------------------------------
1 | namespace Omnius.Axus.Engines;
2 |
3 | public record NodeLocationsFetcherOptions
4 | {
5 | public string? Uri { get; init; }
6 | public required NodeLocationsFetcherOperationType OperationType { get; init; }
7 | }
8 |
9 | public enum NodeLocationsFetcherOperationType : byte
10 | {
11 | None = 0,
12 | HttpGet = 1,
13 | }
14 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/SessionAccepter.SessionChannels.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Concurrent;
2 | using System.Diagnostics.CodeAnalysis;
3 | using System.Threading.Channels;
4 |
5 | namespace Omnius.Axus.Engines;
6 |
7 | public sealed partial class SessionAccepter
8 | {
9 | private sealed class SessionChannels
10 | {
11 | private readonly int _capacity;
12 |
13 | private readonly ConcurrentDictionary> _sessionChannels = new();
14 |
15 | public SessionChannels(int capacity)
16 | {
17 | _capacity = capacity;
18 | }
19 |
20 | public bool TryGet(string scheme, [NotNullWhen(true)] out Channel? channel)
21 | {
22 | return _sessionChannels.TryGetValue(scheme, out channel);
23 | }
24 |
25 | public Channel GetOrCreate(string scheme)
26 | {
27 | return _sessionChannels.GetOrAdd(scheme, (_) => Channel.CreateBounded(new BoundedChannelOptions(_capacity) { FullMode = BoundedChannelFullMode.Wait }));
28 | }
29 |
30 | public bool Contains(string scheme)
31 | {
32 | return _sessionChannels.ContainsKey(scheme);
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/SessionAccepterOptions.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core.Cryptography;
2 |
3 | namespace Omnius.Axus.Engines;
4 |
5 | public record SessionAccepterOptions
6 | {
7 | public required OmniDigitalSignature DigitalSignature { get; init; }
8 | }
9 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/SessionConnectorOptions.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core.Cryptography;
2 |
3 | namespace Omnius.Axus.Engines;
4 |
5 | public record SessionConnectorOptions
6 | {
7 | public required OmniDigitalSignature DigitalSignature { get; init; }
8 | }
9 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/ShoutExchanger.SessionStatus.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core;
2 |
3 | namespace Omnius.Axus.Engines;
4 |
5 | public sealed partial class ShoutExchanger
6 | {
7 | private sealed class SessionStatus : AsyncDisposableBase
8 | {
9 | public SessionStatus(ISession session)
10 | {
11 | this.Session = session;
12 | }
13 |
14 | protected override async ValueTask OnDisposeAsync()
15 | {
16 | await this.Session.DisposeAsync();
17 | }
18 |
19 | public ISession Session { get; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/ShoutExchangerException.cs:
--------------------------------------------------------------------------------
1 | namespace Omnius.Axus.Engines;
2 |
3 | public sealed class ShoutExchangerException : Exception
4 | {
5 | public ShoutExchangerException()
6 | : base()
7 | {
8 | }
9 |
10 | public ShoutExchangerException(string? message)
11 | : base(message)
12 | {
13 | }
14 |
15 | public ShoutExchangerException(string? message, Exception? innerException)
16 | : base(message, innerException)
17 | {
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/ShoutExchangerOptions.cs:
--------------------------------------------------------------------------------
1 | namespace Omnius.Axus.Engines;
2 |
3 | public record ShoutExchangerOptions
4 | {
5 | public required uint MaxSessionCount { get; init; }
6 | }
7 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/ShoutPublisherStorageOptions.cs:
--------------------------------------------------------------------------------
1 | namespace Omnius.Axus.Engines;
2 |
3 | public record ShoutPublisherStorageOptions
4 | {
5 | public required string ConfigDirectoryPath { get; init; }
6 | }
7 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Implementations/ShoutSubscriberStorageOptions.cs:
--------------------------------------------------------------------------------
1 | namespace Omnius.Axus.Engines;
2 |
3 | public record ShoutSubscriberStorageOptions
4 | {
5 | public required string ConfigDirectoryPath { get; init; }
6 | }
7 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Interfaces/IConnectionAcceptor.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Engines.Models;
2 | using Omnius.Core.Net;
3 |
4 | namespace Omnius.Axus.Engines;
5 |
6 | public interface IConnectionAcceptor : IAsyncDisposable
7 | {
8 | ValueTask AcceptAsync(CancellationToken cancellationToken = default);
9 | ValueTask GetListenEndpointsAsync(CancellationToken cancellationToken = default);
10 | }
11 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Interfaces/IConnectionConnector.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core.Net;
2 | using Omnius.Core.Net.Connections;
3 |
4 | namespace Omnius.Axus.Engines;
5 |
6 | public interface IConnectionConnector : IAsyncDisposable
7 | {
8 | ValueTask ConnectAsync(OmniAddress address, CancellationToken cancellationToken = default);
9 | }
10 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Interfaces/IFileExchanger.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Messages;
2 |
3 | namespace Omnius.Axus.Engines;
4 |
5 | public interface IFileExchanger : IAsyncDisposable
6 | {
7 | ValueTask> GetSessionReportsAsync(CancellationToken cancellationToken = default);
8 | }
9 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Interfaces/IFilePublisherStorage.cs:
--------------------------------------------------------------------------------
1 | using System.Buffers;
2 | using Omnius.Axus.Engines.Primitives;
3 | using Omnius.Axus.Messages;
4 | using Omnius.Core.Cryptography;
5 |
6 | namespace Omnius.Axus.Engines;
7 |
8 | public interface IFilePublisherStorage : IReadOnlyFileStorage, IAsyncDisposable
9 | {
10 | ValueTask> GetPublishedFileReportsAsync(string zone, CancellationToken cancellationToken = default);
11 | ValueTask> GetPushRootHashesAsync(CancellationToken cancellationToken = default);
12 | ValueTask> GetPushBlockHashesAsync(OmniHash rootHash, CancellationToken cancellationToken = default);
13 | ValueTask ContainsPushContentAsync(OmniHash rootHash, CancellationToken cancellationToken = default);
14 | ValueTask ContainsPushBlockAsync(OmniHash rootHash, OmniHash blockHash, CancellationToken cancellationToken = default);
15 | ValueTask PublishFileAsync(string filePath, int maxBlockSize, string zone, CancellationToken cancellationToken = default);
16 | ValueTask PublishFileAsync(ReadOnlySequence sequence, int maxBlockSize, string zone, CancellationToken cancellationToken = default);
17 | ValueTask UnpublishFileAsync(string filePath, string zone, CancellationToken cancellationToken = default);
18 | ValueTask UnpublishFileAsync(OmniHash rootHash, string zone, CancellationToken cancellationToken = default);
19 | }
20 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Interfaces/IFileSubscriberStorage.cs:
--------------------------------------------------------------------------------
1 | using System.Buffers;
2 | using Omnius.Axus.Engines.Primitives;
3 | using Omnius.Axus.Messages;
4 | using Omnius.Core.Cryptography;
5 |
6 | namespace Omnius.Axus.Engines;
7 |
8 | public interface IFileSubscriberStorage : IWritableFileStorage, IAsyncDisposable
9 | {
10 | ValueTask> GetSubscribedFileReportsAsync(string zone, CancellationToken cancellationToken = default);
11 | ValueTask> GetWantRootHashesAsync(CancellationToken cancellationToken = default);
12 | ValueTask> GetWantBlockHashesAsync(OmniHash rootHash, CancellationToken cancellationToken = default);
13 | ValueTask ContainsWantContentAsync(OmniHash rootHash, CancellationToken cancellationToken = default);
14 | ValueTask ContainsWantBlockAsync(OmniHash rootHash, OmniHash blockHash, CancellationToken cancellationToken = default);
15 | ValueTask SubscribeFileAsync(OmniHash rootHash, string zone, CancellationToken cancellationToken = default);
16 | ValueTask UnsubscribeFileAsync(OmniHash rootHash, string zone, CancellationToken cancellationToken = default);
17 | ValueTask TryExportFileAsync(OmniHash rootHash, string filePath, CancellationToken cancellationToken = default);
18 | ValueTask TryExportFileAsync(OmniHash rootHash, IBufferWriter bufferWriter, CancellationToken cancellationToken = default);
19 | }
20 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Interfaces/INodeFinder.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Engines.Models;
2 | using Omnius.Axus.Messages;
3 | using Omnius.Core.Pipelines;
4 |
5 | namespace Omnius.Axus.Engines;
6 |
7 | public interface INodeFinder : IAsyncDisposable
8 | {
9 | IFuncListener> OnGetPushContentClues { get; }
10 | IFuncListener> OnGetWantContentClues { get; }
11 |
12 | ValueTask> GetSessionReportsAsync(CancellationToken cancellationToken = default);
13 | ValueTask> GetCloudNodeLocationsAsync(CancellationToken cancellationToken);
14 | ValueTask GetMyNodeLocationAsync(CancellationToken cancellationToken = default);
15 | ValueTask AddCloudNodeLocationsAsync(IEnumerable nodeLocations, CancellationToken cancellationToken = default);
16 | ValueTask FindNodeLocationsAsync(ContentClue contentClue, CancellationToken cancellationToken = default);
17 | }
18 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Interfaces/INodeLocationsFetcher.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Messages;
2 |
3 | namespace Omnius.Axus.Engines;
4 |
5 | public interface INodeLocationsFetcher
6 | {
7 | ValueTask> FetchAsync(CancellationToken cancellationToken = default);
8 | }
9 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Interfaces/ISession.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Messages;
2 | using Omnius.Core.Cryptography;
3 | using Omnius.Core.Net;
4 | using Omnius.Core.Net.Connections;
5 |
6 | namespace Omnius.Axus.Engines;
7 |
8 | public interface ISession : IAsyncDisposable
9 | {
10 | IConnection Connection { get; }
11 | OmniAddress Address { get; }
12 | SessionHandshakeType HandshakeType { get; }
13 | OmniSignature Signature { get; }
14 | string Scheme { get; }
15 | }
16 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Interfaces/ISessionAccepter.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core.Net;
2 |
3 | namespace Omnius.Axus.Engines;
4 |
5 | public interface ISessionAccepter : IAsyncDisposable
6 | {
7 | ValueTask AcceptAsync(string scheme, CancellationToken cancellationToken = default);
8 | ValueTask GetListenEndpointsAsync(CancellationToken cancellationToken = default);
9 | }
10 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Interfaces/ISessionConnector.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core.Net;
2 |
3 | namespace Omnius.Axus.Engines;
4 |
5 | public interface ISessionConnector : IAsyncDisposable
6 | {
7 | ValueTask ConnectAsync(OmniAddress address, string scheme, CancellationToken cancellationToken = default);
8 | }
9 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Interfaces/IShoutExchanger.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Messages;
2 |
3 | namespace Omnius.Axus.Engines;
4 |
5 | public interface IShoutExchanger : IAsyncDisposable
6 | {
7 | ValueTask> GetSessionReportsAsync(CancellationToken cancellationToken = default);
8 | }
9 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Interfaces/IShoutPublisherStorage.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Engines.Primitives;
2 | using Omnius.Axus.Messages;
3 | using Omnius.Core.Cryptography;
4 |
5 | namespace Omnius.Axus.Engines;
6 |
7 | public interface IShoutPublisherStorage : IReadOnlyShoutStorage, IAsyncDisposable
8 | {
9 | ValueTask> GetPublishedShoutReportsAsync(string zone, CancellationToken cancellationToken = default);
10 | ValueTask PublishShoutAsync(Shout shout, string zone, CancellationToken cancellationToken = default);
11 | ValueTask UnpublishShoutAsync(OmniSignature signature, string channel, string zone, CancellationToken cancellationToken = default);
12 | }
13 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Interfaces/IShoutSubscriberStorage.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Engines.Primitives;
2 | using Omnius.Axus.Messages;
3 | using Omnius.Core.Cryptography;
4 |
5 | namespace Omnius.Axus.Engines;
6 |
7 | public interface IShoutSubscriberStorage : IWritableShoutStorage, IAsyncDisposable
8 | {
9 | ValueTask> GetSubscribedShoutReportsAsync(string zone, CancellationToken cancellationToken = default);
10 | ValueTask SubscribeShoutAsync(OmniSignature signature, string channel, string zone, CancellationToken cancellationToken = default);
11 | ValueTask UnsubscribeShoutAsync(OmniSignature signature, string channel, string zone, CancellationToken cancellationToken = default);
12 | }
13 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Interfaces/Primitives/IReadOnlyFileStorage.cs:
--------------------------------------------------------------------------------
1 | using System.Buffers;
2 | using Omnius.Axus.Messages;
3 | using Omnius.Core.Cryptography;
4 |
5 | namespace Omnius.Axus.Engines.Primitives;
6 |
7 | public interface IReadOnlyFileStorage
8 | {
9 | ValueTask CheckConsistencyAsync(Action callback, CancellationToken cancellationToken = default);
10 | ValueTask?> TryReadBlockAsync(OmniHash rootHash, OmniHash blockHash, CancellationToken cancellationToken = default);
11 | }
12 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Interfaces/Primitives/IReadOnlyShoutStorage.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Messages;
2 | using Omnius.Core.Cryptography;
3 |
4 | namespace Omnius.Axus.Engines.Primitives;
5 |
6 | public interface IReadOnlyShoutStorage
7 | {
8 | ValueTask CheckConsistencyAsync(Action callback, CancellationToken cancellationToken = default);
9 | ValueTask> GetKeysAsync(CancellationToken cancellationToken = default);
10 | ValueTask ContainsShoutAsync(OmniSignature signature, string channel, CancellationToken cancellationToken = default);
11 | ValueTask ReadShoutUpdatedTimeAsync(OmniSignature signature, string channel, CancellationToken cancellationToken = default);
12 | ValueTask TryReadShoutAsync(OmniSignature signature, string channel, DateTime updatedTime, CancellationToken cancellationToken = default);
13 | }
14 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Interfaces/Primitives/IWritableFileStorage.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core.Cryptography;
2 |
3 | namespace Omnius.Axus.Engines.Primitives;
4 |
5 | public interface IWritableFileStorage : IReadOnlyFileStorage
6 | {
7 | ValueTask WriteBlockAsync(OmniHash rootHash, OmniHash blockHash, ReadOnlyMemory memory, CancellationToken cancellationToken = default);
8 | }
9 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Interfaces/Primitives/IWritableShoutStorage.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Messages;
2 |
3 | namespace Omnius.Axus.Engines.Primitives;
4 |
5 | public interface IWritableShoutStorage : IReadOnlyShoutStorage
6 | {
7 | ValueTask WriteShoutAsync(Shout shout, CancellationToken cancellationToken = default);
8 | }
9 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Models/ConnectionAcceptedResult.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core.Net;
2 | using Omnius.Core.Net.Connections;
3 |
4 | namespace Omnius.Axus.Engines.Models;
5 |
6 | public record ConnectionAcceptedResult
7 | {
8 | public ConnectionAcceptedResult(IConnection connection, OmniAddress address)
9 | {
10 | this.Connection = connection;
11 | this.Address = address;
12 | }
13 |
14 | public IConnection Connection { get; }
15 | public OmniAddress Address { get; }
16 | }
17 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Engines/Omnius.Axus.Engines.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Extensions/AxusUriConverterSeedExtensions.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics.CodeAnalysis;
2 | using Omnius.Axus.Interactors.Models;
3 | using Omnius.Axus.Messages;
4 |
5 | namespace Omnius.Axus.Interactors;
6 |
7 | public static class AxusUriConverterSeedExtensions
8 | {
9 | public static string SeedToString(this AxusUriConverter converter, Seed seed)
10 | {
11 | return converter.Encode("seed", 1, seed);
12 | }
13 |
14 | public static bool TryStringToSeed(this AxusUriConverter converter, string text, [NotNullWhen(true)] out Seed? seed)
15 | {
16 | seed = null;
17 | return converter.TryDecode("seed", 1, text, out seed);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Implementations/FileDownloaderOptions.cs:
--------------------------------------------------------------------------------
1 | namespace Omnius.Axus.Interactors;
2 |
3 | public record FileDownloaderOptions
4 | {
5 | public FileDownloaderOptions(string configDirectoryPath)
6 | {
7 | this.ConfigDirectoryPath = configDirectoryPath;
8 | }
9 |
10 | public string ConfigDirectoryPath { get; }
11 | }
12 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Implementations/FileUploaderOptions.cs:
--------------------------------------------------------------------------------
1 | namespace Omnius.Axus.Interactors;
2 |
3 | public record FileUploaderOptions
4 | {
5 | public FileUploaderOptions(string configDirectoryPath)
6 | {
7 | this.ConfigDirectoryPath = configDirectoryPath;
8 | }
9 |
10 | public string ConfigDirectoryPath { get; }
11 | }
12 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Implementations/Internal/Entities/CaskDownloadingItemEntity.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Interactors.Internal.Models;
2 | using Omnius.Core.Cryptography;
3 |
4 | namespace Omnius.Axus.Interactors.Internal.Entities;
5 |
6 | internal record CaskDownloadingItemEntity
7 | {
8 | public OmniSignatureEntity? Signature { get; set; }
9 | public OmniHashEntity? RootHash { get; set; }
10 | public DateTime ShoutUpdatedTime { get; set; }
11 |
12 | public static CaskDownloadingItemEntity Import(CaskDownloadingItem item)
13 | {
14 | return new CaskDownloadingItemEntity()
15 | {
16 | Signature = OmniSignatureEntity.Import(item.Signature),
17 | RootHash = OmniHashEntity.Import(item.RootHash),
18 | ShoutUpdatedTime = item.ShoutUpdatedTime,
19 | };
20 | }
21 |
22 | public CaskDownloadingItem Export()
23 | {
24 | return new CaskDownloadingItem()
25 | {
26 | Signature = this.Signature?.Export() ?? OmniSignature.Empty,
27 | RootHash = this.RootHash?.Export() ?? OmniHash.Empty,
28 | ShoutUpdatedTime = this.ShoutUpdatedTime,
29 | };
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Implementations/Internal/Entities/FileDownloadingItemEntity.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Interactors.Internal.Models;
2 | using Omnius.Axus.Interactors.Models;
3 |
4 | namespace Omnius.Axus.Interactors.Internal.Entities;
5 |
6 | internal record FileDownloadingItemEntity
7 | {
8 | public SeedEntity? Seed { get; set; }
9 | public string? FilePath { get; set; }
10 | public int State { get; set; }
11 | public DateTime CreatedTime { get; set; }
12 |
13 | public static FileDownloadingItemEntity Import(FileDownloadingItem item)
14 | {
15 | return new FileDownloadingItemEntity()
16 | {
17 | Seed = SeedEntity.Import(item.Seed),
18 | FilePath = item.FilePath,
19 | State = (int)item.State,
20 | CreatedTime = item.CreatedTime,
21 | };
22 | }
23 |
24 | public FileDownloadingItem Export()
25 | {
26 | return new FileDownloadingItem()
27 | {
28 | Seed = this.Seed?.Export() ?? Interactors.Models.Seed.Empty,
29 | FilePath = this.FilePath,
30 | State = (FileDownloadingState)this.State,
31 | CreatedTime = this.CreatedTime,
32 | };
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Implementations/Internal/Entities/FileUploadingItemEntity.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Interactors.Internal.Models;
2 | using Omnius.Axus.Interactors.Models;
3 |
4 | namespace Omnius.Axus.Interactors.Internal.Entities;
5 |
6 | internal record FileUploadingItemEntity
7 | {
8 | public string? FilePath { get; set; }
9 | public SeedEntity? Seed { get; set; }
10 | public int State { get; set; }
11 | public DateTime CreatedTime { get; set; }
12 | public DateTime UpdatedTime { get; set; }
13 |
14 | public static FileUploadingItemEntity Import(FileUploadingItem item)
15 | {
16 | return new FileUploadingItemEntity()
17 | {
18 | Seed = SeedEntity.Import(item.Seed),
19 | FilePath = item.FilePath,
20 | State = (int)item.State,
21 | CreatedTime = item.CreatedTime,
22 | };
23 | }
24 |
25 | public FileUploadingItem Export()
26 | {
27 | return new FileUploadingItem()
28 | {
29 | FilePath = this.FilePath ?? string.Empty,
30 | Seed = this.Seed?.Export() ?? Interactors.Models.Seed.Empty,
31 | State = (FileUploadingState)this.State,
32 | CreatedTime = this.CreatedTime,
33 | };
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Implementations/Internal/Entities/NoteDownloadingItemEntity.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Interactors.Internal.Models;
2 | using Omnius.Core.Cryptography;
3 |
4 | namespace Omnius.Axus.Interactors.Internal.Entities;
5 |
6 | internal record NoteDownloadingItemEntity
7 | {
8 | public OmniSignatureEntity? Signature { get; set; }
9 | public OmniHashEntity? RootHash { get; set; }
10 | public DateTime ShoutUpdatedTime { get; set; }
11 |
12 | public static NoteDownloadingItemEntity Import(NoteDownloadingItem item)
13 | {
14 | return new NoteDownloadingItemEntity()
15 | {
16 | Signature = OmniSignatureEntity.Import(item.Signature),
17 | RootHash = OmniHashEntity.Import(item.RootHash),
18 | ShoutUpdatedTime = item.ShoutUpdatedTime,
19 | };
20 | }
21 |
22 | public NoteDownloadingItem Export()
23 | {
24 | return new NoteDownloadingItem()
25 | {
26 | Signature = this.Signature?.Export() ?? OmniSignature.Empty,
27 | RootHash = this.RootHash?.Export() ?? OmniHash.Empty,
28 | ShoutUpdatedTime = this.ShoutUpdatedTime,
29 | };
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Implementations/Internal/Entities/NoteUploadingItemEntity.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Interactors.Internal.Models;
2 | using Omnius.Core.Cryptography;
3 |
4 | namespace Omnius.Axus.Interactors.Internal.Entities;
5 |
6 | internal record NoteUploadingItemEntity
7 | {
8 | public OmniSignatureEntity? Signature { get; set; }
9 | public OmniHashEntity? RootHash { get; set; }
10 |
11 | public static NoteUploadingItemEntity Import(NoteUploadingItem item)
12 | {
13 | return new NoteUploadingItemEntity()
14 | {
15 | Signature = OmniSignatureEntity.Import(item.Signature),
16 | RootHash = OmniHashEntity.Import(item.RootHash),
17 | };
18 | }
19 |
20 | public NoteUploadingItem Export()
21 | {
22 | return new NoteUploadingItem
23 | {
24 | Signature = this.Signature?.Export() ?? OmniSignature.Empty,
25 | RootHash = this.RootHash?.Export() ?? OmniHash.Empty,
26 | };
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Implementations/Internal/Entities/OmniHashEntity.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core.Cryptography;
2 |
3 | namespace Omnius.Axus.Interactors.Internal.Entities;
4 |
5 | internal record OmniHashEntity
6 | {
7 | public int AlgorithmType { get; set; }
8 | public byte[]? Value { get; set; }
9 |
10 | public static OmniHashEntity Import(OmniHash item)
11 | {
12 | return new OmniHashEntity()
13 | {
14 | AlgorithmType = (int)item.AlgorithmType,
15 | Value = item.Value.ToArray(),
16 | };
17 | }
18 |
19 | public OmniHash Export()
20 | {
21 | return new OmniHash((OmniHashAlgorithmType)this.AlgorithmType, this.Value);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Implementations/Internal/Entities/OmniSignatureEntity.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core.Cryptography;
2 |
3 | namespace Omnius.Axus.Interactors.Internal.Entities;
4 |
5 | internal record OmniSignatureEntity
6 | {
7 | public string? Name { get; set; }
8 | public OmniHashEntity? Hash { get; set; }
9 |
10 | public static OmniSignatureEntity Import(OmniSignature item)
11 | {
12 | return new OmniSignatureEntity()
13 | {
14 | Name = item.Name,
15 | Hash = OmniHashEntity.Import(item.Hash)
16 | };
17 | }
18 |
19 | public OmniSignature Export()
20 | {
21 | return new OmniSignature(this.Name!, this.Hash!.Export());
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Implementations/Internal/Entities/ProfileDownloadingItemEntity.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Interactors.Internal.Models;
2 | using Omnius.Core.Cryptography;
3 |
4 | namespace Omnius.Axus.Interactors.Internal.Entities;
5 |
6 | internal record ProfileDownloadingItemEntity
7 | {
8 | public OmniSignatureEntity? Signature { get; set; }
9 | public OmniHashEntity? RootHash { get; set; }
10 | public DateTime ShoutUpdatedTime { get; set; }
11 |
12 | public static ProfileDownloadingItemEntity Import(ProfileDownloadingItem item)
13 | {
14 | return new ProfileDownloadingItemEntity()
15 | {
16 | Signature = OmniSignatureEntity.Import(item.Signature),
17 | RootHash = OmniHashEntity.Import(item.RootHash),
18 | ShoutUpdatedTime = item.ShoutUpdatedTime,
19 | };
20 | }
21 |
22 | public ProfileDownloadingItem Export()
23 | {
24 | return new ProfileDownloadingItem
25 | {
26 | Signature = this.Signature?.Export() ?? OmniSignature.Empty,
27 | RootHash = this.RootHash?.Export() ?? OmniHash.Empty,
28 | ShoutUpdatedTime = this.ShoutUpdatedTime,
29 | };
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Implementations/Internal/Entities/ProfileUploadingItemEntity.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Interactors.Internal.Models;
2 | using Omnius.Core.Cryptography;
3 |
4 | namespace Omnius.Axus.Interactors.Internal.Entities;
5 |
6 | internal record ProfileUploadingItemEntity
7 | {
8 | public OmniSignatureEntity? Signature { get; set; }
9 | public OmniHashEntity? RootHash { get; set; }
10 |
11 | public static ProfileUploadingItemEntity Import(ProfileUploadingItem item)
12 | {
13 | return new ProfileUploadingItemEntity()
14 | {
15 | Signature = OmniSignatureEntity.Import(item.Signature),
16 | RootHash = OmniHashEntity.Import(item.RootHash),
17 | };
18 | }
19 |
20 | public ProfileUploadingItem Export()
21 | {
22 | return new ProfileUploadingItem
23 | {
24 | Signature = this.Signature?.Export() ?? OmniSignature.Empty,
25 | RootHash = this.RootHash?.Export() ?? OmniHash.Empty,
26 | };
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Implementations/Internal/Entities/SeedEntity.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Interactors.Models;
2 | using Omnius.Core.Cryptography;
3 | using Omnius.Core.RocketPack;
4 |
5 | namespace Omnius.Axus.Interactors.Internal.Entities;
6 |
7 | internal record SeedEntity
8 | {
9 | public OmniHashEntity? RootHash { get; set; }
10 | public string? Name { get; set; }
11 | public DateTime CreatedTime { get; set; }
12 | public ulong Size { get; set; }
13 |
14 | public static SeedEntity Import(Seed item)
15 | {
16 | return new SeedEntity()
17 | {
18 | RootHash = OmniHashEntity.Import(item.RootHash),
19 | Name = item.Name,
20 | Size = item.Size,
21 | CreatedTime = item.CreatedTime.ToDateTime(),
22 | };
23 | }
24 |
25 | public Seed Export()
26 | {
27 | return new Seed(this.RootHash?.Export() ?? OmniHash.Empty, this.Name ?? string.Empty, this.Size, Timestamp64.FromDateTime(this.CreatedTime));
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Implementations/Internal/Entities/SeedUploadingItemEntity.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Interactors.Internal.Models;
2 | using Omnius.Core.Cryptography;
3 |
4 | namespace Omnius.Axus.Interactors.Internal.Entities;
5 |
6 | internal record SeedUploadingItemEntity
7 | {
8 | public OmniSignatureEntity? Signature { get; set; }
9 | public OmniHashEntity? RootHash { get; set; }
10 |
11 | public static SeedUploadingItemEntity Import(CaskUploadingItem item)
12 | {
13 | return new SeedUploadingItemEntity()
14 | {
15 | Signature = OmniSignatureEntity.Import(item.Signature),
16 | RootHash = OmniHashEntity.Import(item.RootHash),
17 | };
18 | }
19 |
20 | public CaskUploadingItem Export()
21 | {
22 | return new CaskUploadingItem
23 | {
24 | Signature = this.Signature?.Export() ?? OmniSignature.Empty,
25 | RootHash = this.RootHash?.Export() ?? OmniHash.Empty,
26 | };
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Implementations/Internal/Models/CaskDownloadingItem.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core.Cryptography;
2 |
3 | namespace Omnius.Axus.Interactors.Internal.Models;
4 |
5 | internal record CaskDownloadingItem
6 | {
7 | public OmniSignature Signature { get; init; } = OmniSignature.Empty;
8 | public OmniHash RootHash { get; init; }
9 | public DateTime ShoutUpdatedTime { get; init; }
10 | }
11 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Implementations/Internal/Models/CaskUploadingItem.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core.Cryptography;
2 |
3 | namespace Omnius.Axus.Interactors.Internal.Models;
4 |
5 | internal record CaskUploadingItem
6 | {
7 | public OmniSignature Signature { get; init; } = OmniSignature.Empty;
8 | public OmniHash RootHash { get; init; }
9 | }
10 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Implementations/Internal/Models/FileDownloadingItem.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Interactors.Models;
2 |
3 | namespace Omnius.Axus.Interactors.Internal.Models;
4 |
5 | internal record FileDownloadingItem
6 | {
7 | public Seed Seed { get; init; } = Seed.Empty;
8 | public string? FilePath { get; init; }
9 | public FileDownloadingState State { get; init; }
10 | public DateTime CreatedTime { get; init; }
11 | }
12 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Implementations/Internal/Models/FileUploadingItem.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Interactors.Models;
2 |
3 | namespace Omnius.Axus.Interactors.Internal.Models;
4 |
5 | internal record FileUploadingItem
6 | {
7 | public string FilePath { get; init; } = string.Empty;
8 | public Seed Seed { get; init; } = Seed.Empty;
9 | public string Name { get; init; } = string.Empty;
10 | public long Length { get; init; }
11 | public FileUploadingState State { get; init; }
12 | public DateTime CreatedTime { get; init; }
13 | }
14 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Implementations/Internal/Models/NoteDownloadingItem.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core.Cryptography;
2 |
3 | namespace Omnius.Axus.Interactors.Internal.Models;
4 |
5 | internal record NoteDownloadingItem
6 | {
7 | public OmniSignature Signature { get; init; } = OmniSignature.Empty;
8 | public OmniHash RootHash { get; init; }
9 | public DateTime ShoutUpdatedTime { get; init; }
10 | }
11 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Implementations/Internal/Models/NoteUploadingItem.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core.Cryptography;
2 |
3 | namespace Omnius.Axus.Interactors.Internal.Models;
4 |
5 | internal record NoteUploadingItem
6 | {
7 | public OmniSignature Signature { get; init; } = OmniSignature.Empty;
8 | public OmniHash RootHash { get; init; }
9 | }
10 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Implementations/Internal/Models/ProfileDownloadingItem.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core.Cryptography;
2 |
3 | namespace Omnius.Axus.Interactors.Internal.Models;
4 |
5 | internal record ProfileDownloadingItem
6 | {
7 | public OmniSignature Signature { get; init; } = OmniSignature.Empty;
8 | public OmniHash RootHash { get; init; }
9 | public DateTime ShoutUpdatedTime { get; init; }
10 | }
11 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Implementations/Internal/Models/ProfileUploadingItem.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core.Cryptography;
2 |
3 | namespace Omnius.Axus.Interactors.Internal.Models;
4 |
5 | internal record ProfileUploadingItem
6 | {
7 | public OmniSignature Signature { get; init; } = OmniSignature.Empty;
8 | public OmniHash RootHash { get; init; }
9 | }
10 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Implementations/Internal/Models/_RocketPack/CachedCaskContent.cs:
--------------------------------------------------------------------------------
1 | namespace Omnius.Axus.Interactors.Internal.Models;
2 |
3 | public partial class CachedCaskContent
4 | {
5 | public IEnumerable ToSeeds()
6 | {
7 | var results = new List();
8 |
9 | foreach (var seed in this.Value.Seeds)
10 | {
11 | var result = new CachedSeed(this.Signature, seed);
12 | results.Add(result);
13 | }
14 |
15 | return results;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Implementations/Internal/Models/_RocketPack/CachedMemo.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Interactors.Models;
2 | using Omnius.Core;
3 | using Omnius.Core.Cryptography;
4 | using Omnius.Core.Cryptography.Functions;
5 | using Omnius.Core.Pipelines;
6 |
7 | namespace Omnius.Axus.Interactors.Internal.Models;
8 |
9 | public partial class CachedMemo
10 | {
11 | private OmniHash _selfHash = OmniHash.Empty;
12 |
13 | private OmniHash ComputeSelfHash()
14 | {
15 | var bytesPipe = new BytesPipe(BytesPool.Shared);
16 | this.Export(bytesPipe.Writer, BytesPool.Shared);
17 | var hash = new OmniHash(OmniHashAlgorithmType.Sha2_256, Sha2_256.ComputeHash(bytesPipe.Reader.GetSequence()));
18 | return hash;
19 | }
20 |
21 | public OmniHash SelfHash
22 | {
23 | get
24 | {
25 | if (_selfHash == OmniHash.Empty)
26 | {
27 | _selfHash = this.ComputeSelfHash();
28 | }
29 |
30 | return _selfHash;
31 | }
32 | }
33 |
34 | public MemoReport ToReport()
35 | {
36 | var result = new MemoReport(this.Signature, this.SelfHash, this.Value);
37 | return result;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Implementations/Internal/Models/_RocketPack/CachedNoteContent.cs:
--------------------------------------------------------------------------------
1 | namespace Omnius.Axus.Interactors.Internal.Models;
2 |
3 | public partial class CachedNoteContent
4 | {
5 | public IEnumerable ToMemos()
6 | {
7 | var results = new List();
8 |
9 | foreach (var memo in this.Value.Memos)
10 | {
11 | var result = new CachedMemo(this.Signature, memo);
12 | results.Add(result);
13 | }
14 |
15 | return results;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Implementations/Internal/Models/_RocketPack/CachedSeed.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Interactors.Models;
2 | using Omnius.Core;
3 | using Omnius.Core.Cryptography;
4 | using Omnius.Core.Cryptography.Functions;
5 | using Omnius.Core.Pipelines;
6 |
7 | namespace Omnius.Axus.Interactors.Internal.Models;
8 |
9 | public partial class CachedSeed
10 | {
11 | private OmniHash _selfHash = OmniHash.Empty;
12 |
13 | private OmniHash ComputeSelfHash()
14 | {
15 | var bytesPipe = new BytesPipe(BytesPool.Shared);
16 | this.Export(bytesPipe.Writer, BytesPool.Shared);
17 | var hash = new OmniHash(OmniHashAlgorithmType.Sha2_256, Sha2_256.ComputeHash(bytesPipe.Reader.GetSequence()));
18 | return hash;
19 | }
20 |
21 | public OmniHash SelfHash
22 | {
23 | get
24 | {
25 | if (_selfHash == OmniHash.Empty)
26 | {
27 | _selfHash = this.ComputeSelfHash();
28 | }
29 |
30 | return _selfHash;
31 | }
32 | }
33 |
34 | public SeedReport ToReport()
35 | {
36 | var result = new SeedReport(this.Signature, this.Value);
37 | return result;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Implementations/Internal/Repositories/CachedProfileRepository.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.CompilerServices;
2 | using Omnius.Axus.Interactors.Internal.Models;
3 | using Omnius.Core;
4 | using Omnius.Core.Cryptography;
5 | using Omnius.Core.Serialization;
6 | using Omnius.Core.Storages;
7 |
8 | namespace Omnius.Axus.Interactors.Internal.Repositories;
9 |
10 | internal sealed class CachedProfileRepository : DisposableBase
11 | {
12 | private IKeyValueStorage _storage;
13 | private readonly IBytesPool _bytesPool;
14 |
15 | private static readonly Lazy _base16 = new Lazy(() => new Base16(ConvertStringCase.Lower));
16 |
17 | private readonly object _lockObject = new();
18 |
19 | public CachedProfileRepository(string dirPath, IKeyValueStorageFactory keyValueStorageFactory, IBytesPool bytesPool)
20 | {
21 | _storage = keyValueStorageFactory.Create(dirPath, bytesPool);
22 | _bytesPool = bytesPool;
23 | }
24 |
25 | public async ValueTask MigrateAsync(CancellationToken cancellationToken = default)
26 | {
27 | await _storage.MigrateAsync(cancellationToken);
28 | }
29 |
30 | protected override void OnDispose(bool disposing)
31 | {
32 | _storage.Dispose();
33 | }
34 |
35 | public async IAsyncEnumerable GetSignaturesAsync([EnumeratorCancellation] CancellationToken cancellationToken = default)
36 | {
37 | await foreach (var key in _storage.GetKeysAsync(cancellationToken))
38 | {
39 | yield return OmniSignature.Parse(key);
40 | }
41 | }
42 |
43 | public async ValueTask UpsertAsync(CachedProfile content, CancellationToken cancellationToken = default)
44 | {
45 | await _storage.WriteAsync(content.Signature.ToString(), content, cancellationToken);
46 | }
47 |
48 | public async ValueTask TryReadAsync(OmniSignature signature, CancellationToken cancellationToken = default)
49 | {
50 | return await _storage.TryReadAsync(signature.ToString(), cancellationToken);
51 | }
52 |
53 | public async ValueTask TryDeleteAsync(OmniSignature signature, CancellationToken cancellationToken = default)
54 | {
55 | return await _storage.TryDeleteAsync(signature.ToString(), cancellationToken);
56 | }
57 |
58 | public async ValueTask ShrinkAsync(IEnumerable excludedSignatures, CancellationToken cancellationToken = default)
59 | {
60 | var excludedKeys = excludedSignatures.Select(n => n.ToString()).ToArray();
61 | await _storage.ShrinkAsync(excludedKeys, cancellationToken);
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Implementations/Internal/StringConverter.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core;
2 | using Omnius.Core.Cryptography;
3 | using Omnius.Core.Cryptography.Functions;
4 | using Omnius.Core.Pipelines;
5 | using Omnius.Core.Serialization;
6 |
7 | namespace Omnius.Axus.Interactors.Internal;
8 |
9 | internal static class StringConverter
10 | {
11 | public static string SignatureToString(OmniSignature signature)
12 | {
13 | using var bytesPipe = new BytesPipe(BytesPool.Shared);
14 | signature.Export(bytesPipe.Writer, BytesPool.Shared);
15 | var hash = new OmniHash(OmniHashAlgorithmType.Sha2_256, Sha2_256.ComputeHash(bytesPipe.Reader.GetSequence()));
16 | return hash.ToString(ConvertStringType.Base16);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Implementations/MemoDownloaderOptions.cs:
--------------------------------------------------------------------------------
1 | namespace Omnius.Axus.Interactors;
2 |
3 | public record MemoDownloaderOptions
4 | {
5 | public MemoDownloaderOptions(string configDirectoryPath)
6 | {
7 | this.ConfigDirectoryPath = configDirectoryPath;
8 | }
9 |
10 | public string ConfigDirectoryPath { get; }
11 | }
12 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Implementations/MemoUploaderOptions.cs:
--------------------------------------------------------------------------------
1 | namespace Omnius.Axus.Interactors;
2 |
3 | public record MemoUploaderOptions
4 | {
5 | public MemoUploaderOptions(string configDirectoryPath)
6 | {
7 | this.ConfigDirectoryPath = configDirectoryPath;
8 | }
9 |
10 | public string ConfigDirectoryPath { get; }
11 | }
12 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Implementations/ProfileDownloaderOptions.cs:
--------------------------------------------------------------------------------
1 | namespace Omnius.Axus.Interactors;
2 |
3 | public record ProfileDownloaderOptions
4 | {
5 | public ProfileDownloaderOptions(string configDirectoryPath)
6 | {
7 | this.ConfigDirectoryPath = configDirectoryPath;
8 | }
9 |
10 | public string ConfigDirectoryPath { get; }
11 | }
12 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Implementations/ProfileUploaderOptions.cs:
--------------------------------------------------------------------------------
1 | namespace Omnius.Axus.Interactors;
2 |
3 | public record ProfileUploaderOptions
4 | {
5 | public ProfileUploaderOptions(string configDirectoryPath)
6 | {
7 | this.ConfigDirectoryPath = configDirectoryPath;
8 | }
9 |
10 | public string ConfigDirectoryPath { get; }
11 | }
12 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Implementations/SeedUploaderOptions.cs:
--------------------------------------------------------------------------------
1 | namespace Omnius.Axus.Interactors;
2 |
3 | public record SeedUploaderOptions
4 | {
5 | public SeedUploaderOptions(string configDirectoryPath)
6 | {
7 | this.ConfigDirectoryPath = configDirectoryPath;
8 | }
9 |
10 | public string ConfigDirectoryPath { get; }
11 | }
12 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Interfaces/IAxusServiceProvider.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Remoting;
2 |
3 | namespace Omnius.Axus.Interactors;
4 |
5 | internal interface IAxusServiceProvider
6 | {
7 | bool IsConnected { get; }
8 |
9 | IAxusService Create();
10 | }
11 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Interfaces/IFileDownloader.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Interactors.Models;
2 |
3 | namespace Omnius.Axus.Interactors;
4 |
5 | public interface IFileDownloader : IAsyncDisposable
6 | {
7 | ValueTask> GetDownloadingFileReportsAsync(CancellationToken cancellationToken = default);
8 | ValueTask RegisterAsync(Seed seed, CancellationToken cancellationToken = default);
9 | ValueTask UnregisterAsync(Seed seed, CancellationToken cancellationToken = default);
10 | ValueTask GetConfigAsync(CancellationToken cancellationToken = default);
11 | ValueTask SetConfigAsync(FileDownloaderConfig config, CancellationToken cancellationToken = default);
12 | }
13 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Interfaces/IFileUploader.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Interactors.Models;
2 |
3 | namespace Omnius.Axus.Interactors;
4 |
5 | public interface IFileUploader : IAsyncDisposable
6 | {
7 | ValueTask> GetUploadingFileReportsAsync(CancellationToken cancellationToken = default);
8 | ValueTask RegisterAsync(string filePath, string name, CancellationToken cancellationToken = default);
9 | ValueTask UnregisterAsync(string filePath, CancellationToken cancellationToken = default);
10 | }
11 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Interfaces/IInteractorProvider.cs:
--------------------------------------------------------------------------------
1 | namespace Omnius.Axus.Interactors;
2 |
3 | public interface IInteractorProvider : IAsyncDisposable
4 | {
5 | IProfileUploader GetProfileUploader();
6 | IProfileDownloader GetProfileDownloader();
7 | IMemoUploader GetMemoUploader();
8 | IMemoDownloader GetMemoDownloader();
9 | ISeedUploader GetSeedUploader();
10 | ISeedDownloader GetSeedDownloader();
11 | IFileUploader GetFileUploader();
12 | IFileDownloader GetFileDownloader();
13 | }
14 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Interfaces/IMemoDownloader.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Interactors.Models;
2 | using Omnius.Core.Cryptography;
3 |
4 | namespace Omnius.Axus.Interactors;
5 |
6 | public interface IMemoDownloader : IAsyncDisposable
7 | {
8 | ValueTask> FindMessagesByTagAsync(string tag, CancellationToken cancellationToken = default);
9 | ValueTask FindMessageBySelfHashAsync(OmniHash selfHash, CancellationToken cancellationToken = default);
10 | ValueTask GetConfigAsync(CancellationToken cancellationToken = default);
11 | ValueTask SetConfigAsync(MemoDownloaderConfig config, CancellationToken cancellationToken = default);
12 | }
13 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Interfaces/IMemoUploader.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Interactors.Models;
2 |
3 | namespace Omnius.Axus.Interactors;
4 |
5 | public interface IMemoUploader : IAsyncDisposable
6 | {
7 | ValueTask GetConfigAsync(CancellationToken cancellationToken = default);
8 | ValueTask SetConfigAsync(MemoUploaderConfig config, CancellationToken cancellationToken = default);
9 | }
10 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Interfaces/IProfileDownloader.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Interactors.Models;
2 | using Omnius.Core.Cryptography;
3 |
4 | namespace Omnius.Axus.Interactors;
5 |
6 | public interface IProfileDownloader : IAsyncDisposable
7 | {
8 | ValueTask> GetSignaturesAsync(CancellationToken cancellationToken = default);
9 | ValueTask FindProfileBySignatureAsync(OmniSignature signature, CancellationToken cancellationToken = default);
10 | ValueTask GetConfigAsync(CancellationToken cancellationToken = default);
11 | ValueTask SetConfigAsync(ProfileDownloaderConfig config, CancellationToken cancellationToken = default);
12 | }
13 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Interfaces/IProfileUploader.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Interactors.Models;
2 |
3 | namespace Omnius.Axus.Interactors;
4 |
5 | public interface IProfileUploader : IAsyncDisposable
6 | {
7 | ValueTask GetConfigAsync(CancellationToken cancellationToken = default);
8 | ValueTask SetConfigAsync(ProfileUploaderConfig config, CancellationToken cancellationToken = default);
9 | }
10 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Interfaces/ISeedDownloader.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Interactors.Models;
2 |
3 | namespace Omnius.Axus.Interactors;
4 |
5 | public interface ISeedDownloader
6 | {
7 | ValueTask FindSeedsAsync(FindSeedsCondition condition, CancellationToken cancellationToken = default);
8 | ValueTask GetConfigAsync(CancellationToken cancellationToken = default);
9 | ValueTask SetConfigAsync(SeedDownloaderConfig config, CancellationToken cancellationToken = default);
10 | }
11 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Interfaces/ISeedUploader.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Interactors.Models;
2 |
3 | namespace Omnius.Axus.Interactors;
4 |
5 | public interface ISeedUploader : IAsyncDisposable
6 | {
7 | ValueTask GetConfigAsync(CancellationToken cancellationToken = default);
8 | ValueTask SetConfigAsync(SeedUploaderConfig config, CancellationToken cancellationToken = default);
9 | }
10 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Models/ConditionRange.cs:
--------------------------------------------------------------------------------
1 | namespace Omnius.Axus.Interactors.Models;
2 |
3 | public struct ConditionRange
4 | {
5 |
6 | }
7 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Models/FileDownloadReport.cs:
--------------------------------------------------------------------------------
1 | namespace Omnius.Axus.Interactors.Models;
2 |
3 | public record FileDownloadingReport
4 | {
5 | public FileDownloadingReport(Seed seed, string? filePath, DateTime createdTime, FileDownloadingStatus status)
6 | {
7 | this.Seed = seed;
8 | this.FilePath = filePath;
9 | this.CreatedTime = createdTime;
10 | this.Status = status;
11 | }
12 |
13 | public Seed Seed { get; }
14 | public string? FilePath { get; }
15 | public DateTime CreatedTime { get; }
16 | public FileDownloadingStatus Status { get; }
17 | }
18 |
19 | public record FileDownloadingStatus
20 | {
21 | public FileDownloadingStatus(int currentDepth, uint downloadedBlockCount, uint totalBlockCount, FileDownloadingState State)
22 | {
23 | this.CurrentDepth = currentDepth;
24 | this.DownloadedBlockCount = downloadedBlockCount;
25 | this.TotalBlockCount = totalBlockCount;
26 | this.State = State;
27 | }
28 |
29 | public int CurrentDepth { get; }
30 | public uint DownloadedBlockCount { get; }
31 | public uint TotalBlockCount { get; }
32 | public FileDownloadingState State { get; }
33 | }
34 |
35 | public enum FileDownloadingState : byte
36 | {
37 | Unknown = 0,
38 | Downloading = 1,
39 | Decoding = 2,
40 | Completed = 3,
41 | }
42 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Models/FileUploadingReport.cs:
--------------------------------------------------------------------------------
1 | namespace Omnius.Axus.Interactors.Models;
2 |
3 | public record FileUploadingReport
4 | {
5 | public FileUploadingReport(string filePath, Seed? seed, DateTime createdTime, FileUploadingStatus status)
6 | {
7 | this.FilePath = filePath;
8 | this.Seed = seed;
9 | this.CreatedTime = createdTime;
10 | this.Status = status;
11 | }
12 |
13 | public string FilePath { get; }
14 | public Seed? Seed { get; }
15 | public DateTime CreatedTime { get; }
16 | public FileUploadingStatus Status { get; }
17 | }
18 |
19 | public record FileUploadingStatus
20 | {
21 | public FileUploadingStatus(FileUploadingState State)
22 | {
23 | this.State = State;
24 | }
25 |
26 | public FileUploadingState State { get; }
27 | }
28 |
29 | public enum FileUploadingState : byte
30 | {
31 | Unknown = 0,
32 | Waiting = 1,
33 | Encoding = 2,
34 | Completed = 3,
35 | }
36 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Models/FindSeedsCondition.cs:
--------------------------------------------------------------------------------
1 | namespace Omnius.Axus.Interactors.Models;
2 |
3 | public class FindSeedsCondition
4 | {
5 | }
6 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Models/FindSeedsResult.cs:
--------------------------------------------------------------------------------
1 | namespace Omnius.Axus.Interactors.Models;
2 |
3 | public class FindSeedsResult
4 | {
5 | }
6 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Models/MemoReport.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core.Cryptography;
2 |
3 | namespace Omnius.Axus.Interactors.Models;
4 |
5 | public record MemoReport
6 | {
7 | public MemoReport(OmniSignature signature, OmniHash selfHash, Memo memo)
8 | {
9 | this.Signature = signature;
10 | this.SelfHash = selfHash;
11 | this.Memo = memo;
12 | }
13 |
14 | public OmniSignature Signature { get; }
15 | public OmniHash SelfHash { get; }
16 | public Memo Memo { get; }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Models/ProfileReport.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core.Cryptography;
2 |
3 | namespace Omnius.Axus.Interactors.Models;
4 |
5 | public record ProfileReport
6 | {
7 | public ProfileReport(OmniSignature signature, DateTime createdTime, Profile profile)
8 | {
9 | this.Signature = signature;
10 | this.CreatedTime = createdTime;
11 | this.Profile = profile;
12 | }
13 |
14 | public OmniSignature Signature { get; }
15 | public DateTime CreatedTime { get; }
16 | public Profile Profile { get; }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Models/SeedReport.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core.Cryptography;
2 |
3 | namespace Omnius.Axus.Interactors.Models;
4 |
5 | public record SeedReport
6 | {
7 | public SeedReport(OmniSignature signature, Seed seed)
8 | {
9 | this.Signature = signature;
10 | this.Seed = seed;
11 | }
12 |
13 | public OmniSignature Signature { get; }
14 | public Seed Seed { get; }
15 | }
16 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Interactors/Omnius.Axus.Interactors.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Launcher/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | [assembly: AssemblyVersion(ThisAssembly.Git.BaseVersion.Major + "." + ThisAssembly.Git.BaseVersion.Minor + "." + ThisAssembly.Git.BaseVersion.Patch)]
4 | [assembly: AssemblyFileVersion(ThisAssembly.Git.SemVer.Major + "." + ThisAssembly.Git.SemVer.Minor + "." + ThisAssembly.Git.SemVer.Patch)]
5 | [assembly: AssemblyInformationalVersion(ThisAssembly.Git.SemVer.Major + "." + ThisAssembly.Git.SemVer.Minor + "." + ThisAssembly.Git.SemVer.Patch + "-" + ThisAssembly.Git.Branch + "+" + ThisAssembly.Git.Commit)]
6 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Launcher/Helpers/DirectoryHelper.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace Omnius.Axus.Launcher.Helpers;
3 |
4 | public static class DirectoryHelper
5 | {
6 | public static void CreateOrTrancate(string path)
7 | {
8 | if (Directory.Exists(path)) Directory.Delete(path, true);
9 | Directory.CreateDirectory(path);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Launcher/Helpers/FileLock.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 |
3 | namespace Omnius.Axus.Launcher.Helpers;
4 |
5 | public sealed class FileLock
6 | {
7 | private static readonly NLog.Logger _logger = NLog.LogManager.GetCurrentClassLogger();
8 |
9 | private readonly string _path;
10 |
11 | public FileLock(string path)
12 | {
13 | _path = path;
14 | }
15 |
16 | public async Task LockAsync(TimeSpan timeout, CancellationToken cancellationToken = default)
17 | {
18 | var sw = Stopwatch.StartNew();
19 |
20 | for (; ; )
21 | {
22 | if (sw.Elapsed > timeout) throw new TimeoutException();
23 |
24 | cancellationToken.ThrowIfCancellationRequested();
25 |
26 | try
27 | {
28 | return new FileStream(_path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None, 1, FileOptions.DeleteOnClose);
29 | }
30 | catch (Exception e)
31 | {
32 | _logger.Info(e, "FileLock waiting...");
33 | }
34 |
35 | await Task.Delay(1000).ConfigureAwait(false);
36 | }
37 | }
38 |
39 | public IDisposable Lock(TimeSpan timeout, CancellationToken cancellationToken = default)
40 | {
41 | var sw = Stopwatch.StartNew();
42 |
43 | for (; ; )
44 | {
45 | if (sw.Elapsed > timeout) throw new TimeoutException();
46 |
47 | cancellationToken.ThrowIfCancellationRequested();
48 |
49 | try
50 | {
51 | return new FileStream(_path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None, 1, FileOptions.DeleteOnClose);
52 | }
53 | catch (Exception e)
54 | {
55 | _logger.Info(e, "FileLock waiting...");
56 | }
57 |
58 | Thread.Sleep(1000);
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Launcher/NLog.config:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
18 |
22 |
23 |
24 |
25 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Launcher/Omnius.Axus.Launcher.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 |
6 | false
7 | false
8 | false
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | Always
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Launcher/Options.cs:
--------------------------------------------------------------------------------
1 | using CommandLine;
2 |
3 | namespace Omnius.Axus.Launcher;
4 |
5 | public class Options
6 | {
7 | [Option('m', "mode")]
8 | public string? Mode { get; set; } = null;
9 | }
10 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Launcher/Program.cs:
--------------------------------------------------------------------------------
1 | namespace Omnius.Axus.Launcher;
2 |
3 | public class Program
4 | {
5 | private static readonly NLog.Logger _logger = NLog.LogManager.GetCurrentClassLogger();
6 |
7 | public static async Task Main(string[] args)
8 | {
9 | if (Updater.TryUpdate()) return;
10 |
11 | await Runner.RunAsync();
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Messages/AxusUriConverter.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics.CodeAnalysis;
2 | using Omnius.Core;
3 | using Omnius.Core.Pipelines;
4 | using Omnius.Core.RocketPack;
5 | using Omnius.Core.Serialization;
6 |
7 | namespace Omnius.Axus.Messages;
8 |
9 | public class AxusUriConverter
10 | {
11 | private static readonly string _schema = "axus";
12 |
13 | public static AxusUriConverter Instance { get; } = new AxusUriConverter();
14 |
15 | public string Encode(string path, int version, T message)
16 | where T : IRocketMessage
17 | {
18 | var bytesPool = BytesPool.Shared;
19 |
20 | using var inBytesPipe = new BytesPipe(bytesPool);
21 | message.Export(inBytesPipe.Writer, bytesPool);
22 |
23 | using var outBytesPipe = new BytesPipe(bytesPool);
24 | if (!OmniMessageConverter.TryWrite(inBytesPipe.Reader.GetSequence(), outBytesPipe.Writer)) throw new Exception();
25 |
26 | return AddSchemaAndPath(path, version, OmniBase.Encode(outBytesPipe.Reader.GetSequence(), ConvertStringType.Base58)!);
27 | }
28 |
29 | public bool TryDecode(string path, int version, string text, [NotNullWhen(true)] out T? message)
30 | where T : IRocketMessage
31 | {
32 | message = default!;
33 |
34 | if (!TryRemoveSchemaAndPath(text, path, version, out var value)) return false;
35 |
36 | var bytesPool = BytesPool.Shared;
37 |
38 | using var inBytesPipe = new BytesPipe(bytesPool);
39 | if (!OmniBase.TryDecode(value, inBytesPipe.Writer)) return false;
40 |
41 | using var outBytesPipe = new BytesPipe(bytesPool);
42 | if (!OmniMessageConverter.TryRead(inBytesPipe.Reader.GetSequence(), outBytesPipe.Writer)) return false;
43 |
44 | message = IRocketMessage.Import(outBytesPipe.Reader.GetSequence(), bytesPool);
45 | return true;
46 | }
47 |
48 | private static string AddSchemaAndPath(string path, int version, string value)
49 | {
50 | return $"{_schema}:{path}/v{version}/{value}";
51 | }
52 |
53 | private static bool TryRemoveSchemaAndPath(string text, string path, int version, [NotNullWhen(true)] out string? value)
54 | {
55 | var targetPrefix = $"{_schema}:{path}/v{version}/";
56 |
57 | value = null;
58 | if (!text.StartsWith(targetPrefix)) return false;
59 |
60 | value = text[targetPrefix.Length..];
61 | return true;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Messages/Extensions/AxusUriConverterNodeLocationExtensions.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics.CodeAnalysis;
2 |
3 | namespace Omnius.Axus.Messages;
4 |
5 | public static class AxusUriConverterNodeLocationExtensions
6 | {
7 | public static string NodeLocationToString(this AxusUriConverter converter, NodeLocation nodeLocation)
8 | {
9 | return converter.Encode("node", 1, nodeLocation);
10 | }
11 |
12 | public static bool TryStringToNodeLocation(this AxusUriConverter converter, string text, [NotNullWhen(true)] out NodeLocation? nodeLocation)
13 | {
14 | nodeLocation = null;
15 | return converter.TryDecode("node", 1, text, out nodeLocation);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Messages/Omnius.Axus.Messages.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Messages/_RocketPack/NodeLocation.cs:
--------------------------------------------------------------------------------
1 | namespace Omnius.Axus.Messages;
2 |
3 | public sealed partial class NodeLocation
4 | {
5 | public override string ToString()
6 | {
7 | return string.Join(",", this.Addresses);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Messages/_RocketPack/Shout.cs:
--------------------------------------------------------------------------------
1 | using System.Buffers;
2 | using Omnius.Core;
3 | using Omnius.Core.Cryptography;
4 | using Omnius.Core.Pipelines;
5 | using Omnius.Core.RocketPack;
6 |
7 | namespace Omnius.Axus.Messages;
8 |
9 | public sealed partial class Shout
10 | {
11 | public static Shout Create(string channel, Timestamp64 createdTime, IMemoryOwner value, OmniDigitalSignature digitalSignature)
12 | {
13 | using var bytesPipe = new BytesPipe();
14 | var target = new Shout(channel, createdTime, value, null);
15 | target.Export(bytesPipe.Writer, BytesPool.Shared);
16 |
17 | var certificate = OmniDigitalSignature.CreateOmniCertificate(digitalSignature, bytesPipe.Reader.GetSequence());
18 | return new Shout(channel, createdTime, value, certificate);
19 | }
20 |
21 | public bool Verify()
22 | {
23 | using var bytesPipe = new BytesPipe();
24 | var target = new Shout(this.Channel, this.UpdatedTime, this.Value, null);
25 | target.Export(bytesPipe.Writer, BytesPool.Shared);
26 |
27 | return this.Certificate?.Verify(bytesPipe.Reader.GetSequence()) ?? false;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Remoting/Omnius.Axus.Remoting.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Remoting/_RocketPack/ServiceConfig.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Remoting.Internal.Entities;
2 | using Omnius.Core.Utils;
3 |
4 | namespace Omnius.Axus.Remoting;
5 |
6 | public sealed partial class ServiceConfig
7 | {
8 | private static readonly NLog.Logger _logger = NLog.LogManager.GetCurrentClassLogger();
9 |
10 | public static ServiceConfig? LoadFile(string path)
11 | {
12 | try
13 | {
14 | if (!File.Exists(path)) return null;
15 | using var fileStream = new FileStream(path, FileMode.Open);
16 | var entity = YamlHelper.ReadStream(fileStream);
17 | return entity.Export();
18 | }
19 | catch (Exception e)
20 | {
21 | _logger.Error(e, "Unexpected Exception");
22 |
23 | return null;
24 | }
25 | }
26 |
27 | public void SaveFile(string path)
28 | {
29 | var entity = ServiceConfigEntity.Import(this);
30 | using var fileStream = new FileStream(path, FileMode.Create);
31 | YamlHelper.WriteStream(fileStream, entity);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/App.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | [assembly: AssemblyVersion(ThisAssembly.Git.BaseVersion.Major + "." + ThisAssembly.Git.BaseVersion.Minor + "." + ThisAssembly.Git.BaseVersion.Patch)]
4 | [assembly: AssemblyFileVersion(ThisAssembly.Git.SemVer.Major + "." + ThisAssembly.Git.SemVer.Minor + "." + ThisAssembly.Git.SemVer.Patch)]
5 | [assembly: AssemblyInformationalVersion(ThisAssembly.Git.SemVer.Major + "." + ThisAssembly.Git.SemVer.Minor + "." + ThisAssembly.Git.SemVer.Patch + "-" + ThisAssembly.Git.Branch + "+" + ThisAssembly.Git.Commit)]
6 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Assets/axus.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
29 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Assets/chat.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Assets/download.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Assets/menu.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
14 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Assets/peers.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
24 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Assets/search.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
17 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Assets/upload.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Configuration/AxusEnvironment.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core.Net;
2 |
3 | namespace Omnius.Axus.Ui.Desktop.Configuration;
4 |
5 | public record class AxusEnvironment
6 | {
7 | public required string StorageDirectoryPath { get; init; }
8 | public required string DatabaseDirectoryPath { get; init; }
9 | public required string LogsDirectoryPath { get; init; }
10 | public required OmniAddress ListenAddress { get; init; }
11 | }
12 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Configuration/UiStatus.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core.Helpers;
2 | using Omnius.Core.Utils;
3 |
4 | namespace Omnius.Axus.Ui.Desktop.Configuration;
5 |
6 | public sealed class UiStatus
7 | {
8 | private static readonly NLog.Logger _logger = NLog.LogManager.GetCurrentClassLogger();
9 |
10 | public int Version { get; set; }
11 | public MainWindowStatus? MainWindow { get; set; }
12 | public SettingsWindowStatus? SettingsWindow { get; set; }
13 | public TextEditWindowStatus? TextEditWindow { get; set; }
14 | public DownloadViewStatus? DownloadView { get; set; }
15 |
16 | public static async ValueTask LoadAsync(string configPath)
17 | {
18 | UiStatus? result = null;
19 |
20 | try
21 | {
22 | result = await JsonHelper.ReadFileAsync(configPath);
23 | }
24 | catch (Exception e)
25 | {
26 | _logger.Error(e, "Unexpected Exception");
27 | }
28 |
29 | result ??= new UiStatus();
30 |
31 | return result;
32 | }
33 |
34 | public async ValueTask SaveAsync(string configPath)
35 | {
36 | DirectoryHelper.CreateDirectory(Path.GetDirectoryName(configPath)!);
37 | await JsonHelper.WriteFileAsync(configPath, this, true);
38 | }
39 | }
40 |
41 | public sealed class MainWindowStatus
42 | {
43 | }
44 |
45 | public sealed class SettingsWindowStatus
46 | {
47 | }
48 |
49 | public sealed class TextEditWindowStatus
50 | {
51 | }
52 |
53 | public sealed class DownloadViewStatus
54 | {
55 | public double DataGrid_Rate_Width { get; set; }
56 | }
57 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Converters/OmniDigitalSignatureToStringConverter.cs:
--------------------------------------------------------------------------------
1 | using System.Globalization;
2 | using Avalonia.Data;
3 | using Avalonia.Data.Converters;
4 | using Omnius.Core.Cryptography;
5 |
6 | namespace Omnius.Axus.Ui.Desktop.Converters;
7 |
8 | public class OmniDigitalSignatureToStringConverter : IValueConverter
9 | {
10 | public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
11 | {
12 | if (value is OmniDigitalSignature digitalSignature)
13 | {
14 | return digitalSignature.ToString();
15 | }
16 |
17 | return new BindingNotification(new InvalidCastException(), BindingErrorType.Error);
18 | }
19 |
20 | public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
21 | {
22 | throw new NotSupportedException();
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Helpers/ConvertHelper.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 |
3 | namespace Omnius.Axus.Ui.Desktop.Helpers;
4 |
5 | public static class ConvertHelper
6 | {
7 | public static GridLength DoubleToGridLength(double value)
8 | {
9 | return new GridLength(value);
10 | }
11 |
12 | public static double GridLengthToDouble(GridLength gridLength)
13 | {
14 | return gridLength.Value;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/NLog.config:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
18 |
22 |
23 |
24 |
25 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Options.cs:
--------------------------------------------------------------------------------
1 | using CommandLine;
2 | using Omnius.Core.Net;
3 |
4 | namespace Omnius.Axus.Ui.Desktop;
5 |
6 | public class Options
7 | {
8 | [Option('l', "listen")]
9 | public string ListenAddress { get; set; } = OmniAddress.Empty.ToString();
10 |
11 | [Option('s', "storage")]
12 | public string StorageDirectoryPath { get; set; } = "../storage";
13 |
14 | [Option('v', "verbose")]
15 | public bool Verbose { get; set; } = false;
16 | }
17 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Program.cs:
--------------------------------------------------------------------------------
1 | using Avalonia;
2 |
3 | namespace Omnius.Axus.Ui.Desktop;
4 |
5 | public static class Program
6 | {
7 | public static void Main(string[] args) => BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
8 |
9 | public static AppBuilder BuildAvaloniaApp()
10 | => AppBuilder.Configure()
11 | .UsePlatformDetect()
12 | .LogToTrace();
13 | }
14 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "Omnius.Axus.Ui.Desktop": {
4 | "commandLineArgs": "\"-s\" \"./storage/ui-desktop\" \"-l\" \"tcp(ip4(127.0.0.1),43200)\" \"-v\" \"true\"",
5 | "commandName": "Project",
6 | "workingDirectory": "../../demo/0"
7 | }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Styles/OptionMenu.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
18 |
19 |
20 |
21 |
29 |
34 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Windows/DIalogs/MultilineTextEdit/MultilineTextEditWindow.xaml:
--------------------------------------------------------------------------------
1 |
21 |
22 |
23 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Windows/DIalogs/MultilineTextEdit/MultilineTextEditWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia;
2 | using Avalonia.Markup.Xaml;
3 | using Omnius.Core.Avalonia;
4 |
5 | namespace Omnius.Axus.Ui.Desktop.Windows.Dialogs.MultilineTextEdit;
6 |
7 | public partial class MultilineTextEditWindow : StatefulWindowBase
8 | {
9 | private string? _result = null;
10 |
11 | public MultilineTextEditWindow()
12 | : base()
13 | {
14 | this.InitializeComponent();
15 | }
16 |
17 | public MultilineTextEditWindow(string configDirectoryPath)
18 | : base(configDirectoryPath)
19 | {
20 | this.InitializeComponent();
21 |
22 | #if DEBUG
23 | this.AttachDevTools();
24 | #endif
25 |
26 | this.Closed += new EventHandler((_, _) => this.OnClosed());
27 | }
28 |
29 | private void InitializeComponent()
30 | {
31 | AvaloniaXamlLoader.Load(this);
32 | }
33 |
34 | public string? GetResult() => _result;
35 |
36 | private async void OnClosed()
37 | {
38 | _result = this.ViewModel?.GetResult() ?? string.Empty;
39 |
40 | if (this.ViewModel is IAsyncDisposable disposable)
41 | {
42 | await disposable.DisposeAsync();
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Windows/DIalogs/MultilineTextEdit/MultilineTextEditWindowModel.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Omnius.Axus.Ui.Desktop.Configuration;
3 | using Omnius.Core;
4 | using Omnius.Core.Avalonia;
5 | using Reactive.Bindings;
6 | using Reactive.Bindings.Extensions;
7 |
8 | namespace Omnius.Axus.Ui.Desktop.Windows.Dialogs.MultilineTextEdit;
9 |
10 | public abstract class MultilineTextEditWindowModelBase : AsyncDisposableBase
11 | {
12 | public TextEditWindowStatus? Status { get; protected set; }
13 | public ReactivePropertySlim? Text { get; protected set; }
14 | public AsyncReactiveCommand? OkCommand { get; protected set; }
15 | public AsyncReactiveCommand? CancelCommand { get; protected set; }
16 |
17 | public abstract string GetResult();
18 | }
19 |
20 | public class MultilineTextEditWindowModel : MultilineTextEditWindowModelBase
21 | {
22 | private readonly UiStatus _uiState;
23 | private readonly IClipboardService _clipboardService;
24 |
25 | private readonly CompositeDisposable _disposable = new();
26 |
27 | public MultilineTextEditWindowModel(UiStatus uiState, IClipboardService clipboardService)
28 | {
29 | _uiState = uiState;
30 | _clipboardService = clipboardService;
31 |
32 | this.Status = _uiState.TextEditWindow ??= new TextEditWindowStatus();
33 |
34 | this.Text = new ReactivePropertySlim().AddTo(_disposable);
35 | this.OkCommand = new AsyncReactiveCommand().AddTo(_disposable);
36 | this.OkCommand.Subscribe(async (state) => await this.OkAsync(state)).AddTo(_disposable);
37 | this.CancelCommand = new AsyncReactiveCommand().AddTo(_disposable);
38 | this.CancelCommand.Subscribe(async (state) => await this.CancelAsync(state)).AddTo(_disposable);
39 | }
40 |
41 | protected override async ValueTask OnDisposeAsync()
42 | {
43 | _disposable.Dispose();
44 | }
45 |
46 | public override string GetResult() => this.Text!.Value;
47 |
48 | private async Task OkAsync(object state)
49 | {
50 | var window = (Window)state;
51 | window.Close();
52 | }
53 |
54 | private async Task CancelAsync(object state)
55 | {
56 | this.Text!.Value = string.Empty;
57 |
58 | var window = (Window)state;
59 | window.Close();
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Windows/DIalogs/SinglelineTextEdit/SinglelineTextEditWindow.xaml:
--------------------------------------------------------------------------------
1 |
21 |
22 |
23 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Windows/DIalogs/SinglelineTextEdit/SinglelineTextEditWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia;
2 | using Avalonia.Markup.Xaml;
3 | using Omnius.Core.Avalonia;
4 |
5 | namespace Omnius.Axus.Ui.Desktop.Windows.Dialogs.SinglelineTextEdit;
6 |
7 | public partial class SinglelineTextEditWindow : StatefulWindowBase
8 | {
9 | private string? _result = null;
10 |
11 | public SinglelineTextEditWindow()
12 | : base()
13 | {
14 | this.InitializeComponent();
15 | }
16 |
17 | public SinglelineTextEditWindow(string configDirectoryPath)
18 | : base(configDirectoryPath)
19 | {
20 | this.InitializeComponent();
21 |
22 | #if DEBUG
23 | this.AttachDevTools();
24 | #endif
25 |
26 | this.Closed += new EventHandler((_, _) => this.OnClosed());
27 | }
28 |
29 | private void InitializeComponent()
30 | {
31 | AvaloniaXamlLoader.Load(this);
32 | }
33 |
34 | public string? GetResult() => _result;
35 |
36 | private async void OnClosed()
37 | {
38 | _result = this.ViewModel?.GetResult() ?? string.Empty;
39 |
40 | if (this.ViewModel is IAsyncDisposable disposable)
41 | {
42 | await disposable.DisposeAsync();
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Windows/DIalogs/SinglelineTextEdit/SinglelineTextEditWindowModel.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Omnius.Axus.Ui.Desktop.Configuration;
3 | using Omnius.Core;
4 | using Omnius.Core.Avalonia;
5 | using Reactive.Bindings;
6 | using Reactive.Bindings.Extensions;
7 |
8 | namespace Omnius.Axus.Ui.Desktop.Windows.Dialogs.SinglelineTextEdit;
9 |
10 | public abstract class SinglelineTextEditWindowModelBase : AsyncDisposableBase
11 | {
12 | public TextEditWindowStatus? Status { get; protected set; }
13 | public ReactivePropertySlim? Text { get; protected set; }
14 | public AsyncReactiveCommand? OkCommand { get; protected set; }
15 | public AsyncReactiveCommand? CancelCommand { get; protected set; }
16 |
17 | public abstract string GetResult();
18 | }
19 |
20 | public class SinglelineTextEditWindowModel : SinglelineTextEditWindowModelBase
21 | {
22 | private readonly UiStatus _uiState;
23 | private readonly IClipboardService _clipboardService;
24 |
25 | private readonly CompositeDisposable _disposable = new();
26 |
27 | public SinglelineTextEditWindowModel(UiStatus uiState, IClipboardService clipboardService)
28 | {
29 | _uiState = uiState;
30 | _clipboardService = clipboardService;
31 |
32 | this.Status = _uiState.TextEditWindow ??= new TextEditWindowStatus();
33 |
34 | this.Text = new ReactivePropertySlim().AddTo(_disposable);
35 | this.OkCommand = new AsyncReactiveCommand().AddTo(_disposable);
36 | this.OkCommand.Subscribe(async (state) => await this.OkAsync(state)).AddTo(_disposable);
37 | this.CancelCommand = new AsyncReactiveCommand().AddTo(_disposable);
38 | this.CancelCommand.Subscribe(async (state) => await this.CancelAsync(state)).AddTo(_disposable);
39 | }
40 |
41 | protected override async ValueTask OnDisposeAsync()
42 | {
43 | _disposable.Dispose();
44 | }
45 |
46 | public override string GetResult() => this.Text!.Value;
47 |
48 | private async Task OkAsync(object state)
49 | {
50 | var window = (Window)state;
51 | window.Close();
52 | }
53 |
54 | private async Task CancelAsync(object state)
55 | {
56 | this.Text!.Value = string.Empty;
57 |
58 | var window = (Window)state;
59 | window.Close();
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Windows/Main/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia;
2 | using Avalonia.Markup.Xaml;
3 | using Omnius.Core.Avalonia;
4 |
5 | namespace Omnius.Axus.Ui.Desktop.Windows.Main;
6 |
7 | public partial class MainWindow : StatefulWindowBase
8 | {
9 | public MainWindow()
10 | : base()
11 | {
12 | this.InitializeComponent();
13 | }
14 |
15 | public MainWindow(string configDirectoryPath)
16 | : base(configDirectoryPath)
17 | {
18 | this.InitializeComponent();
19 |
20 | #if DEBUG
21 | this.AttachDevTools();
22 | #endif
23 |
24 | this.Closed += new EventHandler((_, _) => this.OnClosed());
25 | }
26 |
27 | private void InitializeComponent()
28 | {
29 | AvaloniaXamlLoader.Load(this);
30 | }
31 |
32 | private async void OnClosed()
33 | {
34 | if (this.ViewModel is IAsyncDisposable disposable)
35 | {
36 | await disposable.DisposeAsync();
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Windows/Main/MainWindowDesignModel.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Axus.Ui.Desktop.Configuration;
2 | using Omnius.Axus.Ui.Desktop.Windows.Settings;
3 | using Omnius.Core;
4 | using Reactive.Bindings;
5 | using Reactive.Bindings.Extensions;
6 |
7 | namespace Omnius.Axus.Ui.Desktop.Windows.Main;
8 |
9 | public class MainWindowDesignModel : MainWindowModelBase
10 | {
11 | private readonly CompositeDisposable _disposable = new();
12 |
13 | public MainWindowDesignModel()
14 | {
15 | this.Status = new MainWindowStatus();
16 |
17 | this.PeersViewModel = new PeersViewDesignViewModel();
18 |
19 | this.SettingsCommand = new AsyncReactiveCommand().AddTo(_disposable);
20 | this.SettingsCommand.Subscribe(async () => await this.SettingsAsync()).AddTo(_disposable);
21 | }
22 |
23 | protected override async ValueTask OnDisposeAsync()
24 | {
25 | _disposable.Dispose();
26 |
27 | await this.PeersViewModel!.DisposeAsync();
28 | }
29 |
30 | private async Task SettingsAsync()
31 | {
32 | var window = new SettingsWindow();
33 | window.ViewModel = new SettingsWindowDesignModel();
34 | await window.ShowDialog(App.Current!.MainWindow);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Windows/Main/MainWindowModel.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.DependencyInjection;
2 | using Omnius.Axus.Ui.Desktop.Configuration;
3 | using Omnius.Axus.Ui.Desktop.Internal;
4 | using Omnius.Core;
5 | using Reactive.Bindings;
6 | using Reactive.Bindings.Extensions;
7 |
8 | namespace Omnius.Axus.Ui.Desktop.Windows.Main;
9 |
10 | public abstract class MainWindowModelBase : AsyncDisposableBase
11 | {
12 | public MainWindowStatus? Status { get; protected set; }
13 | public StatusViewModel? StatusViewModel { get; protected set; }
14 | public PeersViewModelBase? PeersViewModel { get; protected set; }
15 | public DownloadViewModel? DownloadViewModel { get; protected set; }
16 | public UploadViewModel? UploadViewModel { get; protected set; }
17 | public AsyncReactiveCommand? SettingsCommand { get; protected set; }
18 | }
19 |
20 | public class MainWindowModel : MainWindowModelBase
21 | {
22 | private readonly UiStatus _uiState;
23 | private readonly IDialogService _dialogService;
24 |
25 | private readonly CompositeDisposable _disposable = new();
26 |
27 | public MainWindowModel(UiStatus uiState, IDialogService dialogService)
28 | {
29 | _uiState = uiState;
30 | _dialogService = dialogService;
31 |
32 | this.Status = _uiState.MainWindow ??= new MainWindowStatus();
33 |
34 | var serviceProvider = Bootstrapper.Instance.GetServiceProvider();
35 |
36 | this.StatusViewModel = serviceProvider.GetRequiredService();
37 | this.PeersViewModel = serviceProvider.GetRequiredService();
38 | this.DownloadViewModel = serviceProvider.GetRequiredService();
39 | this.UploadViewModel = serviceProvider.GetRequiredService();
40 | this.SettingsCommand = new AsyncReactiveCommand().AddTo(_disposable);
41 | this.SettingsCommand.Subscribe(async () => await this.SettingsAsync()).AddTo(_disposable);
42 | }
43 |
44 | protected override async ValueTask OnDisposeAsync()
45 | {
46 | _disposable.Dispose();
47 |
48 | await this.StatusViewModel!.DisposeAsync();
49 | await this.PeersViewModel!.DisposeAsync();
50 | await this.DownloadViewModel!.DisposeAsync();
51 | await this.UploadViewModel!.DisposeAsync();
52 | }
53 |
54 | private async Task SettingsAsync()
55 | {
56 | await _dialogService.ShowSettingsWindowAsync();
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Windows/Main/Views/Download/DownloadView.xaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Avalonia.Markup.Xaml;
3 |
4 | namespace Omnius.Axus.Ui.Desktop.Windows.Main;
5 |
6 | public partial class DownloadView : UserControl
7 | {
8 | public DownloadView()
9 | {
10 | this.InitializeComponent();
11 | }
12 |
13 | private void InitializeComponent()
14 | {
15 | AvaloniaXamlLoader.Load(this);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Windows/Main/Views/Download/Models/DownloadingFileModel.cs:
--------------------------------------------------------------------------------
1 | using Generator.Equals;
2 | using Omnius.Axus.Interactors.Models;
3 | using Omnius.Core.Avalonia;
4 |
5 | namespace Omnius.Axus.Ui.Desktop.Windows.Main;
6 |
7 | [Equatable]
8 | public partial class DownloadingFileViewModel : BindableBase, ICollectionViewModel
9 | {
10 | private FileDownloadingReport? _model;
11 |
12 | public void Update(FileDownloadingReport? model)
13 | {
14 | this.Model = model;
15 | }
16 |
17 | public FileDownloadingReport? Model
18 | {
19 | get => _model;
20 | set
21 | {
22 | this.SetProperty(ref _model, value);
23 | this.RaisePropertyChanged(null);
24 | }
25 | }
26 |
27 | public string Name => this.Model?.Seed.Name ?? "";
28 |
29 | public DateTime CreatedTime => this.Model?.CreatedTime ?? DateTime.MinValue;
30 |
31 | public FileDownloadingState State => this.Model?.Status.State ?? FileDownloadingState.Unknown;
32 |
33 | public double Depth => this.Model?.Status?.CurrentDepth ?? -1;
34 |
35 | public double Rate => Math.Round(((double)(this.Model?.Status?.DownloadedBlockCount ?? 0) / this.Model?.Status?.TotalBlockCount ?? 1) * 100 * 100) / 100;
36 |
37 | public string RateText
38 | {
39 | get
40 | {
41 | var downloadedBlockCount = this.Model?.Status?.DownloadedBlockCount ?? 0;
42 | var totalBlockCount = this.Model?.Status?.TotalBlockCount ?? 1;
43 | var currentDepth = this.Model?.Status?.CurrentDepth ?? -1;
44 | var currentDepthText = currentDepth >= 0 ? currentDepth.ToString() : "?";
45 |
46 | return string.Format("[{0}/{1}] ({2})", downloadedBlockCount, totalBlockCount, currentDepthText);
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Windows/Main/Views/Peers/Models/SessionModel.cs:
--------------------------------------------------------------------------------
1 | using Generator.Equals;
2 | using Omnius.Axus.Messages;
3 | using Omnius.Core.Avalonia;
4 |
5 | namespace Omnius.Axus.Ui.Desktop.Windows.Main;
6 |
7 | [Equatable]
8 | public partial class SessionViewModel : BindableBase, ICollectionViewModel
9 | {
10 | private SessionReport? _model;
11 |
12 | public void Update(SessionReport? model)
13 | {
14 | this.Model = model;
15 | }
16 |
17 | public SessionReport? Model
18 | {
19 | get => _model;
20 | set
21 | {
22 | this.SetProperty(ref _model, value);
23 | this.RaisePropertyChanged(null);
24 | }
25 | }
26 |
27 | public string Scheme => this.Model?.Scheme ?? "";
28 |
29 | public string HandshakeType => this.Model?.HandshakeType.ToString() ?? "";
30 |
31 | public string Address => this.Model?.Address.ToString() ?? "";
32 | }
33 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Windows/Main/Views/Peers/PeersView.xaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Avalonia.Markup.Xaml;
3 |
4 | namespace Omnius.Axus.Ui.Desktop.Windows.Main;
5 |
6 | public partial class PeersView : UserControl
7 | {
8 | public PeersView()
9 | {
10 | this.InitializeComponent();
11 | }
12 |
13 | private void InitializeComponent()
14 | {
15 | AvaloniaXamlLoader.Load(this);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Windows/Main/Views/Peers/PeersViewDesignModel.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.ObjectModel;
2 | using Omnius.Axus.Messages;
3 | using Omnius.Core;
4 | using Omnius.Core.Net;
5 |
6 | namespace Omnius.Axus.Ui.Desktop.Windows.Main;
7 |
8 | public class PeersViewDesignViewModel : PeersViewModelBase
9 | {
10 | private ObservableCollection _sessionReports = new();
11 |
12 | private readonly CompositeDisposable _disposable = new();
13 |
14 | public PeersViewDesignViewModel()
15 | {
16 | _sessionReports.Add(new SessionViewModel() { Model = new SessionReport("test_service_1", SessionHandshakeType.Connected, OmniAddress.Parse("tcp(127.0.0.1,1000)")) });
17 | _sessionReports.Add(new SessionViewModel() { Model = new SessionReport("test_service_2", SessionHandshakeType.Accepted, OmniAddress.Parse("tcp(127.0.0.1,2000)")) });
18 | this.SessionReports = new ReadOnlyObservableCollection(_sessionReports);
19 | }
20 |
21 | protected override async ValueTask OnDisposeAsync()
22 | {
23 | _disposable.Dispose();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Windows/Main/Views/Search/Models/IFileSearchCondition.cs:
--------------------------------------------------------------------------------
1 | namespace Omnius.Axus.Ui.Desktop.Windows.Main;
2 |
3 | public enum FileSearchConditionType
4 | {
5 | Allow,
6 | Deny,
7 | }
8 |
9 | public interface IFileSearchCondition
10 | {
11 | FileSearchConditionType Type { get; }
12 | bool IsMatch(T value);
13 | }
14 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Windows/Main/Views/Search/Models/RangeCondition.cs:
--------------------------------------------------------------------------------
1 | namespace Omnius.Axus.Ui.Desktop.Windows.Main;
2 |
3 | public class RangeCondition : IFileSearchCondition, IEquatable>
4 | where T : IComparable, IEquatable
5 | {
6 | public FileSearchConditionType Type => throw new NotImplementedException();
7 |
8 | public T? Min { get; init; }
9 |
10 | public T? Max { get; init; }
11 |
12 | public bool IsMatch(T value)
13 | {
14 | if (this.Min is null) throw new ArgumentNullException(nameof(this.Min));
15 | if (this.Max is null) throw new ArgumentNullException(nameof(this.Max));
16 |
17 | var ret = (this.Min.CompareTo(value) <= 0 && this.Max.CompareTo(value) >= 0);
18 |
19 | return this.Type switch
20 | {
21 | FileSearchConditionType.Allow => ret,
22 | FileSearchConditionType.Deny => !ret,
23 | _ => throw new NotSupportedException(nameof(this.Type)),
24 | };
25 | }
26 |
27 | public override int GetHashCode()
28 | {
29 | return (this.Min?.GetHashCode() ?? 0) ^ (this.Max?.GetHashCode() ?? 0);
30 | }
31 |
32 | public override bool Equals(object? obj)
33 | {
34 | return this.Equals(obj as RangeCondition);
35 | }
36 |
37 | public bool Equals(RangeCondition? other)
38 | {
39 | if (other is null) return false;
40 | if (this.Type != other.Type) return false;
41 | if (!(this.Min is null ? other.Min is null : this.Min.Equals(other.Min))) return false;
42 | if (!(this.Max is null ? other.Max is null : this.Max.Equals(other.Max))) return false;
43 |
44 | return true;
45 | }
46 |
47 | public override string ToString()
48 | {
49 | var rets = new List
50 | {
51 | $"{nameof(this.Type)} = {this.Type}",
52 | $"{nameof(this.Min)} = {this.Min}",
53 | $"{nameof(this.Max)} = {this.Max}",
54 | };
55 | return string.Join(", ", rets);
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Windows/Main/Views/Search/Models/RegexCondition.cs:
--------------------------------------------------------------------------------
1 | using System.Text.RegularExpressions;
2 |
3 | namespace Omnius.Axus.Ui.Desktop.Windows.Main;
4 |
5 | public class RegexCondition : IFileSearchCondition, IEquatable
6 | {
7 | public FileSearchConditionType Type => throw new NotImplementedException();
8 |
9 | public string Value { get; init; } = string.Empty;
10 |
11 | public bool IsIgnoreCase { get; init; }
12 |
13 | private Regex? _regex;
14 |
15 | private Regex GetRegex()
16 | {
17 | var o = RegexOptions.Compiled | RegexOptions.Singleline;
18 | if (this.IsIgnoreCase)
19 | {
20 | o |= RegexOptions.IgnoreCase;
21 | }
22 |
23 | if (_regex == null)
24 | {
25 | _regex = new Regex(this.Value, o);
26 | }
27 |
28 | return _regex;
29 | }
30 |
31 | public bool IsMatch(string value)
32 | {
33 | var ret = this.GetRegex().IsMatch(value);
34 |
35 | return this.Type switch
36 | {
37 | FileSearchConditionType.Allow => ret,
38 | FileSearchConditionType.Deny => !ret,
39 | _ => throw new NotSupportedException(nameof(this.Type)),
40 | };
41 | }
42 |
43 | public override int GetHashCode()
44 | {
45 | return this.Value.GetHashCode();
46 | }
47 |
48 | public override bool Equals(object? obj)
49 | {
50 | return this.Equals(obj as RegexCondition);
51 | }
52 |
53 | public bool Equals(RegexCondition? other)
54 | {
55 | if (other is null)
56 | {
57 | return false;
58 | }
59 |
60 | if (this.Type != other.Type)
61 | {
62 | return false;
63 | }
64 |
65 | if (this.IsIgnoreCase != other.IsIgnoreCase)
66 | {
67 | return false;
68 | }
69 |
70 | return this.Value == other.Value;
71 | }
72 |
73 | public override string ToString()
74 | {
75 | var rets = new List
76 | {
77 | $"{nameof(this.Type)} = {this.Type}",
78 | $"{nameof(this.IsIgnoreCase)} = {this.IsIgnoreCase}",
79 | $"{nameof(this.Value)} = {this.Value}",
80 | };
81 | return string.Join(", ", rets);
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Windows/Main/Views/Search/SearchView.xaml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Windows/Main/Views/Search/SearchView.xaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Avalonia.Markup.Xaml;
3 |
4 | namespace Omnius.Axus.Ui.Desktop.Windows.Main;
5 |
6 | public partial class SearchView : UserControl
7 | {
8 | public SearchView()
9 | {
10 | this.InitializeComponent();
11 | }
12 |
13 | private void InitializeComponent()
14 | {
15 | AvaloniaXamlLoader.Load(this);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Windows/Main/Views/Search/SearchViewModel.cs:
--------------------------------------------------------------------------------
1 | using Omnius.Core;
2 |
3 | namespace Omnius.Axus.Ui.Desktop.Windows.Main;
4 |
5 | public class SearchViewModel : AsyncDisposableBase
6 | {
7 | private static readonly NLog.Logger _logger = NLog.LogManager.GetCurrentClassLogger();
8 |
9 | public SearchViewModel()
10 | {
11 | }
12 |
13 | protected override async ValueTask OnDisposeAsync()
14 | {
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Windows/Main/Views/Status/StatusView.xaml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Windows/Main/Views/Status/StatusView.xaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Avalonia.Markup.Xaml;
3 |
4 | namespace Omnius.Axus.Ui.Desktop.Windows.Main;
5 |
6 | public partial class StatusView : UserControl
7 | {
8 | public StatusView()
9 | {
10 | this.InitializeComponent();
11 | }
12 |
13 | private void InitializeComponent()
14 | {
15 | AvaloniaXamlLoader.Load(this);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Windows/Main/Views/Upload/Models/UploadingFileModel.cs:
--------------------------------------------------------------------------------
1 | using Generator.Equals;
2 | using Omnius.Axus.Interactors.Models;
3 | using Omnius.Core.Avalonia;
4 |
5 | namespace Omnius.Axus.Ui.Desktop.Windows.Main;
6 |
7 | [Equatable]
8 | public partial class UploadingFileViewModel : BindableBase, ICollectionViewModel
9 | {
10 | private FileUploadingReport? _model;
11 |
12 | public void Update(FileUploadingReport? model)
13 | {
14 | this.Model = model;
15 | }
16 |
17 | public FileUploadingReport? Model
18 | {
19 | get => _model;
20 | set
21 | {
22 | this.SetProperty(ref _model, value);
23 | this.RaisePropertyChanged(null);
24 | }
25 | }
26 |
27 | public string Name => Path.GetFileName(this.Model?.FilePath ?? "");
28 |
29 | public string FilePath => this.Model?.FilePath ?? "";
30 |
31 | public DateTime CreatedTime => this.Model?.CreatedTime ?? DateTime.MinValue;
32 |
33 | public FileUploadingState State => this.Model?.Status.State ?? FileUploadingState.Unknown;
34 | }
35 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Windows/Main/Views/Upload/UploadVew.xaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Avalonia.Markup.Xaml;
3 |
4 | namespace Omnius.Axus.Ui.Desktop.Windows.Main;
5 |
6 | public partial class UploadView : UserControl
7 | {
8 | public UploadView()
9 | {
10 | this.InitializeComponent();
11 | }
12 |
13 | private void InitializeComponent()
14 | {
15 | AvaloniaXamlLoader.Load(this);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Windows/Settings/SettingsWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia;
2 | using Avalonia.Markup.Xaml;
3 | using Omnius.Core.Avalonia;
4 |
5 | namespace Omnius.Axus.Ui.Desktop.Windows.Settings;
6 |
7 | public class SettingsWindow : StatefulWindowBase
8 | {
9 | public SettingsWindow()
10 | : base()
11 | {
12 | this.InitializeComponent();
13 | }
14 |
15 | public SettingsWindow(string configDirectoryPath)
16 | : base(configDirectoryPath)
17 | {
18 | this.InitializeComponent();
19 |
20 | #if DEBUG
21 | this.AttachDevTools();
22 | #endif
23 |
24 | this.Closed += new EventHandler((_, _) => this.OnClosed());
25 | }
26 |
27 | private void InitializeComponent()
28 | {
29 | AvaloniaXamlLoader.Load(this);
30 | }
31 |
32 | private async void OnClosed()
33 | {
34 | if (this.ViewModel is IAsyncDisposable disposable)
35 | {
36 | await disposable.DisposeAsync();
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Windows/Settings/SettingsWindowDesignModel.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Omnius.Axus.Ui.Desktop.Configuration;
3 | using Omnius.Core;
4 | using Reactive.Bindings;
5 | using Reactive.Bindings.Extensions;
6 |
7 | namespace Omnius.Axus.Ui.Desktop.Windows.Settings;
8 |
9 | public class SettingsWindowDesignModel : SettingsWindowModelBase
10 | {
11 | private readonly CompositeDisposable _disposable = new();
12 |
13 | public SettingsWindowDesignModel()
14 | {
15 | this.Status = new SettingsWindowStatus();
16 |
17 | this.TrustedSignaturesViewModel = new SignaturesViewDesignModel();
18 | this.TrustedSignaturesViewModel.SetTitle("Trusted Signatures");
19 | this.BlockedSignaturesViewModel = new SignaturesViewDesignModel();
20 | this.BlockedSignaturesViewModel.SetTitle("Blocked Signatures");
21 |
22 | this.OkCommand = new AsyncReactiveCommand().AddTo(_disposable);
23 | this.OkCommand.Subscribe(async (state) => await this.OkAsync(state)).AddTo(_disposable);
24 |
25 | this.CancelCommand = new AsyncReactiveCommand().AddTo(_disposable);
26 | this.CancelCommand.Subscribe(async (state) => await this.CancelAsync(state)).AddTo(_disposable);
27 | }
28 |
29 | public override async ValueTask InitializeAsync(CancellationToken cancellationToken = default)
30 | {
31 | }
32 |
33 | protected override async ValueTask OnDisposeAsync()
34 | {
35 | _disposable.Dispose();
36 | }
37 |
38 | private async Task OkAsync(object state)
39 | {
40 | var window = (Window)state;
41 | window.Close();
42 | }
43 |
44 | private async Task CancelAsync(object state)
45 | {
46 | var window = (Window)state;
47 | window.Close();
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Windows/Settings/Views/Signatures/SignaturesView.xaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Markup.Xaml;
2 | using Omnius.Core.Avalonia;
3 |
4 | namespace Omnius.Axus.Ui.Desktop.Windows.Settings;
5 |
6 | public partial class SignaturesView : StatefulUserControl
7 | {
8 | public SignaturesView()
9 | {
10 | this.InitializeComponent();
11 | }
12 |
13 | private void InitializeComponent()
14 | {
15 | AvaloniaXamlLoader.Load(this);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/Windows/Settings/Views/Signatures/SignaturesViewDesignModel.cs:
--------------------------------------------------------------------------------
1 | using System.Reactive.Disposables;
2 | using Omnius.Core.Cryptography;
3 | using Reactive.Bindings;
4 | using Reactive.Bindings.Extensions;
5 |
6 | namespace Omnius.Axus.Ui.Desktop.Windows.Settings;
7 |
8 | public class SignaturesViewDesignModel : SignaturesViewModelBase
9 | {
10 | private readonly CompositeDisposable _disposable = new();
11 |
12 | public SignaturesViewDesignModel()
13 | {
14 | this.Title = new ReactivePropertySlim().AddTo(_disposable);
15 |
16 | this.AddCommand = new AsyncReactiveCommand().AddTo(_disposable);
17 | this.AddCommand.Subscribe(async () => await this.RegisterAsync()).AddTo(_disposable);
18 |
19 | var sampleSignature1 = OmniDigitalSignature.Create("sample1", OmniDigitalSignatureAlgorithmType.EcDsa_P521_Sha2_256).GetOmniSignature();
20 | var sampleSignature2 = OmniDigitalSignature.Create("sample2", OmniDigitalSignatureAlgorithmType.EcDsa_P521_Sha2_256).GetOmniSignature();
21 |
22 | this.Signatures = new(new[] { sampleSignature1, sampleSignature2 });
23 | this.SelectedSignatures = new();
24 |
25 | this.ItemDeleteCommand = new AsyncReactiveCommand().AddTo(_disposable);
26 | this.ItemDeleteCommand.Subscribe(async () => await this.ItemDeleteAsync()).AddTo(_disposable);
27 |
28 | this.ItemCopySignatureCommand = new AsyncReactiveCommand().AddTo(_disposable);
29 | this.ItemCopySignatureCommand.Subscribe(async () => await this.ItemCopySeedAsync()).AddTo(_disposable);
30 | }
31 |
32 | protected override async ValueTask OnDisposeAsync()
33 | {
34 | _disposable.Dispose();
35 | }
36 |
37 | public override string GetTitle()
38 | {
39 | return this.Title?.Value ?? string.Empty;
40 | }
41 |
42 | public override void SetTitle(string title)
43 | {
44 | this.Title!.Value = title;
45 | }
46 |
47 | public override IEnumerable GetSignatures()
48 | {
49 | return Array.Empty();
50 | }
51 |
52 | public override void SetSignatures(IEnumerable signatures)
53 | {
54 | }
55 |
56 | private async Task RegisterAsync()
57 | {
58 | }
59 |
60 | private async Task ItemDeleteAsync()
61 | {
62 | }
63 |
64 | private async Task ItemCopySeedAsync()
65 | {
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Ui.Desktop/nuget.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Utils/Extentions/LiteDatabaseExtensions.cs:
--------------------------------------------------------------------------------
1 | using LiteDB;
2 |
3 | namespace Omnius.Axus.Utils;
4 |
5 | public static class LiteDatabaseExtensions
6 | {
7 | public static int GetDocumentVersion(this ILiteDatabase database, string name)
8 | {
9 | var col = database.GetCollection("_document_status");
10 |
11 | var entry = col.FindById(name);
12 | if (entry is null) return 0;
13 |
14 | return entry.Version;
15 | }
16 |
17 | public static void SetDocumentVersion(this ILiteDatabase database, string name, int version)
18 | {
19 | var col = database.GetCollection("_document_status");
20 |
21 | col.Upsert(new DocumentStatusEntity() { Name = name, Version = version });
22 | }
23 |
24 | private sealed class DocumentStatusEntity
25 | {
26 | [BsonId]
27 | public string? Name { get; set; }
28 |
29 | public int Version { get; set; }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/Omnius.Axus.Utils/Omnius.Axus.Utils.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/style.ruleset:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/test/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | false
9 | true
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/test/Omnius.Axus.Engines.Tests/NLog.config:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
12 |
13 |
14 |
15 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/test/Omnius.Axus.Engines.Tests/Omnius.Axus.Engines.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Omnius.Axus.Engines
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 | Always
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/test/Omnius.Axus.IntegrationTests/NLog.config:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
12 |
13 |
14 |
15 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/test/Omnius.Axus.IntegrationTests/Omnius.Axus.IntegrationTests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Omnius.Axus.IntegrationTests
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 | Always
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------