├── nuget └── .gitkeep ├── Aurum.Interop ├── paket.references ├── paket.template ├── Aurum.Interop.fsproj ├── LogStream.fs └── ProcessWrapper.fs ├── Aurum.Filesystem ├── paket.references ├── paket.template └── Aurum.Filesystem.fsproj ├── docfx_project ├── articles │ ├── intro.md │ └── toc.yml ├── api │ ├── .gitignore │ └── index.md ├── toc.yml ├── .gitignore ├── index.md └── docfx.json ├── docs ├── img │ └── logo.png └── Share-Links.md ├── Aurum.DataProtection ├── paket.references ├── paket.template ├── Windows.fs └── Aurum.DataProtection.fsproj ├── global.json ├── Aurum.Configuration ├── paket.references ├── SubscriptionAdapter │ ├── OOCv1.fs │ └── V2rayNBase64.fs ├── Base.fs ├── paket.template ├── Sing │ ├── Base.fs │ ├── Shared.fs │ ├── DNS.fs │ ├── Routing.fs │ ├── Outbound.fs │ └── Inbound.fs ├── Shared │ ├── Adapter.fs │ ├── Subscription.fs │ ├── Shadowsocks.fs │ ├── Routing.fs │ └── V2fly.fs ├── V2fly │ ├── Base.fs │ ├── Inbound.fs │ ├── Routing.fs │ └── Outbound.fs ├── AdapterTypes │ └── VMessLegacyShare.fs ├── Aurum.Configuration.fsproj └── ShareLinks.fs ├── renovate.json ├── Aurum ├── paket.references ├── Exceptions.fs ├── paket.template ├── SnakeCase.fs ├── Aurum.fsproj └── Helpers.fs ├── .gitignore ├── .editorconfig ├── nuget.config ├── .config └── dotnet-tools.json ├── paket.dependencies ├── .github └── workflows │ ├── publish-myget.yml │ ├── build.yml │ └── publish-github.yml ├── README.md ├── Aurum.sln.DotSettings ├── Aurum.sln ├── paket.lock └── LICENSE /nuget/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Aurum.Interop/paket.references: -------------------------------------------------------------------------------- 1 | FSharp.Control.Reactive -------------------------------------------------------------------------------- /Aurum.Filesystem/paket.references: -------------------------------------------------------------------------------- 1 | FSharp.Core 2 | FSharpPlus 3 | -------------------------------------------------------------------------------- /docfx_project/articles/intro.md: -------------------------------------------------------------------------------- 1 | # Add your introductions here! 2 | -------------------------------------------------------------------------------- /docfx_project/articles/toc.yml: -------------------------------------------------------------------------------- 1 | - name: Introduction 2 | href: intro.md 3 | -------------------------------------------------------------------------------- /docs/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shadowsocks-NET/Aurum/HEAD/docs/img/logo.png -------------------------------------------------------------------------------- /Aurum.DataProtection/paket.references: -------------------------------------------------------------------------------- 1 | FSharp.Core 2 | System.Security.Cryptography.ProtectedData 3 | -------------------------------------------------------------------------------- /global.json: -------------------------------------------------------------------------------- 1 | { 2 | "sdk": { 3 | "rollForward": "latestMajor", 4 | "allowPrerelease": false 5 | } 6 | } -------------------------------------------------------------------------------- /docfx_project/api/.gitignore: -------------------------------------------------------------------------------- 1 | ############### 2 | # temp file # 3 | ############### 4 | *.yml 5 | .manifest 6 | -------------------------------------------------------------------------------- /Aurum.Configuration/paket.references: -------------------------------------------------------------------------------- 1 | FSharp.SystemTextJson 2 | Microsoft.AspNetCore.WebUtilities 3 | Serilog 4 | Nanoid 5 | FSharpPlus 6 | -------------------------------------------------------------------------------- /docfx_project/toc.yml: -------------------------------------------------------------------------------- 1 | - name: Articles 2 | href: articles/ 3 | - name: Api Documentation 4 | href: api/ 5 | homepage: api/index.md 6 | -------------------------------------------------------------------------------- /docfx_project/api/index.md: -------------------------------------------------------------------------------- 1 | # PLACEHOLDER 2 | TODO: Add .NET projects to the *src* folder and run `docfx` to generate **REAL** *API Documentation*! 3 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "config:base" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /Aurum/paket.references: -------------------------------------------------------------------------------- 1 | Microsoft.Extensions.Primitives 2 | Microsoft.AspNetCore.WebUtilities 3 | FSharp.Json 4 | FSharp.SystemTextJson 5 | Messerli.ChangeCase 6 | Aether 7 | FSharpPlus 8 | -------------------------------------------------------------------------------- /docfx_project/.gitignore: -------------------------------------------------------------------------------- 1 | ############### 2 | # folder # 3 | ############### 4 | /**/DROP/ 5 | /**/TEMP/ 6 | /**/packages/ 7 | /**/bin/ 8 | /**/obj/ 9 | _site 10 | -------------------------------------------------------------------------------- /Aurum/Exceptions.fs: -------------------------------------------------------------------------------- 1 | [] 2 | module Aurum.Exceptions 3 | 4 | exception ShareLinkFormatException of string 5 | exception ConfigurationParameterException of string 6 | exception RuleTypeNotMatchException 7 | -------------------------------------------------------------------------------- /Aurum.Configuration/SubscriptionAdapter/OOCv1.fs: -------------------------------------------------------------------------------- 1 | module Aurum.Configuration.SubscriptionAdapter.OOCv1 2 | 3 | type OocApiToken = 4 | { version: int 5 | baseUrl: string 6 | secret: string 7 | userId: string } 8 | -------------------------------------------------------------------------------- /Aurum.Configuration/Base.fs: -------------------------------------------------------------------------------- 1 | module Aurum.Configuration.Base 2 | 3 | open Aurum.Configuration.Sing.Base 4 | open Aurum.Configuration.V2fly.Base 5 | 6 | type Backend = 7 | | SingBox of SingBaseConfiguration 8 | | V2fly of V2flyBaseConfiguration 9 | -------------------------------------------------------------------------------- /Aurum/paket.template: -------------------------------------------------------------------------------- 1 | type project 2 | id Aurum 3 | version 0.1.0-beta.1 4 | authors Shanoa Ice 5 | description 6 | Helper library for the Aurum project. 7 | licenseExpression LGPL-3.0-only 8 | repositoryUrl https://github.com/Shadowsocks-NET/Aurum 9 | -------------------------------------------------------------------------------- /docfx_project/index.md: -------------------------------------------------------------------------------- 1 | # This is the **HOMEPAGE**. 2 | Refer to [Markdown](http://daringfireball.net/projects/markdown/) for how to write markdown files. 3 | ## Quick Start Notes: 4 | 1. Add images to the *images* folder if the file is referencing an image. 5 | -------------------------------------------------------------------------------- /Aurum.Interop/paket.template: -------------------------------------------------------------------------------- 1 | type project 2 | id Aurum.Interop 3 | version 0.1.0-beta.1 4 | authors Shanoa Ice 5 | description 6 | Program interop component library for the Aurum project. 7 | licenseExpression LGPL-3.0-only 8 | repositoryUrl https://github.com/Shadowsocks-NET/Aurum 9 | -------------------------------------------------------------------------------- /Aurum.DataProtection/paket.template: -------------------------------------------------------------------------------- 1 | type project 2 | id Aurum.DataProtection 3 | version 0.1.0-beta.1 4 | authors Shanoa Ice 5 | description 6 | Data protection component for the Aurum project. 7 | licenseExpression LGPL-3.0-only 8 | repositoryUrl https://github.com/Shadowsocks-NET/Aurum 9 | -------------------------------------------------------------------------------- /Aurum.Filesystem/paket.template: -------------------------------------------------------------------------------- 1 | type project 2 | id Aurum.AssetManagement 3 | version 0.1.0-alpha.1 4 | authors Shanoa Ice 5 | description 6 | Asset Management component of the Aurum project. 7 | licenseExpression LGPL-3.0-only 8 | repositoryUrl https://github.com/Shadowsocks-NET/Aurum 9 | -------------------------------------------------------------------------------- /Aurum.Configuration/paket.template: -------------------------------------------------------------------------------- 1 | type project 2 | id Aurum.Configuration 3 | version 0.1.0-beta.1 4 | authors Shanoa Ice 5 | description 6 | Configuration generation component for the Aurum project. 7 | licenseExpression LGPL-3.0-only 8 | repositoryUrl https://github.com/Shadowsocks-NET/Aurum 9 | -------------------------------------------------------------------------------- /Aurum.Configuration/Sing/Base.fs: -------------------------------------------------------------------------------- 1 | module Aurum.Configuration.Sing.Base 2 | 3 | open Aurum.Configuration.Sing.Outbound 4 | 5 | type SingBaseConfiguration = 6 | { dns: obj 7 | log: obj 8 | inbounds: obj list 9 | outbounds: Outbounds list 10 | route: obj 11 | experimental: obj } 12 | -------------------------------------------------------------------------------- /Aurum.Configuration/SubscriptionAdapter/V2rayNBase64.fs: -------------------------------------------------------------------------------- 1 | module Aurum.Configuration.SubscriptionAdapter.V2rayNBase64 2 | 3 | open Aurum 4 | 5 | let extractShareLinks content = 6 | let decodedBase64 = decodeBase64 content 7 | 8 | decodedBase64.Split "\n" 9 | |> List.ofArray 10 | |> List.map (fun link -> link.Substring 8) 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | obj/ 3 | /packages/ 4 | riderModule.iml 5 | /_ReSharper.Caches/ 6 | .vs 7 | .vscode 8 | .idea 9 | 10 | .fake 11 | .ionide 12 | 13 | #Paket dependency manager 14 | .paket/ 15 | paket-files/ 16 | paket-cache/ 17 | 18 | #nuget files 19 | nuget/**/* 20 | !.gitkeep 21 | 22 | #fsdocs 23 | tmp 24 | .fsdocs 25 | output 26 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: https://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | [*] 7 | indent_style = space 8 | indent_size = 4 9 | end_of_line = crlf 10 | charset = utf-8 11 | trim_trailing_whitespace = true 12 | insert_final_newline = true 13 | 14 | [*.{yml,yaml,fs,fsx}] 15 | indent_size = 2 16 | -------------------------------------------------------------------------------- /nuget.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Aurum/SnakeCase.fs: -------------------------------------------------------------------------------- 1 | module System.Text.Json.JsonNamingPolicy 2 | 3 | open System.Text.Json 4 | open Messerli.ChangeCase 5 | 6 | type SnakeCaseNamingPolicy() = 7 | inherit JsonNamingPolicy() 8 | 9 | override this.ConvertName(name) = name.ToSnakeCase() 10 | 11 | /// Added by Sing Configuration Generator. 12 | /// 13 | /// This naming policy converts all names to lower-cased snake case, such as PascalCase -> pascal_case 14 | let SnakeCase = SnakeCaseNamingPolicy() 15 | -------------------------------------------------------------------------------- /.config/dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "paket": { 6 | "version": "8.0.0", 7 | "commands": [ 8 | "paket" 9 | ] 10 | }, 11 | "fake-cli": { 12 | "version": "6.0.0", 13 | "commands": [ 14 | "fake" 15 | ] 16 | }, 17 | "fantomas": { 18 | "version": "6.2.3", 19 | "commands": [ 20 | "fantomas" 21 | ] 22 | }, 23 | "fsdocs-tool": { 24 | "version": "19.1.1", 25 | "commands": [ 26 | "fsdocs" 27 | ] 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /paket.dependencies: -------------------------------------------------------------------------------- 1 | source https://api.nuget.org/v3/index.json 2 | cache ./paket-cache versions: current 3 | 4 | framework: net7.0 5 | 6 | nuget Akka.FSharp 7 | nuget Akka.Hosting 8 | nuget sqlite-net-pcl 9 | nuget Serilog.Sinks.Console 10 | nuget Serilog.Sinks.File 11 | nuget Microsoft.AspNetCore.WebUtilities 12 | nuget Nanoid 13 | nuget FSharp.Json 14 | nuget FSharp.SystemTextJson 15 | nuget FSharp.Core 16 | nuget Aether 17 | nuget System.Security.Cryptography.ProtectedData 18 | nuget ProtoBuf.FSharp 19 | nuget FSharp.Control.Reactive 20 | nuget FSharpPlus 21 | nuget Messerli.ChangeCase 22 | -------------------------------------------------------------------------------- /Aurum.Configuration/Shared/Adapter.fs: -------------------------------------------------------------------------------- 1 | module Aurum.Configuration.Shared.Adapter 2 | 3 | open Aurum.Configuration.Shared.V2fly 4 | open Aurum.Configuration.Shared.Shadowsocks 5 | 6 | type SharedConfigObject = { TcpFastOpen: bool } 7 | 8 | type ConfigurationFamily = 9 | | V2fly of V2flyObject 10 | | Shadowsocks of ShadowsocksObject 11 | 12 | type ConfigurationEntry = 13 | { Name: string 14 | Config: ConfigurationFamily } 15 | 16 | module ConfigurationEntry = 17 | let inline _Name f p = 18 | f p.Name <&> fun x -> { p with Name = x } 19 | 20 | let createConfigurationEntry name config = { Name = name; Config = config } 21 | -------------------------------------------------------------------------------- /Aurum.DataProtection/Windows.fs: -------------------------------------------------------------------------------- 1 | namespace Aurum.DataProtection 2 | 3 | module Windows = 4 | let encryptString (data: string) = 5 | let rawBytes = System.Text.Encoding.UTF8.GetBytes data 6 | 7 | System.Security.Cryptography.ProtectedData.Protect( 8 | rawBytes, 9 | null, 10 | System.Security.Cryptography.DataProtectionScope.CurrentUser 11 | ) 12 | 13 | let decryptString protectedData = 14 | let decryptedBytes = 15 | System.Security.Cryptography.ProtectedData.Unprotect( 16 | protectedData, 17 | null, 18 | System.Security.Cryptography.DataProtectionScope.CurrentUser 19 | ) 20 | 21 | System.Text.Encoding.UTF8.GetString decryptedBytes 22 | -------------------------------------------------------------------------------- /Aurum.Configuration/V2fly/Base.fs: -------------------------------------------------------------------------------- 1 | module Aurum.Configuration.V2fly.Base 2 | 3 | open Aurum.Configuration.V2fly.Inbound 4 | open Aurum.Configuration.V2fly.Outbound 5 | open Aurum.Configuration.V2fly.Routing 6 | 7 | type LogLevel = 8 | | Debug 9 | | Info 10 | | Warning 11 | | Error 12 | | None 13 | 14 | type LogObject = 15 | { Access: string option 16 | Error: string option 17 | Loglevel: LogLevel } 18 | 19 | static member Access_ = (fun a -> a.Access), (fun b a -> { a with Access = b }) 20 | 21 | static member Error_ = (fun a -> a.Error), (fun b a -> { a with Error = b }) 22 | 23 | static member Loglevel_ = (fun a -> a.Loglevel), (fun b a -> { a with Loglevel = b }) 24 | 25 | type V2flyBaseConfiguration = 26 | { Log: LogObject 27 | Routing: RoutingObject 28 | Inbounds: InboundObject list 29 | Outbounds: OutboundObject list } 30 | -------------------------------------------------------------------------------- /Aurum.Interop/Aurum.Interop.fsproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | true 6 | Aurum.Interop 7 | 0.1.0-beta.1 8 | Shanoa Ice 9 | Process Interop Component for the Aurum project. 10 | git 11 | https://github.com/Shadowsocks-NET/Aurum 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Aurum/Aurum.fsproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | true 6 | Aurum 7 | 0.1.0-beta.1 8 | Shanoa Ice 9 | Helper library for the Aurum project. 10 | git 11 | https://github.com/Shadowsocks-NET/Aurum 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Aurum.Interop/LogStream.fs: -------------------------------------------------------------------------------- 1 | module Aurum.Interop.LogStream 2 | 3 | open System.Text.RegularExpressions 4 | open FSharp.Control.Reactive 5 | 6 | type LogEntry = 7 | | General of string 8 | | Error of string 9 | | Warning of string 10 | | Info of string 11 | | Debug of string 12 | 13 | let matchLog logContent = 14 | let regexMatcher = Regex(@"\[(Debug|Info|Warning|Error)\]") 15 | let result = regexMatcher.Match(logContent) 16 | 17 | if not result.Success then 18 | General logContent 19 | else 20 | match result.Captures.[0].Value with 21 | | "Debug" -> Debug logContent 22 | | "Info" -> Info logContent 23 | | "Warning" -> Warning logContent 24 | | "Error" -> Error logContent 25 | | _ -> General logContent 26 | 27 | type LogEvent() = 28 | let event = Event() 29 | 30 | [] 31 | member this.Event = event.Publish 32 | 33 | member this.Trigger(log) = event.Trigger(matchLog log) 34 | 35 | let logStream = LogEvent() 36 | -------------------------------------------------------------------------------- /.github/workflows/publish-myget.yml: -------------------------------------------------------------------------------- 1 | name: Publish MyGet Packages 2 | 3 | on: 4 | push: 5 | tags: 6 | - 'myget-v*' 7 | 8 | env: 9 | DOTNET_VERSION: ${{ vars.DOTNET_VERSION }} 10 | 11 | jobs: 12 | publish_upload: 13 | name: Publish MyGet Packages 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - uses: actions/checkout@v4 18 | 19 | - name: Setup .NET Core 20 | uses: actions/setup-dotnet@v4 21 | with: 22 | dotnet-version: ${{ env.DOTNET_VERSION }} 23 | 24 | - name: Install buildtools 25 | run: dotnet tool restore 26 | 27 | - name: Install dependencies 28 | run: dotnet paket restore 29 | 30 | - name: Pack and upload NuGet package 31 | run: | 32 | dotnet pack -c Release 33 | dotnet nuget push Aurum/bin/Release/*.nupkg --skip-duplicate --no-symbols -s https://www.myget.org/F/aurum/api/v3/index.json -k ${{ secrets.MYGET_API_KEY }} 34 | dotnet nuget push Aurum.*/bin/Release/*.nupkg --skip-duplicate --no-symbols -s https://www.myget.org/F/aurum/api/v3/index.json -k ${{ secrets.MYGET_API_KEY }} 35 | -------------------------------------------------------------------------------- /Aurum.Configuration/Shared/Subscription.fs: -------------------------------------------------------------------------------- 1 | module Aurum.Configuration.Shared.Share 2 | 3 | open Aurum.Configuration.SubscriptionAdapter.OOCv1 4 | open FSharpPlus.Lens 5 | 6 | type Subscriptions = 7 | | Base64 of url: string 8 | | Clash of url: string // WIP 9 | | OocV1 of apiToken: OocApiToken // WIP 10 | | SingOutbound of url: OocApiToken 11 | 12 | module Subscriptions = 13 | let inline _Base64 f = 14 | prism' 15 | Base64 16 | (fun x -> 17 | match x with 18 | | Base64 x -> Some x 19 | | _ -> None) 20 | f 21 | 22 | let inline _Clash f = 23 | prism' 24 | Clash 25 | (fun x -> 26 | match x with 27 | | Clash x -> Some x 28 | | _ -> None) 29 | f 30 | 31 | let inline _OocV1 f = 32 | prism' 33 | OocV1 34 | (fun x -> 35 | match x with 36 | | OocV1 x -> Some x 37 | | _ -> None) 38 | f 39 | 40 | let inline _SingOutbound f = 41 | prism' 42 | SingOutbound 43 | (fun x -> 44 | match x with 45 | | SingOutbound x -> Some x 46 | | _ -> None) 47 | f 48 | -------------------------------------------------------------------------------- /Aurum.Filesystem/Aurum.Filesystem.fsproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | true 6 | Aurum.Filesystem 7 | 0.1.0-beta.1 8 | Shanoa Ice 9 | Filesystem Related Component for the Aurum project. 10 | git 11 | https://github.com/Shadowsocks-NET/Aurum 12 | Aurum.Filesystem 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Aurum.Configuration/AdapterTypes/VMessLegacyShare.fs: -------------------------------------------------------------------------------- 1 | module Aurum.Configuration.AdapterTypes.VMessLegacyShare 2 | 3 | open System.Text.Json.Serialization 4 | 5 | // this implementation disregards alterId, an obsolete feature 6 | // the only *disguise* method supported is HTTP host 7 | 8 | type VMessSecurity = 9 | | [] None 10 | | [] Zero 11 | | [] Auto 12 | | [] AES 13 | | [] ChaCha20 14 | 15 | type VMessTransport = 16 | | [] TCP 17 | | [] WebSocket 18 | | [] QUIC 19 | | [] GRPC 20 | | [] MKCP // sing-box does not support this. 21 | 22 | type TLSSetting = 23 | | [] None 24 | | [] TLS 25 | 26 | type DisguiseType = 27 | | [] None 28 | | [] HTTP 29 | 30 | type ShareObject = 31 | { v: int 32 | add: string 33 | port: int 34 | id: string 35 | scy: VMessSecurity 36 | net: VMessTransport 37 | tls: TLSSetting 38 | sni: string 39 | [] 40 | dType: DisguiseType 41 | host: string } 42 | -------------------------------------------------------------------------------- /Aurum.Configuration/Sing/Shared.fs: -------------------------------------------------------------------------------- 1 | module Aurum.Configuration.Sing.Shared 2 | 3 | 4 | type TLSOutbound = 5 | { enabled: bool 6 | disableSNI: bool option 7 | serverName: string option 8 | insecure: bool option 9 | alpn: string list option 10 | minVersion: string option 11 | maxVersion: string option 12 | cipherSuites: string list option 13 | certificate: string option 14 | certificatePath: string option } 15 | 16 | type ACMERecord = 17 | { domain: string list 18 | dataDirectory: string 19 | defaultServerName: string 20 | email: string 21 | provider: string option 22 | disableHTTPChallenge: bool option 23 | disableTlsAlpnChallenge: bool option 24 | alternativeHTTPPort: int option 25 | alternativeTLSPort: int option 26 | externalAccount: obj option } 27 | 28 | type TLSInbound = 29 | { enabled: bool 30 | serverName: string option 31 | alpn: string list option 32 | minVersion: string option 33 | maxVersion: string option 34 | cipherSuites: string list option 35 | certificate: string option 36 | certificatePath: string option 37 | key: string option 38 | keyPath: string option 39 | acme: ACMERecord } 40 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: build 2 | 3 | on: 4 | push: 5 | pull_request: 6 | branches: [main] 7 | paths: 8 | - "**.fs" 9 | - "**.fsproj" 10 | 11 | env: 12 | DOTNET_VERSION: ${{ vars.DOTNET_VERSION }} # The .NET SDK version to use 13 | 14 | jobs: 15 | build: 16 | name: build-${{matrix.os}} 17 | runs-on: ${{ matrix.os }} 18 | strategy: 19 | matrix: 20 | os: [ubuntu-latest, windows-latest, macOS-latest] 21 | 22 | steps: 23 | - uses: actions/checkout@v4 24 | 25 | - name: Setup .NET Core 26 | uses: actions/setup-dotnet@v4 27 | with: 28 | dotnet-version: ${{ env.DOTNET_VERSION }} 29 | 30 | - name: Cache dependencies 31 | uses: actions/cache@v3 32 | with: 33 | path: paket-cache 34 | key: ${{ runner.os }}-paket-${{ hashFiles('paket.lock') }} 35 | restore-keys: | 36 | ${{ runner.os }}-paket- 37 | 38 | - name: Install buildtools 39 | run: dotnet tool restore 40 | 41 | - name: Install dependencies 42 | run: dotnet paket restore && dotnet restore 43 | 44 | - name: Build 45 | run: dotnet build --configuration Release --no-restore 46 | -------------------------------------------------------------------------------- /.github/workflows/publish-github.yml: -------------------------------------------------------------------------------- 1 | name: Publish Github Packages 2 | 3 | on: 4 | push: 5 | tags: 6 | - 'github-v*' 7 | 8 | permissions: 9 | packages: write 10 | 11 | env: 12 | DOTNET_VERSION: ${{ vars.DOTNET_VERSION }} 13 | 14 | jobs: 15 | publish_upload: 16 | name: Publish Github Packages 17 | runs-on: ubuntu-latest 18 | 19 | steps: 20 | - uses: actions/checkout@v4 21 | 22 | - name: Setup .NET Core 23 | uses: actions/setup-dotnet@v4 24 | with: 25 | dotnet-version: ${{ env.DOTNET_VERSION }} 26 | source-url: https://nuget.pkg.github.com/Shadowsocks-NET/index.json 27 | env: 28 | NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 29 | 30 | - name: Install buildtools 31 | run: dotnet tool restore 32 | 33 | - name: Install dependencies 34 | run: dotnet paket restore 35 | 36 | - name: Pack and upload NuGet package 37 | run: | 38 | dotnet pack -c Release 39 | dotnet nuget push Aurum/bin/Release/*.nupkg --skip-duplicate --no-symbols --api-key ${{ secrets.HUB_PACKAGE_PAT }} --source https://nuget.pkg.github.com/Shadowsocks-NET/index.json 40 | dotnet nuget push Aurum.*/bin/Release/*.nupkg --skip-duplicate --no-symbols --api-key ${{ secrets.HUB_PACKAGE_PAT }} --source https://nuget.pkg.github.com/Shadowsocks-NET/index.json 41 | -------------------------------------------------------------------------------- /docfx_project/docfx.json: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": [ 3 | { 4 | "src": [ 5 | { 6 | "files": [ 7 | "Aurum*/bin/**/*.dll" 8 | ], 9 | "src": "../" 10 | } 11 | ], 12 | "dest": "api", 13 | "includePrivateMembers": false, 14 | "disableGitFeatures": false, 15 | "disableDefaultFilter": false, 16 | "noRestore": false, 17 | "namespaceLayout": "flattened", 18 | "memberLayout": "samePage", 19 | "EnumSortOrder": "alphabetic", 20 | "allowCompilationErrors": false 21 | } 22 | ], 23 | "build": { 24 | "content": [ 25 | { 26 | "files": [ 27 | "api/**.yml", 28 | "api/index.md" 29 | ] 30 | }, 31 | { 32 | "files": [ 33 | "articles/**.md", 34 | "articles/**/toc.yml", 35 | "toc.yml", 36 | "*.md" 37 | ] 38 | } 39 | ], 40 | "resource": [ 41 | { 42 | "files": [ 43 | "images/**" 44 | ] 45 | } 46 | ], 47 | "output": "_site", 48 | "globalMetadataFiles": [], 49 | "fileMetadataFiles": [], 50 | "template": [ 51 | "default", 52 | "modern" 53 | ], 54 | "postProcessors": [], 55 | "keepFileLink": false, 56 | "disableGitFeatures": false 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Aurum.DataProtection/Aurum.DataProtection.fsproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | true 6 | Aurum.DataProtection 7 | 0.1.0-beta.1 8 | Shanoa Ice 9 | Data Protection Component for the Aurum project. 10 | git 11 | https://github.com/Shadowsocks-NET/Aurum 12 | 13 | 14 | true 15 | true 16 | true 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Aurum 2 | 3 | [![build](https://github.com/Shadowsocks-NET/Aurum/actions/workflows/build.yml/badge.svg)](https://github.com/Shadowsocks-NET/Aurum/actions/workflows/build.yml) [![Publish Github Packages](https://github.com/Shadowsocks-NET/Aurum/actions/workflows/publish-github.yml/badge.svg)](https://github.com/Shadowsocks-NET/Aurum/actions/workflows/publish-github.yml) [![Publish MyGet Packages](https://github.com/Shadowsocks-NET/Aurum/actions/workflows/publish-myget.yml/badge.svg)](https://github.com/Shadowsocks-NET/Aurum/actions/workflows/publish-myget.yml) 4 | 5 | Aurum is a cross-platform GUI for anti-censorship applications such as sing-box, v2ray, etc. 6 | 7 | `Aurum.*` is the backend library for command operations such as configuration generation and evaluation, proxy instance 8 | management. 9 | 10 | The graphical frontend is not available as of now, but it will be based on Avalonia. 11 | 12 | The backend is under active development and is not tested at all, please be careful. 13 | 14 | ## Usage 15 | 16 | Aurum is still in active development. To use the development version of this library, please use 17 | this [MyGet Feed](https://www.myget.org/feed/Packages/aurum). 18 | 19 | ## Stargazers over time 20 | 21 | [![Stargazers over time](https://starchart.cc/Shadowsocks-NET/Aurum.svg)](https://starchart.cc/Shadowsocks-NET/Aurum) 22 | 23 | ## License 24 | 25 | The Aurum project is licensed under [LGPL-3.0-only](LICENSE). 26 | 27 | [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FShadowsocks-NET%2FAurum.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2FShadowsocks-NET%2FAurum?ref=badge_large) 28 | -------------------------------------------------------------------------------- /Aurum.Configuration/Aurum.Configuration.fsproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net7.0 4 | true 5 | Aurum.Configuration 6 | 0.1.0-beta.1 7 | Shanoa Ice 8 | Configuration Component for the Aurum project. 9 | git 10 | https://github.com/Shadowsocks-NET/Aurum 11 | LGPL-3.0-only 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 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Aurum.sln.DotSettings: -------------------------------------------------------------------------------- 1 | 2 | True 3 | True 4 | True 5 | 6 | True 7 | True 8 | True 9 | True 10 | True 11 | True 12 | True 13 | ShowAndRun 14 | INFO 15 | On 16 | On 17 | On 18 | True 19 | True 20 | -------------------------------------------------------------------------------- /Aurum.Interop/ProcessWrapper.fs: -------------------------------------------------------------------------------- 1 | // fsharplint:disable FL0065 2 | module Aurum.Interop.ProcessWrapper 3 | 4 | open System.Diagnostics 5 | open System.Threading 6 | 7 | type CoreProcess 8 | (coreProcessInfo: ProcessStartInfo, loggerTaskBuilder: System.IO.StreamReader -> CancellationToken -> Tasks.Task) 9 | = 10 | let mutable disposed = false 11 | let coreProcessInfo = coreProcessInfo 12 | let cancelLogging = new CancellationTokenSource() 13 | 14 | let mutable internalProcess = new Process() 15 | 16 | interface System.IDisposable with 17 | member this.Dispose() = 18 | if (not disposed) then 19 | cancelLogging.Cancel() 20 | cancelLogging.Dispose() 21 | this.Process.Dispose() 22 | disposed <- false 23 | 24 | member this.Process 25 | with get () = internalProcess 26 | and set (value) = internalProcess <- value 27 | 28 | member this.Start() = 29 | (this.Process <- Process.Start(coreProcessInfo)) 30 | 31 | let loggerTask = loggerTaskBuilder this.Process.StandardOutput cancelLogging.Token 32 | 33 | loggerTask.Start() 34 | () 35 | 36 | member this.Stop() = 37 | cancelLogging.Cancel() 38 | this.Process.Kill(true) 39 | 40 | let startCoreProcess (executablePath, configPath: string, assetPath) = 41 | let coreProcessInfo = 42 | ProcessStartInfo(executablePath, $"-config={configPath} -format=json") 43 | 44 | coreProcessInfo.UseShellExecute <- false 45 | coreProcessInfo.CreateNoWindow <- false 46 | 47 | coreProcessInfo.RedirectStandardError <- true 48 | 49 | coreProcessInfo.RedirectStandardOutput <- true 50 | 51 | assetPath 52 | |> Option.iter (fun a -> coreProcessInfo.Environment.["v2ray.location.asset"] <- a) 53 | 54 | let createCoreLoggerTask (stdout: System.IO.StreamReader) (cancellationToken: CancellationToken) = 55 | backgroundTask { 56 | while (not cancellationToken.IsCancellationRequested) do 57 | let! logLine = stdout.ReadLineAsync() 58 | LogStream.logStream.Trigger logLine 59 | } 60 | 61 | new CoreProcess(coreProcessInfo, createCoreLoggerTask) 62 | -------------------------------------------------------------------------------- /docs/Share-Links.md: -------------------------------------------------------------------------------- 1 | # Import Share Links 2 | 3 | Aurum supports importing VMessAEAD/VLESS (deprecated), Shadowsocks SIP002 ( 4 | via [Shadowsocks.NET](https://github.com/Shadowsocks-NET/Shadowsocks.NET)) and legacy v2rayN base64 share links. This describes behaviors when importing share links. 5 | 6 | ## VMessAEAD/VLESS 7 | 8 | In the original v2ray-core, VLESS is considered obsolete, thus Aurum will not include its support in any version prior to `v1` release. 9 | 10 | VMessAEAD will be the major supported protocol, but there is some subtle difference compared to the VMessAEAD share links standard proposal: 11 | 12 | - Blank strings for all non-mandatory fields are silently ignored and won't throw error, instead falling back to the default entry value. 13 | - gRPC's `mode` field is always silently ignored, since none of `v2ray@5` and `sing-box` supports alternative gRPC modes specified in the share link spec (those modes are proposed mainly by the Xray branch). 14 | - XTLS related field is ignored (as VMess does not support XTLS, and VLESS which supports that is obsolete). 15 | 16 | Xray support is undetermined, as XTLS and its successor Reality is a largely incompatible feature which requires VLESS, a protocol that is considered obsolete for most other implementations. Also, its developer and community had shown public hostility for some members of the original v2fly community. 17 | 18 | ## Legacy v2rayN base64 format 19 | 20 | The legacy v2rayN base64 share link format support generally follows the [v2rayN spec (in Chinese)](https://github.com/2dust/v2rayN/wiki/%E5%88%86%E4%BA%AB%E9%93%BE%E6%8E%A5%E6%A0%BC%E5%BC%8F%E8%AF%B4%E6%98%8E(ver-2)), with the following exceptions: 21 | 22 | - None of `v2ray@5` and `sing-box` supports disguise type (other than `http` which is the only available one in TCP) with KCP and QUIC, thus the `type` field will always be ignored. This might cause you to not be able to connect to some proxy providers that still uses this feature, please be careful. 23 | - Although disguise type other than `http` is always ignored, `host` will still be respected when the transport is TCP or HTTP (HTTP/2). None of `v2ray@5` and `sing-box` supports custom headers on QUIC and KCP, thus `host` will be ignored on these transports. 24 | 25 | ## Shadowsocks SIP002 URI Scheme 26 | 27 | Shadowsocks SIP002 URI Scheme is fully implemented with the exception of obsolete Stream Ciphers. 28 | 29 | Only simple-obfs and v2ray plugins are supported. Simple-obfs is deprecated, though, thus you should consider migrating to v2ray. 30 | -------------------------------------------------------------------------------- /Aurum.Configuration/Sing/DNS.fs: -------------------------------------------------------------------------------- 1 | module Aurum.Configuration.Sing.DNS 2 | 3 | open Aurum.Configuration.Shared.Routing 4 | open Aurum.Configuration.Sing.Routing 5 | 6 | type DnsRuleObject = 7 | { Inbound: string list option 8 | QueryType: string list option 9 | Network: NetworkType option 10 | Protocol: RuleMatchProtocol list option 11 | Domain: string list option 12 | DomainSuffix: string list option 13 | DomainKeyword: string list option 14 | DomainRegex: string list option 15 | Port: int list option 16 | PortRange: string list option 17 | ProcessName: string list option 18 | ProcessPath: string list option 19 | PackageName: string list option 20 | ClashMode: string option 21 | Outbound: string list option 22 | Server: string 23 | DisableCache: bool option 24 | RewriteTtl: int option } 25 | 26 | type DnsDomainRuleType = 27 | | Full of string list 28 | | Suffix of string list 29 | | Keyword of string list 30 | | Regex of string list 31 | 32 | type DnsServerObject = { tag: string; address: string } 33 | 34 | type RuleType = 35 | | Block of rules: DnsDomainRuleType 36 | | Redirect of rules: DnsDomainRuleType * tag: string 37 | 38 | type DnsStrategy = 39 | | PreferIpv4 40 | | PreferIpv6 41 | | Ipv4Only 42 | | Ipv6Only 43 | 44 | type InternalDnsObject = 45 | { rules: RuleType list 46 | servers: DnsServerObject list 47 | final: string 48 | strategy: DnsStrategy } 49 | 50 | type DnsObject = 51 | { rules: DnsRuleObject list 52 | servers: DnsServerObject list 53 | final: string 54 | strategy: DnsStrategy } 55 | 56 | let mapDnsRuleType dnsRuleType (origObject: DnsRuleObject) = 57 | match dnsRuleType with 58 | | Full domain -> { origObject with Domain = Some domain } 59 | | Suffix domain -> 60 | { origObject with 61 | DomainSuffix = Some domain } 62 | | Keyword domain -> 63 | { origObject with 64 | DomainKeyword = Some domain } 65 | | Regex domain -> 66 | { origObject with 67 | DomainRegex = Some domain } 68 | 69 | let mapRuleType ruleType = 70 | match ruleType with 71 | | Block rules -> 72 | { Inbound = None 73 | QueryType = None 74 | Network = None 75 | Protocol = None 76 | Domain = None 77 | DomainSuffix = None 78 | DomainKeyword = None 79 | DomainRegex = None 80 | Port = None 81 | PortRange = None 82 | ProcessName = None 83 | ProcessPath = None 84 | PackageName = None 85 | ClashMode = None 86 | Outbound = None 87 | Server = "block" 88 | DisableCache = None 89 | RewriteTtl = None } 90 | |> mapDnsRuleType rules 91 | | Redirect(rules, tag) -> 92 | { Inbound = None 93 | QueryType = None 94 | Network = None 95 | Protocol = None 96 | Domain = None 97 | DomainSuffix = None 98 | DomainKeyword = None 99 | DomainRegex = None 100 | Port = None 101 | PortRange = None 102 | ProcessName = None 103 | ProcessPath = None 104 | PackageName = None 105 | ClashMode = None 106 | Outbound = None 107 | Server = tag 108 | DisableCache = None 109 | RewriteTtl = None } 110 | |> mapDnsRuleType rules 111 | 112 | let createDnsObject (internalDnsObject: InternalDnsObject) = 113 | { DnsObject.rules = List.map mapRuleType internalDnsObject.rules 114 | DnsObject.servers = internalDnsObject.servers 115 | DnsObject.final = internalDnsObject.final 116 | DnsObject.strategy = internalDnsObject.strategy } 117 | -------------------------------------------------------------------------------- /Aurum.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Aurum", "Aurum\Aurum.fsproj", "{3559AFD9-7176-4BFB-8E7F-0688EABD0B53}" 5 | EndProject 6 | Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Aurum.DataProtection", "Aurum.DataProtection\Aurum.DataProtection.fsproj", "{4B035052-7B27-47E3-A6A5-C96D524111AA}" 7 | EndProject 8 | Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Aurum.Interop", "Aurum.Interop\Aurum.Interop.fsproj", "{D7F8C1C8-29E9-459A-B068-03E6FB89D721}" 9 | EndProject 10 | Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Aurum.Filesystem", "Aurum.Filesystem\Aurum.Filesystem.fsproj", "{9943C3ED-1A4E-4F75-8C5B-AF6E678EB264}" 11 | EndProject 12 | Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Aurum.Configuration", "Aurum.Configuration\Aurum.Configuration.fsproj", "{7239D687-21A3-4014-879F-4BE110216A01}" 13 | EndProject 14 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Item", "Solution Item", "{B8A29A61-BBD8-47CC-98E8-8C1DF40C79DB}" 15 | ProjectSection(SolutionItems) = preProject 16 | build.fsx = build.fsx 17 | LICENSE = LICENSE 18 | paket.dependencies = paket.dependencies 19 | README.md = README.md 20 | nuget.config = nuget.config 21 | EndProjectSection 22 | EndProject 23 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{5756B958-4D9E-4CE4-9E02-04E9072829E0}" 24 | ProjectSection(SolutionItems) = preProject 25 | docs\Share-Links.md = docs\Share-Links.md 26 | EndProjectSection 27 | EndProject 28 | Global 29 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 30 | Debug|Any CPU = Debug|Any CPU 31 | Release|Any CPU = Release|Any CPU 32 | EndGlobalSection 33 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 34 | {3559AFD9-7176-4BFB-8E7F-0688EABD0B53}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 35 | {3559AFD9-7176-4BFB-8E7F-0688EABD0B53}.Debug|Any CPU.Build.0 = Debug|Any CPU 36 | {3559AFD9-7176-4BFB-8E7F-0688EABD0B53}.Release|Any CPU.ActiveCfg = Release|Any CPU 37 | {3559AFD9-7176-4BFB-8E7F-0688EABD0B53}.Release|Any CPU.Build.0 = Release|Any CPU 38 | {4B035052-7B27-47E3-A6A5-C96D524111AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 39 | {4B035052-7B27-47E3-A6A5-C96D524111AA}.Debug|Any CPU.Build.0 = Debug|Any CPU 40 | {4B035052-7B27-47E3-A6A5-C96D524111AA}.Release|Any CPU.ActiveCfg = Release|Any CPU 41 | {4B035052-7B27-47E3-A6A5-C96D524111AA}.Release|Any CPU.Build.0 = Release|Any CPU 42 | {D7F8C1C8-29E9-459A-B068-03E6FB89D721}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 43 | {D7F8C1C8-29E9-459A-B068-03E6FB89D721}.Debug|Any CPU.Build.0 = Debug|Any CPU 44 | {D7F8C1C8-29E9-459A-B068-03E6FB89D721}.Release|Any CPU.ActiveCfg = Release|Any CPU 45 | {D7F8C1C8-29E9-459A-B068-03E6FB89D721}.Release|Any CPU.Build.0 = Release|Any CPU 46 | {9943C3ED-1A4E-4F75-8C5B-AF6E678EB264}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 47 | {9943C3ED-1A4E-4F75-8C5B-AF6E678EB264}.Debug|Any CPU.Build.0 = Debug|Any CPU 48 | {9943C3ED-1A4E-4F75-8C5B-AF6E678EB264}.Release|Any CPU.ActiveCfg = Release|Any CPU 49 | {9943C3ED-1A4E-4F75-8C5B-AF6E678EB264}.Release|Any CPU.Build.0 = Release|Any CPU 50 | {7239D687-21A3-4014-879F-4BE110216A01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 51 | {7239D687-21A3-4014-879F-4BE110216A01}.Debug|Any CPU.Build.0 = Debug|Any CPU 52 | {7239D687-21A3-4014-879F-4BE110216A01}.Release|Any CPU.ActiveCfg = Release|Any CPU 53 | {7239D687-21A3-4014-879F-4BE110216A01}.Release|Any CPU.Build.0 = Release|Any CPU 54 | EndGlobalSection 55 | GlobalSection(NestedProjects) = preSolution 56 | {5756B958-4D9E-4CE4-9E02-04E9072829E0} = {B8A29A61-BBD8-47CC-98E8-8C1DF40C79DB} 57 | EndGlobalSection 58 | EndGlobal 59 | -------------------------------------------------------------------------------- /Aurum.Configuration/V2fly/Inbound.fs: -------------------------------------------------------------------------------- 1 | module Aurum.Configuration.V2fly.Inbound 2 | 3 | open System.Text.Json.Serialization 4 | 5 | type Protocols = 6 | | [] HTTP 7 | | [] Socks 8 | | [] DokodemoDoor 9 | 10 | type SocksAuth = 11 | | [] NoAuth 12 | | [] Password 13 | 14 | type DestinationOverride = 15 | | [] HTTP 16 | | [] TLS 17 | | [] FakeDNS 18 | | [] FakeDNSOthers 19 | 20 | type AccountObject = { User: string; Pass: string } 21 | 22 | type InboundConfigurationObject = 23 | { Accounts: AccountObject list option 24 | UserLevel: int option 25 | Timeout: int option 26 | (*HTTP specific*) 27 | AllowTransparent: bool option 28 | (*SOCKS specific*) 29 | Auth: SocksAuth option 30 | UDP: bool option 31 | IP: string option 32 | (*Dokodemo-door specific*) 33 | Address: string option 34 | Port: int option 35 | Network: string option 36 | FollowRedirect: bool option } 37 | 38 | // stub object (reserved) 39 | type SocksInboundConfigurationObject = 40 | { Accounts: AccountObject list option 41 | UserLevel: int option 42 | Timeout: int option 43 | Auth: SocksAuth option 44 | UDP: bool option 45 | IP: string option } 46 | 47 | // stub object (reserved) 48 | type DokodemoDoorInboundConfigurationObject = 49 | { Accounts: AccountObject list option 50 | UserLevel: int option 51 | Timeout: int option 52 | Address: string option 53 | Port: int option 54 | Network: string option 55 | FollowRedirect: bool option } 56 | 57 | type SniffingObject = 58 | { Enabled: bool 59 | DestOverride: DestinationOverride list 60 | MetadataOnly: bool } 61 | 62 | type InboundObject = 63 | { Listen: string 64 | Port: int 65 | Protocol: Protocols 66 | Settings: InboundConfigurationObject 67 | Tag: string 68 | Sniffing: SniffingObject } 69 | 70 | let createSocksAccount (user, pass) = 71 | { AccountObject.User = user 72 | Pass = pass } 73 | 74 | let createSocksInboundObject (auth, accounts, udp, ip, userLevel) = 75 | { InboundConfigurationObject.Auth = auth 76 | Accounts = accounts 77 | UserLevel = userLevel 78 | UDP = udp 79 | IP = ip 80 | Timeout = None 81 | AllowTransparent = None 82 | Address = None 83 | Port = None 84 | Network = None 85 | FollowRedirect = None } 86 | 87 | let createHttpInboundObject (timeout, accounts, allowTransparent, userLevel) = 88 | { InboundConfigurationObject.Auth = None 89 | Accounts = accounts 90 | UserLevel = userLevel 91 | UDP = None 92 | IP = None 93 | Timeout = timeout 94 | AllowTransparent = allowTransparent 95 | Address = None 96 | Port = None 97 | Network = None 98 | FollowRedirect = None } 99 | 100 | let createDokodemoDoorInboundObject (address, port, network, timeout, followRedirect, userLevel) = 101 | { InboundConfigurationObject.Auth = None 102 | Accounts = None 103 | UserLevel = userLevel 104 | UDP = None 105 | IP = None 106 | Timeout = timeout 107 | AllowTransparent = None 108 | Address = address 109 | Port = port 110 | Network = network 111 | FollowRedirect = followRedirect } 112 | 113 | let createSniffingObject (enabled, destinationOverride, metadataOnly) = 114 | { SniffingObject.Enabled = enabled 115 | DestOverride = destinationOverride 116 | MetadataOnly = metadataOnly } 117 | 118 | let createInboundObject (allowLocalConnection, port, protocol, settings, sniffing, tag) = 119 | { InboundObject.Listen = if allowLocalConnection then "0.0.0.0" else "127.0.0.1" 120 | Port = port 121 | Protocol = protocol 122 | Settings = settings 123 | Sniffing = sniffing 124 | Tag = Option.defaultValue "Default" tag } 125 | -------------------------------------------------------------------------------- /Aurum.Configuration/V2fly/Routing.fs: -------------------------------------------------------------------------------- 1 | module Aurum.Configuration.V2fly.Routing 2 | 3 | open Aurum 4 | open Aurum.Configuration.Shared 5 | open Aurum.Configuration.Shared.Routing 6 | open System.Text.Json.Serialization 7 | 8 | type DomainStrategy = 9 | | [] AsIs 10 | | [] IPIfNonMatch 11 | | [] IPOnDemand 12 | 13 | type DomainMatcher = 14 | | [] MinimalPerfectHash 15 | | [] Original 16 | 17 | type RuleMatchProtocol = 18 | | [] HTTP 19 | | [] TLS 20 | 21 | [] 22 | type DomainObject = 23 | | Plain of string 24 | | Regex of string 25 | | RootDomain of string 26 | | Full of string 27 | 28 | type GeoDataObject = 29 | { InverseMatch: bool option 30 | Code: string option 31 | FilePath: string option } 32 | 33 | type CidrObject = { IpAddr: string; Prefix: int } 34 | 35 | let createGeoDataObject (code, filepath) = 36 | { InverseMatch = None 37 | Code = Some code 38 | FilePath = filepath } 39 | 40 | let mapDomainMatchingType domainMatchingType = 41 | match domainMatchingType with 42 | | DomainMatchingType.Full str -> Full str 43 | | DomainMatchingType.Regex str -> Regex str 44 | | Keyword str -> Plain str 45 | | Suffix str -> RootDomain str 46 | 47 | let parseCidrString (cidrString: string) = 48 | let cidrStringParts = cidrString.Split("/") 49 | 50 | { IpAddr = cidrStringParts[0] 51 | Prefix = System.Int32.Parse(cidrStringParts[1]) } 52 | 53 | type RuleObject = 54 | { Tag: string 55 | Domain: DomainObject list option 56 | GeoDomain: GeoDataObject list option 57 | Ip: CidrObject list option 58 | GeoIp: GeoDataObject list option 59 | Networks: RuleMatchNetwork option 60 | PortList: string option 61 | InboundTag: string list option } 62 | 63 | static member FromGenericRuleObject(genericRuleObject: Routing.RuleObject) = 64 | let ipList = 65 | genericRuleObject.Ip 66 | |> Option.map (fun imp -> 67 | imp 68 | |> List.choose (fun x -> 69 | match x with 70 | | Ip ip -> parseCidrString ip |> Some 71 | | _ -> None)) 72 | |> Option.bind emptyListToNone 73 | 74 | let geoipList = 75 | genericRuleObject.Ip 76 | |> Option.map (fun inp -> 77 | inp 78 | |> List.choose (fun x -> 79 | match x with 80 | | Geoip geoip -> createGeoDataObject (geoip, None) |> Some 81 | | _ -> None)) 82 | |> Option.bind emptyListToNone 83 | 84 | let domainList = 85 | genericRuleObject.Domain 86 | |> Option.map (fun inp -> 87 | inp 88 | |> List.choose (fun entries -> 89 | match entries with 90 | | Domain domainMatchingType -> mapDomainMatchingType domainMatchingType |> Some 91 | | _ -> None)) 92 | |> Option.bind emptyListToNone 93 | 94 | let geositeList = 95 | genericRuleObject.Domain 96 | |> Option.map (fun inp -> 97 | inp 98 | |> List.choose (fun entries -> 99 | match entries with 100 | | Geosite geosite -> createGeoDataObject (geosite, None) |> Some 101 | | _ -> None)) 102 | |> Option.bind emptyListToNone 103 | 104 | { RuleObject.Tag = genericRuleObject.Tag 105 | Domain = domainList 106 | GeoDomain = geositeList 107 | Ip = ipList 108 | GeoIp = geoipList 109 | Networks = genericRuleObject.Networks 110 | PortList = genericRuleObject.Port |> Option.map (fun imp -> System.String.Join(",", imp)) 111 | InboundTag = genericRuleObject.InboundTag } 112 | 113 | type RoutingObject = 114 | { DomainStrategy: DomainStrategy option 115 | DomainMatcher: DomainMatcher option 116 | Rules: RuleObject list option } 117 | 118 | let createRoutingObject rules domainStrategy = 119 | { RoutingObject.Rules = rules 120 | DomainMatcher = Some MinimalPerfectHash 121 | DomainStrategy = domainStrategy } 122 | -------------------------------------------------------------------------------- /Aurum/Helpers.fs: -------------------------------------------------------------------------------- 1 | namespace Aurum 2 | 3 | open System 4 | open System.Runtime.InteropServices 5 | open System.IO 6 | open System.Collections.Generic 7 | open Microsoft.Extensions.Primitives 8 | open System.Text.Json 9 | open System.Text.Json.Serialization 10 | open FSharpPlus 11 | 12 | [] 13 | module Helpers = 14 | type identity<'a> = 'a -> 'a 15 | 16 | let retrieveKeyFromDict (dict: Dictionary<'K, 'V>) key = 17 | try 18 | Ok(dict.[key]) 19 | with :? KeyNotFoundException as e -> 20 | Error(e :> exn) 21 | 22 | let tryRetrieveKeyFromDict (dict: Dictionary<'K, 'V>) key = 23 | try 24 | Some(dict.[key]) 25 | with :? KeyNotFoundException -> 26 | None 27 | 28 | let unwrapResult result = 29 | match result with 30 | | Ok some -> some 31 | | Error error -> raise error 32 | 33 | let getFirstQuerystringEntry (dict: Dictionary) (key: string) = 34 | retrieveKeyFromDict dict key |> Result.map (fun x -> x.[0]) 35 | 36 | let tryGetFirstQuerystringEntry (dict: Dictionary) (key: string) : string option = 37 | match tryRetrieveKeyFromDict dict key with 38 | | Some value -> Some(value.[0]) 39 | | None -> None 40 | 41 | let blankStringToNone (string: string option) = 42 | Option.filter (fun x -> x.Equals("")) string 43 | 44 | let emptyListToNone list = 45 | if List.isEmpty list then None else Some list 46 | 47 | let tryRetrieveFromShareLink queryParams key = 48 | tryGetFirstQuerystringEntry queryParams key |> blankStringToNone 49 | 50 | let mergeOptionList op1 op2 = 51 | match op1, op2 with 52 | | Some x, Some y -> Some(x @ y) 53 | | op1, op2 -> Option.orElse op1 op2 54 | 55 | let singSystemTextJsonOptions = 56 | JsonSerializerOptions( 57 | PropertyNamingPolicy = JsonNamingPolicy.SnakeCase, 58 | WriteIndented = true, 59 | NumberHandling = JsonNumberHandling.AllowReadingFromString 60 | ) 61 | 62 | JsonFSharpOptions() 63 | .WithUnionInternalTag() 64 | .WithUnionAllowUnorderedTag() 65 | .WithUnwrapOption() 66 | .WithUnionUnwrapRecordCases() 67 | .WithUnionTagName("type") 68 | .WithUnionTagNamingPolicy(JsonNamingPolicy.SnakeCase) 69 | .WithUnionFieldNamingPolicy(JsonNamingPolicy.SnakeCase) 70 | .WithSkippableOptionFields() 71 | .WithAllowOverride() 72 | .AddToJsonSerializerOptions(singSystemTextJsonOptions) 73 | 74 | let v2flySystemTextJsonOptions = 75 | JsonSerializerOptions( 76 | PropertyNamingPolicy = JsonNamingPolicy.CamelCase, 77 | WriteIndented = true, 78 | NumberHandling = JsonNumberHandling.AllowReadingFromString 79 | ) 80 | 81 | JsonFSharpOptions 82 | .ThothLike() 83 | .WithUnwrapOption() 84 | .WithUnionUnwrapRecordCases() 85 | .WithUnionTagName("type") 86 | .WithUnionTagNamingPolicy(JsonNamingPolicy.CamelCase) 87 | .WithUnionFieldNamingPolicy(JsonNamingPolicy.CamelCase) 88 | .WithSkippableOptionFields() 89 | .AddToJsonSerializerOptions(v2flySystemTextJsonOptions) 90 | 91 | let encodeBase64 (text: string) = 92 | let plainBytes = System.Text.Encoding.UTF8.GetBytes text 93 | System.Convert.ToBase64String plainBytes 94 | 95 | let decodeBase64 string = 96 | let rawBytes = System.Convert.FromBase64String string 97 | System.Text.Encoding.UTF8.GetString rawBytes 98 | 99 | let decodeBase64Url string = 100 | let rawBytes = Microsoft.AspNetCore.WebUtilities.WebEncoders.Base64UrlDecode string 101 | System.Text.Encoding.UTF8.GetString rawBytes 102 | 103 | let getDataDirectory appName = 104 | let baseDirectory = 105 | if RuntimeInformation.IsOSPlatform(OSPlatform.Windows) then 106 | Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) 107 | elif RuntimeInformation.IsOSPlatform(OSPlatform.OSX) then 108 | Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "/Library/Application Support") 109 | else 110 | Option.ofObj (Environment.GetEnvironmentVariable("XDG_DATA_HOME")) 111 | |> Option.defaultValue ( 112 | Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".local/share") 113 | ) 114 | 115 | Path.Combine(baseDirectory, appName) 116 | -------------------------------------------------------------------------------- /Aurum.Configuration/Shared/Shadowsocks.fs: -------------------------------------------------------------------------------- 1 | module Aurum.Configuration.Shared.Shadowsocks 2 | 3 | open System.Text.Json.Serialization 4 | open FSharpPlus.Lens 5 | open FSharpPlus.Data 6 | 7 | // ShadowsocksR and legacy stream cipher are not supported, since they have serious security issues. If users really wish to use them, they could supply custom JSON config provided their backend has proper support. 8 | // Password / PSKs are embedded in this DU's fields 9 | [] 10 | type ShadowsocksEncryption = 11 | | [] None 12 | | [] Plain 13 | | [] ChaCha20 of Password: string 14 | | [] ChaCha20Ietf of Password: string 15 | | [] AES128 of Password: string 16 | | [] AES256 of Password: string 17 | | [] AES128_2022 of PSKs: string list 18 | | [] AES256_2022 of PSKs: string list 19 | | [] ChaCha20_2022 of PSKs: string list 20 | | [] ChaCha8_2022 of PSKs: string list 21 | 22 | module ShadowsocksEncryption = 23 | let inline _None f p = 24 | prism' 25 | (fun _ -> ShadowsocksEncryption.None) 26 | (fun x -> 27 | match x with 28 | | ShadowsocksEncryption.None -> Some ShadowsocksEncryption.None 29 | | _ -> None) 30 | f 31 | p 32 | 33 | let inline _Plain f p = 34 | prism' 35 | (fun _ -> ShadowsocksEncryption.Plain) 36 | (fun x -> 37 | match x with 38 | | ShadowsocksEncryption.Plain -> Some ShadowsocksEncryption.Plain 39 | | _ -> None) 40 | f 41 | p 42 | 43 | let inline _ChaCha20 f p = 44 | prism' 45 | ShadowsocksEncryption.ChaCha20 46 | (fun x -> 47 | match x with 48 | | ShadowsocksEncryption.ChaCha20 x -> Some(ShadowsocksEncryption.ChaCha20 x) 49 | | _ -> None) 50 | f 51 | p 52 | 53 | let inline _ChaCha20Ietf f p = 54 | prism' 55 | ShadowsocksEncryption.ChaCha20Ietf 56 | (fun x -> 57 | match x with 58 | | ShadowsocksEncryption.ChaCha20Ietf x -> Some(ShadowsocksEncryption.ChaCha20Ietf x) 59 | | _ -> None) 60 | f 61 | p 62 | 63 | let inline _AES128 f p = 64 | prism' 65 | ShadowsocksEncryption.AES128 66 | (fun x -> 67 | match x with 68 | | ShadowsocksEncryption.AES128 x -> Some(ShadowsocksEncryption.AES128 x) 69 | | _ -> None) 70 | f 71 | p 72 | 73 | let inline _AES256 f p = 74 | prism' 75 | ShadowsocksEncryption.AES256 76 | (fun x -> 77 | match x with 78 | | ShadowsocksEncryption.AES256 x -> Some(ShadowsocksEncryption.AES256 x) 79 | | _ -> None) 80 | f 81 | p 82 | 83 | let inline _AES128_2022 f p = 84 | prism' 85 | ShadowsocksEncryption.AES128_2022 86 | (fun x -> 87 | match x with 88 | | ShadowsocksEncryption.AES128_2022 x -> Some(ShadowsocksEncryption.AES128_2022 x) 89 | | _ -> None) 90 | f 91 | p 92 | 93 | let inline _AES256_2022 f p = 94 | prism' 95 | ShadowsocksEncryption.AES256_2022 96 | (fun x -> 97 | match x with 98 | | ShadowsocksEncryption.AES256_2022 x -> Some(ShadowsocksEncryption.AES256_2022 x) 99 | | _ -> None) 100 | f 101 | p 102 | 103 | let inline _ChaCha20_2022 f p = 104 | prism' 105 | ShadowsocksEncryption.ChaCha20_2022 106 | (fun x -> 107 | match x with 108 | | ShadowsocksEncryption.ChaCha20_2022 x -> Some(ShadowsocksEncryption.ChaCha20_2022 x) 109 | | _ -> None) 110 | f 111 | p 112 | 113 | let inline _ChaCha8_2022 f p = 114 | prism' 115 | ShadowsocksEncryption.ChaCha8_2022 116 | (fun x -> 117 | match x with 118 | | ShadowsocksEncryption.ChaCha8_2022 x -> Some(ShadowsocksEncryption.ChaCha8_2022 x) 119 | | _ -> None) 120 | f 121 | p 122 | 123 | type ShadowsocksPlugin = 124 | | SimpleObfs of option: string 125 | | V2ray of option: string 126 | 127 | module ShadowsocksPlugin = 128 | let inline _SimpleObfs f p = 129 | prism' 130 | ShadowsocksPlugin.SimpleObfs 131 | (fun x -> 132 | match x with 133 | | ShadowsocksPlugin.SimpleObfs x -> Some(ShadowsocksPlugin.SimpleObfs x) 134 | | _ -> None) 135 | f 136 | p 137 | 138 | let inline _V2ray f p = 139 | prism' 140 | ShadowsocksPlugin.V2ray 141 | (fun x -> 142 | match x with 143 | | ShadowsocksPlugin.V2ray x -> Some(ShadowsocksPlugin.V2ray x) 144 | | _ -> None) 145 | f 146 | p 147 | 148 | type ShadowsocksObject = 149 | { Host: string 150 | Port: int 151 | Encryption: ShadowsocksEncryption 152 | Plugin: ShadowsocksPlugin option } 153 | 154 | module ShadowsocksObject = 155 | let inline _Host f p = 156 | f p.Host <&> fun x -> { p with Host = x } 157 | 158 | let inline _Port f p = 159 | f p.Port <&> fun x -> { p with Port = x } 160 | 161 | let inline _Encryption f p = 162 | f p.Encryption <&> fun x -> { p with Encryption = x } 163 | 164 | let inline _Plugin f p = 165 | f p.Plugin <&> fun x -> { p with Plugin = x } 166 | 167 | let createShadowsocksObject host port encryption plugin = 168 | { Host = host 169 | Port = port 170 | Encryption = encryption 171 | Plugin = plugin } 172 | -------------------------------------------------------------------------------- /Aurum.Configuration/Sing/Routing.fs: -------------------------------------------------------------------------------- 1 | module Aurum.Configuration.Sing.Routing 2 | 3 | open System.Text.Json.Serialization 4 | open Aurum.Configuration.Shared 5 | open Aurum.Configuration.Shared.Routing 6 | 7 | type IpVersion = 8 | | [] IpV4 9 | | [] IpV6 10 | 11 | type NetworkType = 12 | | [] TCP 13 | | [] UDP 14 | 15 | static member FromRuleMatchNetwork(ruleMatchNetwork: RuleMatchNetwork option) = 16 | Option.map 17 | (fun inp -> 18 | match inp with 19 | | RuleMatchNetwork.TCP -> [ TCP ] 20 | | RuleMatchNetwork.UDP -> [ UDP ] 21 | | RuleMatchNetwork.TCPAndUDP -> [ TCP; UDP ]) 22 | ruleMatchNetwork 23 | 24 | type RuleObject = 25 | { inbound: string list option 26 | ipVersion: IpVersion option 27 | network: NetworkType list option 28 | authUser: string list option 29 | protocol: RuleMatchProtocol list option 30 | domain: string list option 31 | domainSuffix: string list option 32 | domainKeyword: string list option 33 | domainRegex: string list option 34 | geosite: string list option 35 | geoip: string list option 36 | ipCidr: string list option 37 | port: int list option 38 | processName: string list option 39 | processPath: string list option 40 | packageName: string list option 41 | user: string list option 42 | userId: string list option 43 | clashMode: string option 44 | invert: bool option 45 | outbound: string } 46 | 47 | static member FromGenericRuleObject(genericRuleObject: Routing.RuleObject) = 48 | let ipList = 49 | genericRuleObject.Ip 50 | |> Option.map (fun inp -> 51 | inp 52 | |> List.choose (fun x -> 53 | match x with 54 | | Ip ip -> Some ip 55 | | _ -> None)) 56 | 57 | let geoipList = 58 | genericRuleObject.Ip 59 | |> Option.map (fun inp -> 60 | inp 61 | |> List.choose (fun x -> 62 | match x with 63 | | Geoip code -> Some code 64 | | _ -> None)) 65 | 66 | let domainList = 67 | genericRuleObject.Domain 68 | |> Option.map (fun inp -> 69 | inp 70 | |> List.choose (fun x -> 71 | match x with 72 | | Domain domainType -> 73 | match domainType with 74 | | Full domain -> Some domain 75 | | _ -> None 76 | | _ -> None)) 77 | 78 | let domainSuffixList = 79 | genericRuleObject.Domain 80 | |> Option.map (fun inp -> 81 | inp 82 | |> List.choose (fun x -> 83 | match x with 84 | | Domain domainType -> 85 | match domainType with 86 | | Suffix domain -> Some domain 87 | | _ -> None 88 | | _ -> None)) 89 | 90 | let domainRegexList = 91 | genericRuleObject.Domain 92 | |> Option.map (fun inp -> 93 | inp 94 | |> List.choose (fun x -> 95 | match x with 96 | | Domain domainType -> 97 | match domainType with 98 | | Regex domain -> Some domain 99 | | _ -> None 100 | | _ -> None)) 101 | 102 | let domainKeywordList = 103 | genericRuleObject.Domain 104 | |> Option.map (fun inp -> 105 | inp 106 | |> List.choose (fun x -> 107 | match x with 108 | | Domain domainType -> 109 | match domainType with 110 | | Keyword domain -> Some domain 111 | | _ -> None 112 | | _ -> None)) 113 | 114 | let geositeList = 115 | genericRuleObject.Domain 116 | |> Option.map (fun inp -> 117 | inp 118 | |> List.choose (fun x -> 119 | match x with 120 | | Geosite code -> Some code 121 | | _ -> None)) 122 | 123 | { inbound = genericRuleObject.InboundTag 124 | ipVersion = None 125 | network = NetworkType.FromRuleMatchNetwork genericRuleObject.Networks 126 | authUser = None 127 | protocol = None 128 | domain = domainList 129 | domainSuffix = domainSuffixList 130 | domainKeyword = domainKeywordList 131 | domainRegex = domainRegexList 132 | geosite = geositeList 133 | geoip = geoipList 134 | ipCidr = ipList 135 | port = None 136 | processName = None 137 | processPath = None 138 | packageName = None 139 | user = None 140 | userId = None 141 | clashMode = None 142 | invert = None 143 | outbound = genericRuleObject.Tag } 144 | 145 | module RuleObject = 146 | let inline _inbound f p = 147 | f p.inbound <&> fun x -> { p with inbound = x } 148 | 149 | let inline _ipVersion f p = 150 | f p.ipVersion <&> fun x -> { p with ipVersion = x } 151 | 152 | let inline _network f p = 153 | f p.network <&> fun x -> { p with network = x } 154 | 155 | let inline _authUser f p = 156 | f p.authUser <&> fun x -> { p with authUser = x } 157 | 158 | let inline _protocol f p = 159 | f p.protocol <&> fun x -> { p with protocol = x } 160 | 161 | let inline _domainKeyword f p = 162 | f p.domainKeyword <&> fun x -> { p with domainKeyword = x } 163 | 164 | let inline _domainRegex f p = 165 | f p.domainRegex <&> fun x -> { p with domainRegex = x } 166 | 167 | let inline _geoip f p = 168 | f p.geoip <&> fun x -> { p with geoip = x } 169 | 170 | let inline _ipCidr f p = 171 | f p.ipCidr <&> fun x -> { p with ipCidr = x } 172 | 173 | let inline _port f p = 174 | f p.port <&> fun x -> { p with port = x } 175 | 176 | let inline _processName f p = 177 | f p.processName <&> fun x -> { p with processName = x } 178 | 179 | let inline _processPath f p = 180 | f p.processPath <&> fun x -> { p with processPath = x } 181 | 182 | let inline _packageName f p = 183 | f p.packageName <&> fun x -> { p with packageName = x } 184 | 185 | let inline _user f p = 186 | f p.user <&> fun x -> { p with user = x } 187 | 188 | let inline _userId f p = 189 | f p.userId <&> fun x -> { p with userId = x } 190 | 191 | let inline _clashMode f p = 192 | f p.clashMode <&> fun x -> { p with clashMode = x } 193 | 194 | let inline _invert f p = 195 | f p.invert <&> fun x -> { p with invert = x } 196 | 197 | let inline _outbound f p = 198 | f p.outbound <&> fun x -> { p with outbound = x } 199 | -------------------------------------------------------------------------------- /Aurum.Configuration/ShareLinks.fs: -------------------------------------------------------------------------------- 1 | module Aurum.Configuration.ShareLinks 2 | 3 | open System.Collections.Generic 4 | open Microsoft.AspNetCore.WebUtilities 5 | open Aurum 6 | open Aurum.Configuration.Shared.Adapter 7 | open Aurum.Configuration.Shared.Shadowsocks 8 | open Aurum.Configuration.Shared.V2fly 9 | open FSharpPlus 10 | open FSharpPlus.Data 11 | 12 | let createV2FlyObjectFromUri (uriObject: System.Uri) = 13 | let protocolSetting = 14 | match uriObject.Scheme with 15 | | "vmess" -> 16 | createVMessObject uriObject.Host uriObject.Port uriObject.UserInfo VMessSecurity.Auto 17 | |> Success 18 | | unknown -> Failure([ ShareLinkFormatException $"unknown sharelink protocol {unknown}" ]) 19 | 20 | let description = 21 | if uriObject.Fragment.Length = 0 then 22 | "" 23 | else 24 | uriObject.Fragment.Substring(1) 25 | 26 | let queryParams = QueryHelpers.ParseQuery uriObject.Query 27 | 28 | let retrieveFromShareLink = getFirstQuerystringEntry queryParams 29 | 30 | let tryRetrieveFromShareLink = tryRetrieveFromShareLink queryParams 31 | 32 | let securityType = tryRetrieveFromShareLink "security" |> Option.defaultValue "none" 33 | 34 | let securitySetting = 35 | match securityType with 36 | | "tls" -> 37 | createTLSObject 38 | (tryRetrieveFromShareLink "sni") 39 | (tryRetrieveFromShareLink "alpn" 40 | |> Option.map (fun alpn -> alpn.Split(",") |> Seq.toList)) 41 | 42 | |> Success 43 | | "none" -> Success(TransportSecurity.None) 44 | | unsupported -> Failure([ ShareLinkFormatException $"unsupported security type {unsupported}" ]) 45 | 46 | let transportType: Validation = 47 | retrieveFromShareLink "type" 48 | |> Result.mapError (fun e -> [ e ]) 49 | |> Validation.ofResult 50 | 51 | let transportSetting = 52 | Validation.bind 53 | (fun transportType -> 54 | match transportType with 55 | | "ws" -> 56 | createWebSocketObject (tryRetrieveFromShareLink "path") None None None (tryRetrieveFromShareLink "host") None 57 | |> Success 58 | | "grpc" -> 59 | retrieveFromShareLink "serviceName" 60 | |> Result.mapError (fun e -> [ e ]) 61 | |> Validation.ofResult 62 | |> Validation.map createGrpcObject 63 | | "http" -> 64 | createHttpObjectWithHost 65 | (tryRetrieveFromShareLink "path") 66 | (tryRetrieveFromShareLink "host") 67 | (HTTP2) 68 | (Some(Dictionary())) 69 | |> Success 70 | | "quic" -> createQuicObject () |> Success 71 | | "kcp" -> 72 | createKCPObject None None None None None None None (tryRetrieveFromShareLink "seed") 73 | |> Success 74 | | "tcp" -> createHttpObjectWithHost None None HTTP1 None |> Success 75 | | unknown -> Failure([ ConfigurationParameterException $"unknown transport protocol {unknown}" ])) 76 | transportType 77 | 78 | let v2flyObject = 79 | createV2flyObject protocolSetting <*> transportSetting <*> securitySetting 80 | |> Validation.map V2fly 81 | 82 | Validation.map (createConfigurationEntry description) v2flyObject 83 | 84 | type SsEncryptionInfo = { Method: string; PSKs: string list } 85 | 86 | let createShadowsocksObjectFromUri (uriObject: System.Uri) = 87 | let host = uriObject.Host 88 | let port = uriObject.Port 89 | 90 | let queryParams = QueryHelpers.ParseQuery uriObject.Query 91 | 92 | let tryRetrieveFromShareLink = tryRetrieveFromShareLink queryParams 93 | 94 | let description = 95 | if uriObject.Fragment.Length = 0 then 96 | "" 97 | else 98 | uriObject.Fragment.Substring(1) 99 | 100 | let encryptionInfo = 101 | match 102 | (if uriObject.UserInfo.IndexOf(":") <> -1 then 103 | Array.toList (System.Uri.UnescapeDataString(uriObject.UserInfo).Split(":")) 104 | else 105 | Array.toList ((decodeBase64Url uriObject.UserInfo).Split(":"))) 106 | with 107 | | protocol :: info -> { Method = protocol; PSKs = info } |> Success 108 | | _ -> Failure([ ShareLinkFormatException $"ill-formed user info \"{uriObject.UserInfo}\"" ]) 109 | 110 | let method = 111 | Validation.bind 112 | (fun encryptionInfo -> 113 | match encryptionInfo.Method with 114 | | "none" -> ShadowsocksEncryption.None |> Success 115 | | "plain" -> ShadowsocksEncryption.Plain |> Success 116 | | "chacha20-poly1305" -> ShadowsocksEncryption.ChaCha20 encryptionInfo.PSKs.Head |> Success 117 | | "chacha20-ietf-poly1305" -> ShadowsocksEncryption.ChaCha20Ietf encryptionInfo.PSKs.Head |> Success 118 | | "aes-128-gcm" -> ShadowsocksEncryption.AES128 encryptionInfo.PSKs.Head |> Success 119 | | "aes-256-gcm" -> ShadowsocksEncryption.AES256 encryptionInfo.PSKs.Head |> Success 120 | | "2022-blake3-aes-128-gcm" -> ShadowsocksEncryption.AES128_2022 encryptionInfo.PSKs |> Success 121 | | "2022-blake3-aes-256-gcm" -> ShadowsocksEncryption.AES256_2022 encryptionInfo.PSKs |> Success 122 | | "2022-blake3-chacha20-poly1305" -> ShadowsocksEncryption.ChaCha20_2022 encryptionInfo.PSKs |> Success 123 | | "2022-blake3-chacha8-poly1305" -> ShadowsocksEncryption.ChaCha8_2022 encryptionInfo.PSKs |> Success 124 | | method -> Failure([ ShareLinkFormatException $"unknown Shadowsocks encryption method {method}" ])) 125 | encryptionInfo 126 | 127 | let plugin = 128 | tryRetrieveFromShareLink "plugin" 129 | |> Option.map (fun op -> 130 | let pluginOpt = op.Split ";" |> Array.toList 131 | 132 | match pluginOpt with 133 | | "obfs" :: opts -> SimpleObfs(System.String.Join(",", List.toArray opts)) |> Success 134 | | "v2ray" :: opts -> V2ray(System.String.Join(",", List.toArray opts)) |> Success 135 | | pluginName :: _ -> Failure([ ShareLinkFormatException $"unknown plugin {pluginName}" ]) 136 | | unknown -> Failure([ ShareLinkFormatException $"ill-formed plugin option \"{unknown}\"" ])) 137 | |> sequence 138 | 139 | let shadowsocksObject = 140 | createShadowsocksObject host port method <*> plugin 141 | |> Validation.map Shadowsocks 142 | 143 | Validation.map (createConfigurationEntry description) shadowsocksObject 144 | 145 | 146 | let decodeShareLink link = 147 | let uriObject = System.Uri link 148 | 149 | match uriObject.Scheme with 150 | | "vmess" 151 | | "vless" -> createV2FlyObjectFromUri uriObject 152 | | "ss" -> createShadowsocksObjectFromUri uriObject 153 | | unknown -> Failure([ ShareLinkFormatException $"unsupported sharelink protocol {unknown}" ]) 154 | -------------------------------------------------------------------------------- /Aurum.Configuration/V2fly/Outbound.fs: -------------------------------------------------------------------------------- 1 | module Aurum.Configuration.V2fly.Outbound 2 | 3 | open System.Text.Json.Serialization 4 | open Aurum 5 | open Aurum.Configuration.Shared 6 | open Aurum.Configuration.Shared.Adapter 7 | open Aurum.Configuration.Shared.V2fly 8 | open Aurum.Configuration.Shared.Shadowsocks 9 | 10 | [] 11 | type ShadowsocksEncryption = 12 | | [] None 13 | | [] Plain 14 | | [] ChaCha20 15 | | [] ChaCha20Ietf 16 | | [] AES128 17 | | [] AES256 18 | 19 | type V2flyShadowsocksObject = 20 | { Address: string 21 | Port: int 22 | Method: ShadowsocksEncryption 23 | Password: string } 24 | 25 | static member FromGenericShadowsocksObject(genericShadowsocksObject: ShadowsocksObject) = 26 | let method, password = 27 | match genericShadowsocksObject.Encryption with 28 | | Shadowsocks.ShadowsocksEncryption.None -> ShadowsocksEncryption.None, "" 29 | | Shadowsocks.ShadowsocksEncryption.Plain -> ShadowsocksEncryption.Plain, "" 30 | | Shadowsocks.ShadowsocksEncryption.AES128 password -> ShadowsocksEncryption.AES128, password 31 | | Shadowsocks.ShadowsocksEncryption.AES256 password -> ShadowsocksEncryption.AES256, password 32 | | Shadowsocks.ShadowsocksEncryption.ChaCha20 password -> ShadowsocksEncryption.ChaCha20, password 33 | | Shadowsocks.ShadowsocksEncryption.ChaCha20Ietf password -> ShadowsocksEncryption.ChaCha20Ietf, password 34 | | encryption -> raise (ConfigurationParameterException $"unsupported Shadowsocks encryption ${encryption}") 35 | 36 | { Address = genericShadowsocksObject.Host 37 | Port = genericShadowsocksObject.Port 38 | Method = method 39 | Password = password } 40 | 41 | type OutboundProtocols = 42 | | VMess of VMessObject 43 | | VLESS of obj 44 | | VLite of obj 45 | | Shadowsocks of V2flyShadowsocksObject 46 | | Trojan of obj 47 | 48 | type OutboundObject = 49 | { SendThrough: string option 50 | Settings: OutboundProtocols 51 | Tag: string 52 | StreamSettings: StreamSettings option 53 | Mux: MuxObject option } 54 | 55 | static member ParseGenericShadowsocksPlugin(genericConfiguration: ShadowsocksObject) = 56 | genericConfiguration.Plugin 57 | |> Option.map (fun inp -> 58 | match inp with 59 | | SimpleObfs _ -> raise (ConfigurationParameterException "simple-obfs plugin is unsupported by v2ray") 60 | | V2ray opt -> 61 | let options = opt.Split(";") |> Array.toList 62 | 63 | if options.Length = 0 then 64 | let transportSettings = createWebSocketObject None None None None None None 65 | 66 | { TransportSettings = transportSettings 67 | SecuritySettings = TransportSecurity.None } 68 | elif options |> List.contains "tls" then 69 | let host = (options |> List.find (fun a -> a.IndexOf("host") <> -1)).Split("=")[1] 70 | 71 | let transportSettings = createWebSocketObject None None None (Some host) None None 72 | 73 | let securitySettings = createTLSObject (Some host) None 74 | 75 | { TransportSettings = transportSettings 76 | SecuritySettings = securitySettings } 77 | elif options |> List.exists (fun a -> a.IndexOf("mode") <> -1) then 78 | let host = (options |> List.find (fun a -> a.IndexOf("host") <> -1)).Split("=")[1] 79 | let transportSettings = createQuicObject () 80 | let securitySettings = createTLSObject (Some host) None 81 | 82 | { TransportSettings = transportSettings 83 | SecuritySettings = securitySettings } 84 | else 85 | raise (ConfigurationParameterException $"unknown Shadowsocks v2ray-plugin options '{opt}'")) 86 | 87 | static member FromGenericConfigurationObject(tag, genericConfiguration: ConfigurationFamily) = 88 | match genericConfiguration with 89 | | V2fly settings -> 90 | match settings.Protocol with 91 | | Protocols.VMess protocolSettings -> 92 | { OutboundObject.SendThrough = None 93 | Settings = VMess protocolSettings 94 | Tag = tag 95 | StreamSettings = Some settings.StreamSettings 96 | Mux = None } 97 | | Protocols.VLESS -> 98 | { OutboundObject.SendThrough = None 99 | Settings = VLESS {| |} // this is a stub. VLESS support will be implemented later 100 | Tag = tag 101 | StreamSettings = Some settings.StreamSettings 102 | Mux = None } 103 | | ConfigurationFamily.Shadowsocks settings -> 104 | { OutboundObject.SendThrough = None 105 | Settings = V2flyShadowsocksObject.FromGenericShadowsocksObject settings |> Shadowsocks 106 | Tag = tag 107 | StreamSettings = OutboundObject.ParseGenericShadowsocksPlugin settings 108 | Mux = None } 109 | 110 | type OutboundJsonObject = 111 | { SendThrough: string option 112 | Protocol: string 113 | Settings: obj 114 | Tag: string 115 | StreamSettings: StreamSettings option 116 | Mux: MuxObject option } 117 | 118 | static member FromOutboundObject(outboundObject: OutboundObject) = 119 | let protocol, (settings: obj) = 120 | match outboundObject.Settings with 121 | | VMess setting -> "vmess", setting 122 | | VLESS setting -> "vless", setting 123 | | VLite setting -> "vlite", setting 124 | | Shadowsocks setting -> "shadowsocks", setting 125 | | Trojan setting -> "trojan", setting 126 | 127 | { SendThrough = outboundObject.SendThrough 128 | Protocol = protocol 129 | Settings = settings 130 | Tag = outboundObject.Tag 131 | StreamSettings = outboundObject.StreamSettings 132 | Mux = outboundObject.Mux } 133 | 134 | member this.ToOutboundObject() = 135 | let settings = // this process is error-prone, but there is no choice since FSharp.SystemTextJson does not have support for unwrapping records onto its upper-layer records. 136 | match this.Protocol with 137 | | "vmess" -> VMess(downcast this.Settings) |> Ok 138 | | "vless" -> VLESS(downcast this.Settings) |> Ok 139 | | "vlite" -> VLite(downcast this.Settings) |> Ok 140 | | "shadowsocks" -> Shadowsocks(downcast this.Settings) |> Ok 141 | | "trojan" -> Trojan(downcast this.Settings) |> Ok 142 | | _ -> Error(ConfigurationParameterException $"unknown protocol type '{this.Protocol}'") 143 | 144 | match settings with 145 | | Ok settings -> 146 | { OutboundObject.SendThrough = this.SendThrough 147 | Settings = settings 148 | Tag = this.Tag 149 | StreamSettings = this.StreamSettings 150 | Mux = this.Mux } 151 | |> Ok 152 | | Error e -> Error e 153 | 154 | let createV2flyOutboundObject sendThrough setting streamSetting tag mux = 155 | { OutboundObject.SendThrough = sendThrough 156 | StreamSettings = streamSetting 157 | Settings = setting 158 | Mux = mux 159 | Tag = tag } 160 | -------------------------------------------------------------------------------- /Aurum.Configuration/Sing/Outbound.fs: -------------------------------------------------------------------------------- 1 | module Aurum.Configuration.Sing.Outbound 2 | 3 | open Aurum.Configuration.Shared.Adapter 4 | open System.Text.Json.Serialization 5 | open System.Collections.Generic 6 | open FSharpPlus.Lens 7 | 8 | [] 9 | type MultiplexProtocol = 10 | | Smux 11 | | Yamux 12 | | H2mux 13 | 14 | type MultiplexRecord = 15 | { enabled: bool 16 | protocol: MultiplexProtocol option 17 | maxConnections: int option 18 | minStreams: int option 19 | maxStreams: int option 20 | padding: bool option } 21 | 22 | module MultiplexRecord = 23 | let inline _enabled f p = 24 | f p.enabled <&> fun x -> { p with enabled = x } 25 | 26 | let inline _protocol f p = 27 | f p.protocol <&> fun x -> { p with protocol = x } 28 | 29 | let inline _maxConnections f p = 30 | f p.maxConnections <&> fun x -> { p with maxConnections = x } 31 | 32 | let inline _minStreams f p = 33 | f p.minStreams <&> fun x -> { p with minStreams = x } 34 | 35 | let inline _maxStreams f p = 36 | f p.maxStreams <&> fun x -> { p with maxStreams = x } 37 | 38 | let inline _padding f p = 39 | f p.padding <&> fun x -> { p with padding = x } 40 | 41 | type DirectRecord = 42 | { tag: string 43 | 44 | overrideAddress: string 45 | overridePort: int16 46 | proxyProtocol: int 47 | 48 | detour: string option 49 | bindInterface: string option 50 | bindAddress: string option 51 | routingMark: int option 52 | reuseAddr: bool option 53 | connectTimeout: string option 54 | tcpFastOpen: bool option 55 | domainStrategy: string option 56 | fallbackDelay: string option } 57 | 58 | module DirectRecord = 59 | let inline _tag f p = f p.tag <&> fun x -> { p with tag = x } 60 | 61 | let inline _overrideAddress f p = 62 | f p.overrideAddress <&> fun x -> { p with overrideAddress = x } 63 | 64 | let inline _overridePort f p = 65 | f p.overridePort <&> fun x -> { p with overridePort = x } 66 | 67 | let inline _proxyProtocol f p = 68 | f p.proxyProtocol <&> fun x -> { p with proxyProtocol = x } 69 | 70 | let inline _detour f p = 71 | f p.detour <&> fun x -> { p with detour = x } 72 | 73 | let inline _bindInterface f p = 74 | f p.bindInterface <&> fun x -> { p with bindInterface = x } 75 | 76 | let inline _bindAddress f p = 77 | f p.bindAddress <&> fun x -> { p with bindAddress = x } 78 | 79 | let inline _routingMark f p = 80 | f p.routingMark <&> fun x -> { p with routingMark = x } 81 | 82 | let inline _reuseAddr f p = 83 | f p.reuseAddr <&> fun x -> { p with reuseAddr = x } 84 | 85 | let inline _connectTimeout f p = 86 | f p.connectTimeout <&> fun x -> { p with connectTimeout = x } 87 | 88 | let inline _tcpFastOpen f p = 89 | f p.tcpFastOpen <&> fun x -> { p with tcpFastOpen = x } 90 | 91 | let inline _domainStrategy f p = 92 | f p.domainStrategy <&> fun x -> { p with domainStrategy = x } 93 | 94 | let inline _fallbackDelay f p = 95 | f p.fallbackDelay <&> fun x -> { p with fallbackDelay = x } 96 | 97 | type BlockRecord = { tag: string } 98 | 99 | module BlockRecord = 100 | let inline _tag f p = f p.tag <&> fun x -> { p with tag = x } 101 | 102 | type ShadowsocksRecord = 103 | { tag: string 104 | 105 | server: string 106 | serverPort: int16 107 | method: string 108 | password: string 109 | network: string option 110 | udpOverTcp: obj option 111 | multiplex: MultiplexRecord option 112 | 113 | detour: string option 114 | bindInterface: string option 115 | bindAddress: string option 116 | routingMark: int option 117 | reuseAddr: bool option 118 | connectTimeout: string option 119 | tcpFastOpen: bool option 120 | domainStrategy: string option 121 | fallbackDelay: string option } 122 | 123 | module ShadowsocksRecord = 124 | let inline _tag f p = f p.tag <&> fun x -> { p with tag = x } 125 | 126 | let inline _server f p = 127 | f p.server <&> fun x -> { p with server = x } 128 | 129 | let inline _serverPort f p = 130 | f p.serverPort <&> fun x -> { p with serverPort = x } 131 | 132 | let inline _method f p = 133 | f p.method <&> fun x -> { p with method = x } 134 | 135 | let inline _password f p = 136 | f p.password <&> fun x -> { p with password = x } 137 | 138 | let inline _network f p = 139 | f p.network <&> fun x -> { p with network = x } 140 | 141 | let inline _udpOverTcp f p = 142 | f p.udpOverTcp <&> fun x -> { p with udpOverTcp = x } 143 | 144 | let inline _multiplex f p = 145 | f p.multiplex <&> fun x -> { p with multiplex = x } 146 | 147 | let inline _detour f p = 148 | f p.detour <&> fun x -> { p with detour = x } 149 | 150 | let inline _bindInterface f p = 151 | f p.bindInterface <&> fun x -> { p with bindInterface = x } 152 | 153 | let inline _bindAddress f p = 154 | f p.bindAddress <&> fun x -> { p with bindAddress = x } 155 | 156 | let inline _routingMark f p = 157 | f p.routingMark <&> fun x -> { p with routingMark = x } 158 | 159 | let inline _reuseAddr f p = 160 | f p.reuseAddr <&> fun x -> { p with reuseAddr = x } 161 | 162 | let inline _connectTimeout f p = 163 | f p.connectTimeout <&> fun x -> { p with connectTimeout = x } 164 | 165 | let inline _tcpFastOpen f p = 166 | f p.tcpFastOpen <&> fun x -> { p with tcpFastOpen = x } 167 | 168 | let inline _domainStrategy f p = 169 | f p.domainStrategy <&> fun x -> { p with domainStrategy = x } 170 | 171 | let inline _fallbackDelay f p = 172 | f p.fallbackDelay <&> fun x -> { p with fallbackDelay = x } 173 | 174 | type HttpTransport = 175 | { host: string list 176 | path: string 177 | method: string 178 | headers: Dictionary 179 | idleTimeout: string 180 | pingTimeout: string } 181 | 182 | type WebSocketTransport = 183 | { path: string 184 | headers: Dictionary 185 | maxEarlyData: int 186 | earlyDataHeaderName: string } 187 | 188 | type GrpcTransport = 189 | { serviceName: string 190 | idleTimeout: string 191 | pingTimeout: string 192 | permitWithoutStream: bool } 193 | 194 | type V2RayTransport = 195 | | HTTP of HttpTransport 196 | | WebSocket of WebSocketTransport 197 | | QUIC 198 | | GRPC of GrpcTransport 199 | 200 | [] 201 | type V2RayPaketEncoding = 202 | | [] None 203 | | [] PaketAddr 204 | | [] Xudp 205 | 206 | type VMessRecord = 207 | { tag: string 208 | 209 | server: string 210 | serverPort: int16 211 | security: string option 212 | uuid: string 213 | alterId: int option 214 | globalPadding: bool option 215 | authenticatedLength: bool option 216 | network: string option 217 | paketEncoding: V2RayPaketEncoding option 218 | multiplex: MultiplexRecord option 219 | transport: V2RayTransport 220 | 221 | detour: string option 222 | bindInterface: string option 223 | bindAddress: string option 224 | routingMark: int option 225 | reuseAddr: bool option 226 | connectTimeout: string option 227 | tcpFastOpen: bool option 228 | domainStrategy: string option 229 | fallbackDelay: string option } 230 | 231 | static member FromV2FlyObject v2flyObject = () 232 | 233 | module VMessRecord = 234 | let inline _tag f p = f p.tag <&> fun x -> { p with tag = x } 235 | 236 | let inline _server f p = 237 | f p.server <&> fun x -> { p with server = x } 238 | 239 | let inline _serverPort f p = 240 | f p.serverPort <&> fun x -> { p with serverPort = x } 241 | 242 | let inline _security f p = 243 | f p.security <&> fun x -> { p with security = x } 244 | 245 | let inline _uuid f p = 246 | f p.uuid <&> fun x -> { p with uuid = x } 247 | 248 | let inline _network f p = 249 | f p.network <&> fun x -> { p with network = x } 250 | 251 | let inline _multiplex f p = 252 | f p.multiplex <&> fun x -> { p with multiplex = x } 253 | 254 | type SelectorRecord = 255 | { tag: string 256 | 257 | outbounds: string list 258 | [] 259 | defaultOutbound: string option } 260 | 261 | module SelectorRecord = 262 | let inline _tag f p = f p.tag <&> fun x -> { p with tag = x } 263 | 264 | let inline _outbounds f p = 265 | f p.outbounds <&> fun x -> { p with outbounds = x } 266 | 267 | let inline _defaultOutbound f p = 268 | f p.defaultOutbound <&> fun x -> { p with defaultOutbound = x } 269 | 270 | type Outbounds = 271 | | Direct of DirectRecord 272 | | Block of BlockRecord 273 | | SOCKS of obj // SOCKSRecord 274 | | HTTP of obj // HTTPRecord 275 | | Shadowsocks of ShadowsocksRecord 276 | | VMess of VMessRecord 277 | | Selector of SelectorRecord 278 | 279 | static member FromSharedAdapters sharedAdapter = () 280 | -------------------------------------------------------------------------------- /paket.lock: -------------------------------------------------------------------------------- 1 | RESTRICTION: == net7.0 2 | NUGET 3 | remote: https://api.nuget.org/v3/index.json 4 | Aether (8.3.1) 5 | FSharp.Core (>= 4.3.4) 6 | Akka (1.5.13) 7 | Microsoft.Extensions.ObjectPool (>= 7.0.10) 8 | Newtonsoft.Json (>= 13.0.1) 9 | System.Collections.Immutable (>= 5.0) 10 | System.Configuration.ConfigurationManager (>= 6.0.1) 11 | System.Reflection.Emit (>= 4.7) 12 | System.Threading.Channels (>= 5.0) 13 | Akka.DependencyInjection (1.5.13) 14 | Akka (>= 1.5.13) 15 | Microsoft.Extensions.DependencyInjection.Abstractions (>= 3.1) 16 | Akka.FSharp (1.5.13) 17 | Akka (>= 1.5.13) 18 | FSharp.Core (>= 7.0) 19 | FSharp.Quotations.Evaluator (>= 2.1) 20 | FsPickler (>= 5.3.2) 21 | Akka.Hosting (1.5.12.1) 22 | Akka.DependencyInjection (>= 1.5.12) 23 | Microsoft.Extensions.Configuration (>= 3.0) 24 | Microsoft.Extensions.Hosting (>= 3.0) 25 | FSharp.Control.Reactive (5.0.5) 26 | FSharp.Core (>= 4.7.2) 27 | System.Reactive (>= 5.0 < 6.0) 28 | FSharp.Core (7.0.400) 29 | FSharp.Json (0.4.1) 30 | FSharp.Core (>= 4.6.2) 31 | FSharp.Quotations.Evaluator (2.1) 32 | FSharp.Core (>= 4.3.1) 33 | FSharp.SystemTextJson (1.2.42) 34 | FSharp.Core (>= 4.7) 35 | System.Text.Json (>= 6.0) 36 | FSharpPlus (1.4.1) 37 | FSharp.Core (>= 6.0.6) 38 | FsPickler (5.3.2) 39 | FSharp.Core (>= 4.3.2) 40 | System.Reflection.Emit.Lightweight (>= 4.3) 41 | Funcky (3.3) 42 | Google.Protobuf (3.24.3) 43 | Messerli.ChangeCase (1.2.1) 44 | Funcky (>= 3.0 < 4.0) 45 | Microsoft.AspNetCore.WebUtilities (2.2) 46 | Microsoft.Net.Http.Headers (>= 2.2) 47 | System.Text.Encodings.Web (>= 4.5) 48 | Microsoft.Extensions.Configuration (7.0) 49 | Microsoft.Extensions.Configuration.Abstractions (>= 7.0) 50 | Microsoft.Extensions.Primitives (>= 7.0) 51 | Microsoft.Extensions.Configuration.Abstractions (7.0) 52 | Microsoft.Extensions.Primitives (>= 7.0) 53 | Microsoft.Extensions.Configuration.Binder (7.0.4) 54 | Microsoft.Extensions.Configuration.Abstractions (>= 7.0) 55 | Microsoft.Extensions.Configuration.CommandLine (7.0) 56 | Microsoft.Extensions.Configuration (>= 7.0) 57 | Microsoft.Extensions.Configuration.Abstractions (>= 7.0) 58 | Microsoft.Extensions.Configuration.EnvironmentVariables (7.0) 59 | Microsoft.Extensions.Configuration (>= 7.0) 60 | Microsoft.Extensions.Configuration.Abstractions (>= 7.0) 61 | Microsoft.Extensions.Configuration.FileExtensions (7.0) 62 | Microsoft.Extensions.Configuration (>= 7.0) 63 | Microsoft.Extensions.Configuration.Abstractions (>= 7.0) 64 | Microsoft.Extensions.FileProviders.Abstractions (>= 7.0) 65 | Microsoft.Extensions.FileProviders.Physical (>= 7.0) 66 | Microsoft.Extensions.Primitives (>= 7.0) 67 | Microsoft.Extensions.Configuration.Json (7.0) 68 | Microsoft.Extensions.Configuration (>= 7.0) 69 | Microsoft.Extensions.Configuration.Abstractions (>= 7.0) 70 | Microsoft.Extensions.Configuration.FileExtensions (>= 7.0) 71 | Microsoft.Extensions.FileProviders.Abstractions (>= 7.0) 72 | System.Text.Json (>= 7.0) 73 | Microsoft.Extensions.Configuration.UserSecrets (7.0) 74 | Microsoft.Extensions.Configuration.Abstractions (>= 7.0) 75 | Microsoft.Extensions.Configuration.Json (>= 7.0) 76 | Microsoft.Extensions.FileProviders.Abstractions (>= 7.0) 77 | Microsoft.Extensions.FileProviders.Physical (>= 7.0) 78 | Microsoft.Extensions.DependencyInjection (7.0) 79 | Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0) 80 | Microsoft.Extensions.DependencyInjection.Abstractions (7.0) 81 | Microsoft.Extensions.FileProviders.Abstractions (7.0) 82 | Microsoft.Extensions.Primitives (>= 7.0) 83 | Microsoft.Extensions.FileProviders.Physical (7.0) 84 | Microsoft.Extensions.FileProviders.Abstractions (>= 7.0) 85 | Microsoft.Extensions.FileSystemGlobbing (>= 7.0) 86 | Microsoft.Extensions.Primitives (>= 7.0) 87 | Microsoft.Extensions.FileSystemGlobbing (7.0) 88 | Microsoft.Extensions.Hosting (7.0.1) 89 | Microsoft.Extensions.Configuration (>= 7.0) 90 | Microsoft.Extensions.Configuration.Abstractions (>= 7.0) 91 | Microsoft.Extensions.Configuration.Binder (>= 7.0.3) 92 | Microsoft.Extensions.Configuration.CommandLine (>= 7.0) 93 | Microsoft.Extensions.Configuration.EnvironmentVariables (>= 7.0) 94 | Microsoft.Extensions.Configuration.FileExtensions (>= 7.0) 95 | Microsoft.Extensions.Configuration.Json (>= 7.0) 96 | Microsoft.Extensions.Configuration.UserSecrets (>= 7.0) 97 | Microsoft.Extensions.DependencyInjection (>= 7.0) 98 | Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0) 99 | Microsoft.Extensions.FileProviders.Abstractions (>= 7.0) 100 | Microsoft.Extensions.FileProviders.Physical (>= 7.0) 101 | Microsoft.Extensions.Hosting.Abstractions (>= 7.0) 102 | Microsoft.Extensions.Logging (>= 7.0) 103 | Microsoft.Extensions.Logging.Abstractions (>= 7.0) 104 | Microsoft.Extensions.Logging.Configuration (>= 7.0) 105 | Microsoft.Extensions.Logging.Console (>= 7.0) 106 | Microsoft.Extensions.Logging.Debug (>= 7.0) 107 | Microsoft.Extensions.Logging.EventLog (>= 7.0) 108 | Microsoft.Extensions.Logging.EventSource (>= 7.0) 109 | Microsoft.Extensions.Options (>= 7.0.1) 110 | System.Diagnostics.DiagnosticSource (>= 7.0.1) 111 | Microsoft.Extensions.Hosting.Abstractions (7.0) 112 | Microsoft.Extensions.Configuration.Abstractions (>= 7.0) 113 | Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0) 114 | Microsoft.Extensions.FileProviders.Abstractions (>= 7.0) 115 | Microsoft.Extensions.Logging (7.0) 116 | Microsoft.Extensions.DependencyInjection (>= 7.0) 117 | Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0) 118 | Microsoft.Extensions.Logging.Abstractions (>= 7.0) 119 | Microsoft.Extensions.Options (>= 7.0) 120 | Microsoft.Extensions.Logging.Abstractions (7.0.1) 121 | Microsoft.Extensions.Logging.Configuration (7.0) 122 | Microsoft.Extensions.Configuration (>= 7.0) 123 | Microsoft.Extensions.Configuration.Abstractions (>= 7.0) 124 | Microsoft.Extensions.Configuration.Binder (>= 7.0) 125 | Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0) 126 | Microsoft.Extensions.Logging (>= 7.0) 127 | Microsoft.Extensions.Logging.Abstractions (>= 7.0) 128 | Microsoft.Extensions.Options (>= 7.0) 129 | Microsoft.Extensions.Options.ConfigurationExtensions (>= 7.0) 130 | Microsoft.Extensions.Logging.Console (7.0) 131 | Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0) 132 | Microsoft.Extensions.Logging (>= 7.0) 133 | Microsoft.Extensions.Logging.Abstractions (>= 7.0) 134 | Microsoft.Extensions.Logging.Configuration (>= 7.0) 135 | Microsoft.Extensions.Options (>= 7.0) 136 | System.Text.Json (>= 7.0) 137 | Microsoft.Extensions.Logging.Debug (7.0) 138 | Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0) 139 | Microsoft.Extensions.Logging (>= 7.0) 140 | Microsoft.Extensions.Logging.Abstractions (>= 7.0) 141 | Microsoft.Extensions.Logging.EventLog (7.0) 142 | Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0) 143 | Microsoft.Extensions.Logging (>= 7.0) 144 | Microsoft.Extensions.Logging.Abstractions (>= 7.0) 145 | Microsoft.Extensions.Options (>= 7.0) 146 | System.Diagnostics.EventLog (>= 7.0) 147 | Microsoft.Extensions.Logging.EventSource (7.0) 148 | Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0) 149 | Microsoft.Extensions.Logging (>= 7.0) 150 | Microsoft.Extensions.Logging.Abstractions (>= 7.0) 151 | Microsoft.Extensions.Options (>= 7.0) 152 | Microsoft.Extensions.Primitives (>= 7.0) 153 | System.Text.Json (>= 7.0) 154 | Microsoft.Extensions.ObjectPool (7.0.11) 155 | Microsoft.Extensions.Options (7.0.1) 156 | Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0) 157 | Microsoft.Extensions.Primitives (>= 7.0) 158 | Microsoft.Extensions.Options.ConfigurationExtensions (7.0) 159 | Microsoft.Extensions.Configuration.Abstractions (>= 7.0) 160 | Microsoft.Extensions.Configuration.Binder (>= 7.0) 161 | Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0) 162 | Microsoft.Extensions.Options (>= 7.0) 163 | Microsoft.Extensions.Primitives (>= 7.0) 164 | Microsoft.Extensions.Primitives (7.0) 165 | Microsoft.Net.Http.Headers (2.2.8) 166 | Microsoft.Extensions.Primitives (>= 2.2) 167 | System.Buffers (>= 4.5) 168 | Microsoft.Win32.SystemEvents (7.0) 169 | Nanoid (3.0) 170 | Newtonsoft.Json (13.0.3) 171 | Protobuf.FSharp (0.2) 172 | FSharp.Core (>= 6.0.2) 173 | Google.Protobuf (>= 3.17.3) 174 | Serilog (3.0.1) 175 | Serilog.Sinks.Console (4.1) 176 | Serilog (>= 2.10) 177 | Serilog.Sinks.File (5.0) 178 | Serilog (>= 2.10) 179 | sqlite-net-pcl (1.8.116) 180 | SQLitePCLRaw.bundle_green (>= 2.0.4) 181 | SQLitePCLRaw.bundle_green (2.1.6) 182 | SQLitePCLRaw.lib.e_sqlite3 (>= 2.1.6) 183 | SQLitePCLRaw.provider.e_sqlite3 (>= 2.1.6) 184 | SQLitePCLRaw.core (2.1.6) 185 | System.Memory (>= 4.5.3) 186 | SQLitePCLRaw.lib.e_sqlite3 (2.1.6) 187 | SQLitePCLRaw.provider.e_sqlite3 (2.1.6) 188 | SQLitePCLRaw.core (>= 2.1.6) 189 | System.Buffers (4.5.1) 190 | System.Collections.Immutable (7.0) 191 | System.Configuration.ConfigurationManager (7.0) 192 | System.Diagnostics.EventLog (>= 7.0) 193 | System.Security.Cryptography.ProtectedData (>= 7.0) 194 | System.Security.Permissions (>= 7.0) 195 | System.Diagnostics.DiagnosticSource (7.0.2) 196 | System.Diagnostics.EventLog (7.0) 197 | System.Drawing.Common (7.0) 198 | Microsoft.Win32.SystemEvents (>= 7.0) 199 | System.Memory (4.5.5) 200 | System.Reactive (5.0) 201 | System.Reflection.Emit (4.7) 202 | System.Reflection.Emit.Lightweight (4.7) 203 | System.Security.Cryptography.ProtectedData (7.0.1) 204 | System.Security.Permissions (7.0) 205 | System.Windows.Extensions (>= 7.0) 206 | System.Text.Encodings.Web (7.0) 207 | System.Text.Json (7.0.3) 208 | System.Text.Encodings.Web (>= 7.0) 209 | System.Threading.Channels (7.0) 210 | System.Windows.Extensions (7.0) 211 | System.Drawing.Common (>= 7.0) 212 | -------------------------------------------------------------------------------- /Aurum.Configuration/Sing/Inbound.fs: -------------------------------------------------------------------------------- 1 | module Aurum.Configuration.Sing.Inbound 2 | 3 | open Aurum.Configuration.Sing.Shared 4 | open FSharpPlus.Lens 5 | 6 | type SOCKSRecord = 7 | { tag: string 8 | 9 | listen: string 10 | listenPort: int16 option 11 | tcpFastOpen: bool option 12 | udpFragment: bool option 13 | sniff: bool option 14 | sniffOverrideDestination: bool option 15 | domainStrategy: string option 16 | udpTimeout: int option 17 | proxyProtocol: bool option 18 | proxyProtocolAcceptNoHeader: bool option 19 | detour: string option 20 | 21 | users: obj list } 22 | 23 | module SOCKSRecord = 24 | let inline _tag f p = f p.tag <&> fun x -> { p with tag = x } 25 | 26 | let inline _listen f p = 27 | f p.listen <&> fun x -> { p with listen = x } 28 | 29 | let inline _listenPort f p = 30 | f p.listenPort <&> fun x -> { p with listenPort = x } 31 | 32 | let inline _tcpFastOpen f p = 33 | f p.tcpFastOpen <&> fun x -> { p with tcpFastOpen = x } 34 | 35 | let inline _udpFragment f p = 36 | f p.udpFragment <&> fun x -> { p with udpFragment = x } 37 | 38 | let inline _sniff f p = 39 | f p.sniff <&> fun x -> { p with sniff = x } 40 | 41 | let inline _sniffOverrideDestination f p = 42 | f p.sniffOverrideDestination 43 | <&> fun x -> { p with sniffOverrideDestination = x } 44 | 45 | let inline _domainStrategy f p = 46 | f p.domainStrategy <&> fun x -> { p with domainStrategy = x } 47 | 48 | let inline _udpTimeout f p = 49 | f p.udpTimeout <&> fun x -> { p with udpTimeout = x } 50 | 51 | let inline _proxyProtocol f p = 52 | f p.proxyProtocol <&> fun x -> { p with proxyProtocol = x } 53 | 54 | let inline _proxyProtocolAcceptNoHeader f p = 55 | f p.proxyProtocolAcceptNoHeader 56 | <&> fun x -> 57 | { p with 58 | proxyProtocolAcceptNoHeader = x } 59 | 60 | let inline _detour f p = 61 | f p.detour <&> fun x -> { p with detour = x } 62 | 63 | let inline _users f p = 64 | f p.users <&> fun x -> { p with users = x } 65 | 66 | type HttpRecord = 67 | { tag: string 68 | 69 | listen: string 70 | listenPort: int16 option 71 | tcpFastOpen: bool option 72 | udpFragment: bool option 73 | sniff: bool option 74 | sniffOverrideDestination: bool option 75 | domainStrategy: string option 76 | udpTimeout: int option 77 | proxyProtocol: bool option 78 | proxyProtocolAcceptNoHeader: bool option 79 | detour: string option 80 | 81 | users: obj list option 82 | tls: TLSInbound option 83 | setSystemProxy: bool option } 84 | 85 | module HttpRecord = 86 | let inline _tag f p = f p.tag <&> fun x -> { p with tag = x } 87 | 88 | let inline _listen f p = 89 | f p.listen <&> fun x -> { p with listen = x } 90 | 91 | let inline _listenPort f p = 92 | f p.listenPort <&> fun x -> { p with listenPort = x } 93 | 94 | let inline _tcpFastOpen f p = 95 | f p.tcpFastOpen <&> fun x -> { p with tcpFastOpen = x } 96 | 97 | let inline _udpFragment f p = 98 | f p.udpFragment <&> fun x -> { p with udpFragment = x } 99 | 100 | let inline _sniff f p = 101 | f p.sniff <&> fun x -> { p with sniff = x } 102 | 103 | let inline _sniffOverrideDestination f p = 104 | f p.sniffOverrideDestination 105 | <&> fun x -> { p with sniffOverrideDestination = x } 106 | 107 | let inline _domainStrategy f p = 108 | f p.domainStrategy <&> fun x -> { p with domainStrategy = x } 109 | 110 | let inline _udpTimeout f p = 111 | f p.udpTimeout <&> fun x -> { p with udpTimeout = x } 112 | 113 | let inline _proxyProtocol f p = 114 | f p.proxyProtocol <&> fun x -> { p with proxyProtocol = x } 115 | 116 | let inline _proxyProtocolAcceptNoHeader f p = 117 | f p.proxyProtocolAcceptNoHeader 118 | <&> fun x -> 119 | { p with 120 | proxyProtocolAcceptNoHeader = x } 121 | 122 | let inline _detour f p = 123 | f p.detour <&> fun x -> { p with detour = x } 124 | 125 | let inline _users f p = 126 | f p.users <&> fun x -> { p with users = x } 127 | 128 | let inline _tls f p = f p.tls <&> fun x -> { p with tls = x } 129 | 130 | let inline _setSystemProxy f p = 131 | f p.setSystemProxy <&> fun x -> { p with setSystemProxy = x } 132 | 133 | type MixedRecord = 134 | { tag: string 135 | 136 | listen: string 137 | listenPort: int16 option 138 | tcpFastOpen: bool option 139 | udpFragment: bool option 140 | sniff: bool option 141 | sniffOverrideDestination: bool option 142 | domainStrategy: string option 143 | udpTimeout: int option 144 | proxyProtocol: bool option 145 | proxyProtocolAcceptNoHeader: bool option 146 | detour: string option 147 | 148 | users: obj list option 149 | setSystemProxy: bool option } 150 | 151 | module MixedRecord = 152 | let inline tag_ f p = f p.tag <&> fun x -> { p with tag = x } 153 | 154 | let inline _listen f p = 155 | f p.listen <&> fun x -> { p with listen = x } 156 | 157 | let inline _listenPort f p = 158 | f p.listenPort <&> fun x -> { p with listenPort = x } 159 | 160 | let inline _tcpFastOpen f p = 161 | f p.tcpFastOpen <&> fun x -> { p with tcpFastOpen = x } 162 | 163 | let inline _udpFragment f p = 164 | f p.udpFragment <&> fun x -> { p with udpFragment = x } 165 | 166 | let inline _sniff f p = 167 | f p.sniff <&> fun x -> { p with sniff = x } 168 | 169 | let inline _sniffOverrideDestination f p = 170 | f p.sniffOverrideDestination 171 | <&> fun x -> { p with sniffOverrideDestination = x } 172 | 173 | let inline _domainStrategy f p = 174 | f p.domainStrategy <&> fun x -> { p with domainStrategy = x } 175 | 176 | let inline _udpTimeout f p = 177 | f p.udpTimeout <&> fun x -> { p with udpTimeout = x } 178 | 179 | let inline _proxyProtocol f p = 180 | f p.proxyProtocol <&> fun x -> { p with proxyProtocol = x } 181 | 182 | let inline _proxyProtocolAcceptNoHeader f p = 183 | f p.proxyProtocolAcceptNoHeader 184 | <&> fun x -> 185 | { p with 186 | proxyProtocolAcceptNoHeader = x } 187 | 188 | let inline _detour f p = 189 | f p.detour <&> fun x -> { p with detour = x } 190 | 191 | let inline _users f p = 192 | f p.users <&> fun x -> { p with users = x } 193 | 194 | let inline _setSystemProxy f p = 195 | f p.setSystemProxy <&> fun x -> { p with setSystemProxy = x } 196 | 197 | type TunStack = 198 | | System 199 | | GVisor // not included by default 200 | | Mixed 201 | | Lwip // upstream archived 202 | 203 | type TunRecord = 204 | { tag: string 205 | interfaceName: string option 206 | inet4Address: string 207 | inet6Address: string option 208 | mtu: int option 209 | autoRoute: bool option 210 | strictRoute: bool option 211 | inet4RouteAddress: string list option 212 | inet6RouteAddress: string list option 213 | endpointIndependentNat: bool option 214 | udpTimeout: int option 215 | stack: TunStack option 216 | includeInterface: string list option 217 | excludeInterface: string list option 218 | includeUid: int list option 219 | includeUidRange: string list option 220 | excludeUid: int list option 221 | excludeUidRange: string list option 222 | includeAndroidUser: int list option 223 | includePackage: string list option 224 | excludePackage: string list option 225 | platform: obj option 226 | 227 | listen: string 228 | listenPort: int16 option 229 | tcpFastOpen: bool option 230 | udpFragment: bool option 231 | sniff: bool option 232 | sniffOverrideDestination: bool option 233 | domainStrategy: string option 234 | proxyProtocol: bool option 235 | proxyProtocolAcceptNoHeader: bool option 236 | detour: string option } 237 | 238 | module TunRecord = 239 | let inline _tag f p = f p.tag <&> fun x -> { p with tag = x } 240 | 241 | let inline _interfaceName f p = 242 | f p.interfaceName <&> fun x -> { p with interfaceName = x } 243 | 244 | let inline _endpointIndependentNat f p = 245 | f p.endpointIndependentNat <&> fun x -> { p with endpointIndependentNat = x } 246 | 247 | let inline _udpTimeout f p = 248 | f p.udpTimeout <&> fun x -> { p with udpTimeout = x } 249 | 250 | let inline _stack f p = 251 | f p.stack <&> fun x -> { p with stack = x } 252 | 253 | let inline _includeInterface f p = 254 | f p.includeInterface <&> fun x -> { p with includeInterface = x } 255 | 256 | let inline _excludeInterface f p = 257 | f p.excludeInterface <&> fun x -> { p with excludeInterface = x } 258 | 259 | let inline _includeUid f p = 260 | f p.includeUid <&> fun x -> { p with includeUid = x } 261 | 262 | let inline _includeUidRange f p = 263 | f p.includeUidRange <&> fun x -> { p with includeUidRange = x } 264 | 265 | let inline _excludeUid f p = 266 | f p.excludeUid <&> fun x -> { p with excludeUid = x } 267 | 268 | let inline _excludeUidRange f p = 269 | f p.excludeUidRange <&> fun x -> { p with excludeUidRange = x } 270 | 271 | let inline _includeAndroidUser f p = 272 | f p.includeAndroidUser <&> fun x -> { p with includeAndroidUser = x } 273 | 274 | let inline _includePackage f p = 275 | f p.includePackage <&> fun x -> { p with includePackage = x } 276 | 277 | let inline _excludePackage f p = 278 | f p.excludePackage <&> fun x -> { p with excludePackage = x } 279 | 280 | let inline _platform f p = 281 | f p.platform <&> fun x -> { p with platform = x } 282 | 283 | let inline _listen f p = 284 | f p.listen <&> fun x -> { p with listen = x } 285 | 286 | let inline _listenPort f p = 287 | f p.listenPort <&> fun x -> { p with listenPort = x } 288 | 289 | let inline _tcpFastOpen f p = 290 | f p.tcpFastOpen <&> fun x -> { p with tcpFastOpen = x } 291 | 292 | let inline _udpFragment f p = 293 | f p.udpFragment <&> fun x -> { p with udpFragment = x } 294 | 295 | let inline _sniff f p = 296 | f p.sniff <&> fun x -> { p with sniff = x } 297 | 298 | let inline _sniffOverrideDestination f p = 299 | f p.sniffOverrideDestination 300 | <&> fun x -> { p with sniffOverrideDestination = x } 301 | 302 | let inline _domainStrategy f p = 303 | f p.domainStrategy <&> fun x -> { p with domainStrategy = x } 304 | 305 | let inline _proxyProtocol f p = 306 | f p.proxyProtocol <&> fun x -> { p with proxyProtocol = x } 307 | 308 | let inline _proxyProtocolAcceptNoHeader f p = 309 | f p.proxyProtocolAcceptNoHeader 310 | <&> fun x -> 311 | { p with 312 | proxyProtocolAcceptNoHeader = x } 313 | 314 | let inline _detour f p = 315 | f p.detour <&> fun x -> { p with detour = x } 316 | -------------------------------------------------------------------------------- /Aurum.Configuration/Shared/Routing.fs: -------------------------------------------------------------------------------- 1 | module Aurum.Configuration.Shared.Routing 2 | 3 | open System.Text.Json.Serialization 4 | open Aurum 5 | open FSharpPlus.Lens 6 | open FSharpPlus.Data 7 | open FSharpPlus 8 | 9 | let inline traverseResultList (f: 'a -> Result<'b, 'e>) (xs: 'a list) : Result<'b list, 'e> = traverse f xs 10 | 11 | type DomainStrategy = 12 | | AsIs 13 | | IPIfNonMatch 14 | | IPOnDemand 15 | 16 | type RuleMatchProtocol = 17 | | HTTP 18 | | TLS 19 | 20 | type RuleMatchNetwork = 21 | | [] TCP 22 | | [] UDP 23 | | [] TCPAndUDP 24 | 25 | type DomainMatchingType = 26 | | Full of string 27 | | Regex of string 28 | | Suffix of string 29 | | Keyword of string 30 | 31 | module DomainMatchingType = 32 | let inline _Full f p = 33 | prism' 34 | Full 35 | (fun x -> 36 | match x with 37 | | Full x -> Some x 38 | | _ -> None) 39 | f 40 | p 41 | 42 | let inline _Regex f p = 43 | prism' 44 | Regex 45 | (fun x -> 46 | match x with 47 | | Regex x -> Some x 48 | | _ -> None) 49 | f 50 | p 51 | 52 | let inline _Suffix f p = 53 | prism' 54 | Suffix 55 | (fun x -> 56 | match x with 57 | | Suffix x -> Some x 58 | | _ -> None) 59 | f 60 | p 61 | 62 | let inline _Keyword f p = 63 | prism' 64 | Keyword 65 | (fun x -> 66 | match x with 67 | | Keyword x -> Some x 68 | | _ -> None) 69 | f 70 | p 71 | 72 | type DomainType = 73 | | Domain of DomainMatchingType 74 | | Geosite of string 75 | 76 | module DomainType = 77 | let inline _Domain f p = 78 | prism' 79 | Domain 80 | (fun x -> 81 | match x with 82 | | Domain x -> Some x 83 | | _ -> None) 84 | f 85 | p 86 | 87 | let inline _Geosite f p = 88 | prism' 89 | Geosite 90 | (fun x -> 91 | match x with 92 | | Geosite x -> Some x 93 | | _ -> None) 94 | f 95 | p 96 | 97 | type IpType = 98 | | Ip of string 99 | | Geoip of string 100 | 101 | module IpType = 102 | let inline _Ip f p = 103 | prism' 104 | Ip 105 | (fun x -> 106 | match x with 107 | | Ip x -> Some x 108 | | _ -> None) 109 | f 110 | p 111 | 112 | let inline _Geoip f p = 113 | prism' 114 | Geoip 115 | (fun x -> 116 | match x with 117 | | Geoip x -> Some x 118 | | _ -> None) 119 | f 120 | p 121 | 122 | type RuleObject = 123 | { Domain: DomainType list option 124 | Ip: IpType list option 125 | Port: string option 126 | Networks: RuleMatchNetwork option 127 | Protocol: RuleMatchProtocol option 128 | InboundTag: string list option 129 | Tag: string } 130 | 131 | module RuleObject = 132 | let inline _Domain f p = 133 | f p.Domain <&> fun x -> { p with Domain = x } 134 | 135 | let inline _Ip f p = f p.Ip <&> fun x -> { p with Ip = x } 136 | 137 | let inline _Port f p = 138 | f p.Port <&> fun x -> { p with Port = x } 139 | 140 | let inline _Networks f p = 141 | f p.Networks <&> fun x -> { p with Networks = x } 142 | 143 | let inline _Protocol f p = 144 | f p.Protocol <&> fun x -> { p with Protocol = x } 145 | 146 | let inline _InboundTag f p = 147 | f p.InboundTag <&> fun x -> { p with InboundTag = x } 148 | 149 | let inline _Tag f p = f p.Tag <&> fun x -> { p with Tag = x } 150 | 151 | type DomainRuleList = DomainType list 152 | type IpRuleList = IpType list 153 | 154 | type DomainStringListObject = 155 | { Direct: DomainRuleList 156 | Proxy: DomainRuleList 157 | Block: DomainRuleList } 158 | 159 | module DomainStringListObject = 160 | let inline _Direct f p = 161 | f p.Direct <&> fun x -> { p with Direct = x } 162 | 163 | let inline _Proxy f p = 164 | f p.Proxy <&> fun x -> { p with Proxy = x } 165 | 166 | let inline _Block f p = 167 | f p.Block <&> fun x -> { p with Block = x } 168 | 169 | type IpStringListObject = 170 | { Direct: IpRuleList 171 | Proxy: IpRuleList 172 | Block: IpRuleList } 173 | 174 | module IpStringListObject = 175 | let inline _Direct f p = 176 | f p.Direct <&> fun x -> { p with Direct = x } 177 | 178 | let inline _Proxy f p = 179 | f p.Proxy <&> fun x -> { p with Proxy = x } 180 | 181 | let inline _Block f p = 182 | f p.Block <&> fun x -> { p with Block = x } 183 | 184 | type RulePresets = 185 | | BypassMainland // adopted from v2rayA's mainland whitelist mode 186 | | GFWList of string list // uses Loyalsoldier/v2ray-rules-dat's gfw.txt 187 | | Loyalsoldier // uses Loyalsoldier/v2ray-rules-dat's recommended v2ray setting in README 188 | | Empty // no preset rules 189 | 190 | // when using full domain list or the recommended setting, these options will be ignored 191 | type RuleConstructionStrategy = { BlockAds: bool } 192 | 193 | module RuleConstructionStrategy = 194 | let inline _BlockAds f p = 195 | f p.BlockAds <&> fun x -> { p with BlockAds = x } 196 | 197 | type ProxyTag = 198 | | Outbound of string 199 | | Balancer of string 200 | 201 | module ProxyTag = 202 | let inline _Outbound f p = 203 | prism' 204 | Outbound 205 | (fun x -> 206 | match x with 207 | | Outbound x -> Some x 208 | | _ -> None) 209 | f 210 | p 211 | 212 | let inline _Balancer f p = 213 | prism' 214 | Balancer 215 | (fun x -> 216 | match x with 217 | | Balancer x -> Some x 218 | | _ -> None) 219 | f 220 | p 221 | 222 | type RuleType = 223 | | Direct of DomainRuleList option * IpRuleList option 224 | | Proxy of DomainRuleList option * IpRuleList option 225 | | Block of DomainRuleList option * IpRuleList option 226 | | Skip 227 | 228 | let constructDirect (domainRule, ipRule) = 229 | { Domain = domainRule 230 | Ip = ipRule 231 | Port = None 232 | Networks = Some TCPAndUDP 233 | Protocol = None 234 | InboundTag = None 235 | Tag = "freedom" } 236 | 237 | let constructProxy (domainRule, ipRule) proxyTag = 238 | { Domain = domainRule 239 | Ip = ipRule 240 | Port = None 241 | Networks = Some TCPAndUDP 242 | Protocol = None 243 | InboundTag = None 244 | Tag = proxyTag } 245 | 246 | let constructBlock (domainRule, ipRule) = 247 | { Domain = domainRule 248 | Ip = ipRule 249 | Port = None 250 | Networks = Some TCPAndUDP 251 | Protocol = None 252 | InboundTag = None 253 | Tag = "blackhole" } 254 | 255 | let constructSingleRule rule proxyTag = 256 | match rule with 257 | | Direct(domainRule, ipRule) -> Some(constructDirect (domainRule, ipRule)) 258 | | Proxy(domainRule, ipRule) -> Some(constructProxy (domainRule, ipRule) proxyTag) 259 | | Block(domainRule, ipRule) -> Some(constructBlock (domainRule, ipRule)) 260 | | Skip -> None 261 | 262 | let constructRuleSet ruleSet proxyTag = 263 | match ruleSet with 264 | | Ok ruleSet -> 265 | List.map (fun rule -> constructSingleRule rule proxyTag) ruleSet 266 | |> List.filter Option.isSome 267 | |> List.map Option.get 268 | |> Ok 269 | | Error e -> Error e 270 | 271 | let mergeRules rule1 rule2 = 272 | match rule1, rule2 with 273 | | Direct(xDomain, xIP), Direct(yDomain, yIP) -> Ok(Direct(mergeOptionList xDomain yDomain, mergeOptionList xIP yIP)) 274 | | Proxy(xDomain, xIP), Proxy(yDomain, yIP) -> Ok(Proxy(mergeOptionList xDomain yDomain, mergeOptionList xIP yIP)) 275 | | Block(xDomain, xIP), Block(yDomain, yIP) -> Ok(Block(mergeOptionList xDomain yDomain, mergeOptionList xIP yIP)) 276 | | _ -> Error RuleTypeNotMatchException 277 | 278 | let constructPreset constructionStrategy = 279 | if constructionStrategy.BlockAds then 280 | Block(Some [ Geosite "category-ads-all" ], None) 281 | else 282 | Skip 283 | 284 | let generateRoutingRules (domainList, constructionStrategy, userDomainRules: DomainStringListObject, userIpRules) = 285 | match domainList with 286 | | BypassMainland -> 287 | let blockPreset = constructPreset constructionStrategy 288 | 289 | let userProxyRule = Proxy(Some userDomainRules.Proxy, Some userIpRules.Proxy) 290 | 291 | let userDirectRule = Direct(Some userDomainRules.Direct, Some userIpRules.Direct) 292 | 293 | let userBlockRule = Block(Some userDomainRules.Block, Some userIpRules.Block) 294 | 295 | let geolocationProxy = Proxy(Some [ Geosite "geolocation-!cn" ], None) 296 | 297 | let scholarProxy = Proxy(Some [ Geosite "google-scholar" ], None) 298 | 299 | let scholarDirect = 300 | Direct(Some [ Geosite "category-scholar-!cn"; Geosite "category-scholar-cn" ], None) 301 | 302 | let siteCNDirect = Direct(Some [ Geosite "cn" ], None) 303 | 304 | let sarProxy = Proxy(None, Some [ Geoip "hk"; Geoip "mo" ]) 305 | 306 | let ipDirect = Direct(None, Some [ Geoip "private"; Geoip "cn" ]) 307 | 308 | constructRuleSet ( 309 | (mergeRules userBlockRule blockPreset 310 | :: ([ userDirectRule 311 | userProxyRule 312 | geolocationProxy 313 | scholarProxy 314 | scholarDirect 315 | siteCNDirect 316 | sarProxy 317 | ipDirect 318 | Proxy(None, None) ] 319 | |> List.map Ok)) 320 | |> traverseResultList id 321 | ) 322 | | GFWList domainList -> 323 | let blockPreset = constructPreset constructionStrategy 324 | 325 | let userBlockRule = Block(Some userDomainRules.Block, Some userIpRules.Block) 326 | 327 | let userDirectRule = Block(Some userDomainRules.Direct, Some userIpRules.Direct) 328 | 329 | let userProxyRule = Proxy(Some userDomainRules.Proxy, Some userIpRules.Proxy) 330 | 331 | let proxyRule = 332 | Proxy(Some(domainList |> List.map (fun a -> Domain(Suffix a))), None) 333 | 334 | constructRuleSet ( 335 | [ mergeRules userBlockRule blockPreset 336 | Ok userDirectRule 337 | mergeRules userProxyRule proxyRule 338 | Ok(Proxy(None, None)) ] 339 | |> traverseResultList id 340 | ) 341 | | Loyalsoldier -> 342 | let userBlockRule = Block(Some userDomainRules.Block, Some userIpRules.Block) 343 | 344 | let userDirectRule = Block(Some userDomainRules.Direct, Some userIpRules.Direct) 345 | 346 | let userProxyRule = Proxy(Some userDomainRules.Proxy, Some userIpRules.Proxy) 347 | 348 | let blockRule = Block(Some([ Geosite "category-ads-all" ]), None) 349 | 350 | let directRule1 = 351 | Direct( 352 | Some( 353 | [ Geosite "private" 354 | Geosite "apple-cn" 355 | Geosite "google-cn" 356 | Geosite "tld-cn" 357 | Geosite "category-games@cn" ] 358 | ), 359 | None 360 | ) 361 | 362 | let proxyRule = Proxy(Some([ Geosite "geolocation-!cn" ]), None) 363 | 364 | let directRule2 = Direct(Some([ Geosite "cn" ]), None) 365 | 366 | constructRuleSet ( 367 | (mergeRules userBlockRule blockRule) 368 | :: ([ userDirectRule 369 | userProxyRule 370 | directRule1 371 | proxyRule 372 | directRule2 373 | Proxy(None, None) ] 374 | |> List.map Ok) 375 | |> traverseResultList id 376 | ) 377 | | Empty -> 378 | let blockPreset = constructPreset constructionStrategy 379 | 380 | constructRuleSet ( 381 | [ mergeRules blockPreset (Block(Some userDomainRules.Block, Some userIpRules.Block)) 382 | Ok(Direct(Some userDomainRules.Direct, Some userIpRules.Direct)) 383 | Ok(Proxy(Some userDomainRules.Proxy, Some userIpRules.Proxy)) ] 384 | |> traverseResultList id 385 | ) 386 | -------------------------------------------------------------------------------- /Aurum.Configuration/Shared/V2fly.fs: -------------------------------------------------------------------------------- 1 | module Aurum.Configuration.Shared.V2fly 2 | 3 | open System.Text.Json.Serialization 4 | open Aurum 5 | open System.Collections.Generic 6 | open FSharpPlus.Lens 7 | 8 | type HttpVersion = 9 | | [] HTTP1 10 | | [] HTTP2 11 | | [] HTTP3 12 | 13 | type TransportProtocol = 14 | | KCP of KcpObject 15 | | WebSocket of WebSocketObject 16 | | HTTP of HttpObject 17 | | QUIC 18 | | GRPC of GrpcObject 19 | 20 | and WebSocketObject = 21 | { Path: string 22 | MaxEarlyData: int 23 | BrowserForwarding: bool 24 | EarlyDataHeader: string 25 | Headers: Dictionary option } 26 | 27 | and KcpObject = 28 | { MTU: int 29 | TTI: int 30 | UplinkCapacity: int 31 | DownlinkCapacity: int 32 | Congestion: bool 33 | ReadBufferSize: int 34 | WriteBufferSize: int 35 | Seed: string option } 36 | 37 | and HttpObject = 38 | { Host: string list 39 | Path: string 40 | Version: HttpVersion 41 | Headers: Dictionary option } 42 | 43 | and GrpcObject = { ServiceName: string } 44 | 45 | module WebSocketObject = 46 | let inline _Path f (p: WebSocketObject) = 47 | f p.Path <&> fun x -> { p with Path = x } 48 | 49 | let inline _MaxEarlyData f (p: WebSocketObject) = 50 | f p.MaxEarlyData <&> fun x -> { p with MaxEarlyData = x } 51 | 52 | let inline _BrowserForwarding f (p: WebSocketObject) = 53 | f p.BrowserForwarding <&> fun x -> { p with BrowserForwarding = x } 54 | 55 | let inline _EarlyDataHeader f (p: WebSocketObject) = 56 | f p.EarlyDataHeader <&> fun x -> { p with EarlyDataHeader = x } 57 | 58 | let inline _Headers f (p: WebSocketObject) = 59 | f p.Headers <&> fun x -> { p with Headers = x } 60 | 61 | module KcpObject = 62 | let inline _MTU f (p: KcpObject) = f p.MTU <&> fun x -> { p with MTU = x } 63 | 64 | let inline _TTI f (p: KcpObject) = f p.TTI <&> fun x -> { p with TTI = x } 65 | 66 | let inline _UplinkCapacity f (p: KcpObject) = 67 | f p.UplinkCapacity <&> fun x -> { p with UplinkCapacity = x } 68 | 69 | let inline _DownlinkCapacity f (p: KcpObject) = 70 | f p.DownlinkCapacity <&> fun x -> { p with DownlinkCapacity = x } 71 | 72 | let inline _Congestion f (p: KcpObject) = 73 | f p.Congestion <&> fun x -> { p with Congestion = x } 74 | 75 | let inline _ReadBufferSize f (p: KcpObject) = 76 | f p.ReadBufferSize <&> fun x -> { p with ReadBufferSize = x } 77 | 78 | let inline _WriteBufferSize f (p: KcpObject) = 79 | f p.WriteBufferSize <&> fun x -> { p with WriteBufferSize = x } 80 | 81 | let inline _Seed f (p: KcpObject) = 82 | f p.Seed <&> fun x -> { p with Seed = x } 83 | 84 | module HttpObject = 85 | let inline _Host f (p: HttpObject) = 86 | f p.Host <&> fun x -> { p with Host = x } 87 | 88 | let inline _Path f (p: HttpObject) = 89 | f p.Path <&> fun x -> { p with Path = x } 90 | 91 | let inline _Headers f (p: HttpObject) = 92 | f p.Headers <&> fun x -> { p with Headers = x } 93 | 94 | module GrpcObject = 95 | let inline _ServiceName f (p: GrpcObject) = 96 | f p.ServiceName <&> fun x -> { p with ServiceName = x } 97 | 98 | module TransportProtocol = 99 | let inline _WebSocket f = 100 | prism' 101 | WebSocket 102 | (fun x -> 103 | match x with 104 | | WebSocket x -> Some(WebSocket x) 105 | | _ -> None) 106 | f 107 | 108 | let inline _KCP f = 109 | prism' 110 | KCP 111 | (fun x -> 112 | match x with 113 | | KCP x -> Some(KCP x) 114 | | _ -> None) 115 | f 116 | 117 | let inline _HTTP f = 118 | prism' 119 | HTTP 120 | (fun x -> 121 | match x with 122 | | HTTP x -> Some(HTTP x) 123 | | _ -> None) 124 | f 125 | 126 | let inline _QUIC f = 127 | prism' 128 | (fun _ -> QUIC) 129 | (fun x -> 130 | match x with 131 | | QUIC -> Some QUIC 132 | | _ -> None) 133 | f 134 | 135 | let inline _GRPC f = 136 | prism' 137 | GRPC 138 | (fun x -> 139 | match x with 140 | | GRPC x -> Some(GRPC x) 141 | | _ -> None) 142 | f 143 | 144 | type TlsObject = 145 | { ServerName: string option 146 | AllowInsecure: bool option 147 | ALPN: string list option } 148 | 149 | module TlsObject = 150 | let inline _ServerName f (p: TlsObject) = 151 | f p.ServerName <&> fun x -> { p with ServerName = x } 152 | 153 | let inline _AllowInsecure f (p: TlsObject) = 154 | f p.AllowInsecure <&> fun x -> { p with AllowInsecure = x } 155 | 156 | let inline _ALPN f (p: TlsObject) = 157 | f p.ALPN <&> fun x -> { p with ALPN = x } 158 | 159 | [] 160 | type TransportSecurity = 161 | | [] None 162 | | [] TLS of TlsObject 163 | // only for reservation. V2fly and Sing backend does not have XTLS support. 164 | | [] XTLS 165 | 166 | module TransportSecurity = 167 | let inline _None f = 168 | prism' 169 | (fun _ -> TransportSecurity.None) 170 | (fun x -> 171 | match x with 172 | | TransportSecurity.None -> Some TransportSecurity.None 173 | | _ -> None) 174 | f 175 | 176 | let inline _TLS f = 177 | prism' 178 | TransportSecurity.TLS 179 | (fun x -> 180 | match x with 181 | | TransportSecurity.TLS x -> Some(TransportSecurity.TLS x) 182 | | _ -> None) 183 | f 184 | 185 | let inline _XTLS f = 186 | prism' 187 | (fun _ -> TransportSecurity.XTLS) 188 | (fun x -> 189 | match x with 190 | | TransportSecurity.XTLS -> Some TransportSecurity.XTLS 191 | | _ -> None) 192 | f 193 | 194 | type StreamSettings = 195 | { TransportSettings: TransportProtocol 196 | SecuritySettings: TransportSecurity } 197 | 198 | module StreamSettings = 199 | let inline _TransportSettings f (p: StreamSettings) = 200 | f p.TransportSettings <&> fun x -> { p with TransportSettings = x } 201 | 202 | let inline _SecuritySettings f (p: StreamSettings) = 203 | f p.SecuritySettings <&> fun x -> { p with SecuritySettings = x } 204 | 205 | [] 206 | // VLESS deprecated and subject to removal in v2fly/v2ray-core v5 207 | // It is not supported in sing-box 208 | type VlessEncryption = | [] None 209 | 210 | module VlessEncryption = 211 | let inline _None f = 212 | prism' 213 | (fun _ -> VlessEncryption.None) 214 | (fun x -> 215 | match x with 216 | | VlessEncryption.None -> Some VlessEncryption.None 217 | | _ -> None) 218 | f 219 | 220 | // V2fly v5 config does not support it yet 221 | // The core retains its support, though, and sing-box also supports it 222 | [] 223 | type VMessSecurity = 224 | | [] None 225 | | [] Zero 226 | | [] Auto 227 | | [] AES 228 | | [] ChaCha20 229 | 230 | type MuxObject = 231 | { Enabled: bool 232 | Concurrency: int option } 233 | 234 | module MuxObject = 235 | let inline _Enabled f (p: MuxObject) = 236 | f p.Enabled <&> fun x -> { p with Enabled = x } 237 | 238 | let inline _Concurrency f (p: MuxObject) = 239 | f p.Concurrency <&> fun x -> { p with Concurrency = x } 240 | 241 | type VMessObject = 242 | { Address: string 243 | Port: int 244 | UUID: string 245 | Security: VMessSecurity } 246 | 247 | member this.GetServerInfo() = this.Address, this.Port 248 | 249 | module VMessObject = 250 | let inline _Address f (p: VMessObject) = 251 | f p.Address <&> fun x -> { p with Address = x } 252 | 253 | let inline _Port f (p: VMessObject) = 254 | f p.Port <&> fun x -> { p with Port = x } 255 | 256 | let inline _UUID f (p: VMessObject) = 257 | f p.UUID <&> fun x -> { p with UUID = x } 258 | 259 | let inline _Security f (p: VMessObject) = 260 | f p.Security <&> fun x -> { p with Security = x } 261 | 262 | type Protocols = 263 | | [] VLESS 264 | | [] VMess of VMessObject 265 | 266 | module Protocols = 267 | let inline _VLESS f = 268 | prism' 269 | (fun _ -> Protocols.VLESS) 270 | (fun x -> 271 | match x with 272 | | Protocols.VLESS -> Some Protocols.VLESS 273 | | _ -> None) 274 | f 275 | 276 | let inline _VMess f = 277 | prism' 278 | Protocols.VMess 279 | (fun x -> 280 | match x with 281 | | Protocols.VMess x -> Some(Protocols.VMess x) 282 | | _ -> None) 283 | f 284 | 285 | type V2flyObject = 286 | { Protocol: Protocols 287 | StreamSettings: StreamSettings } 288 | 289 | module V2flyObject = 290 | let inline _Protocol f (p: V2flyObject) = 291 | f p.Protocol <&> fun x -> { p with Protocol = x } 292 | 293 | let inline _StreamSettings f (p: V2flyObject) = 294 | f p.StreamSettings <&> fun x -> { p with StreamSettings = x } 295 | 296 | let createWebSocketObject path maxEarlyData browserForwarding earlyDataHeader host headers = 297 | let constructedHeaders = Option.defaultValue (Dictionary()) headers 298 | 299 | match host with 300 | | Some host -> constructedHeaders.Add("Host", host) 301 | | None -> () 302 | 303 | let config = 304 | { WebSocketObject.Path = Option.defaultValue "/" path 305 | MaxEarlyData = Option.defaultValue 0 maxEarlyData 306 | BrowserForwarding = Option.defaultValue false browserForwarding 307 | EarlyDataHeader = Option.defaultValue "" earlyDataHeader 308 | Headers = Some(constructedHeaders) } 309 | 310 | WebSocket config 311 | 312 | let createGrpcObject serviceName = 313 | let config = { ServiceName = serviceName } 314 | 315 | GRPC config 316 | 317 | let createHttpObjectWithHost path (host: string option) version headers = 318 | let parsedHost = 319 | Option.map (fun (host: string) -> host.Split "," |> Seq.toList) host 320 | |> Option.defaultValue [] 321 | 322 | let config = 323 | { HttpObject.Path = Option.defaultValue "/" path 324 | Headers = headers 325 | Version = version 326 | Host = parsedHost } 327 | 328 | HTTP config 329 | 330 | let createKCPObject mtu tti uplinkCapacity downlinkCapacity congestion readBufferSize writeBufferSize seed = 331 | 332 | let config = 333 | { KcpObject.MTU = Option.defaultValue 1350 mtu 334 | TTI = Option.defaultValue 20 tti 335 | UplinkCapacity = Option.defaultValue 5 uplinkCapacity 336 | DownlinkCapacity = Option.defaultValue 20 downlinkCapacity 337 | Congestion = Option.defaultValue false congestion 338 | ReadBufferSize = Option.defaultValue 2 readBufferSize 339 | WriteBufferSize = Option.defaultValue 2 writeBufferSize 340 | Seed = seed } 341 | 342 | KCP config 343 | 344 | let createQuicObject () = QUIC 345 | 346 | let createTLSObject serverName alpn = 347 | TransportSecurity.TLS 348 | { TlsObject.ServerName = serverName 349 | ALPN = alpn 350 | AllowInsecure = Some false } 351 | 352 | let createVMessObject host port uuid security = 353 | VMess 354 | { VMessObject.Address = host 355 | Port = port 356 | UUID = uuid 357 | Security = security } 358 | 359 | let parseVMessSecurity security = 360 | let security = Option.defaultValue "auto" security 361 | 362 | match security with 363 | | "none" -> Ok VMessSecurity.None 364 | | "zero" -> Ok VMessSecurity.Zero 365 | | "auto" -> Ok VMessSecurity.Auto 366 | | "aes-128-gcm" -> Ok VMessSecurity.AES 367 | | "chacha20-poly1305" -> Ok VMessSecurity.ChaCha20 368 | | _ -> Error(ConfigurationParameterException "unknown security type") 369 | 370 | let createV2flyObject protocol transportSettings securitySettings = 371 | { Protocol = protocol 372 | StreamSettings = 373 | { TransportSettings = transportSettings 374 | SecuritySettings = securitySettings } } 375 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | 167 | GNU GENERAL PUBLIC LICENSE 168 | Version 3, 29 June 2007 169 | 170 | Copyright (C) 2007 Free Software Foundation, Inc. 171 | Everyone is permitted to copy and distribute verbatim copies 172 | of this license document, but changing it is not allowed. 173 | 174 | Preamble 175 | 176 | The GNU General Public License is a free, copyleft license for 177 | software and other kinds of works. 178 | 179 | The licenses for most software and other practical works are designed 180 | to take away your freedom to share and change the works. By contrast, 181 | the GNU General Public License is intended to guarantee your freedom to 182 | share and change all versions of a program--to make sure it remains free 183 | software for all its users. We, the Free Software Foundation, use the 184 | GNU General Public License for most of our software; it applies also to 185 | any other work released this way by its authors. You can apply it to 186 | your programs, too. 187 | 188 | When we speak of free software, we are referring to freedom, not 189 | price. Our General Public Licenses are designed to make sure that you 190 | have the freedom to distribute copies of free software (and charge for 191 | them if you wish), that you receive source code or can get it if you 192 | want it, that you can change the software or use pieces of it in new 193 | free programs, and that you know you can do these things. 194 | 195 | To protect your rights, we need to prevent others from denying you 196 | these rights or asking you to surrender the rights. Therefore, you have 197 | certain responsibilities if you distribute copies of the software, or if 198 | you modify it: responsibilities to respect the freedom of others. 199 | 200 | For example, if you distribute copies of such a program, whether 201 | gratis or for a fee, you must pass on to the recipients the same 202 | freedoms that you received. You must make sure that they, too, receive 203 | or can get the source code. And you must show them these terms so they 204 | know their rights. 205 | 206 | Developers that use the GNU GPL protect your rights with two steps: 207 | (1) assert copyright on the software, and (2) offer you this License 208 | giving you legal permission to copy, distribute and/or modify it. 209 | 210 | For the developers' and authors' protection, the GPL clearly explains 211 | that there is no warranty for this free software. For both users' and 212 | authors' sake, the GPL requires that modified versions be marked as 213 | changed, so that their problems will not be attributed erroneously to 214 | authors of previous versions. 215 | 216 | Some devices are designed to deny users access to install or run 217 | modified versions of the software inside them, although the manufacturer 218 | can do so. This is fundamentally incompatible with the aim of 219 | protecting users' freedom to change the software. The systematic 220 | pattern of such abuse occurs in the area of products for individuals to 221 | use, which is precisely where it is most unacceptable. Therefore, we 222 | have designed this version of the GPL to prohibit the practice for those 223 | products. If such problems arise substantially in other domains, we 224 | stand ready to extend this provision to those domains in future versions 225 | of the GPL, as needed to protect the freedom of users. 226 | 227 | Finally, every program is threatened constantly by software patents. 228 | States should not allow patents to restrict development and use of 229 | software on general-purpose computers, but in those that do, we wish to 230 | avoid the special danger that patents applied to a free program could 231 | make it effectively proprietary. To prevent this, the GPL assures that 232 | patents cannot be used to render the program non-free. 233 | 234 | The precise terms and conditions for copying, distribution and 235 | modification follow. 236 | 237 | TERMS AND CONDITIONS 238 | 239 | 0. Definitions. 240 | 241 | "This License" refers to version 3 of the GNU General Public License. 242 | 243 | "Copyright" also means copyright-like laws that apply to other kinds of 244 | works, such as semiconductor masks. 245 | 246 | "The Program" refers to any copyrightable work licensed under this 247 | License. Each licensee is addressed as "you". "Licensees" and 248 | "recipients" may be individuals or organizations. 249 | 250 | To "modify" a work means to copy from or adapt all or part of the work 251 | in a fashion requiring copyright permission, other than the making of an 252 | exact copy. The resulting work is called a "modified version" of the 253 | earlier work or a work "based on" the earlier work. 254 | 255 | A "covered work" means either the unmodified Program or a work based 256 | on the Program. 257 | 258 | To "propagate" a work means to do anything with it that, without 259 | permission, would make you directly or secondarily liable for 260 | infringement under applicable copyright law, except executing it on a 261 | computer or modifying a private copy. Propagation includes copying, 262 | distribution (with or without modification), making available to the 263 | public, and in some countries other activities as well. 264 | 265 | To "convey" a work means any kind of propagation that enables other 266 | parties to make or receive copies. Mere interaction with a user through 267 | a computer network, with no transfer of a copy, is not conveying. 268 | 269 | An interactive user interface displays "Appropriate Legal Notices" 270 | to the extent that it includes a convenient and prominently visible 271 | feature that (1) displays an appropriate copyright notice, and (2) 272 | tells the user that there is no warranty for the work (except to the 273 | extent that warranties are provided), that licensees may convey the 274 | work under this License, and how to view a copy of this License. If 275 | the interface presents a list of user commands or options, such as a 276 | menu, a prominent item in the list meets this criterion. 277 | 278 | 1. Source Code. 279 | 280 | The "source code" for a work means the preferred form of the work 281 | for making modifications to it. "Object code" means any non-source 282 | form of a work. 283 | 284 | A "Standard Interface" means an interface that either is an official 285 | standard defined by a recognized standards body, or, in the case of 286 | interfaces specified for a particular programming language, one that 287 | is widely used among developers working in that language. 288 | 289 | The "System Libraries" of an executable work include anything, other 290 | than the work as a whole, that (a) is included in the normal form of 291 | packaging a Major Component, but which is not part of that Major 292 | Component, and (b) serves only to enable use of the work with that 293 | Major Component, or to implement a Standard Interface for which an 294 | implementation is available to the public in source code form. A 295 | "Major Component", in this context, means a major essential component 296 | (kernel, window system, and so on) of the specific operating system 297 | (if any) on which the executable work runs, or a compiler used to 298 | produce the work, or an object code interpreter used to run it. 299 | 300 | The "Corresponding Source" for a work in object code form means all 301 | the source code needed to generate, install, and (for an executable 302 | work) run the object code and to modify the work, including scripts to 303 | control those activities. However, it does not include the work's 304 | System Libraries, or general-purpose tools or generally available free 305 | programs which are used unmodified in performing those activities but 306 | which are not part of the work. For example, Corresponding Source 307 | includes interface definition files associated with source files for 308 | the work, and the source code for shared libraries and dynamically 309 | linked subprograms that the work is specifically designed to require, 310 | such as by intimate data communication or control flow between those 311 | subprograms and other parts of the work. 312 | 313 | The Corresponding Source need not include anything that users 314 | can regenerate automatically from other parts of the Corresponding 315 | Source. 316 | 317 | The Corresponding Source for a work in source code form is that 318 | same work. 319 | 320 | 2. Basic Permissions. 321 | 322 | All rights granted under this License are granted for the term of 323 | copyright on the Program, and are irrevocable provided the stated 324 | conditions are met. This License explicitly affirms your unlimited 325 | permission to run the unmodified Program. The output from running a 326 | covered work is covered by this License only if the output, given its 327 | content, constitutes a covered work. This License acknowledges your 328 | rights of fair use or other equivalent, as provided by copyright law. 329 | 330 | You may make, run and propagate covered works that you do not 331 | convey, without conditions so long as your license otherwise remains 332 | in force. You may convey covered works to others for the sole purpose 333 | of having them make modifications exclusively for you, or provide you 334 | with facilities for running those works, provided that you comply with 335 | the terms of this License in conveying all material for which you do 336 | not control copyright. Those thus making or running the covered works 337 | for you must do so exclusively on your behalf, under your direction 338 | and control, on terms that prohibit them from making any copies of 339 | your copyrighted material outside their relationship with you. 340 | 341 | Conveying under any other circumstances is permitted solely under 342 | the conditions stated below. Sublicensing is not allowed; section 10 343 | makes it unnecessary. 344 | 345 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 346 | 347 | No covered work shall be deemed part of an effective technological 348 | measure under any applicable law fulfilling obligations under article 349 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 350 | similar laws prohibiting or restricting circumvention of such 351 | measures. 352 | 353 | When you convey a covered work, you waive any legal power to forbid 354 | circumvention of technological measures to the extent such circumvention 355 | is effected by exercising rights under this License with respect to 356 | the covered work, and you disclaim any intention to limit operation or 357 | modification of the work as a means of enforcing, against the work's 358 | users, your or third parties' legal rights to forbid circumvention of 359 | technological measures. 360 | 361 | 4. Conveying Verbatim Copies. 362 | 363 | You may convey verbatim copies of the Program's source code as you 364 | receive it, in any medium, provided that you conspicuously and 365 | appropriately publish on each copy an appropriate copyright notice; 366 | keep intact all notices stating that this License and any 367 | non-permissive terms added in accord with section 7 apply to the code; 368 | keep intact all notices of the absence of any warranty; and give all 369 | recipients a copy of this License along with the Program. 370 | 371 | You may charge any price or no price for each copy that you convey, 372 | and you may offer support or warranty protection for a fee. 373 | 374 | 5. Conveying Modified Source Versions. 375 | 376 | You may convey a work based on the Program, or the modifications to 377 | produce it from the Program, in the form of source code under the 378 | terms of section 4, provided that you also meet all of these conditions: 379 | 380 | a) The work must carry prominent notices stating that you modified 381 | it, and giving a relevant date. 382 | 383 | b) The work must carry prominent notices stating that it is 384 | released under this License and any conditions added under section 385 | 7. This requirement modifies the requirement in section 4 to 386 | "keep intact all notices". 387 | 388 | c) You must license the entire work, as a whole, under this 389 | License to anyone who comes into possession of a copy. This 390 | License will therefore apply, along with any applicable section 7 391 | additional terms, to the whole of the work, and all its parts, 392 | regardless of how they are packaged. This License gives no 393 | permission to license the work in any other way, but it does not 394 | invalidate such permission if you have separately received it. 395 | 396 | d) If the work has interactive user interfaces, each must display 397 | Appropriate Legal Notices; however, if the Program has interactive 398 | interfaces that do not display Appropriate Legal Notices, your 399 | work need not make them do so. 400 | 401 | A compilation of a covered work with other separate and independent 402 | works, which are not by their nature extensions of the covered work, 403 | and which are not combined with it such as to form a larger program, 404 | in or on a volume of a storage or distribution medium, is called an 405 | "aggregate" if the compilation and its resulting copyright are not 406 | used to limit the access or legal rights of the compilation's users 407 | beyond what the individual works permit. Inclusion of a covered work 408 | in an aggregate does not cause this License to apply to the other 409 | parts of the aggregate. 410 | 411 | 6. Conveying Non-Source Forms. 412 | 413 | You may convey a covered work in object code form under the terms 414 | of sections 4 and 5, provided that you also convey the 415 | machine-readable Corresponding Source under the terms of this License, 416 | in one of these ways: 417 | 418 | a) Convey the object code in, or embodied in, a physical product 419 | (including a physical distribution medium), accompanied by the 420 | Corresponding Source fixed on a durable physical medium 421 | customarily used for software interchange. 422 | 423 | b) Convey the object code in, or embodied in, a physical product 424 | (including a physical distribution medium), accompanied by a 425 | written offer, valid for at least three years and valid for as 426 | long as you offer spare parts or customer support for that product 427 | model, to give anyone who possesses the object code either (1) a 428 | copy of the Corresponding Source for all the software in the 429 | product that is covered by this License, on a durable physical 430 | medium customarily used for software interchange, for a price no 431 | more than your reasonable cost of physically performing this 432 | conveying of source, or (2) access to copy the 433 | Corresponding Source from a network server at no charge. 434 | 435 | c) Convey individual copies of the object code with a copy of the 436 | written offer to provide the Corresponding Source. This 437 | alternative is allowed only occasionally and noncommercially, and 438 | only if you received the object code with such an offer, in accord 439 | with subsection 6b. 440 | 441 | d) Convey the object code by offering access from a designated 442 | place (gratis or for a charge), and offer equivalent access to the 443 | Corresponding Source in the same way through the same place at no 444 | further charge. You need not require recipients to copy the 445 | Corresponding Source along with the object code. If the place to 446 | copy the object code is a network server, the Corresponding Source 447 | may be on a different server (operated by you or a third party) 448 | that supports equivalent copying facilities, provided you maintain 449 | clear directions next to the object code saying where to find the 450 | Corresponding Source. Regardless of what server hosts the 451 | Corresponding Source, you remain obligated to ensure that it is 452 | available for as long as needed to satisfy these requirements. 453 | 454 | e) Convey the object code using peer-to-peer transmission, provided 455 | you inform other peers where the object code and Corresponding 456 | Source of the work are being offered to the general public at no 457 | charge under subsection 6d. 458 | 459 | A separable portion of the object code, whose source code is excluded 460 | from the Corresponding Source as a System Library, need not be 461 | included in conveying the object code work. 462 | 463 | A "User Product" is either (1) a "consumer product", which means any 464 | tangible personal property which is normally used for personal, family, 465 | or household purposes, or (2) anything designed or sold for incorporation 466 | into a dwelling. In determining whether a product is a consumer product, 467 | doubtful cases shall be resolved in favor of coverage. For a particular 468 | product received by a particular user, "normally used" refers to a 469 | typical or common use of that class of product, regardless of the status 470 | of the particular user or of the way in which the particular user 471 | actually uses, or expects or is expected to use, the product. A product 472 | is a consumer product regardless of whether the product has substantial 473 | commercial, industrial or non-consumer uses, unless such uses represent 474 | the only significant mode of use of the product. 475 | 476 | "Installation Information" for a User Product means any methods, 477 | procedures, authorization keys, or other information required to install 478 | and execute modified versions of a covered work in that User Product from 479 | a modified version of its Corresponding Source. The information must 480 | suffice to ensure that the continued functioning of the modified object 481 | code is in no case prevented or interfered with solely because 482 | modification has been made. 483 | 484 | If you convey an object code work under this section in, or with, or 485 | specifically for use in, a User Product, and the conveying occurs as 486 | part of a transaction in which the right of possession and use of the 487 | User Product is transferred to the recipient in perpetuity or for a 488 | fixed term (regardless of how the transaction is characterized), the 489 | Corresponding Source conveyed under this section must be accompanied 490 | by the Installation Information. But this requirement does not apply 491 | if neither you nor any third party retains the ability to install 492 | modified object code on the User Product (for example, the work has 493 | been installed in ROM). 494 | 495 | The requirement to provide Installation Information does not include a 496 | requirement to continue to provide support service, warranty, or updates 497 | for a work that has been modified or installed by the recipient, or for 498 | the User Product in which it has been modified or installed. Access to a 499 | network may be denied when the modification itself materially and 500 | adversely affects the operation of the network or violates the rules and 501 | protocols for communication across the network. 502 | 503 | Corresponding Source conveyed, and Installation Information provided, 504 | in accord with this section must be in a format that is publicly 505 | documented (and with an implementation available to the public in 506 | source code form), and must require no special password or key for 507 | unpacking, reading or copying. 508 | 509 | 7. Additional Terms. 510 | 511 | "Additional permissions" are terms that supplement the terms of this 512 | License by making exceptions from one or more of its conditions. 513 | Additional permissions that are applicable to the entire Program shall 514 | be treated as though they were included in this License, to the extent 515 | that they are valid under applicable law. If additional permissions 516 | apply only to part of the Program, that part may be used separately 517 | under those permissions, but the entire Program remains governed by 518 | this License without regard to the additional permissions. 519 | 520 | When you convey a copy of a covered work, you may at your option 521 | remove any additional permissions from that copy, or from any part of 522 | it. (Additional permissions may be written to require their own 523 | removal in certain cases when you modify the work.) You may place 524 | additional permissions on material, added by you to a covered work, 525 | for which you have or can give appropriate copyright permission. 526 | 527 | Notwithstanding any other provision of this License, for material you 528 | add to a covered work, you may (if authorized by the copyright holders of 529 | that material) supplement the terms of this License with terms: 530 | 531 | a) Disclaiming warranty or limiting liability differently from the 532 | terms of sections 15 and 16 of this License; or 533 | 534 | b) Requiring preservation of specified reasonable legal notices or 535 | author attributions in that material or in the Appropriate Legal 536 | Notices displayed by works containing it; or 537 | 538 | c) Prohibiting misrepresentation of the origin of that material, or 539 | requiring that modified versions of such material be marked in 540 | reasonable ways as different from the original version; or 541 | 542 | d) Limiting the use for publicity purposes of names of licensors or 543 | authors of the material; or 544 | 545 | e) Declining to grant rights under trademark law for use of some 546 | trade names, trademarks, or service marks; or 547 | 548 | f) Requiring indemnification of licensors and authors of that 549 | material by anyone who conveys the material (or modified versions of 550 | it) with contractual assumptions of liability to the recipient, for 551 | any liability that these contractual assumptions directly impose on 552 | those licensors and authors. 553 | 554 | All other non-permissive additional terms are considered "further 555 | restrictions" within the meaning of section 10. If the Program as you 556 | received it, or any part of it, contains a notice stating that it is 557 | governed by this License along with a term that is a further 558 | restriction, you may remove that term. If a license document contains 559 | a further restriction but permits relicensing or conveying under this 560 | License, you may add to a covered work material governed by the terms 561 | of that license document, provided that the further restriction does 562 | not survive such relicensing or conveying. 563 | 564 | If you add terms to a covered work in accord with this section, you 565 | must place, in the relevant source files, a statement of the 566 | additional terms that apply to those files, or a notice indicating 567 | where to find the applicable terms. 568 | 569 | Additional terms, permissive or non-permissive, may be stated in the 570 | form of a separately written license, or stated as exceptions; 571 | the above requirements apply either way. 572 | 573 | 8. Termination. 574 | 575 | You may not propagate or modify a covered work except as expressly 576 | provided under this License. Any attempt otherwise to propagate or 577 | modify it is void, and will automatically terminate your rights under 578 | this License (including any patent licenses granted under the third 579 | paragraph of section 11). 580 | 581 | However, if you cease all violation of this License, then your 582 | license from a particular copyright holder is reinstated (a) 583 | provisionally, unless and until the copyright holder explicitly and 584 | finally terminates your license, and (b) permanently, if the copyright 585 | holder fails to notify you of the violation by some reasonable means 586 | prior to 60 days after the cessation. 587 | 588 | Moreover, your license from a particular copyright holder is 589 | reinstated permanently if the copyright holder notifies you of the 590 | violation by some reasonable means, this is the first time you have 591 | received notice of violation of this License (for any work) from that 592 | copyright holder, and you cure the violation prior to 30 days after 593 | your receipt of the notice. 594 | 595 | Termination of your rights under this section does not terminate the 596 | licenses of parties who have received copies or rights from you under 597 | this License. If your rights have been terminated and not permanently 598 | reinstated, you do not qualify to receive new licenses for the same 599 | material under section 10. 600 | 601 | 9. Acceptance Not Required for Having Copies. 602 | 603 | You are not required to accept this License in order to receive or 604 | run a copy of the Program. Ancillary propagation of a covered work 605 | occurring solely as a consequence of using peer-to-peer transmission 606 | to receive a copy likewise does not require acceptance. However, 607 | nothing other than this License grants you permission to propagate or 608 | modify any covered work. These actions infringe copyright if you do 609 | not accept this License. Therefore, by modifying or propagating a 610 | covered work, you indicate your acceptance of this License to do so. 611 | 612 | 10. Automatic Licensing of Downstream Recipients. 613 | 614 | Each time you convey a covered work, the recipient automatically 615 | receives a license from the original licensors, to run, modify and 616 | propagate that work, subject to this License. You are not responsible 617 | for enforcing compliance by third parties with this License. 618 | 619 | An "entity transaction" is a transaction transferring control of an 620 | organization, or substantially all assets of one, or subdividing an 621 | organization, or merging organizations. If propagation of a covered 622 | work results from an entity transaction, each party to that 623 | transaction who receives a copy of the work also receives whatever 624 | licenses to the work the party's predecessor in interest had or could 625 | give under the previous paragraph, plus a right to possession of the 626 | Corresponding Source of the work from the predecessor in interest, if 627 | the predecessor has it or can get it with reasonable efforts. 628 | 629 | You may not impose any further restrictions on the exercise of the 630 | rights granted or affirmed under this License. For example, you may 631 | not impose a license fee, royalty, or other charge for exercise of 632 | rights granted under this License, and you may not initiate litigation 633 | (including a cross-claim or counterclaim in a lawsuit) alleging that 634 | any patent claim is infringed by making, using, selling, offering for 635 | sale, or importing the Program or any portion of it. 636 | 637 | 11. Patents. 638 | 639 | A "contributor" is a copyright holder who authorizes use under this 640 | License of the Program or a work on which the Program is based. The 641 | work thus licensed is called the contributor's "contributor version". 642 | 643 | A contributor's "essential patent claims" are all patent claims 644 | owned or controlled by the contributor, whether already acquired or 645 | hereafter acquired, that would be infringed by some manner, permitted 646 | by this License, of making, using, or selling its contributor version, 647 | but do not include claims that would be infringed only as a 648 | consequence of further modification of the contributor version. For 649 | purposes of this definition, "control" includes the right to grant 650 | patent sublicenses in a manner consistent with the requirements of 651 | this License. 652 | 653 | Each contributor grants you a non-exclusive, worldwide, royalty-free 654 | patent license under the contributor's essential patent claims, to 655 | make, use, sell, offer for sale, import and otherwise run, modify and 656 | propagate the contents of its contributor version. 657 | 658 | In the following three paragraphs, a "patent license" is any express 659 | agreement or commitment, however denominated, not to enforce a patent 660 | (such as an express permission to practice a patent or covenant not to 661 | sue for patent infringement). To "grant" such a patent license to a 662 | party means to make such an agreement or commitment not to enforce a 663 | patent against the party. 664 | 665 | If you convey a covered work, knowingly relying on a patent license, 666 | and the Corresponding Source of the work is not available for anyone 667 | to copy, free of charge and under the terms of this License, through a 668 | publicly available network server or other readily accessible means, 669 | then you must either (1) cause the Corresponding Source to be so 670 | available, or (2) arrange to deprive yourself of the benefit of the 671 | patent license for this particular work, or (3) arrange, in a manner 672 | consistent with the requirements of this License, to extend the patent 673 | license to downstream recipients. "Knowingly relying" means you have 674 | actual knowledge that, but for the patent license, your conveying the 675 | covered work in a country, or your recipient's use of the covered work 676 | in a country, would infringe one or more identifiable patents in that 677 | country that you have reason to believe are valid. 678 | 679 | If, pursuant to or in connection with a single transaction or 680 | arrangement, you convey, or propagate by procuring conveyance of, a 681 | covered work, and grant a patent license to some of the parties 682 | receiving the covered work authorizing them to use, propagate, modify 683 | or convey a specific copy of the covered work, then the patent license 684 | you grant is automatically extended to all recipients of the covered 685 | work and works based on it. 686 | 687 | A patent license is "discriminatory" if it does not include within 688 | the scope of its coverage, prohibits the exercise of, or is 689 | conditioned on the non-exercise of one or more of the rights that are 690 | specifically granted under this License. You may not convey a covered 691 | work if you are a party to an arrangement with a third party that is 692 | in the business of distributing software, under which you make payment 693 | to the third party based on the extent of your activity of conveying 694 | the work, and under which the third party grants, to any of the 695 | parties who would receive the covered work from you, a discriminatory 696 | patent license (a) in connection with copies of the covered work 697 | conveyed by you (or copies made from those copies), or (b) primarily 698 | for and in connection with specific products or compilations that 699 | contain the covered work, unless you entered into that arrangement, 700 | or that patent license was granted, prior to 28 March 2007. 701 | 702 | Nothing in this License shall be construed as excluding or limiting 703 | any implied license or other defenses to infringement that may 704 | otherwise be available to you under applicable patent law. 705 | 706 | 12. No Surrender of Others' Freedom. 707 | 708 | If conditions are imposed on you (whether by court order, agreement or 709 | otherwise) that contradict the conditions of this License, they do not 710 | excuse you from the conditions of this License. If you cannot convey a 711 | covered work so as to satisfy simultaneously your obligations under this 712 | License and any other pertinent obligations, then as a consequence you may 713 | not convey it at all. For example, if you agree to terms that obligate you 714 | to collect a royalty for further conveying from those to whom you convey 715 | the Program, the only way you could satisfy both those terms and this 716 | License would be to refrain entirely from conveying the Program. 717 | 718 | 13. Use with the GNU Affero General Public License. 719 | 720 | Notwithstanding any other provision of this License, you have 721 | permission to link or combine any covered work with a work licensed 722 | under version 3 of the GNU Affero General Public License into a single 723 | combined work, and to convey the resulting work. The terms of this 724 | License will continue to apply to the part which is the covered work, 725 | but the special requirements of the GNU Affero General Public License, 726 | section 13, concerning interaction through a network will apply to the 727 | combination as such. 728 | 729 | 14. Revised Versions of this License. 730 | 731 | The Free Software Foundation may publish revised and/or new versions of 732 | the GNU General Public License from time to time. Such new versions will 733 | be similar in spirit to the present version, but may differ in detail to 734 | address new problems or concerns. 735 | 736 | Each version is given a distinguishing version number. If the 737 | Program specifies that a certain numbered version of the GNU General 738 | Public License "or any later version" applies to it, you have the 739 | option of following the terms and conditions either of that numbered 740 | version or of any later version published by the Free Software 741 | Foundation. If the Program does not specify a version number of the 742 | GNU General Public License, you may choose any version ever published 743 | by the Free Software Foundation. 744 | 745 | If the Program specifies that a proxy can decide which future 746 | versions of the GNU General Public License can be used, that proxy's 747 | public statement of acceptance of a version permanently authorizes you 748 | to choose that version for the Program. 749 | 750 | Later license versions may give you additional or different 751 | permissions. However, no additional obligations are imposed on any 752 | author or copyright holder as a result of your choosing to follow a 753 | later version. 754 | 755 | 15. Disclaimer of Warranty. 756 | 757 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 758 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 759 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 760 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 761 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 762 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 763 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 764 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 765 | 766 | 16. Limitation of Liability. 767 | 768 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 769 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 770 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 771 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 772 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 773 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 774 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 775 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 776 | SUCH DAMAGES. 777 | 778 | 17. Interpretation of Sections 15 and 16. 779 | 780 | If the disclaimer of warranty and limitation of liability provided 781 | above cannot be given local legal effect according to their terms, 782 | reviewing courts shall apply local law that most closely approximates 783 | an absolute waiver of all civil liability in connection with the 784 | Program, unless a warranty or assumption of liability accompanies a 785 | copy of the Program in return for a fee. 786 | 787 | END OF TERMS AND CONDITIONS 788 | 789 | How to Apply These Terms to Your New Programs 790 | 791 | If you develop a new program, and you want it to be of the greatest 792 | possible use to the public, the best way to achieve this is to make it 793 | free software which everyone can redistribute and change under these terms. 794 | 795 | To do so, attach the following notices to the program. It is safest 796 | to attach them to the start of each source file to most effectively 797 | state the exclusion of warranty; and each file should have at least 798 | the "copyright" line and a pointer to where the full notice is found. 799 | 800 | 801 | Copyright (C) 802 | 803 | This program is free software: you can redistribute it and/or modify 804 | it under the terms of the GNU General Public License as published by 805 | the Free Software Foundation, either version 3 of the License, or 806 | (at your option) any later version. 807 | 808 | This program is distributed in the hope that it will be useful, 809 | but WITHOUT ANY WARRANTY; without even the implied warranty of 810 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 811 | GNU General Public License for more details. 812 | 813 | You should have received a copy of the GNU General Public License 814 | along with this program. If not, see . 815 | 816 | Also add information on how to contact you by electronic and paper mail. 817 | 818 | If the program does terminal interaction, make it output a short 819 | notice like this when it starts in an interactive mode: 820 | 821 | Copyright (C) 822 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 823 | This is free software, and you are welcome to redistribute it 824 | under certain conditions; type `show c' for details. 825 | 826 | The hypothetical commands `show w' and `show c' should show the appropriate 827 | parts of the General Public License. Of course, your program's commands 828 | might be different; for a GUI interface, you would use an "about box". 829 | 830 | You should also get your employer (if you work as a programmer) or school, 831 | if any, to sign a "copyright disclaimer" for the program, if necessary. 832 | For more information on this, and how to apply and follow the GNU GPL, see 833 | . 834 | 835 | The GNU General Public License does not permit incorporating your program 836 | into proprietary programs. If your program is a subroutine library, you 837 | may consider it more useful to permit linking proprietary applications with 838 | the library. If this is what you want to do, use the GNU Lesser General 839 | Public License instead of this License. But first, please read 840 | . 841 | 842 | --------------------------------------------------------------------------------