diff --git a/.golangci.yml b/.golangci.yml
new file mode 100644
index 0000000..041e989
--- /dev/null
+++ b/.golangci.yml
@@ -0,0 +1,315 @@
+## Golden config for golangci-lint v1.48.0
+#
+# This is the best config for golangci-lint based on my experience and opinion.
+# It is very strict, but not extremely strict.
+# Feel free to adopt and change it for your needs.
+
+run:
+ # Timeout for analysis, e.g. 30s, 5m.
+ # Default: 1m
+ timeout: 3m
+
+# This file contains only configs which differ from defaults.
+# All possible options can be found here https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml
+linters-settings:
+ cyclop:
+ # The maximal code complexity to report.
+ # Default: 10
+ max-complexity: 30
+ # The maximal average package complexity.
+ # If it's higher than 0.0 (float) the check is enabled
+ # Default: 0.0
+ package-average: 10.0
+
+ errcheck:
+ # Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
+ # Such cases aren't reported by default.
+ # Default: false
+ check-type-assertions: true
+
+ funlen:
+ # Checks the number of lines in a function.
+ # If lower than 0, disable the check.
+ # Default: 60
+ lines: 100
+ # Checks the number of statements in a function.
+ # If lower than 0, disable the check.
+ # Default: 40
+ statements: 50
+
+ gocognit:
+ # Minimal code complexity to report
+ # Default: 30 (but we recommend 10-20)
+ min-complexity: 20
+
+ gocritic:
+ # Settings passed to gocritic.
+ # The settings key is the name of a supported gocritic checker.
+ # The list of supported checkers can be find in https://go-critic.github.io/overview.
+ settings:
+ captLocal:
+ # Whether to restrict checker to params only.
+ # Default: true
+ paramsOnly: false
+ underef:
+ # Whether to skip (*x).method() calls where x is a pointer receiver.
+ # Default: true
+ skipRecvDeref: false
+
+ gomnd:
+ # List of function patterns to exclude from analysis.
+ # Values always ignored: `time.Date`
+ # Default: []
+ ignored-functions:
+ - os.Chmod
+ - os.Mkdir
+ - os.MkdirAll
+ - os.OpenFile
+ - os.WriteFile
+ - prometheus.ExponentialBuckets
+ - prometheus.ExponentialBucketsRange
+ - prometheus.LinearBuckets
+ - strconv.FormatFloat
+ - strconv.FormatInt
+ - strconv.FormatUint
+ - strconv.ParseFloat
+ - strconv.ParseInt
+ - strconv.ParseUint
+
+ gomodguard:
+ blocked:
+ # List of blocked modules.
+ # Default: []
+ modules:
+ - github.com/golang/protobuf:
+ recommendations:
+ - google.golang.org/protobuf
+ reason: "see https://developers.google.com/protocol-buffers/docs/reference/go/faq#modules"
+ - github.com/satori/go.uuid:
+ recommendations:
+ - github.com/google/uuid
+ reason: "satori's package is not maintained"
+ - github.com/gofrs/uuid:
+ recommendations:
+ - github.com/google/uuid
+ reason: "see recommendation from dev-infra team: https://confluence.gtforge.com/x/gQI6Aw"
+
+ govet:
+ # Enable all analyzers.
+ # Default: false
+ enable-all: true
+ check-shadowing: false
+ # Disable analyzers by name.
+ # Run `go tool vet help` to see all analyzers.
+ # Default: []
+ disable:
+ - fieldalignment # too strict
+ - shadow
+ # Settings per analyzer.
+ # settings:
+ # shadow:
+ # # Whether to be strict about shadowing; can be noisy.
+ # # Default: false
+ # strict: false
+
+ nakedret:
+ # Make an issue if func has more lines of code than this setting, and it has naked returns.
+ # Default: 30
+ max-func-lines: 0
+
+ nolintlint:
+ # Exclude following linters from requiring an explanation.
+ # Default: []
+ allow-no-explanation: [funlen, gocognit, lll]
+ # Enable to require an explanation of nonzero length after each nolint directive.
+ # Default: false
+ require-explanation: true
+ # Enable to require nolint directives to mention the specific linter being suppressed.
+ # Default: false
+ require-specific: true
+
+ revive:
+ ignore-generated-header: true
+ severity: warning
+ confidence: 0.8
+ rules:
+ - name: line-length-limit
+ severity: error
+ arguments: [180]
+ - name: time-equal
+ - name: time-naming
+ - name: var-declaration
+ - name: unexported-return
+ severity: error
+ - name: blank-imports
+ - name: errorf
+ severity: error
+ - name: error-return
+ # - name: if-return
+ # severity: error
+ - name: increment-decrement
+ - name: range
+ - name: indent-error-flow
+ - name: empty-block
+ - name: superfluous-else
+ # - name: confusing-naming
+ - name: modifies-parameter
+ - name: confusing-results
+ # - name: deep-exit
+ - name: unused-parameter
+ - name: unreachable-code
+ - name: atomic
+ - name: empty-lines
+ - name: duplicated-imports
+ - name: import-shadowing
+ - name: unhandled-error
+ - name: early-return
+ - name: defer
+ - name: identical-branches
+ - name: useless-break
+
+ rowserrcheck:
+ # database/sql is always checked
+ # Default: []
+ packages:
+ - github.com/jmoiron/sqlx
+
+ tenv:
+ # The option `all` will run against whole test files (`_test.go`) regardless of method/function signatures.
+ # Otherwise, only methods that take `*testing.T`, `*testing.B`, and `testing.TB` as arguments are checked.
+ # Default: false
+ all: true
+
+ varcheck:
+ # Check usage of exported fields and variables.
+ # Default: false
+ exported-fields: false # default false # TODO: enable after fixing false positives
+
+linters:
+ disable-all: true
+ enable:
+ ## enabled by default
+ - deadcode # Finds unused code
+ - errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases
+ - gosimple # Linter for Go source code that specializes in simplifying a code
+ - govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
+ - ineffassign # Detects when assignments to existing variables are not used
+ - staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks
+ - structcheck # Finds unused struct fields
+ - typecheck # Like the front-end of a Go compiler, parses and type-checks Go code
+ - unused # Checks Go code for unused constants, variables, functions and types
+ - varcheck # Finds unused global variables and constants
+ ## disabled by default
+ - asasalint # Check for pass []any as any in variadic func(...any)
+ - asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers
+ - bidichk # Checks for dangerous unicode character sequences
+ - bodyclose # checks whether HTTP response body is closed successfully
+ - contextcheck # check the function whether use a non-inherited context
+ - cyclop # checks function and package cyclomatic complexity
+ - dupl # Tool for code clone detection
+ - durationcheck # check for two durations multiplied together
+ - errname # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error.
+ - errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13.
+ - execinquery # execinquery is a linter about query string checker in Query function which reads your Go src files and warning it finds
+ - exhaustive # check exhaustiveness of enum switch statements
+ - exportloopref # checks for pointers to enclosing loop variables
+ # - forbidigo # Forbids identifiers
+ - funlen # Tool for detection of long functions
+ # - gochecknoglobals # check that no global variables exist
+ - gochecknoinits # Checks that no init functions are present in Go code
+ # - gocognit # Computes and checks the cognitive complexity of functions
+ - goconst # Finds repeated strings that could be replaced by a constant
+ # - gocritic # Provides diagnostics that check for bugs, performance and style issues.
+ - gocyclo # Computes and checks the cyclomatic complexity of functions
+ - godot # Check if comments end in a period
+ - goimports # In addition to fixing imports, goimports also formats your code in the same style as gofmt.
+ # - gomnd # An analyzer to detect magic numbers.
+ - gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod.
+ - gomodguard # Allow and block list linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations.
+ - goprintffuncname # Checks that printf-like functions are named with f at the end
+ - gosec # Inspects source code for security problems
+ # - lll # Reports long lines
+ - makezero # Finds slice declarations with non-zero initial length
+ - nakedret # Finds naked returns in functions greater than a specified function length
+ # - nestif # Reports deeply nested if statements
+ - nilerr # Finds the code that returns nil even if it checks that the error is not nil.
+ - nilnil # Checks that there is no simultaneous return of nil error and an invalid value.
+ # - noctx # noctx finds sending http request without context.Context
+ # - nolintlint # Reports ill-formed or insufficient nolint directives
+ - nonamedreturns # Reports all named returns
+ - nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL.
+ - predeclared # find code that shadows one of Go's predeclared identifiers
+ - promlinter # Check Prometheus metrics naming via promlint
+ - revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint.
+ - rowserrcheck # checks whether Err of rows is checked successfully
+ - sqlclosecheck # Checks that sql.Rows and sql.Stmt are closed.
+ # - stylecheck # Stylecheck is a replacement for golint
+ - tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17
+ - testpackage # linter that makes you use a separate _test package
+ - tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes
+ - unconvert # Remove unnecessary type conversions
+ - unparam # Reports unused function parameters
+ - usestdlibvars # detect the possibility to use variables/constants from the Go standard library
+ - wastedassign # wastedassign finds wasted assignment statements.
+ - whitespace # Tool for detection of leading and trailing whitespace
+ ## you may want to enable
+ #- decorder # check declaration order and count of types, constants, variables and functions
+ #- exhaustruct # Checks if all structure fields are initialized
+ #- goheader # Checks is file header matches to pattern
+ #- ireturn # Accept Interfaces, Return Concrete Types
+ #- prealloc # [premature optimization, but can be used in some cases] Finds slice declarations that could potentially be preallocated
+ #- varnamelen # [great idea, but too many false positives] checks that the length of a variable's name matches its scope
+ #- wrapcheck # Checks that errors returned from external packages are wrapped
+ ## disabled
+ #- containedctx # containedctx is a linter that detects struct contained context.Context field
+ #- depguard # [replaced by gomodguard] Go linter that checks if package imports are in a list of acceptable packages
+ #- dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())
+ #- errchkjson # [don't see profit + I'm against of omitting errors like in the first example https://github.com/breml/errchkjson] Checks types passed to the json encoding functions. Reports unsupported types and optionally reports occasions, where the check for the returned error can be omitted.
+ #- forcetypeassert # [replaced by errcheck] finds forced type assertions
+ #- gci # Gci controls golang package import order and makes it always deterministic.
+ #- godox # Tool for detection of FIXME, TODO and other comment keywords
+ #- goerr113 # [too strict] Golang linter to check the errors handling expressions
+ #- gofmt # [replaced by goimports] Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification
+ #- gofumpt # [replaced by goimports, gofumports is not available yet] Gofumpt checks whether code was gofumpt-ed.
+ #- grouper # An analyzer to analyze expression groups.
+ #- importas # Enforces consistent import aliases
+ #- maintidx # maintidx measures the maintainability index of each function.
+ #- misspell # [useless] Finds commonly misspelled English words in comments
+ #- nlreturn # [too strict and mostly code is not more readable] nlreturn checks for a new line before return and branch statements to increase code clarity
+ #- nosnakecase # Detects snake case of variable naming and function name. # TODO: maybe enable after https://github.com/sivchari/nosnakecase/issues/14
+ #- paralleltest # [too many false positives] paralleltest detects missing usage of t.Parallel() method in your Go test
+ #- tagliatelle # Checks the struct tags.
+ #- thelper # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers
+ #- wsl # [too strict and mostly code is not more readable] Whitespace Linter - Forces you to use empty lines!
+ ## deprecated
+ #- exhaustivestruct # [deprecated, replaced by exhaustruct] Checks if all struct's fields are initialized
+ #- golint # [deprecated, replaced by revive] Golint differs from gofmt. Gofmt reformats Go source code, whereas golint prints out style mistakes
+ #- ifshort # [deprecated, by the owner] Checks that your code uses short syntax for if-statements whenever possible
+ #- interfacer # [deprecated] Linter that suggests narrower interface types
+ #- maligned # [deprecated, replaced by govet fieldalignment] Tool to detect Go structs that would take less memory if their fields were sorted
+ #- scopelint # [deprecated, replaced by exportloopref] Scopelint checks for unpinned variables in go programs
+
+issues:
+ # Maximum count of issues with the same text.
+ # Set to 0 to disable.
+ # Default: 3
+ max-same-issues: 50
+
+ exclude-rules:
+ - source: "^//\\s*go:generate\\s"
+ linters: [lll]
+ - source: "(noinspection|TODO)"
+ linters: [godot]
+ - source: "//noinspection"
+ linters: [gocritic]
+ - source: "^\\s+if _, ok := err\\.\\([^.]+\\.InternalError\\); ok {"
+ linters: [errorlint]
+ - path: "_test\\.go"
+ linters:
+ - bodyclose
+ - dupl
+ - funlen
+ - goconst
+ - gosec
+ - noctx
+ - wrapcheck
diff --git a/.tasks.json b/.tasks.json
new file mode 100644
index 0000000..7a330c6
--- /dev/null
+++ b/.tasks.json
@@ -0,0 +1,28 @@
+{
+ "tasks": [
+ {
+ "name": "install",
+ "cmd": "make install"
+ },
+ {
+ "name": "update",
+ "cmd": "make update"
+ },
+ {
+ "name": "tidy",
+ "cmd": "make tidy"
+ },
+ {
+ "name": "lint",
+ "cmd": "make lint"
+ },
+ {
+ "name": "build",
+ "cmd": "make build"
+ },
+ {
+ "name": "docker",
+ "cmd": "make build-docker"
+ }
+ ]
+}
diff --git a/CLI.md b/CLI.md
new file mode 100644
index 0000000..3a3de33
--- /dev/null
+++ b/CLI.md
@@ -0,0 +1,59 @@
+# docker-softether-vpnsrv
+
+Initiates the SoftEtherVPN server that will run in this container.
+
+`docker-softether-vpnsrv [GLOBAL FLAGS] command [COMMAND FLAGS] [ARGUMENTS...]`
+
+## Global Flags
+
+### Dhcp-Server
+
+| Flag / Environment | Description | Type | Required | Default |
+|---------------- | --------------- | --------------- | --------------- | --------------- |
+| `$DHCP_SERVER_TEMPLATE` | Template location for the DHCP server. | `String` | `false` | "/etc/template/dnsmasq.conf.tmpl" |
+| `$DHCP_SERVER_LEASE` | DHCP server lease time for clients. | `String` | `false` | "12h" |
+| `$DHCP_SERVER_SEND_GATEWAY` | Whether to send the default gateway to the client. Sometimes you do not want to proxy traffic through the network, rather just establish a connection to the VPN network. | `Bool` | `false` | true |
+| `$DHCP_SERVER_GATEWAY` | Set the gateway option for the underlying DNS server. | `String`
dynamic("cidr address start") | `false` | |
+| `$DHCP_SERVER_FORWARDING_ZONE` | Set forwarding-zone DNS addresses for the DHCP server. | `StringSlice` | `false` | [8.8.8.8 8.8.4.4] |
+
+| Flag / Environment | Description | Type | Required | Default |
+|---------------- | --------------- | --------------- | --------------- | --------------- |
+| `$DEBUG` | Enable debugging for the application. | `Bool` | `false` | false |
+| `$LOG_LEVEL` | Define the log level for the application. | `String`
enum("PANIC", "FATAL", "WARNING", "INFO", "DEBUG", "TRACE") | `false` | "info" |
+
+### Health
+
+| Flag / Environment | Description | Type | Required | Default |
+|---------------- | --------------- | --------------- | --------------- | --------------- |
+| `$HEALTH_CHECK_INTERVAL` | Health check interval to the upstream server in duration. | `String` | `false` | "1h" |
+| `$HEALTH_DHCP_SERVER_ADDRESS` | Upstream DHCP server address for doing health checks. | `String`
dynamic("cidr address start") | `false` | |
+
+### Linux-Bridge
+
+| Flag / Environment | Description | Type | Required | Default |
+|---------------- | --------------- | --------------- | --------------- | --------------- |
+| `$LINUX_BRIDGE_INTERFACE_NAME` | Interface name for the resulting communication bridge interface. | `String` | `false` | "br100" |
+| `$LINUX_BRIDGE_UPSTREAM_INTERFACE` | Interface name for the upstream parent network interface to bridge to, this interface should provide a DHCP server to handle the clients. | `String` | `false` | "eth0" |
+| `$LINUX_BRIDGE_USE_DHCP` | Use the upstream DHCP server to get ip for the bridge interface. | `Bool` | `false` | true |
+| `$LINUX_BRIDGE_STATIC_IP` | Use a static IP for the bridge interface. | `String` | `false` | |
+
+### Server
+
+| Flag / Environment | Description | Type | Required | Default |
+|---------------- | --------------- | --------------- | --------------- | --------------- |
+| `$SERVER_MODE` | Server mode changes the behavior of the container. | `String`
enum("dhcp", "bridge") | `true` | |
+| `$SERVER_CIDR_ADDRESS` | CIDR address of the server. | `String` | `false` | "10.0.0.0/24" |
+
+### SoftEther
+
+| Flag / Environment | Description | Type | Required | Default |
+|---------------- | --------------- | --------------- | --------------- | --------------- |
+| `$SOFTETHER_TEMPLATE` | Template location for the SoftEtherVPN server. | `String` | `false` | "/etc/template/vpn_server.config.tmpl" |
+| `$SOFTETHER_TAP_INTERFACE` | Interface name for SoftEther and the server to bind to as a tap device. | `String` | `false` | "soft" |
+| `$SOFTETHER_DEFAULT_HUB` | Default hub name for SoftEtherVPN server. | `String` | `false` | "DEFAULT" |
+
+## Commands
+
+### `help` , `h`
+
+`Shows a list of commands or help for one command`
diff --git a/Makefile b/Makefile
index 0db2630..b8e5a8e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-GO_VERSION=1.18
+GO_VERSION=1.19
GO_CMD=go
GO_BUILD=$(GO_CMD) build
@@ -25,7 +25,10 @@ tidy:
BINARY_FOLDER=dist
BINARY_NAME=pipe
-all: test build
+all: lint test build
+
+lint:
+ CGO_ENABLED=$(GO_OPTION_C) golangci-lint run ./...
test:
CGO_ENABLED=$(GO_OPTION_C) $(GO_TEST) -v -p 1 ./...
@@ -46,11 +49,14 @@ build-linux-amd64:
build-linux-arm64:
CGO_ENABLED=$(GO_OPTION_C) GOOS=linux GOARCH=arm64 $(GO_BUILD) -mod=readonly -o $(BINARY_FOLDER)/$(BINARY_NAME)-linux-arm64
+build-docker:
+ docker-compose build
+
dev:
CGO_ENABLED=$(GO_OPTION_C) $(GO_RUN) --log-level debug $(ARGS)
docs:
- CGO_ENABLED=$(GO_OPTION_C) $(GO_RUN) --log-level debug docs
+ CGO_ENABLED=$(GO_OPTION_C) $(GO_RUN) MARKDOWN_DOC
help:
CGO_ENABLED=$(GO_OPTION_C) $(GO_RUN) --help
diff --git a/README.md b/README.md
index 3529b2e..cabe9c0 100644
--- a/README.md
+++ b/README.md
@@ -18,6 +18,9 @@ This container runs a SoftEther VPN Server bundled together with a configuration
[Read more](https://www.softether.org/) about SoftEther in the official documentation.
+---
+
+- [CLI Documentation](./CLI.md)
- [Features](#features)
@@ -88,55 +91,55 @@ This image is built for `linux-amd64` and `linux-arm64` architectures.
### General
-| Environment Variable | Description | Default | Format | Required |
-| -------------------- | ----------------------------- | ------- | ----------------------------------------------------------- | -------- |
-| `TZ` | Timezone for the server. | | string | |
-| `LOG_LEVEL` | Log level for the supervisor. | INFO | enum("PANIC", "FATAL", "WARNING", "INFO", "DEBUG", "TRACE") | |
+| Flag / Environment | Description | Type | Required | Default |
+|---------------- | --------------- | --------------- | --------------- | --------------- |
+| `$DEBUG` | Enable debugging for the application. | `Bool` | `false` | false |
+| `$LOG_LEVEL` | Define the log level for the application. | `String`
enum("PANIC", "FATAL", "WARNING", "INFO", "DEBUG", "TRACE") | `false` | "info" |
### Server
-| Environment Variable | Description | Default | Format | Required |
-| --------------------- | -------------------------------------------------- | ------------- | ---------------------- | -------- |
-| `SERVER_MODE` | Server mode changes the behavior of the container. | | enum("dhcp", "bridge") | yes |
-| `SERVER_CIDR_ADDRESS` | CIDR address of the server. | "10.0.0.0/24" | string(cidr) | |
+| Flag / Environment | Description | Type | Required | Default |
+|---------------- | --------------- | --------------- | --------------- | --------------- |
+| `$SERVER_MODE` | Server mode changes the behavior of the container. | `String`
enum("dhcp", "bridge") | `true` | |
+| `$SERVER_CIDR_ADDRESS` | CIDR address of the server. | `String` | `false` | "10.0.0.0/24" |
### SoftEther
-| Environment Variable | Description | Default | Format | Required |
-| ------------------------- | ----------------------------------------------------------------------- | -------------------------------------- | ------------ | -------- |
-| `SOFTETHER_TAP_INTERFACE` | Interface name for SoftEther and the server to bind to as a tap device. | "soft" | string | |
-| `SOFTETHER_TEMPLATE` | Template location for the SoftEtherVPN server. | "/etc/template/vpn_server.config.tmpl" | string(path) | |
-| `SOFTETHER_DEFAULT_HUB` | Default hub name for SoftEtherVPN server. | "DEFAULT" | string | |
+| Flag / Environment | Description | Type | Required | Default |
+|---------------- | --------------- | --------------- | --------------- | --------------- |
+| `$SOFTETHER_TEMPLATE` | Template location for the SoftEtherVPN server. | `String` | `false` | "/etc/template/vpn_server.config.tmpl" |
+| `$SOFTETHER_TAP_INTERFACE` | Interface name for SoftEther and the server to bind to as a tap device. | `String` | `false` | "soft" |
+| `$SOFTETHER_DEFAULT_HUB` | Default hub name for SoftEtherVPN server. | `String` | `false` | "DEFAULT" |
### Health
-| Environment Variable | Description | Default | Format | Required |
-| ---------------------------- | --------------------------------------------------------- | ------------------ | ---------------- | -------- |
-| `HEALTH_CHECK_INTERVAL` | Health check interval to the upstream server in duration. | "1h" | string(duration) | |
-| `HEALTH_DHCP_SERVER_ADDRESS` | Upstream DHCP server address for doing health checks. | cidr address start | string(cidr) | |
+| Flag / Environment | Description | Type | Required | Default |
+|---------------- | --------------- | --------------- | --------------- | --------------- |
+| `$HEALTH_CHECK_INTERVAL` | Health check interval to the upstream server in duration. | `String` | `false` | "1h" |
+| `$HEALTH_DHCP_SERVER_ADDRESS` | Upstream DHCP server address for doing health checks. | `String`
dynamic("cidr address start") | `false` | |
### DHCP-Server
The following options are only valid whenever `SERVER_MODE` is `dhcp`.
-| Environment Variable | Description | Default | Format | Required |
-| --- | --- | --- | --- | --- |
-| `DHCP_SERVER_TEMPLATE` | Template location for the DHCP server. | "/etc/template/dnsmasq.conf.tmpl" | string(path) | |
-| `DHCP_SERVER_GATEWAY` | Set the gateway option for the underlying DNS server. | cidr address start | string(cidr) | |
-| `DHCP_SERVER_SEND_GATEWAY` | Whether to send the default gateway to the client. Sometimes you do not want to proxy traffic through the network, rather just establish a connection to the VPN network. | true | boolean | |
-| `DHCP_SERVER_LEASE` | DHCP server lease time for clients. | "12h" | string(duration) | |
-| `DHCP_SERVER_FORWARDING_ZONE` | Set forwarding-zone DNS addresses for the DHCP server. | "8.8.8.8,8.8.4.4" | multiple(string, ",") | |
+| Flag / Environment | Description | Type | Required | Default |
+|---------------- | --------------- | --------------- | --------------- | --------------- |
+| `$DHCP_SERVER_TEMPLATE` | Template location for the DHCP server. | `String` | `false` | "/etc/template/dnsmasq.conf.tmpl" |
+| `$DHCP_SERVER_LEASE` | DHCP server lease time for clients. | `String` | `false` | "12h" |
+| `$DHCP_SERVER_SEND_GATEWAY` | Whether to send the default gateway to the client. Sometimes you do not want to proxy traffic through the network, rather just establish a connection to the VPN network. | `Bool` | `false` | true |
+| `$DHCP_SERVER_GATEWAY` | Set the gateway option for the underlying DNS server. | `String`
dynamic("cidr address start") | `false` | |
+| `$DHCP_SERVER_FORWARDING_ZONE` | Set forwarding-zone DNS addresses for the DHCP server. | `StringSlice` | `false` | [8.8.8.8 8.8.4.4] |
### Linux-Bridge
The following options are only valid whenever `SERVER_MODE` is `bridge`.
-| Environment Variable | Description | Default | Format | Required |
-| --- | --- | --- | --- | --- |
-| `LINUX_BRIDGE_INTERFACE_NAME` | Interface name for the resulting communication bridge interface. | "br100" | string | |
-| `LINUX_BRIDGE_UPSTREAM_INTERFACE` | Interface name for the upstream parent network interface to bridge to, this interface should provide a DHCP server to handle the clients. | "eth0" | string | |
-| `LINUX_BRIDGE_USE_DHCP` | Use the upstream DHCP server to get ip for the bridge interface. | true | boolean | |
-| `LINUX_BRIDGE_STATIC_IP` | Use a static IP for the bridge interface. | | string | |
+| Flag / Environment | Description | Type | Required | Default |
+|---------------- | --------------- | --------------- | --------------- | --------------- |
+| `$LINUX_BRIDGE_INTERFACE_NAME` | Interface name for the resulting communication bridge interface. | `String` | `false` | "br100" |
+| `$LINUX_BRIDGE_UPSTREAM_INTERFACE` | Interface name for the upstream parent network interface to bridge to, this interface should provide a DHCP server to handle the clients. | `String` | `false` | "eth0" |
+| `$LINUX_BRIDGE_USE_DHCP` | Use the upstream DHCP server to get ip for the bridge interface. | `Bool` | `false` | true |
+| `$LINUX_BRIDGE_STATIC_IP` | Use a static IP for the bridge interface. | `String` | `false` | |
## Setup
diff --git a/go.mod b/go.mod
index bf18c62..2d50c1b 100644
--- a/go.mod
+++ b/go.mod
@@ -1,13 +1,13 @@
module github.com/cenk1cenk2/docker-softether-vpnsrv
-go 1.18
+go 1.19
require (
github.com/apparentlymart/go-cidr v1.1.0
github.com/go-ping/ping v1.1.0
github.com/mitchellh/go-ps v1.0.0
- github.com/urfave/cli/v2 v2.10.3
- gitlab.kilic.dev/libraries/plumber/v3 v3.20.1
+ github.com/urfave/cli/v2 v2.16.3
+ gitlab.kilic.dev/libraries/plumber/v3 v3.26.3
)
require (
@@ -15,19 +15,20 @@ require (
github.com/creasty/defaults v1.6.0 // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
- github.com/go-playground/validator/v10 v10.11.0 // indirect
+ github.com/go-playground/validator/v10 v10.11.1 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/joho/godotenv v1.4.0 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
- github.com/sirupsen/logrus v1.8.1 // indirect
+ github.com/sirupsen/logrus v1.9.0 // indirect
github.com/workanator/go-floc/v3 v3.0.1 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
gitlab.kilic.dev/libraries/go-utils v1.1.2 // indirect
- golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect
- golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect
- golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f // indirect
- golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e // indirect
+ golang.org/x/crypto v0.0.0-20220924013350-4ba4fb4dd9e7 // indirect
+ golang.org/x/exp v0.0.0-20220921164117-439092de6870 // indirect
+ golang.org/x/net v0.0.0-20220923203811-8be639271d50 // indirect
+ golang.org/x/sync v0.0.0-20220923202941-7f9b1623fab7 // indirect
+ golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8 // indirect
golang.org/x/text v0.3.7 // indirect
)
diff --git a/go.sum b/go.sum
index 893f7e7..5f657f9 100644
--- a/go.sum
+++ b/go.sum
@@ -16,8 +16,8 @@ github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb
github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs=
github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho=
github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA=
-github.com/go-playground/validator/v10 v10.11.0 h1:0W+xRM511GY47Yy3bZUbJVitCNg2BOGlCyvTqsp/xIw=
-github.com/go-playground/validator/v10 v10.11.0/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU=
+github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ=
+github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU=
github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
@@ -40,41 +40,42 @@ github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTE
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
-github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
-github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
+github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
+github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
-github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
-github.com/urfave/cli/v2 v2.10.3 h1:oi571Fxz5aHugfBAJd5nkwSk3fzATXtMlpxdLylSCMo=
-github.com/urfave/cli/v2 v2.10.3/go.mod h1:f8iq5LtQ/bLxafbdBSLPPNsgaW0l/2fYYEHhAyPlwvo=
+github.com/urfave/cli/v2 v2.16.3 h1:gHoFIwpPjoyIMbJp/VFd+/vuD0dAgFK4B6DpEMFJfQk=
+github.com/urfave/cli/v2 v2.16.3/go.mod h1:1CNUng3PtjQMtRzJO4FMXBQvkGtuYRxxiR9xMa7jMwI=
github.com/workanator/go-floc/v3 v3.0.1 h1:cbJIGUi+PS0Iqw86tBd5+3sWlT0eeS1mWqvaBd20W84=
github.com/workanator/go-floc/v3 v3.0.1/go.mod h1:s5amjW/Zo5LB74oH0wo9AEd0P/2iw9Qwbc84ES0anZc=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
gitlab.kilic.dev/libraries/go-utils v1.1.2 h1:bxsYz6zw9gpz/ZkyZbLbL4c3QhS7EQ1071hcelcgKo4=
gitlab.kilic.dev/libraries/go-utils v1.1.2/go.mod h1:OZi5+ignKLdxrlWo1kykO7A5yw8Rj+Wv8iKHw7oawcQ=
-gitlab.kilic.dev/libraries/plumber/v3 v3.20.1 h1:NSkEZ7QOv4Ws1lskKY9nwrEM9Q9DMlHYsry3brJ7izM=
-gitlab.kilic.dev/libraries/plumber/v3 v3.20.1/go.mod h1:nVzdf8GmFBr7hmR0j6Ba/fuRC5XSOGCYnH2sk8QZeZ4=
+gitlab.kilic.dev/libraries/plumber/v3 v3.26.3 h1:1XUA133CDZ+YgHHbxJmHsLxhUoH+IA07upgD5EGKCOc=
+gitlab.kilic.dev/libraries/plumber/v3 v3.26.3/go.mod h1:4pYTW3lsjBy6wmpmekPVeGF9txTeXqpTebpuKaEeYeQ=
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
-golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY=
-golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
+golang.org/x/crypto v0.0.0-20220924013350-4ba4fb4dd9e7 h1:WJywXQVIb56P2kAvXeMGTIgQ1ZHQxR60+F9dLsodECc=
+golang.org/x/crypto v0.0.0-20220924013350-4ba4fb4dd9e7/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
+golang.org/x/exp v0.0.0-20220921164117-439092de6870 h1:j8b6j9gzSigH28O5SjSpQSSh9lFd6f5D/q0aHjNTulc=
+golang.org/x/exp v0.0.0-20220921164117-439092de6870/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE=
golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
-golang.org/x/net v0.0.0-20220630215102-69896b714898 h1:K7wO6V1IrczY9QOQ2WkVpw4JQSwCd52UsxVEirZUfiw=
-golang.org/x/net v0.0.0-20220630215102-69896b714898/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
+golang.org/x/net v0.0.0-20220923203811-8be639271d50 h1:vKyz8L3zkd+xrMeIaBsQ/MNVPVFSffdaU3ZyYlBGFnI=
+golang.org/x/net v0.0.0-20220923203811-8be639271d50/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f h1:Ax0t5p6N38Ga0dThY21weqDEyz2oklo4IvDkpigvkD8=
-golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sync v0.0.0-20220923202941-7f9b1623fab7 h1:ZrnxWX62AgTKOSagEqxvb3ffipvEDX2pl7E1TdqLqIc=
+golang.org/x/sync v0.0.0-20220923202941-7f9b1623fab7/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e h1:CsOuNlbOuf0mzxJIefr6Q4uAUetRUwZE4qt7VfzP+xo=
-golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8 h1:h+EGohizhe9XlX18rfpa8k8RAc5XyaeamM+0VHRd4lc=
+golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
diff --git a/main.go b/main.go
index 9de4cf4..6e98f54 100644
--- a/main.go
+++ b/main.go
@@ -8,7 +8,10 @@ import (
)
func main() {
- p := Plumber{}
+ p := Plumber{
+ DocsFile: "CLI.md",
+ DocsExcludeFlags: true,
+ }
p.New(
func(p *Plumber) *cli.App {
diff --git a/pipe/flags.go b/pipe/flags.go
index d218e73..c43b370 100644
--- a/pipe/flags.go
+++ b/pipe/flags.go
@@ -4,12 +4,14 @@ import (
"github.com/urfave/cli/v2"
)
+//revive:disable:line-length-limit
+
const (
- category_health = "health"
- category_dhcp_server = "dhcp-server"
- category_linux_bridge = "linux-bridge"
- category_server = "server"
- category_softether = "softether"
+ category_health = "Health"
+ category_dhcp_server = "Dhcp-Server"
+ category_linux_bridge = "Linux-Bridge"
+ category_server = "Server"
+ category_softether = "SoftEther"
)
var Flags = []cli.Flag{
@@ -27,7 +29,7 @@ var Flags = []cli.Flag{
&cli.StringFlag{
Name: "health.dhcp-server-address",
- Usage: "Upstream DHCP server address for doing health checks. (default: cidr address start)",
+ Usage: `Upstream DHCP server address for doing health checks. dynamic("cidr address start")`,
Category: category_health,
Required: false,
EnvVars: []string{"HEALTH_DHCP_SERVER_ADDRESS"},
@@ -69,7 +71,7 @@ var Flags = []cli.Flag{
&cli.StringFlag{
Name: "dhcp-server.gateway",
- Usage: "Set the gateway option for the underlying DNS server. (default: cidr address start)",
+ Usage: `Set the gateway option for the underlying DNS server. dynamic("cidr address start")`,
Category: category_dhcp_server,
Required: false,
EnvVars: []string{"DHCP_SERVER_GATEWAY"},
@@ -165,7 +167,7 @@ var Flags = []cli.Flag{
&cli.StringFlag{
Name: "server.mode",
- Usage: `Server mode changes the behavior of the container. [enum: "dhcp", "bridge"]`,
+ Usage: `Server mode changes the behavior of the container. enum("dhcp", "bridge")`,
Category: category_server,
Required: true,
EnvVars: []string{"SERVER_MODE"},
diff --git a/pipe/tasks.go b/pipe/tasks.go
index ce08f85..0f04087 100644
--- a/pipe/tasks.go
+++ b/pipe/tasks.go
@@ -98,7 +98,6 @@ func GenerateDhcpServerConfiguration(tl *TaskList[Pipe]) *Task[Pipe] {
return t.Pipe.Server.Mode != SERVER_MODE_DHCP
}).
ShouldRunBefore(func(t *Task[Pipe]) error {
-
// set default gateway address
if t.Pipe.DhcpServer.Gateway == "" && t.Pipe.DhcpServer.SendGateway {
t.Lock.Lock()
@@ -366,7 +365,6 @@ func CreateBridgeDevice(tl *TaskList[Pipe]) *Task[Pipe] {
).
SetLogLevel(LOG_LEVEL_DEBUG, LOG_LEVEL_DEFAULT, LOG_LEVEL_DEBUG).
AddSelfToTheTask()
-
}
// start the interface