Compare commits

...

No commits in common. 'master' and 'go' have entirely different histories.
master ... go

  1. 1
      agent.go
  2. 8
      identity.go
  3. 2
      main.go

1
agent.go

@ -85,7 +85,6 @@ func (a *Agent) start() {
fmt.Fprintf(os.Stderr, "Start new agent for identity %s\n", a.Identity.Name)
sock := a.Path + ".sock"
syscall.Unlink(sock)
cmd := exec.Command("ssh-agent", "-a", sock)
o, e, err := capture3(cmd)
if err != nil {

8
identity.go

@ -28,15 +28,13 @@ func extractHost(prog string, args []string) string {
args = removeOptions(prog, args)
switch prog {
case "ssh":
if len(args) == 0 {
return ""
}
re := hostRegexps["ssh"]
arg := args[0]
p := matchParams(re, arg)
return p["host"]
case "scp":
re := hostRegexps["scp"]
args = args[0:2]
for _, arg := range args {
if p := matchParams(re, arg); p != nil {
return p["host"]
@ -53,9 +51,7 @@ func findIdentityName(config Config, prog string, args []string) string {
}
identities := config.Identities
host := extractHost(prog, args)
for _, identity := range identities {
match := identity.Key.(string)
name := identity.Value.(string)
for match, name := range identities {
if strings.Contains(host, match) {
return name
}

2
main.go

@ -15,7 +15,7 @@ type Config struct {
AgentsDir string
IdentitiesDir string
DefaultIdentity string `yaml:"default_identity"`
Identities yaml.MapSlice
Identities map[string]string
}
var sshOptions = map[string]map[string]string{

Loading…
Cancel
Save