mandatory commit

This commit is contained in:
Wyatt J. Miller 2019-09-26 20:23:36 -04:00
parent 5afa2c0f9a
commit 3871351ace
3 changed files with 26 additions and 18 deletions

18
sftp.go
View File

@ -14,30 +14,34 @@ var (
filename string = "dpkg.log" filename string = "dpkg.log"
) )
func getFile(client *ssh.Client) { func (s SSHConnection) getFile(client *ssh.Client) {
sftp, err := sftp.NewClient(client) sftp, err := sftp.NewClient(client)
//var srcFile []*os.File
//var dstFile []*os.File
if err != nil { if err != nil {
fmt.Errorf("FUCK") fmt.Errorf("Error")
} }
defer sftp.Close() defer sftp.Close()
srcFile, err := sftp.Open(srcPath + filename) for _, j := range s.Logs {
srcFile, err := sftp.Open(srcPath + j)
if err != nil { if err != nil {
fmt.Errorf("FUCK") fmt.Errorf("Error")
} }
defer srcFile.Close() defer srcFile.Close()
dstFile, err := os.Create(dstPath + filename) dstFile, err := os.Create(dstPath + j)
if err != nil { if err != nil {
fmt.Errorf("FUCK") fmt.Errorf("Error")
} }
defer dstFile.Close() defer dstFile.Close()
srcFile.WriteTo(dstFile) srcFile.WriteTo(dstFile)
} }
}

4
ssh.go
View File

@ -18,6 +18,7 @@ type SSHConnection struct {
Password string Password string
Port int Port int
Hosts []string Hosts []string
Logs []string
} }
type SSHClients []*ssh.Client type SSHClients []*ssh.Client
@ -39,6 +40,7 @@ func initializeConnection(config Configuration) (*SSHConnection, *ssh.ClientConf
Password: config.Password, Password: config.Password,
Port: config.Port, Port: config.Port,
Hosts: config.Hosts, Hosts: config.Hosts,
Logs: config.Logs,
} }
sshConfig := &ssh.ClientConfig{ sshConfig := &ssh.ClientConfig{
@ -96,7 +98,7 @@ func (s SSHConnection) executeSFTP(execute SSHClients) SSHSFTP {
for _, j := range execute { for _, j := range execute {
// TODO: this is just a placeholder, change to the actual tarring executable // TODO: this is just a placeholder, change to the actual tarring executable
getFile(j) s.getFile(j)
err := gzipit(homedir+filename, ".") err := gzipit(homedir+filename, ".")

View File

@ -5,3 +5,5 @@
- Allow different machines to collect different log files - Allow different machines to collect different log files
- Allow to gather directories of log files - Allow to gather directories of log files
- Develop a log getting logs for sanity - Develop a log getting logs for sanity
Developing a way to include a log space in the config which this program does not have.