Fix share count bug
Also make username in client config less dumb
This commit is contained in:
parent
2e8083e42f
commit
e2e27c51fe
1 changed files with 13 additions and 9 deletions
22
main.go
22
main.go
|
|
@ -35,6 +35,9 @@ func main() {
|
|||
httpport := flag.String("httpport", "8888", "the remote server's http port")
|
||||
sharecount := flag.Uint("count", 1, "Amount of times you want to share this file")
|
||||
flag.Parse()
|
||||
if *sharecount > 0 {
|
||||
*sharecount--
|
||||
}
|
||||
if *server {
|
||||
runServer("0.0.0.0", *sshport, *httpport, "id_rsa")
|
||||
}
|
||||
|
|
@ -65,8 +68,16 @@ func main() {
|
|||
fmt.Println(err)
|
||||
auth = SSHAgent()
|
||||
}
|
||||
var username string
|
||||
userobj, err := user.Current()
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "Could not get user with user.Current()")
|
||||
username = "unknown"
|
||||
} else {
|
||||
username = userobj.Username
|
||||
}
|
||||
sshConfig := &ssh.ClientConfig{
|
||||
User: "otremblay",
|
||||
User: username,
|
||||
Auth: []ssh.AuthMethod{
|
||||
auth,
|
||||
},
|
||||
|
|
@ -86,14 +97,7 @@ func main() {
|
|||
}
|
||||
enc := gob.NewEncoder(ch)
|
||||
path = flag.Arg(0)
|
||||
var username string
|
||||
userobj, err := user.Current()
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "Could not get user with user.Current()")
|
||||
username = "unknown"
|
||||
} else {
|
||||
username = userobj.Username
|
||||
}
|
||||
|
||||
hostname, err := os.Hostname()
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "Could not get hostname with os.Hostname()")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue