Clean up option handling, comment on openssh compat
This commit is contained in:
parent
0befb7719d
commit
98a6f4ec64
1 changed files with 5 additions and 3 deletions
8
sshd.go
8
sshd.go
|
@ -391,13 +391,15 @@ func loadAuthorisedKeys(authorisedkeys string) {
|
|||
|
||||
devinfo := deviceInfo{Comment: comment}
|
||||
|
||||
// TODO: Compatibility with permitopen=foo,permitopen=bar,
|
||||
// permitremoteopen=quux,permitremoteopen=wobble
|
||||
for _, option := range options {
|
||||
ports, err := parseOption(option, "local")
|
||||
ports, err := parseOption(option, "localports")
|
||||
if err == nil {
|
||||
devinfo.LocalPorts = ports
|
||||
continue
|
||||
}
|
||||
ports, err := parseOption(option, "remote")
|
||||
ports, err = parseOption(option, "remoteports")
|
||||
if err == nil {
|
||||
devinfo.RemotePorts = ports
|
||||
continue
|
||||
|
@ -452,7 +454,7 @@ func portPermitted(port uint32, ports []uint32) bool {
|
|||
}
|
||||
|
||||
func parseOption(option string, prefix string) (string, error) {
|
||||
str := fmt.Sprintf("%sports=", prefix)
|
||||
str := fmt.Sprintf("%s=", prefix)
|
||||
if !strings.HasPrefix(option, str) {
|
||||
return "", fmt.Errorf("Option does not start with %s", str)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue