fix: Improve docvalues; Improve documentation

This commit is contained in:
Myzel394 2024-07-31 22:47:01 +02:00
parent 09ab63d61f
commit 1254ebfd8a
No known key found for this signature in database
GPG Key ID: DEC4AAB876F73185
5 changed files with 284 additions and 161 deletions

View File

@ -64,8 +64,8 @@ func UserValue(separatorForMultiple string, enforceValues bool) Value {
enumValues := EnumValue{ enumValues := EnumValue{
EnforceValues: enforceValues, EnforceValues: enforceValues,
Values: utils.Map(infos, func(info passwdInfo) string { Values: utils.Map(infos, func(info passwdInfo) EnumString {
return info.Name return CreateEnumString(info.Name)
}), }),
} }
@ -134,8 +134,8 @@ func GroupValue(separatorForMultiple string, enforceValues bool) Value {
enumValues := EnumValue{ enumValues := EnumValue{
EnforceValues: enforceValues, EnforceValues: enforceValues,
Values: utils.Map(infos, func(info groupInfo) string { Values: utils.Map(infos, func(info groupInfo) EnumString {
return info.Name return CreateEnumString(info.Name)
}), }),
} }

View File

@ -1,6 +1,7 @@
package docvalues package docvalues
import ( import (
"config-lsp/utils"
"fmt" "fmt"
"strings" "strings"
@ -16,8 +17,32 @@ func (e ValueNotInEnumError) Error() string {
return fmt.Sprintf("This value is not valid. Select one from: %s", strings.Join(e.AvailableValues, ",")) return fmt.Sprintf("This value is not valid. Select one from: %s", strings.Join(e.AvailableValues, ","))
} }
type EnumString struct {
// What is actually inserted into the document
InsertText string
// What is shown in the completion list
DescriptionText string
// Documentation for this value
Documentation string
}
func CreateEnumString(value string) EnumString {
return EnumString{
InsertText: value,
DescriptionText: value,
}
}
func CreateEnumStringWithDoc(value string, doc string) EnumString {
return EnumString{
InsertText: value,
DescriptionText: value,
Documentation: doc,
}
}
type EnumValue struct { type EnumValue struct {
Values []string Values []EnumString
// If `true`, the value MUST be one of the values in the Values array // If `true`, the value MUST be one of the values in the Values array
// Otherwise an error is shown // Otherwise an error is shown
// If `false`, the value is just a hint // If `false`, the value is just a hint
@ -26,14 +51,14 @@ type EnumValue struct {
func (v EnumValue) GetTypeDescription() []string { func (v EnumValue) GetTypeDescription() []string {
if len(v.Values) == 1 { if len(v.Values) == 1 {
return []string{"'" + v.Values[0] + "'"} return []string{"'" + v.Values[0].DescriptionText + "'"}
} }
lines := make([]string, len(v.Values)+1) lines := make([]string, len(v.Values)+1)
lines[0] = "Enum of:" lines[0] = "Enum of:"
for index, value := range v.Values { for index, value := range v.Values {
lines[index+1] += "\t* " + value lines[index+1] += "\t* " + value.DescriptionText
} }
return lines return lines
@ -44,8 +69,7 @@ func (v EnumValue) CheckIsValid(value string) error {
} }
for _, validValue := range v.Values { for _, validValue := range v.Values {
if validValue == value { if validValue.InsertText == value {
println("Yep so", value, "is equal to", validValue)
return nil return nil
} }
@ -53,7 +77,7 @@ func (v EnumValue) CheckIsValid(value string) error {
return ValueNotInEnumError{ return ValueNotInEnumError{
ProvidedValue: value, ProvidedValue: value,
AvailableValues: v.Values, AvailableValues: utils.Map(v.Values, func(value EnumString) string { return value.InsertText }),
} }
} }
func (v EnumValue) FetchCompletions(line string, cursor uint32) []protocol.CompletionItem { func (v EnumValue) FetchCompletions(line string, cursor uint32) []protocol.CompletionItem {
@ -64,9 +88,10 @@ func (v EnumValue) FetchCompletions(line string, cursor uint32) []protocol.Compl
kind := protocol.CompletionItemKindEnum kind := protocol.CompletionItemKindEnum
completions[index] = protocol.CompletionItem{ completions[index] = protocol.CompletionItem{
Label: value, Label: value.InsertText,
InsertTextFormat: &textFormat, InsertTextFormat: &textFormat,
Kind: &kind, Kind: &kind,
Documentation: &value.Documentation,
} }
} }

View File

@ -34,19 +34,19 @@ func (v OrValue) GetTypeDescription() []string {
) )
} }
func (v OrValue) CheckIsValid(value string) error { func (v OrValue) CheckIsValid(value string) error {
var firstError error = nil var lastError error = nil
for _, subValue := range v.Values { for _, subValue := range v.Values {
err := subValue.CheckIsValid(value) err := subValue.CheckIsValid(value)
if err == nil { if err == nil {
return nil return nil
} else if firstError == nil { } else {
firstError = err lastError = err
} }
} }
return firstError return lastError
} }
func (v OrValue) FetchCompletions(line string, cursor uint32) []protocol.CompletionItem { func (v OrValue) FetchCompletions(line string, cursor uint32) []protocol.CompletionItem {
completions := make([]protocol.CompletionItem, 0) completions := make([]protocol.CompletionItem, 0)

View File

@ -2,13 +2,17 @@ package openssh
import ( import (
docvalues "config-lsp/doc-values" docvalues "config-lsp/doc-values"
"config-lsp/utils"
"os/exec" "os/exec"
"strings" "strings"
) )
var BooleanEnumValue = docvalues.EnumValue{ var BooleanEnumValue = docvalues.EnumValue{
EnforceValues: true, EnforceValues: true,
Values: []string{"yes", "no"}, Values: []docvalues.EnumString{
docvalues.CreateEnumString("yes"),
docvalues.CreateEnumString("no"),
},
} }
var plusMinuxCaretPrefixes = []docvalues.Prefix{ var plusMinuxCaretPrefixes = []docvalues.Prefix{
@ -29,7 +33,7 @@ var plusMinuxCaretPrefixes = []docvalues.Prefix{
var ChannelTimeoutExtractor = docvalues.ExtractKeyDuplicatesExtractor("=") var ChannelTimeoutExtractor = docvalues.ExtractKeyDuplicatesExtractor("=")
var SetEnvExtractor = docvalues.ExtractKeyDuplicatesExtractor("=") var SetEnvExtractor = docvalues.ExtractKeyDuplicatesExtractor("=")
func PrefixPlusMinusCaret(values []string) docvalues.PrefixWithMeaningValue { func PrefixPlusMinusCaret(values []docvalues.EnumString) docvalues.PrefixWithMeaningValue {
return docvalues.PrefixWithMeaningValue{ return docvalues.PrefixWithMeaningValue{
Prefixes: []docvalues.Prefix{ Prefixes: []docvalues.Prefix{
{ {
@ -55,7 +59,7 @@ func PrefixPlusMinusCaret(values []string) docvalues.PrefixWithMeaningValue {
} }
} }
var _cachedQueries map[string][]string = make(map[string][]string) var _cachedQueries map[string][]docvalues.EnumString = make(map[string][]docvalues.EnumString)
func queryValues(query string) ([]string, error) { func queryValues(query string) ([]string, error) {
cmd := exec.Command("ssh", "-Q", query) cmd := exec.Command("ssh", "-Q", query)
@ -71,17 +75,18 @@ func queryValues(query string) ([]string, error) {
func QueryOpenSSHOptions( func QueryOpenSSHOptions(
query string, query string,
) ([]string, error) { ) ([]docvalues.EnumString, error) {
var availableQueries []string var availableQueries []docvalues.EnumString
key := query key := query
if _cachedQueries[key] != nil && len(_cachedQueries[key]) > 0 { if _cachedQueries[key] != nil && len(_cachedQueries[key]) > 0 {
return _cachedQueries[key], nil return _cachedQueries[key], nil
} else { } else {
availableQueries, err := queryValues(query) availableRawQueries, err := queryValues(query)
availableQueries = utils.Map(availableRawQueries, docvalues.CreateEnumString)
if err != nil { if err != nil {
return []string{}, err return []docvalues.EnumString{}, err
} }
_cachedQueries[key] = availableQueries _cachedQueries[key] = availableQueries

View File

@ -19,7 +19,11 @@ var Options = map[string]common.Option{
`Specifies which address family should be used by sshd(8). Valid arguments are any (the default), inet (use IPv4 only), or inet6 (use IPv6 only).`, `Specifies which address family should be used by sshd(8). Valid arguments are any (the default), inet (use IPv4 only), or inet6 (use IPv6 only).`,
docvalues.EnumValue{ docvalues.EnumValue{
EnforceValues: true, EnforceValues: true,
Values: []string{"any", "inet", "inet6"}, Values: []docvalues.EnumString{
docvalues.CreateEnumString("any"),
docvalues.CreateEnumString("inet"),
docvalues.CreateEnumString("inet6"),
},
}, },
), ),
"AllowAgentForwarding": common.NewOption( "AllowAgentForwarding": common.NewOption(
@ -36,14 +40,26 @@ See PATTERNS in ssh_config(5) for more information on patterns. This keyword may
`Specifies whether StreamLocal (Unix-domain socket) forwarding is permitted. The available options are yes (the default) or all to allow StreamLocal forwarding, no to prevent all StreamLocal forwarding, local to allow local (from the perspective of ssh(1)) forwarding only or remote to allow remote forwarding only. Note that disabling StreamLocal forwarding does not improve security unless users are also denied shell access, as they can always install their own forwarders.`, `Specifies whether StreamLocal (Unix-domain socket) forwarding is permitted. The available options are yes (the default) or all to allow StreamLocal forwarding, no to prevent all StreamLocal forwarding, local to allow local (from the perspective of ssh(1)) forwarding only or remote to allow remote forwarding only. Note that disabling StreamLocal forwarding does not improve security unless users are also denied shell access, as they can always install their own forwarders.`,
docvalues.EnumValue{ docvalues.EnumValue{
EnforceValues: true, EnforceValues: true,
Values: []string{"yes", "all", "no", "local", "remote"}, Values: []docvalues.EnumString{
docvalues.CreateEnumString("yes"),
docvalues.CreateEnumString("all"),
docvalues.CreateEnumString("no"),
docvalues.CreateEnumString("local"),
docvalues.CreateEnumString("remote"),
},
}, },
), ),
"AllowTcpForwarding": common.NewOption( "AllowTcpForwarding": common.NewOption(
`Specifies whether TCP forwarding is permitted. The available options are yes (the default) or all to allow TCP forwarding, no to prevent all TCP forwarding, local to allow local (from the perspective of ssh(1)) forwarding only or remote to allow remote forwarding only. Note that disabling TCP forwarding does not improve security unless users are also denied shell access, as they can always install their own forwarders.`, `Specifies whether TCP forwarding is permitted. The available options are yes (the default) or all to allow TCP forwarding, no to prevent all TCP forwarding, local to allow local (from the perspective of ssh(1)) forwarding only or remote to allow remote forwarding only. Note that disabling TCP forwarding does not improve security unless users are also denied shell access, as they can always install their own forwarders.`,
docvalues.EnumValue{ docvalues.EnumValue{
EnforceValues: true, EnforceValues: true,
Values: []string{"yes", "all", "no", "local", "remote"}, Values: []docvalues.EnumString{
docvalues.CreateEnumString("yes"),
docvalues.CreateEnumString("all"),
docvalues.CreateEnumString("no"),
docvalues.CreateEnumString("local"),
docvalues.CreateEnumString("remote"),
},
}, },
), ),
"AllowUsers": common.NewOption( "AllowUsers": common.NewOption(
@ -62,31 +78,33 @@ See PATTERNS in ssh_config(5) for more information on patterns. This keyword may
Values: []docvalues.Value{ Values: []docvalues.Value{
docvalues.EnumValue{ docvalues.EnumValue{
EnforceValues: true, EnforceValues: true,
Values: []string{"any"}, Values: []docvalues.EnumString{
docvalues.CreateEnumString("any"),
},
}, },
docvalues.ArrayValue{ docvalues.ArrayValue{
SubValue: docvalues.EnumValue{ SubValue: docvalues.EnumValue{
EnforceValues: true, EnforceValues: true,
Values: []string{ Values: []docvalues.EnumString{
"none", docvalues.CreateEnumString("none"),
"password", docvalues.CreateEnumString("password"),
"publickey", docvalues.CreateEnumString("publickey"),
"gssapi-with-mic", docvalues.CreateEnumString("gssapi-with-mic"),
"keyboard-interactive", docvalues.CreateEnumString("keyboard-interactive"),
"hostbased", docvalues.CreateEnumString("hostbased"),
"password:bsdauth", docvalues.CreateEnumString("password:bsdauth"),
"publickey:bsdauth", docvalues.CreateEnumString("publickey:bsdauth"),
"gssapi-with-mic:bsdauth", docvalues.CreateEnumString("gssapi-with-mic:bsdauth"),
"keyboard-interactive:bsdauth", docvalues.CreateEnumString("keyboard-interactive:bsdauth"),
"hostbased:bsdauth", docvalues.CreateEnumString("hostbased:bsdauth"),
"password:pam", docvalues.CreateEnumString("password:pam"),
"publickey:pam", docvalues.CreateEnumString("publickey:pam"),
"gssapi-with-mic:pam", docvalues.CreateEnumString("gssapi-with-mic:pam"),
"keyboard-interactive:pam", docvalues.CreateEnumString("keyboard-interactive:pam"),
"hostbased:pam", docvalues.CreateEnumString("hostbased:pam"),
}, },
}, },
}, },
@ -179,15 +197,16 @@ See PATTERNS in ssh_config(5) for more information on patterns. This keyword may
ValueIsOptional: false, ValueIsOptional: false,
Separator: "=", Separator: "=",
Key: docvalues.EnumValue{ Key: docvalues.EnumValue{
Values: []string{ Values: []docvalues.EnumString{
"*", docvalues.CreateEnumString("global"),
"global", docvalues.CreateEnumString("agent-connection"),
"agent-connection", docvalues.CreateEnumString("direct-tcpip"),
"direct-tcpip", "direct-streamlocal@openssh.com", docvalues.CreateEnumString("direct-streamlocal@openssh.com"),
"forwarded-tcpip", "forwarded-streamlocal@openssh.com", docvalues.CreateEnumString("forwarded-tcpip"),
"session", docvalues.CreateEnumString("forwarded-streamlocal@openssh.com"),
"tun-connection", docvalues.CreateEnumString("session"),
"x11-connection", docvalues.CreateEnumString("tun-connection"),
docvalues.CreateEnumString("x11-connection"),
}, },
}, },
Value: TimeFormatValue{}, Value: TimeFormatValue{},
@ -206,17 +225,17 @@ See PATTERNS in ssh_config(5) for more information on patterns. This keyword may
The default is: The default is:
chacha20-poly1305@openssh.com, aes128-ctr,aes192-ctr,aes256-ctr, aes128-gcm@openssh.com,aes256-gcm@openssh.com chacha20-poly1305@openssh.com, aes128-ctr,aes192-ctr,aes256-ctr, aes128-gcm@openssh.com,aes256-gcm@openssh.com
The list of available ciphers may also be obtained using "ssh -Q cipher".`, The list of available ciphers may also be obtained using "ssh -Q cipher".`,
PrefixPlusMinusCaret([]string{ PrefixPlusMinusCaret([]docvalues.EnumString{
"3des-cbc", docvalues.CreateEnumString("3des-cbc"),
"aes128-cbc", docvalues.CreateEnumString("aes128-cbc"),
"aes192-cbc", docvalues.CreateEnumString("aes192-cbc"),
"aes256-cbc", docvalues.CreateEnumString("aes256-cbc"),
"aes128-ctr", docvalues.CreateEnumString("aes128-ctr"),
"aes192-ctr", docvalues.CreateEnumString("aes192-ctr"),
"aes256-ctr", docvalues.CreateEnumString("aes256-ctr"),
"aes128-gcm@openssh.com", docvalues.CreateEnumString("aes128-gcm@openssh.com"),
"aes256-gcm@openssh.com", docvalues.CreateEnumString("aes256-gcm@openssh.com"),
"chacha20-poly1305@openssh.com", docvalues.CreateEnumString("chacha20-poly1305@openssh.com"),
}), }),
), ),
"ClientAliveCountMax": common.NewOption(`Sets the number of client alive messages which may be sent without sshd(8) receiving any messages back from the client. If this threshold is reached while client alive messages are being sent, sshd will disconnect the client, terminating the session. It is important to note that the use of client alive messages is very different from TCPKeepAlive. The client alive messages are sent through the encrypted channel and therefore will not be spoofable. The TCP keepalive option enabled by TCPKeepAlive is spoofable. The client alive mechanism is valuable when the client or server depend on knowing when a connection has become unresponsive. "ClientAliveCountMax": common.NewOption(`Sets the number of client alive messages which may be sent without sshd(8) receiving any messages back from the client. If this threshold is reached while client alive messages are being sent, sshd will disconnect the client, terminating the session. It is important to note that the use of client alive messages is very different from TCPKeepAlive. The client alive messages are sent through the encrypted channel and therefore will not be spoofable. The TCP keepalive option enabled by TCPKeepAlive is spoofable. The client alive mechanism is valuable when the client or server depend on knowing when a connection has become unresponsive.
@ -231,10 +250,10 @@ See PATTERNS in ssh_config(5) for more information on patterns. This keyword may
`Specifies whether compression is enabled after the user has authenticated successfully. The argument must be yes, delayed (a legacy synonym for yes) or no. The default is yes.`, `Specifies whether compression is enabled after the user has authenticated successfully. The argument must be yes, delayed (a legacy synonym for yes) or no. The default is yes.`,
docvalues.EnumValue{ docvalues.EnumValue{
EnforceValues: true, EnforceValues: true,
Values: []string{ Values: []docvalues.EnumString{
"yes", docvalues.CreateEnumString("yes"),
"delayed", docvalues.CreateEnumString("delayed"),
"no", docvalues.CreateEnumString("no"),
}, },
}, },
), ),
@ -258,9 +277,9 @@ See PATTERNS in ssh_config(5) for more information on patterns. This keyword may
`Specifies the hash algorithm used when logging key fingerprints. Valid options are: md5 and sha256. The default is sha256.`, `Specifies the hash algorithm used when logging key fingerprints. Valid options are: md5 and sha256. The default is sha256.`,
docvalues.EnumValue{ docvalues.EnumValue{
EnforceValues: true, EnforceValues: true,
Values: []string{ Values: []docvalues.EnumString{
"md5", docvalues.CreateEnumString("md5"),
"sha256", docvalues.CreateEnumString("sha256"),
}, },
}, },
), ),
@ -323,7 +342,9 @@ See PATTERNS in ssh_config(5) for more information on patterns. This keyword may
Values: []docvalues.Value{ Values: []docvalues.Value{
docvalues.EnumValue{ docvalues.EnumValue{
EnforceValues: true, EnforceValues: true,
Values: []string{"SSH_AUTH_SOCK"}, Values: []docvalues.EnumString{
docvalues.CreateEnumStringWithDoc("SSH_AUTH_SOCK", "The location of the socket will be read from the SSH_AUTH_SOCK environment variable."),
},
}, },
docvalues.StringValue{}, docvalues.StringValue{},
}, },
@ -344,7 +365,11 @@ See PATTERNS in ssh_config(5) for more information on patterns. This keyword may
Accepted values are yes (the default) to ignore all per- user files, shosts-only to allow the use of .shosts but to ignore .rhosts or no to allow both .shosts and rhosts.`, Accepted values are yes (the default) to ignore all per- user files, shosts-only to allow the use of .shosts but to ignore .rhosts or no to allow both .shosts and rhosts.`,
docvalues.EnumValue{ docvalues.EnumValue{
EnforceValues: true, EnforceValues: true,
Values: []string{"yes", "shosts-only", "no"}, Values: []docvalues.EnumString{
docvalues.CreateEnumString("yes"),
docvalues.CreateEnumString("shosts-only"),
docvalues.CreateEnumString("no"),
},
}, },
), ),
"IgnoreUserKnownHosts": common.NewOption( "IgnoreUserKnownHosts": common.NewOption(
@ -367,19 +392,41 @@ See PATTERNS in ssh_config(5) for more information on patterns. This keyword may
Values: []docvalues.Value{ Values: []docvalues.Value{
docvalues.NumberValue{}, docvalues.NumberValue{},
docvalues.EnumValue{ docvalues.EnumValue{
Values: []string{"none"}, Values: []docvalues.EnumString{
docvalues.CreateEnumString("none"),
},
}, },
docvalues.ArrayValue{ docvalues.ArrayValue{
Separator: " ", Separator: " ",
SubValue: docvalues.EnumValue{ SubValue: docvalues.EnumValue{
EnforceValues: true, EnforceValues: true,
Values: []string{ Values: []docvalues.EnumString{
"af11", "af12", "af13", docvalues.CreateEnumString("af11"),
"af21", "af22", "af23", docvalues.CreateEnumString("af12"),
"af31", "af32", "af33", docvalues.CreateEnumString("af13"),
"af41", "af42", "af43", docvalues.CreateEnumString("af21"),
"cs0", "cs1", "cs2", "cs3", "cs4", "cs5", "cs6", "cs7", docvalues.CreateEnumString("af22"),
"ef", "le", "lowdelay", "throughput", "reliability", "none", docvalues.CreateEnumString("af23"),
docvalues.CreateEnumString("af31"),
docvalues.CreateEnumString("af32"),
docvalues.CreateEnumString("af33"),
docvalues.CreateEnumString("af41"),
docvalues.CreateEnumString("af42"),
docvalues.CreateEnumString("af43"),
docvalues.CreateEnumString("cs0"),
docvalues.CreateEnumString("cs1"),
docvalues.CreateEnumString("cs2"),
docvalues.CreateEnumString("cs3"),
docvalues.CreateEnumString("cs4"),
docvalues.CreateEnumString("cs5"),
docvalues.CreateEnumString("cs6"),
docvalues.CreateEnumString("cs7"),
docvalues.CreateEnumString("ef"),
docvalues.CreateEnumString("le"),
docvalues.CreateEnumString("lowdelay"),
docvalues.CreateEnumString("throughput"),
docvalues.CreateEnumString("reliability"),
docvalues.CreateEnumString("none"),
}, },
}, },
}, },
@ -407,20 +454,20 @@ See PATTERNS in ssh_config(5) for more information on patterns. This keyword may
The default is: The default is:
sntrup761x25519-sha512@openssh.com, curve25519-sha256,curve25519-sha256@libssh.org, ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521, diffie-hellman-group-exchange-sha256, diffie-hellman-group16-sha512,diffie-hellman-group18-sha512, diffie-hellman-group14-sha256 sntrup761x25519-sha512@openssh.com, curve25519-sha256,curve25519-sha256@libssh.org, ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521, diffie-hellman-group-exchange-sha256, diffie-hellman-group16-sha512,diffie-hellman-group18-sha512, diffie-hellman-group14-sha256
The list of available key exchange algorithms may also be obtained using "ssh -Q KexAlgorithms".`, The list of available key exchange algorithms may also be obtained using "ssh -Q KexAlgorithms".`,
PrefixPlusMinusCaret([]string{ PrefixPlusMinusCaret([]docvalues.EnumString{
"curve25519-sha256", docvalues.CreateEnumString("curve25519-sha256"),
"curve25519-sha256@libssh.org", docvalues.CreateEnumString("curve25519-sha256@libssh.org"),
"diffie-hellman-group1-sha1", docvalues.CreateEnumString("diffie-hellman-group1-sha1"),
"diffie-hellman-group14-sha1", docvalues.CreateEnumString("diffie-hellman-group14-sha1"),
"diffie-hellman-group14-sha256", docvalues.CreateEnumString("diffie-hellman-group14-sha256"),
"diffie-hellman-group16-sha512", docvalues.CreateEnumString("diffie-hellman-group16-sha512"),
"diffie-hellman-group18-sha512", docvalues.CreateEnumString("diffie-hellman-group18-sha512"),
"diffie-hellman-group-exchange-sha1", docvalues.CreateEnumString("diffie-hellman-group-exchange-sha1"),
"diffie-hellman-group-exchange-sha256", docvalues.CreateEnumString("diffie-hellman-group-exchange-sha256"),
"ecdh-sha2-nistp256", docvalues.CreateEnumString("ecdh-sha2-nistp256"),
"ecdh-sha2-nistp384", docvalues.CreateEnumString("ecdh-sha2-nistp384"),
"ecdh-sha2-nistp521", docvalues.CreateEnumString("ecdh-sha2-nistp521"),
"sntrup761x25519-sha512@openssh.com", docvalues.CreateEnumString("sntrup761x25519-sha512@openssh.com"),
}), }),
), ),
"ListenAddress": common.NewOption(`Specifies the local addresses sshd(8) should listen on. The following forms may be used: "ListenAddress": common.NewOption(`Specifies the local addresses sshd(8) should listen on. The following forms may be used:
@ -444,16 +491,16 @@ See PATTERNS in ssh_config(5) for more information on patterns. This keyword may
"LogLevel": common.NewOption(`Gives the verbosity level that is used when logging messages from sshd(8). The possible values are: QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUG, DEBUG1, DEBUG2, and DEBUG3. The default is INFO. DEBUG and DEBUG1 are equivalent. DEBUG2 and DEBUG3 each specify higher levels of debugging output. Logging with a DEBUG level violates the privacy of users and is not recommended.`, "LogLevel": common.NewOption(`Gives the verbosity level that is used when logging messages from sshd(8). The possible values are: QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUG, DEBUG1, DEBUG2, and DEBUG3. The default is INFO. DEBUG and DEBUG1 are equivalent. DEBUG2 and DEBUG3 each specify higher levels of debugging output. Logging with a DEBUG level violates the privacy of users and is not recommended.`,
docvalues.EnumValue{ docvalues.EnumValue{
EnforceValues: true, EnforceValues: true,
Values: []string{ Values: []docvalues.EnumString{
"QUIET", docvalues.CreateEnumString("QUIET"),
"FATAL", docvalues.CreateEnumString("FATAL"),
"ERROR", docvalues.CreateEnumString("ERROR"),
"INFO", docvalues.CreateEnumString("INFO"),
"VERBOSE", docvalues.CreateEnumString("VERBOSE"),
"DEBUG", docvalues.CreateEnumString("DEBUG"),
"DEBUG1", docvalues.CreateEnumString("DEBUG1"),
"DEBUG2", docvalues.CreateEnumString("DEBUG2"),
"DEBUG3", docvalues.CreateEnumString("DEBUG3"),
}, },
}, },
), ),
@ -469,24 +516,24 @@ See PATTERNS in ssh_config(5) for more information on patterns. This keyword may
The default is: The default is:
umac-64-etm@openssh.com,umac-128-etm@openssh.com, hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com, hmac-sha1-etm@openssh.com, umac-64@openssh.com,umac-128@openssh.com, hmac-sha2-256,hmac-sha2-512,hmac-sha1 umac-64-etm@openssh.com,umac-128-etm@openssh.com, hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com, hmac-sha1-etm@openssh.com, umac-64@openssh.com,umac-128@openssh.com, hmac-sha2-256,hmac-sha2-512,hmac-sha1
The list of available MAC algorithms may also be obtained using "ssh -Q mac".`, The list of available MAC algorithms may also be obtained using "ssh -Q mac".`,
PrefixPlusMinusCaret([]string{ PrefixPlusMinusCaret([]docvalues.EnumString{
"hmac-md5", docvalues.CreateEnumString("hmac-md5"),
"hmac-md5-96", docvalues.CreateEnumString("hmac-md5-96"),
"hmac-sha1", docvalues.CreateEnumString("hmac-sha1"),
"hmac-sha1-96", docvalues.CreateEnumString("hmac-sha1-96"),
"hmac-sha2-256", docvalues.CreateEnumString("hmac-sha2-256"),
"hmac-sha2-256", docvalues.CreateEnumString("hmac-sha2-256"),
"hmac-sha2-512", docvalues.CreateEnumString("hmac-sha2-512"),
"umac-64@openssh.com", docvalues.CreateEnumString("umac-64@openssh.com"),
"umac-128@openssh.com", docvalues.CreateEnumString("umac-128@openssh.com"),
"hmac-md5-etm@openssh.com", docvalues.CreateEnumString("hmac-md5-etm@openssh.com"),
"hmac-md5-96-etm@openssh.com", docvalues.CreateEnumString("hmac-md5-96-etm@openssh.com"),
"hmac-sha1-etm@openssh.com", docvalues.CreateEnumString("hmac-sha1-etm@openssh.com"),
"hmac-sha1-96-etm@openssh.com", docvalues.CreateEnumString("hmac-sha1-96-etm@openssh.com"),
"hmac-sha2-256-etm@openssh.com", docvalues.CreateEnumString("hmac-sha2-256-etm@openssh.com"),
"hmac-sha2-512-etm@openssh.com", docvalues.CreateEnumString("hmac-sha2-512-etm@openssh.com"),
"umac-64-etm@openssh.com", docvalues.CreateEnumString("umac-64-etm@openssh.com"),
"umac-128-etm@openssh.com", docvalues.CreateEnumString("umac-128-etm@openssh.com"),
}), }),
), ),
@ -537,7 +584,13 @@ See PATTERNS in ssh_config(5) for more information on patterns. This keyword may
Value: docvalues.OrValue{ Value: docvalues.OrValue{
Values: []docvalues.Value{ Values: []docvalues.Value{
docvalues.EnumValue{ docvalues.EnumValue{
Values: []string{"*"}, Values: []docvalues.EnumString{
{
InsertText: "*",
DescriptionText: "\\*",
Documentation: "Allow all ports",
},
},
EnforceValues: true, EnforceValues: true,
}, },
docvalues.NumberValue{Min: &ZERO, Max: &MAX_PORT}, docvalues.NumberValue{Min: &ZERO, Max: &MAX_PORT},
@ -554,17 +607,36 @@ See PATTERNS in ssh_config(5) for more information on patterns. This keyword may
DuplicatesExtractor: &docvalues.SimpleDuplicatesExtractor, DuplicatesExtractor: &docvalues.SimpleDuplicatesExtractor,
SubValue: docvalues.KeyValueAssignmentValue{ SubValue: docvalues.KeyValueAssignmentValue{
ValueIsOptional: true, ValueIsOptional: true,
Key: docvalues.IPAddressValue{ Key: docvalues.OrValue{
AllowIPv4: true, Values: []docvalues.Value{
AllowIPv6: true, docvalues.EnumValue{
AllowRange: false, Values: []docvalues.EnumString{
DisallowedIPs: &docvalues.NonRoutableNetworks, {
InsertText: "*",
DescriptionText: "\\*",
Documentation: "Allow all hosts",
},
},
},
docvalues.IPAddressValue{
AllowIPv4: true,
AllowIPv6: true,
AllowRange: false,
DisallowedIPs: &docvalues.NonRoutableNetworks,
},
},
}, },
Separator: ":", Separator: ":",
Value: docvalues.OrValue{ Value: docvalues.OrValue{
Values: []docvalues.Value{ Values: []docvalues.Value{
docvalues.EnumValue{ docvalues.EnumValue{
Values: []string{"*"}, Values: []docvalues.EnumString{
{
InsertText: "*",
DescriptionText: "\\*",
Documentation: "Allow all ports",
},
},
EnforceValues: true, EnforceValues: true,
}, },
docvalues.NumberValue{Min: &ZERO, Max: &MAX_PORT}, docvalues.NumberValue{Min: &ZERO, Max: &MAX_PORT},
@ -579,11 +651,11 @@ See PATTERNS in ssh_config(5) for more information on patterns. This keyword may
If this option is set to no, root is not allowed to log in.`, If this option is set to no, root is not allowed to log in.`,
docvalues.EnumValue{ docvalues.EnumValue{
EnforceValues: true, EnforceValues: true,
Values: []string{ Values: []docvalues.EnumString{
"yes", docvalues.CreateEnumString("yes"),
"prohibit-password", docvalues.CreateEnumString("prohibit-password"),
"forced-commands-only", docvalues.CreateEnumString("forced-commands-only"),
"no", docvalues.CreateEnumString("no"),
}, },
}, },
), ),
@ -594,11 +666,11 @@ See PATTERNS in ssh_config(5) for more information on patterns. This keyword may
Independent of this setting, the permissions of the selected tun(4) device must allow access to the user.`, Independent of this setting, the permissions of the selected tun(4) device must allow access to the user.`,
docvalues.EnumValue{ docvalues.EnumValue{
EnforceValues: true, EnforceValues: true,
Values: []string{ Values: []docvalues.EnumString{
"yes", docvalues.CreateEnumString("yes"),
"point-to-point", docvalues.CreateEnumString("point-to-point"),
"ethernet", docvalues.CreateEnumString("ethernet"),
"no", docvalues.CreateEnumString("no"),
}, },
}, },
), ),
@ -606,7 +678,10 @@ See PATTERNS in ssh_config(5) for more information on patterns. This keyword may
docvalues.OrValue{ docvalues.OrValue{
Values: []docvalues.Value{ Values: []docvalues.Value{
docvalues.EnumValue{ docvalues.EnumValue{
Values: []string{"yes", "no"}, Values: []docvalues.EnumString{
docvalues.CreateEnumString("yes"),
docvalues.CreateEnumString("no"),
},
}, },
docvalues.ArrayValue{ docvalues.ArrayValue{
SubValue: docvalues.StringValue{}, SubValue: docvalues.StringValue{},
@ -624,7 +699,13 @@ See PATTERNS in ssh_config(5) for more information on patterns. This keyword may
Values: []docvalues.Value{ Values: []docvalues.Value{
docvalues.EnumValue{ docvalues.EnumValue{
EnforceValues: true, EnforceValues: true,
Values: []string{"none"}, Values: []docvalues.EnumString{
{
InsertText: "none",
DescriptionText: "none",
Documentation: "No limit",
},
},
}, },
docvalues.NumberValue{Min: &ZERO}, docvalues.NumberValue{Min: &ZERO},
}, },
@ -663,7 +744,11 @@ See PATTERNS in ssh_config(5) for more information on patterns. This keyword may
Separator: ",", Separator: ",",
SubValue: docvalues.EnumValue{ SubValue: docvalues.EnumValue{
EnforceValues: true, EnforceValues: true,
Values: []string{"none", "touch-required", "verify-required"}, Values: []docvalues.EnumString{
docvalues.CreateEnumString("none"),
docvalues.CreateEnumString("touch-required"),
docvalues.CreateEnumString("verify-required"),
},
}, },
}, },
), ),
@ -677,16 +762,22 @@ See PATTERNS in ssh_config(5) for more information on patterns. This keyword may
"RevokedKeys": common.NewOption(`Specifies revoked public keys file, or none to not use one. Keys listed in this file will be refused for public key authentication. Note that if this file is not readable, then public key authentication will be refused for all users. Keys may be specified as a text file, listing one public key per line, or as an OpenSSH Key Revocation List (KRL) as generated by ssh-keygen(1). For more information on KRLs, see the KEY REVOCATION LISTS section in ssh-keygen(1).`, "RevokedKeys": common.NewOption(`Specifies revoked public keys file, or none to not use one. Keys listed in this file will be refused for public key authentication. Note that if this file is not readable, then public key authentication will be refused for all users. Keys may be specified as a text file, listing one public key per line, or as an OpenSSH Key Revocation List (KRL) as generated by ssh-keygen(1). For more information on KRLs, see the KEY REVOCATION LISTS section in ssh-keygen(1).`,
docvalues.StringValue{}, docvalues.StringValue{},
), ),
"RDomain": common.NewOption(`Specifies an explicit routing domain that is applied after authentication has completed. The user session, as well as any forwarded or listening IP sockets, will be bound to this rdomain(4). If the routing domain is set to %D, then the domain in which the incoming connection was received will be applied.`, "RDomain": common.NewOption(`Specifies an explicit routing domain that is applied after authentication has completed. The user session, as well as any forwarded or listening IP sockets, will be bound to this rdomain(4). If the routing domain is set to %D, then the domain in which the incoming connection was received will be applied.`,
docvalues.OrValue{ docvalues.OrValue{
Values: []docvalues.Value{ Values: []docvalues.Value{
docvalues.EnumValue{ docvalues.EnumValue{
Values: []string{"%D"}, Values: []docvalues.EnumString{
{
InsertText: "%D",
DescriptionText: "%D",
Documentation: "The domain in which the incoming connection was received",
},
},
}, },
docvalues.StringValue{}, docvalues.StringValue{},
}, },
}, },
), ),
"SecurityKeyProvider": common.NewOption(`Specifies a path to a library that will be used when loading FIDO authenticator-hosted keys, overriding the default of using the built-in USB HID support.`, "SecurityKeyProvider": common.NewOption(`Specifies a path to a library that will be used when loading FIDO authenticator-hosted keys, overriding the default of using the built-in USB HID support.`,
docvalues.PathValue{ docvalues.PathValue{
RequiredType: docvalues.PathTypeFile, RequiredType: docvalues.PathTypeFile,
@ -723,18 +814,18 @@ See PATTERNS in ssh_config(5) for more information on patterns. This keyword may
"SyslogFacility": common.NewOption(`Gives the facility code that is used when logging messages from sshd(8). The possible values are: DAEMON, USER, AUTH, LOCAL0, LOCAL1, LOCAL2, LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7. The default is AUTH.`, "SyslogFacility": common.NewOption(`Gives the facility code that is used when logging messages from sshd(8). The possible values are: DAEMON, USER, AUTH, LOCAL0, LOCAL1, LOCAL2, LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7. The default is AUTH.`,
docvalues.EnumValue{ docvalues.EnumValue{
EnforceValues: true, EnforceValues: true,
Values: []string{ Values: []docvalues.EnumString{
"DAEMON", docvalues.CreateEnumString("DAEMON"),
"USER", docvalues.CreateEnumString("USER"),
"AUTH", docvalues.CreateEnumString("AUTH"),
"LOCAL0", docvalues.CreateEnumString("LOCAL0"),
"LOCAL1", docvalues.CreateEnumString("LOCAL1"),
"LOCAL2", docvalues.CreateEnumString("LOCAL2"),
"LOCAL3", docvalues.CreateEnumString("LOCAL3"),
"LOCAL4", docvalues.CreateEnumString("LOCAL4"),
"LOCAL5", docvalues.CreateEnumString("LOCAL5"),
"LOCAL6", docvalues.CreateEnumString("LOCAL6"),
"LOCAL7", docvalues.CreateEnumString("LOCAL7"),
}, },
}, },
), ),
@ -746,11 +837,11 @@ See PATTERNS in ssh_config(5) for more information on patterns. This keyword may
"TrustedUserCAKeys": common.NewOption(`Specifies a file containing public keys of certificate authorities that are trusted to sign user certificates for authentication, or none to not use one. Keys are listed one per line; empty lines and comments starting with # are allowed. If a certificate is presented for authentication and has its signing CA key listed in this file, then it may be used for authentication for any user listed in the certificate's principals list. Note that certificates that lack a list of principals will not be permitted for authentication using TrustedUserCAKeys. For more details on certificates, see the CERTIFICATES section in ssh-keygen(1).`, "TrustedUserCAKeys": common.NewOption(`Specifies a file containing public keys of certificate authorities that are trusted to sign user certificates for authentication, or none to not use one. Keys are listed one per line; empty lines and comments starting with # are allowed. If a certificate is presented for authentication and has its signing CA key listed in this file, then it may be used for authentication for any user listed in the certificate's principals list. Note that certificates that lack a list of principals will not be permitted for authentication using TrustedUserCAKeys. For more details on certificates, see the CERTIFICATES section in ssh-keygen(1).`,
docvalues.StringValue{}, docvalues.StringValue{},
), ),
"UnusedConnectionTimeout": common.NewOption(`Specifies whether and how quickly sshd(8) should close client connections with no open channels. Open channels include active shell, command execution or subsystem sessions, connected network, socket, agent or X11 forwardings. Forwarding listeners, such as those from the ssh(1) -R flag, are not considered as open channels and do not prevent the timeout. The timeout value is specified in seconds or may use any of the units documented in the TIME FORMATS section. "UnusedConnectionTimeout": common.NewOption(`Specifies whether and how quickly sshd(8) should close client connections with no open channels. Open channels include active shell, command execution or subsystem sessions, connected network, socket, agent or X11 forwardings. Forwarding listeners, such as those from the ssh(1) -R flag, are not considered as open channels and do not prevent the timeout. The timeout value is specified in seconds or may use any of the units documented in the TIME FORMATS section.
Note that this timeout starts when the client connection completes user authentication but before the client has an opportunity to open any channels. Caution should be used when using short timeout values, as they may not provide sufficient time for the client to request and open its channels before terminating the connection. Note that this timeout starts when the client connection completes user authentication but before the client has an opportunity to open any channels. Caution should be used when using short timeout values, as they may not provide sufficient time for the client to request and open its channels before terminating the connection.
The default none is to never expire connections for having no open channels. This option may be useful in conjunction with ChannelTimeout.`, The default none is to never expire connections for having no open channels. This option may be useful in conjunction with ChannelTimeout.`,
TimeFormatValue{}, TimeFormatValue{},
), ),
"UseDNS": common.NewOption(`Specifies whether sshd(8) should look up the remote host name, and to check that the resolved host name for the remote IP address maps back to the very same IP address. "UseDNS": common.NewOption(`Specifies whether sshd(8) should look up the remote host name, and to check that the resolved host name for the remote IP address maps back to the very same IP address.
If this option is set to no (the default) then only addresses and not host names may be used in ~/.ssh/authorized_keys from and sshd_config Match Host directives.`, If this option is set to no (the default) then only addresses and not host names may be used in ~/.ssh/authorized_keys from and sshd_config Match Host directives.`,
BooleanEnumValue, BooleanEnumValue,
@ -766,7 +857,9 @@ See PATTERNS in ssh_config(5) for more information on patterns. This keyword may
Values: []docvalues.Value{ Values: []docvalues.Value{
docvalues.EnumValue{ docvalues.EnumValue{
EnforceValues: true, EnforceValues: true,
Values: []string{"none"}, Values: []docvalues.EnumString{
docvalues.CreateEnumString("none"),
},
}, },
docvalues.StringValue{}, docvalues.StringValue{},
}, },