Skip to content
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

add server.sshsync.io #38

Merged
merged 1 commit into from
Mar 21, 2024
Merged
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
50 changes: 33 additions & 17 deletions pkg/actions/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,26 +349,42 @@ func Setup(c *cli.Context) error {
fmt.Println("ssh-sync has already been set up on this system.")
return nil
}
// ask user if they already have an account on the ssh-sync server.
fmt.Print("Please enter your server address (http/https): ")
var serverAddress string
if err := utils.ReadLineFromStdin(scanner, &serverAddress); err != nil {
return err
}
serverUrl, err := url.Parse(serverAddress)
if err != nil {
return err
} else if serverUrl.Scheme == "" || serverUrl.Host == "" {
return errors.New("invalid server address")
} else if serverUrl.Scheme != "http" && serverUrl.Scheme != "https" {
return errors.New("server must use http or https")
}
if serverUrl.Scheme == "http" {
fmt.Println("WARNING: Your server is using HTTP. This is not secure. You should use HTTPS.")
fmt.Println("We recommend for the security-conscious that you use your own self-hosted ssh-sync-server.")
fmt.Println("If you don't have one, you'll be able to use the one hosted at https://server.sshsync.io.")
fmt.Print("Do you want to use your own server? (y/n): ")
var useOwnServer string
if err := utils.ReadLineFromStdin(scanner, &useOwnServer); err != nil {
return err
}
var serverUrl *url.URL
if useOwnServer == "n" {
serverUrl, err = url.Parse("https://server.sshsync.io")
if err != nil {
return err
}
} else {
// ask user if they already have an account on the ssh-sync server.
fmt.Print("Please enter your server address (http/https): ")
var serverAddress string
if err := utils.ReadLineFromStdin(scanner, &serverAddress); err != nil {
return err
}
serverUrl, err := url.Parse(serverAddress)
if err != nil {
return err
} else if serverUrl.Scheme == "" || serverUrl.Host == "" {
return errors.New("invalid server address")
} else if serverUrl.Scheme != "http" && serverUrl.Scheme != "https" {
return errors.New("server must use http or https")
}
if serverUrl.Scheme == "http" {
fmt.Println("WARNING: Your server is using HTTP. This is not secure. You should use HTTPS.")
}
}
// test connection to server

// test connection to server
if _, err := http.Get(serverUrl.String()); err != nil {
fmt.Println("It seems we are unable to connect to this ssh-sync server at the moment. Please check your configuration and try again.")
return err
}
fmt.Print("Do you already have an account on the ssh-sync server? (y/n): ")
Expand Down
Loading