FCLauncher/fclauncher/Admin.go

41 lines
753 B
Go

package main
import (
"golang.org/x/crypto/ssh"
)
type Admin struct {
conf *ssh.ClientConfig
}
func sftpConnect(conf *ssh.ClientConfig) (ssh.Conn, error) {
return ssh.Dial("tcp", "gitea.piwalker.net:22", conf)
}
func sftpAuth(username string, password string) (*ssh.ClientConfig, error) {
config := &ssh.ClientConfig{
User: username,
Auth: []ssh.AuthMethod{
ssh.Password(password),
},
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
}
conn, err := sftpConnect(config)
if err != nil {
return nil, err
}
conn.Close()
return config, nil
}
func (a *Admin)adminAuth(username string, password string) bool {
conf, err := sftpAuth(username, password)
if err != nil {
a.conf = nil
return false
}
a.conf = conf
return true
}