| 1 | package ssh_configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/ |
| 2 | |
| 3 | import ( |
| 4 | "fmtscip-go gomod github.com/golang/go/src go1.18 fmt/" |
| 5 | "stringsscip-go gomod github.com/golang/go/src go1.18 strings/" |
| 6 | "unicodescip-go gomod github.com/golang/go/src go1.18 unicode/" |
| 7 | ) |
| 8 | |
| 9 | type sshParserscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser# struct { |
| 10 | ignoreMatchDirectivescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#ignoreMatchDirective. bool |
| 11 | flowscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#flow. chan tokenscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token# |
| 12 | configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#config. *Configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config# |
| 13 | tokensBufferscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#tokensBuffer. []tokenscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token# |
| 14 | currentTablescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#currentTable. []string |
| 15 | seenTableKeysscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#seenTableKeys. []string |
| 16 | // /etc/ssh parser or local parser - used to find the default for relative |
| 17 | // filepaths in the Include directive |
| 18 | systemscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#system. bool |
| 19 | depthscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#depth. uint8 |
| 20 | } |
| 21 | |
| 22 | type sshParserStateFnscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParserStateFn# func() sshParserStateFnscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParserStateFn# |
| 23 | |
| 24 | // Formats and panics an error message based on a token |
| 25 | func (p *sshParserscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#) raiseErrorfscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#raiseErrorf().(tok *tokenscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token#, msg string, args ...interface{}) { |
| 26 | // TODO this format is ugly |
| 27 | panic(tok.Positionscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token#Position..Stringscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Position#String().() + ": " + fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Sprintf().(msg, args...)) |
| 28 | } |
| 29 | |
| 30 | func (p *sshParserscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#) raiseErrorscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#raiseError().(tok *tokenscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token#, err error) { |
| 31 | if err == ErrDepthExceededscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/ErrDepthExceeded. { |
| 32 | panic(err) |
| 33 | } |
| 34 | // TODO this format is ugly |
| 35 | panic(tok.Positionscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token#Position..Stringscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Position#String().() + ": " + err.Error()) |
| 36 | } |
| 37 | |
| 38 | func (p *sshParserscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#) runscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#run().() { |
| 39 | for state := p.parseStartscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#parseStart().; state != nil; { |
| 40 | state = state() |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | func (p *sshParserscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#) peekscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#peek().() *tokenscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token# { |
| 45 | if len(p.tokensBufferscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#tokensBuffer.) != 0 { |
| 46 | return &(p.tokensBufferscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#tokensBuffer.[0]) |
| 47 | } |
| 48 | |
| 49 | tok, ok := <-p.flowscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#flow. |
| 50 | if !ok { |
| 51 | return nil |
| 52 | } |
| 53 | p.tokensBufferscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#tokensBuffer. = append(p.tokensBufferscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#tokensBuffer., tok) |
| 54 | return &tok |
| 55 | } |
| 56 | |
| 57 | func (p *sshParserscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#) getTokenscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#getToken().() *tokenscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token# { |
| 58 | if len(p.tokensBufferscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#tokensBuffer.) != 0 { |
| 59 | tok := p.tokensBufferscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#tokensBuffer.[0] |
| 60 | p.tokensBufferscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#tokensBuffer. = p.tokensBufferscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#tokensBuffer.[1:] |
| 61 | return &tok |
| 62 | } |
| 63 | tok, ok := <-p.flowscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#flow. |
| 64 | if !ok { |
| 65 | return nil |
| 66 | } |
| 67 | return &tok |
| 68 | } |
| 69 | |
| 70 | func (p *sshParserscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#) parseStartscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#parseStart().() sshParserStateFnscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParserStateFn# { |
| 71 | tok := p.peekscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#peek().() |
| 72 | |
| 73 | // end of stream, parsing is finished |
| 74 | if tok == nil { |
| 75 | return nil |
| 76 | } |
| 77 | |
| 78 | switch tok.typscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token#typ. { |
| 79 | case tokenCommentscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/tokenComment., tokenEmptyLinescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/tokenEmptyLine.: |
| 80 | return p.parseCommentscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#parseComment(). |
| 81 | case tokenKeyscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/tokenKey.: |
| 82 | return p.parseKVscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#parseKV(). |
| 83 | case tokenEOFscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/tokenEOF.: |
| 84 | return nil |
| 85 | default: |
| 86 | p.raiseErrorfscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#raiseErrorf().(tok, fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Sprintf().("unexpected token %q\n", tok)) |
| 87 | } |
| 88 | return nil |
| 89 | } |
| 90 | |
| 91 | func (p *sshParserscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#) parseKVscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#parseKV().() sshParserStateFnscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParserStateFn# { |
| 92 | key := p.getTokenscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#getToken().() |
| 93 | hasEquals := false |
| 94 | val := p.getTokenscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#getToken().() |
| 95 | if val.typscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token#typ. == tokenEqualsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/tokenEquals. { |
| 96 | hasEquals = true |
| 97 | val = p.getTokenscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#getToken().() |
| 98 | } |
| 99 | comment := "" |
| 100 | tok := p.peekscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#peek().() |
| 101 | if tok == nil { |
| 102 | tok = &tokenscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token#{typscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token#typ.: tokenEOFscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/tokenEOF.} |
| 103 | } |
| 104 | if tok.typscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token#typ. == tokenCommentscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/tokenComment. && tok.Positionscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token#Position..Linescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Position#Line. == val.Positionscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token#Position..Linescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Position#Line. { |
| 105 | tok = p.getTokenscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#getToken().() |
| 106 | comment = tok.valscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token#val. |
| 107 | } |
| 108 | if stringsscip-go gomod github.com/golang/go/src go1.18 strings/.ToLowerscip-go gomod github.com/golang/go/src go1.18 strings/ToLower().(key.valscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token#val.) == "match" && !p.ignoreMatchDirectivescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#ignoreMatchDirective. { |
| 109 | // https://github.com/kevinburke/ssh_config/issues/6 |
| 110 | p.raiseErrorfscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#raiseErrorf().(val, "ssh_config: Match directive parsing is unsupported") |
| 111 | return nil |
| 112 | } |
| 113 | if stringsscip-go gomod github.com/golang/go/src go1.18 strings/.ToLowerscip-go gomod github.com/golang/go/src go1.18 strings/ToLower().(key.valscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token#val.) == "host" { |
| 114 | strPatterns := stringsscip-go gomod github.com/golang/go/src go1.18 strings/.Splitscip-go gomod github.com/golang/go/src go1.18 strings/Split().(val.valscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token#val., " ") |
| 115 | patterns := make([]*Patternscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Pattern#, 0) |
| 116 | for i := range strPatterns { |
| 117 | if strPatterns[i] == "" { |
| 118 | continue |
| 119 | } |
| 120 | pat, err := NewPatternscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/NewPattern().(strPatterns[i]) |
| 121 | if err != nil { |
| 122 | p.raiseErrorfscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#raiseErrorf().(val, "Invalid host pattern: %v", err) |
| 123 | return nil |
| 124 | } |
| 125 | patterns = append(patterns, pat) |
| 126 | } |
| 127 | // val.val at this point could be e.g. "example.com " |
| 128 | hostval := stringsscip-go gomod github.com/golang/go/src go1.18 strings/.TrimRightFuncscip-go gomod github.com/golang/go/src go1.18 strings/TrimRightFunc().(val.valscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token#val., unicodescip-go gomod github.com/golang/go/src go1.18 unicode/.IsSpacescip-go gomod github.com/golang/go/src go1.18 unicode/IsSpace().) |
| 129 | spaceBeforeComment := val.valscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token#val.[len(hostval):] |
| 130 | val.valscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token#val. = hostval |
| 131 | p.configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#config..ignoreMatchDirectivescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#ignoreMatchDirective. = p.ignoreMatchDirectivescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#ignoreMatchDirective. |
| 132 | p.configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#config..Hostsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#Hosts. = append(p.configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#config..Hostsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#Hosts., &Hostscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#{ |
| 133 | Patternsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#Patterns.: patterns, |
| 134 | Nodesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#Nodes.: make([]Nodescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Node#, 0), |
| 135 | EOLCommentscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#EOLComment.: comment, |
| 136 | spaceBeforeCommentscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#spaceBeforeComment.: spaceBeforeComment, |
| 137 | hasEqualsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#hasEquals.: hasEquals, |
| 138 | }, |
| 139 | ) |
| 140 | return p.parseStartscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#parseStart(). |
| 141 | } |
| 142 | lastHost := p.configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#config..Hostsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#Hosts.[len(p.configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#config..Hostsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#Hosts.)-1] |
| 143 | if stringsscip-go gomod github.com/golang/go/src go1.18 strings/.ToLowerscip-go gomod github.com/golang/go/src go1.18 strings/ToLower().(key.valscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token#val.) == "include" { |
| 144 | inc, err := NewIncludescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/NewInclude().(stringsscip-go gomod github.com/golang/go/src go1.18 strings/.Splitscip-go gomod github.com/golang/go/src go1.18 strings/Split().(val.valscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token#val., " "), hasEquals, key.Positionscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token#Position., comment, p.systemscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#system., p.ignoreMatchDirectivescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#ignoreMatchDirective., p.depthscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#depth.+1) |
| 145 | if err == ErrDepthExceededscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/ErrDepthExceeded. { |
| 146 | p.raiseErrorscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#raiseError().(val, err) |
| 147 | return nil |
| 148 | } |
| 149 | if err != nil { |
| 150 | p.raiseErrorfscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#raiseErrorf().(val, "Error parsing Include directive: %v", err) |
| 151 | return nil |
| 152 | } |
| 153 | lastHost.Nodesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#Nodes. = append(lastHost.Nodesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#Nodes., inc) |
| 154 | return p.parseStartscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#parseStart(). |
| 155 | } |
| 156 | shortval := stringsscip-go gomod github.com/golang/go/src go1.18 strings/.TrimRightFuncscip-go gomod github.com/golang/go/src go1.18 strings/TrimRightFunc().(val.valscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token#val., unicodescip-go gomod github.com/golang/go/src go1.18 unicode/.IsSpacescip-go gomod github.com/golang/go/src go1.18 unicode/IsSpace().) |
| 157 | spaceAfterValue := val.valscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token#val.[len(shortval):] |
| 158 | kv := &KVscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/KV#{ |
| 159 | Keyscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/KV#Key.: key.valscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token#val., |
| 160 | Valuescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/KV#Value.: shortval, |
| 161 | spaceAfterValuescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/KV#spaceAfterValue.: spaceAfterValue, |
| 162 | Commentscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/KV#Comment.: comment, |
| 163 | hasEqualsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/KV#hasEquals.: hasEquals, |
| 164 | leadingSpacescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/KV#leadingSpace.: key.Positionscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token#Position..Colscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Position#Col. - 1, |
| 165 | positionscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/KV#position.: key.Positionscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token#Position., |
| 166 | } |
| 167 | lastHost.Nodesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#Nodes. = append(lastHost.Nodesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#Nodes., kv) |
| 168 | return p.parseStartscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#parseStart(). |
| 169 | } |
| 170 | |
| 171 | func (p *sshParserscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#) parseCommentscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#parseComment().() sshParserStateFnscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParserStateFn# { |
| 172 | comment := p.getTokenscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#getToken().() |
| 173 | lastHost := p.configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#config..Hostsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#Hosts.[len(p.configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#config..Hostsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#Hosts.)-1] |
| 174 | lastHost.Nodesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#Nodes. = append(lastHost.Nodesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#Nodes., &Emptyscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Empty#{ |
| 175 | Commentscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Empty#Comment.: comment.valscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token#val., |
| 176 | // account for the "#" as well |
| 177 | leadingSpacescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Empty#leadingSpace.: comment.Positionscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token#Position..Colscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Position#Col. - 2, |
| 178 | positionscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Empty#position.: comment.Positionscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token#Position., |
| 179 | }, |
| 180 | ) |
| 181 | return p.parseStartscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#parseStart(). |
| 182 | } |
| 183 | |
| 184 | func parseSSHscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/parseSSH().(flow chan tokenscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token#, system, ignoreMatchDirective bool, depth uint8) *Configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config# { |
| 185 | // Ensure we consume tokens to completion even if parser exits early |
| 186 | defer func() { |
| 187 | for range flow { |
| 188 | } |
| 189 | }() |
| 190 | |
| 191 | result := newConfigscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/newConfig().() |
| 192 | result.positionscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#position. = Positionscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Position#{1, 1} |
| 193 | parser := &sshParserscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#{ |
| 194 | ignoreMatchDirectivescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#ignoreMatchDirective.: ignoreMatchDirective, |
| 195 | flowscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#flow.: flow, |
| 196 | configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#config.: result, |
| 197 | tokensBufferscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#tokensBuffer.: make([]tokenscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/token#, 0), |
| 198 | currentTablescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#currentTable.: make([]string, 0), |
| 199 | seenTableKeysscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#seenTableKeys.: make([]string, 0), |
| 200 | systemscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#system.: system, |
| 201 | depthscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#depth.: depth, |
| 202 | } |
| 203 | parser.runscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/sshParser#run().() |
| 204 | return result |
| 205 | } |