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

36
sftp.go
View File

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

4
ssh.go
View File

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

View File

@ -4,4 +4,6 @@
- Allow fetching of multiple log files (fields under the defined host? Seperate key/field? Dynamic?)
- Allow different machines to collect different 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.