Skip to content

Added identities-only global flag, similar to ssh_config's IdentitiesOnly #572

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions duplicacy/duplicacy_main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"io/ioutil"

"github.com/gilbertchen/duplicacy/src"
duplicacy "github.com/gilbertchen/duplicacy/src"
)

const (
Expand Down Expand Up @@ -160,6 +160,7 @@ func setGlobalOptions(context *cli.Context) {
}

duplicacy.RunInBackground = context.GlobalBool("background")
duplicacy.IdentitiesOnly = context.GlobalBool("identities-only")
}

func runScript(context *cli.Context, storageName string, phase string) bool {
Expand Down Expand Up @@ -784,8 +785,6 @@ func restoreRepository(context *cli.Context) {

patterns = append(patterns, pattern)



}
patterns = duplicacy.ProcessFilterLines(patterns, make([]string, 0))

Expand Down Expand Up @@ -1297,7 +1296,7 @@ func benchmark(context *cli.Context) {
if storage == nil {
return
}
duplicacy.Benchmark(repository, storage, int64(fileSize) * 1024 * 1024, chunkSize * 1024 * 1024, chunkCount, uploadThreads, downloadThreads)
duplicacy.Benchmark(repository, storage, int64(fileSize)*1024*1024, chunkSize*1024*1024, chunkCount, uploadThreads, downloadThreads)
}

func main() {
Expand Down Expand Up @@ -1965,6 +1964,10 @@ func main() {
Name: "background",
Usage: "read passwords, tokens, or keys only from keychain/keyring or env",
},
cli.BoolFlag{
Name: "identities-only",
Usage: "use only identities explicitly configured",
},
cli.StringFlag{
Name: "profile",
Value: "",
Expand Down
2 changes: 1 addition & 1 deletion src/duplicacy_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ func CreateStorage(preference Preference, resetPassword bool, threads int) (stor
signers := []ssh.Signer{}

agentSock := os.Getenv("SSH_AUTH_SOCK")
if agentSock != "" {
if agentSock != "" && !IdentitiesOnly {
connection, err := net.Dial("unix", agentSock)
// TODO: looks like we need to close the connection
if err == nil {
Expand Down
3 changes: 2 additions & 1 deletion src/duplicacy_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
)

var RunInBackground bool = false
var IdentitiesOnly bool = false

type RateLimitedReader struct {
Content []byte
Expand Down Expand Up @@ -55,7 +56,7 @@ func IsEmptyFilter(pattern string) bool {
}

func IsUnspecifiedFilter(pattern string) bool {
if pattern[0] != '+' && pattern[0] != '-' && !strings.HasPrefix(pattern, "i:") && !strings.HasPrefix(pattern, "e:") {
if pattern[0] != '+' && pattern[0] != '-' && !strings.HasPrefix(pattern, "i:") && !strings.HasPrefix(pattern, "e:") {
return true
} else {
return false
Expand Down