From 500ff9ae02e01a9e40a59e9d81a36b41d9d10206 Mon Sep 17 00:00:00 2001 From: number571 Date: Mon, 25 Nov 2024 17:44:55 +0700 Subject: [PATCH] update --- CHANGELOG.md | 1 + cmd/hla/common/help.yml | 7 + cmd/hla/common/main.go | 18 +- cmd/hlc/help.yml | 8 + cmd/hlc/main.go | 19 +- cmd/hle/help.yml | 8 + cmd/hle/main.go | 19 +- cmd/hlf/help.yml | 6 + cmd/hlf/main.go | 17 +- cmd/hll/help.yml | 7 + cmd/hll/main.go | 18 +- cmd/hlm/help.yml | 6 + cmd/hlm/main.go | 17 +- cmd/hlr/help.yml | 6 + cmd/hlr/main.go | 17 +- cmd/hls/help.yml | 8 + cmd/hls/main.go | 19 +- cmd/hlt/help.yml | 7 + cmd/hlt/main.go | 18 +- internal/utils/help/help.go | 27 ++ internal/utils/help/help_test.go | 5 + test/result/coverage.svg | 610 ++++++++++++++++--------------- 22 files changed, 485 insertions(+), 383 deletions(-) create mode 100644 cmd/hla/common/help.yml create mode 100644 cmd/hlc/help.yml create mode 100644 cmd/hle/help.yml create mode 100644 cmd/hlf/help.yml create mode 100644 cmd/hll/help.yml create mode 100644 cmd/hlm/help.yml create mode 100644 cmd/hlr/help.yml create mode 100644 cmd/hls/help.yml create mode 100644 cmd/hlt/help.yml create mode 100644 internal/utils/help/help.go create mode 100644 internal/utils/help/help_test.go diff --git a/CHANGELOG.md b/CHANGELOG.md index e811f3e..ca3c0fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - `pkg/request,pkg/response`: update interfaces: IRequestBuilder, IResponseBuilder - `hidden-lake`: move GVersion, GSettings, GNetworks from root dir -> to build/ dir - `build`: default work_size_bits=22 -> work_size_bits=0 +- `cmd/*`: add help.yml diff --git a/cmd/hla/common/help.yml b/cmd/hla/common/help.yml new file mode 100644 index 0000000..8f185ae --- /dev/null +++ b/cmd/hla/common/help.yml @@ -0,0 +1,7 @@ +name: Hidden Lake Adapter = Common (HLA=common) +desc: adapts HL traffic to a custom HTTP server +args: | + [ -h, --help ] - print information about service + [ -v, --version ] - print version of service + [ -p, --path ] - set path to config, database files + [ -n, --network ] - set network key for connections \ No newline at end of file diff --git a/cmd/hla/common/main.go b/cmd/hla/common/main.go index 33be7b4..fa3c6dd 100644 --- a/cmd/hla/common/main.go +++ b/cmd/hla/common/main.go @@ -12,6 +12,14 @@ import ( "github.com/number571/hidden-lake/build" "github.com/number571/hidden-lake/internal/adapters/common/pkg/app" "github.com/number571/hidden-lake/internal/utils/flag" + "github.com/number571/hidden-lake/internal/utils/help" + + _ "embed" +) + +var ( + //go:embed help.yml + gHelpYaml []byte ) func main() { @@ -23,15 +31,7 @@ func main() { } if flag.GetBoolFlagValue(args, []string{"h", "help"}) { - fmt.Print( - "Hidden Lake Adapter = Common (HLA=common)\n" + - "Description: adapts HL traffic to a custom HTTP server\n" + - "Arguments:\n" + - "[ -h, --help ] - print information about service\n" + - "[ -v, --version ] - print version of service\n" + - "[ -p, --path ] - set path to config, database files\n" + - "[ -n, --network ] - set network key for connections\n", - ) + help.Println(gHelpYaml) return } diff --git a/cmd/hlc/help.yml b/cmd/hlc/help.yml new file mode 100644 index 0000000..661a783 --- /dev/null +++ b/cmd/hlc/help.yml @@ -0,0 +1,8 @@ +name: Hidden Lake Composite (HLC) +desc: runs many HL services as one application +args: | + [ -h, --help ] - print information about service + [ -v, --version ] - print version of service + [ -p, --path ] - set path to config, database files + [ -n, --network ] - set network key for connections + [ -t, --threads ] - set num of parallel functions to calculate PoW \ No newline at end of file diff --git a/cmd/hlc/main.go b/cmd/hlc/main.go index 88baad5..4e10469 100644 --- a/cmd/hlc/main.go +++ b/cmd/hlc/main.go @@ -11,6 +11,14 @@ import ( "github.com/number571/hidden-lake/build" "github.com/number571/hidden-lake/internal/composite/pkg/app" "github.com/number571/hidden-lake/internal/utils/flag" + "github.com/number571/hidden-lake/internal/utils/help" + + _ "embed" +) + +var ( + //go:embed help.yml + gHelpYaml []byte ) func main() { @@ -22,16 +30,7 @@ func main() { } if flag.GetBoolFlagValue(args, []string{"h", "help"}) { - fmt.Print( - "Hidden Lake Composite (HLC)\n" + - "Description: runs many HL services as one application\n" + - "Arguments:\n" + - "[ -h, --help ] - print information about service\n" + - "[ -v, --version ] - print version of service\n" + - "[ -p, --path ] - set path to config, database files\n" + - "[ -n, --network ] - set network key for connections\n" + - "[ -t, --threads ] - set num of parallel functions to calculate PoW\n", - ) + help.Println(gHelpYaml) return } diff --git a/cmd/hle/help.yml b/cmd/hle/help.yml new file mode 100644 index 0000000..492ca8f --- /dev/null +++ b/cmd/hle/help.yml @@ -0,0 +1,8 @@ +name: Hidden Lake Encryptor (HLE) +desc: encrypts and decrypts messages +args: | + [ -h, --help ] - print information about service + [ -v, --version ] - print version of service + [ -p, --path ] - set path to config, database files + [ -n, --network ] - set network key for connections + [ -t, --threads ] - set num of parallel functions to calculate PoW \ No newline at end of file diff --git a/cmd/hle/main.go b/cmd/hle/main.go index 3a80496..9d23353 100644 --- a/cmd/hle/main.go +++ b/cmd/hle/main.go @@ -12,6 +12,14 @@ import ( "github.com/number571/hidden-lake/build" "github.com/number571/hidden-lake/internal/helpers/encryptor/pkg/app" "github.com/number571/hidden-lake/internal/utils/flag" + "github.com/number571/hidden-lake/internal/utils/help" + + _ "embed" +) + +var ( + //go:embed help.yml + gHelpYaml []byte ) func main() { @@ -23,16 +31,7 @@ func main() { } if flag.GetBoolFlagValue(args, []string{"h", "help"}) { - fmt.Print( - "Hidden Lake Encryptor (HLE)\n" + - "Description: encrypts and decrypts messages\n" + - "Arguments:\n" + - "[ -h, --help ] - print information about service\n" + - "[ -v, --version ] - print version of service\n" + - "[ -p, --path ] - set path to config, database files\n" + - "[ -n, --network ] - set network key for connections\n" + - "[ -t, --threads ] - set num of parallel functions to calculate PoW\n", - ) + help.Println(gHelpYaml) return } diff --git a/cmd/hlf/help.yml b/cmd/hlf/help.yml new file mode 100644 index 0000000..7df5da2 --- /dev/null +++ b/cmd/hlf/help.yml @@ -0,0 +1,6 @@ +name: Hidden Lake Filesharer (HLF) +desc: file sharing with a web interface +args: | + [ -h, --help ] - print information about service + [ -v, --version ] - print version of service + [ -p, --path ] - set path to config, database files \ No newline at end of file diff --git a/cmd/hlf/main.go b/cmd/hlf/main.go index 68c9a24..556e8ae 100644 --- a/cmd/hlf/main.go +++ b/cmd/hlf/main.go @@ -12,6 +12,14 @@ import ( "github.com/number571/hidden-lake/build" "github.com/number571/hidden-lake/internal/applications/filesharer/pkg/app" "github.com/number571/hidden-lake/internal/utils/flag" + "github.com/number571/hidden-lake/internal/utils/help" + + _ "embed" +) + +var ( + //go:embed help.yml + gHelpYaml []byte ) func main() { @@ -23,14 +31,7 @@ func main() { } if flag.GetBoolFlagValue(args, []string{"h", "help"}) { - fmt.Print( - "Hidden Lake Filesharer (HLF)\n" + - "Description: file sharing with a web interface\n" + - "Arguments:\n" + - "[ -h, --help ] - print information about service\n" + - "[ -v, --version ] - print version of service\n" + - "[ -p, --path ] - set path to config, database files\n", - ) + help.Println(gHelpYaml) return } diff --git a/cmd/hll/help.yml b/cmd/hll/help.yml new file mode 100644 index 0000000..16ae6d9 --- /dev/null +++ b/cmd/hll/help.yml @@ -0,0 +1,7 @@ +name: Hidden Lake Loader (HLL) +desc: distributes the stored traffic between nodes +args: | + [ -h, --help ] - print information about service + [ -v, --version ] - print version of service + [ -p, --path ] - set path to config, database files + [ -n, --network ] - set network key for connections \ No newline at end of file diff --git a/cmd/hll/main.go b/cmd/hll/main.go index 8806cc8..4aac81d 100644 --- a/cmd/hll/main.go +++ b/cmd/hll/main.go @@ -12,6 +12,14 @@ import ( "github.com/number571/hidden-lake/build" "github.com/number571/hidden-lake/internal/helpers/loader/pkg/app" "github.com/number571/hidden-lake/internal/utils/flag" + "github.com/number571/hidden-lake/internal/utils/help" + + _ "embed" +) + +var ( + //go:embed help.yml + gHelpYaml []byte ) func main() { @@ -23,15 +31,7 @@ func main() { } if flag.GetBoolFlagValue(args, []string{"h", "help"}) { - fmt.Print( - "Hidden Lake Loader (HLL)\n" + - "Description: distributes the stored traffic between nodes\n" + - "Arguments:\n" + - "[ -h, --help ] - print information about service\n" + - "[ -v, --version ] - print version of service\n" + - "[ -p, --path ] - set path to config, database files\n" + - "[ -n, --network ] - set network key for connections\n", - ) + help.Println(gHelpYaml) return } diff --git a/cmd/hlm/help.yml b/cmd/hlm/help.yml new file mode 100644 index 0000000..8827110 --- /dev/null +++ b/cmd/hlm/help.yml @@ -0,0 +1,6 @@ +name: Hidden Lake Messenger (HLM) +desc: messenger with a web interface +args: | + [ -h, --help ] - print information about service + [ -v, --version ] - print version of service + [ -p, --path ] - set path to config, database files \ No newline at end of file diff --git a/cmd/hlm/main.go b/cmd/hlm/main.go index 638bf5d..21981a6 100644 --- a/cmd/hlm/main.go +++ b/cmd/hlm/main.go @@ -14,6 +14,14 @@ import ( "github.com/number571/hidden-lake/build" "github.com/number571/hidden-lake/internal/applications/messenger/pkg/app" "github.com/number571/hidden-lake/internal/utils/flag" + "github.com/number571/hidden-lake/internal/utils/help" + + _ "embed" +) + +var ( + //go:embed help.yml + gHelpYaml []byte ) func main() { @@ -25,14 +33,7 @@ func main() { } if flag.GetBoolFlagValue(args, []string{"h", "help"}) { - fmt.Print( - "Hidden Lake Messenger (HLM)\n" + - "Description: messenger with a web interface\n" + - "Arguments:\n" + - "[ -h, --help ] - print information about service\n" + - "[ -v, --version ] - print version of service\n" + - "[ -p, --path ] - set path to config, database files\n", - ) + help.Println(gHelpYaml) return } diff --git a/cmd/hlr/help.yml b/cmd/hlr/help.yml new file mode 100644 index 0000000..624a145 --- /dev/null +++ b/cmd/hlr/help.yml @@ -0,0 +1,6 @@ +name: Hidden Lake Remoter (HLR) +desc: executes remote access commands +args: | + [ -h, --help ] - print information about service + [ -v, --version ] - print version of service + [ -p, --path ] - set path to config, database files \ No newline at end of file diff --git a/cmd/hlr/main.go b/cmd/hlr/main.go index a5666f5..bbca75b 100644 --- a/cmd/hlr/main.go +++ b/cmd/hlr/main.go @@ -12,6 +12,14 @@ import ( "github.com/number571/hidden-lake/build" "github.com/number571/hidden-lake/internal/applications/remoter/pkg/app" "github.com/number571/hidden-lake/internal/utils/flag" + "github.com/number571/hidden-lake/internal/utils/help" + + _ "embed" +) + +var ( + //go:embed help.yml + gHelpYaml []byte ) func main() { @@ -23,14 +31,7 @@ func main() { } if flag.GetBoolFlagValue(args, []string{"h", "help"}) { - fmt.Print( - "Hidden Lake Remoter (HLR)\n" + - "Description: executes remote access commands\n" + - "Arguments:\n" + - "[ -h, --help ] - print information about service\n" + - "[ -v, --version ] - print version of service\n" + - "[ -p, --path ] - set path to config, database files\n", - ) + help.Println(gHelpYaml) return } diff --git a/cmd/hls/help.yml b/cmd/hls/help.yml new file mode 100644 index 0000000..17a6f70 --- /dev/null +++ b/cmd/hls/help.yml @@ -0,0 +1,8 @@ +name: Hidden Lake Service (HLS) +desc: anonymizes traffic using the QB-problem +args: | + [ -h, --help ] - print information about service + [ -v, --version ] - print version of service + [ -p, --path ] - set path to config, database files + [ -n, --network ] - set network key for connections + [ -t, --threads ] - set num of parallel functions to calculate PoW \ No newline at end of file diff --git a/cmd/hls/main.go b/cmd/hls/main.go index 2b61cd3..9279032 100644 --- a/cmd/hls/main.go +++ b/cmd/hls/main.go @@ -12,6 +12,14 @@ import ( "github.com/number571/hidden-lake/build" "github.com/number571/hidden-lake/internal/service/pkg/app" "github.com/number571/hidden-lake/internal/utils/flag" + "github.com/number571/hidden-lake/internal/utils/help" + + _ "embed" +) + +var ( + //go:embed help.yml + gHelpYaml []byte ) func main() { @@ -23,16 +31,7 @@ func main() { } if flag.GetBoolFlagValue(args, []string{"h", "help"}) { - fmt.Print( - "Hidden Lake Service (HLS)\n" + - "Description: anonymizes traffic using the QB-problem\n" + - "Arguments:\n" + - "[ -h, --help ] - print information about service\n" + - "[ -v, --version ] - print version of service\n" + - "[ -p, --path ] - set path to config, database files\n" + - "[ -n, --network ] - set network key for connections\n" + - "[ -t, --threads ] - set num of parallel functions to calculate PoW\n", - ) + help.Println(gHelpYaml) return } diff --git a/cmd/hlt/help.yml b/cmd/hlt/help.yml new file mode 100644 index 0000000..f546475 --- /dev/null +++ b/cmd/hlt/help.yml @@ -0,0 +1,7 @@ +name: Hidden Lake Traffic (HLT) +desc: retransmits and saves encrypted traffic +args: | + [ -h, --help ] - print information about service + [ -v, --version ] - print version of service + [ -p, --path ] - set path to config, database files + [ -n, --network ] - set network key for connections \ No newline at end of file diff --git a/cmd/hlt/main.go b/cmd/hlt/main.go index d6a9874..a7fb6b5 100644 --- a/cmd/hlt/main.go +++ b/cmd/hlt/main.go @@ -12,6 +12,14 @@ import ( "github.com/number571/hidden-lake/build" "github.com/number571/hidden-lake/internal/helpers/traffic/pkg/app" "github.com/number571/hidden-lake/internal/utils/flag" + "github.com/number571/hidden-lake/internal/utils/help" + + _ "embed" +) + +var ( + //go:embed help.yml + gHelpYaml []byte ) func main() { @@ -23,15 +31,7 @@ func main() { } if flag.GetBoolFlagValue(args, []string{"h", "help"}) { - fmt.Print( - "Hidden Lake Traffic (HLT)\n" + - "Description: retransmits and saves encrypted traffic\n" + - "Arguments:\n" + - "[ -h, --help ] - print information about service\n" + - "[ -v, --version ] - print version of service\n" + - "[ -p, --path ] - set path to config, database files\n" + - "[ -n, --network ] - set network key for connections\n", - ) + help.Println(gHelpYaml) return } diff --git a/internal/utils/help/help.go b/internal/utils/help/help.go new file mode 100644 index 0000000..052badf --- /dev/null +++ b/internal/utils/help/help.go @@ -0,0 +1,27 @@ +package help + +import ( + "fmt" + "strings" + + "github.com/number571/go-peer/pkg/encoding" +) + +type sHelp struct { + Name string `yaml:"name"` + Desc string `yaml:"desc"` + Args string `yaml:"args"` +} + +func Println(yamlBytes []byte) { + help := &sHelp{} + if err := encoding.DeserializeYAML(yamlBytes, help); err != nil { + panic(err) + } + fmt.Printf( + "%s\n%s\n%s\n", + strings.TrimSpace(help.Name), + strings.TrimSpace(help.Desc), + strings.TrimSpace(help.Args), + ) +} diff --git a/internal/utils/help/help_test.go b/internal/utils/help/help_test.go new file mode 100644 index 0000000..816f1bc --- /dev/null +++ b/internal/utils/help/help_test.go @@ -0,0 +1,5 @@ +package help + +import "testing" + +func TestNothing(_ *testing.T) {} diff --git a/test/result/coverage.svg b/test/result/coverage.svg index 0ea7ec6..7306a18 100644 --- a/test/result/coverage.svg +++ b/test/result/coverage.svg @@ -7,7 +7,7 @@ > - + - + build/build.go @@ -33,7 +33,7 @@ - + - + pkg @@ -59,12 +59,12 @@ - + adapters @@ -72,7 +72,7 @@ - + - + composite/pkg/app @@ -98,12 +98,12 @@ - + helpers @@ -111,25 +111,25 @@ - + service - + utils @@ -137,18 +137,18 @@ - + - + handler @@ -156,12 +156,12 @@ - + network @@ -169,12 +169,12 @@ - + request @@ -182,12 +182,12 @@ - + response @@ -195,12 +195,12 @@ - + common @@ -208,12 +208,12 @@ - + processor.go @@ -221,7 +221,7 @@ - + - + - + remoter @@ -260,12 +260,12 @@ - + app.go @@ -273,12 +273,12 @@ - + config @@ -286,12 +286,12 @@ - + init_app.go @@ -299,12 +299,12 @@ - + encryptor @@ -312,12 +312,12 @@ - + loader @@ -325,12 +325,12 @@ - + traffic @@ -338,12 +338,12 @@ - + internal/handler @@ -351,12 +351,12 @@ - + pkg @@ -364,12 +364,12 @@ - + api @@ -377,36 +377,42 @@ - + + + + + + + - + - + - + - + language @@ -414,12 +420,12 @@ - + logger @@ -427,18 +433,18 @@ - + - + privkey @@ -446,42 +452,42 @@ - + - + - + - + - + - + internal @@ -489,12 +495,12 @@ - + pkg/app @@ -502,7 +508,7 @@ - + - + pkg @@ -528,7 +534,7 @@ - + - + pkg @@ -554,12 +560,12 @@ - + internal/handler/incoming.go @@ -567,12 +573,12 @@ - + pkg @@ -580,18 +586,18 @@ - + - + internal/handler @@ -599,12 +605,12 @@ - + pkg @@ -612,12 +618,12 @@ - + internal/handler @@ -625,12 +631,12 @@ - + pkg @@ -638,12 +644,12 @@ - + internal @@ -651,12 +657,12 @@ - + pkg @@ -664,12 +670,12 @@ - + config_connects.go @@ -677,12 +683,12 @@ - + config_friends.go @@ -690,30 +696,30 @@ - + - + - + - + network_online.go @@ -721,12 +727,12 @@ - + network_request.go @@ -734,18 +740,18 @@ - + - + service_tcp.go @@ -753,12 +759,12 @@ - + app @@ -766,12 +772,12 @@ - + client @@ -779,42 +785,42 @@ - + - + - + - + - + - + std @@ -822,30 +828,30 @@ - + - + - + - + app.go @@ -853,12 +859,12 @@ - + config @@ -866,13 +872,13 @@ - + - + - + - + - + app @@ -910,18 +916,18 @@ - + - + database @@ -929,7 +935,7 @@ - + - + - + utils @@ -961,12 +967,12 @@ - + app @@ -974,18 +980,18 @@ - + - + app @@ -993,18 +999,18 @@ - + - + config_friends.go @@ -1012,18 +1018,18 @@ - + - + decrypt.go @@ -1031,12 +1037,12 @@ - + encrypt.go @@ -1044,24 +1050,24 @@ - + - + - + app @@ -1069,12 +1075,12 @@ - + client @@ -1082,24 +1088,24 @@ - + - + - + transfer.go @@ -1107,12 +1113,12 @@ - + app @@ -1120,12 +1126,12 @@ - + client @@ -1133,24 +1139,24 @@ - + - + - + handler @@ -1158,18 +1164,18 @@ - + - + app @@ -1177,12 +1183,12 @@ - + client @@ -1190,12 +1196,12 @@ - + app.go @@ -1203,12 +1209,12 @@ - + config @@ -1216,42 +1222,42 @@ - + - + - + - + - + - + client.go @@ -1259,12 +1265,12 @@ - + requester.go @@ -1272,42 +1278,42 @@ - + - + - + - + - + - + friends.go @@ -1315,12 +1321,12 @@ - + incoming_list.go @@ -1328,12 +1334,12 @@ - + incoming_load.go @@ -1341,18 +1347,18 @@ - + - + settings.go @@ -1360,12 +1366,12 @@ - + storage.go @@ -1373,24 +1379,24 @@ - + - + - + app.go @@ -1398,12 +1404,12 @@ - + config @@ -1411,30 +1417,30 @@ - + - + - + - + database.go @@ -1442,36 +1448,36 @@ - + - + - + - + - + data_type.go @@ -1479,18 +1485,18 @@ - + - + friends.go @@ -1498,12 +1504,12 @@ - + friends_chat.go @@ -1511,30 +1517,30 @@ - + - + - + - + incoming_push.go @@ -1542,18 +1548,18 @@ - + - + settings.go @@ -1561,24 +1567,24 @@ - + - + - + app.go @@ -1586,12 +1592,12 @@ - + config @@ -1599,54 +1605,54 @@ - + - + - + - + - + - + - + - + app.go @@ -1654,12 +1660,12 @@ - + config @@ -1667,96 +1673,96 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + message.go @@ -1764,30 +1770,30 @@ - + - + - + - + app.go @@ -1795,12 +1801,12 @@ - + config @@ -1808,42 +1814,42 @@ - + - + - + - + - + - + config.go @@ -1851,12 +1857,12 @@ - + editor.go @@ -1864,12 +1870,12 @@ - + init.go @@ -1877,30 +1883,30 @@ - + - + - + - + config.go @@ -1908,24 +1914,24 @@ - + - + - + config.go @@ -1933,37 +1939,37 @@ - + - + - + - + - + - +