| 679 | } |
| 680 | |
| 681 | func sshConfigParseLastOptions(r io.Reader) (o sshConfigOptions) { |
| 682 | // Default values. |
| 683 | o.waitEnum = "auto" |
| 684 | |
| 685 | s := bufio.NewScanner(r) |
| 686 | for s.Scan() { |
| 687 | line := s.Text() |
| 688 | if strings.HasPrefix(line, "# :") { |
| 689 | line = strings.TrimPrefix(line, "# :") |
| 690 | parts := strings.SplitN(line, "=", 2) |
| 691 | switch parts[0] { |
| 692 | case "wait": |
| 693 | o.waitEnum = parts[1] |
| 694 | case "ssh-host-prefix": |
| 695 | o.userHostPrefix = parts[1] |
| 696 | case "hostname-suffix": |
| 697 | o.hostnameSuffix = parts[1] |
| 698 | case "ssh-option": |
| 699 | o.sshOptions = append(o.sshOptions, parts[1]) |
| 700 | case "disable-autostart": |
| 701 | o.disableAutostart, _ = strconv.ParseBool(parts[1]) |
| 702 | case "header": |
| 703 | o.header = append(o.header, parts[1]) |
| 704 | case "header-command": |
| 705 | o.headerCommand = parts[1] |
| 706 | default: |
| 707 | // Unknown option, ignore. |
| 708 | } |
| 709 | } |
| 710 | } |
| 711 | if err := s.Err(); err != nil { |
| 712 | panic(err) |
| 713 | } |
| 714 | |
| 715 | return o |
| 716 | } |
| 717 | |
| 718 | // sshConfigGetCoderSection is a helper function that only returns the coder |
| 719 | // section of the SSH config and a boolean if it exists. |