diff options
author | Joe <rbo@gmx.us> | 2024-03-29 20:20:20 +0100 |
---|---|---|
committer | Joe <rbo@gmx.us> | 2024-03-29 20:20:20 +0100 |
commit | 486f840694b55452ea212fbf95ebd0cafddb33a8 (patch) | |
tree | d6e3238188d1dc6e0cab6b23ab3f245975c2cd7c /src/i_insert.go | |
parent | here (diff) | |
download | hardflip-486f840694b55452ea212fbf95ebd0cafddb33a8.tar.gz hardflip-486f840694b55452ea212fbf95ebd0cafddb33a8.tar.bz2 hardflip-486f840694b55452ea212fbf95ebd0cafddb33a8.tar.xz hardflip-486f840694b55452ea212fbf95ebd0cafddb33a8.tar.zst hardflip-486f840694b55452ea212fbf95ebd0cafddb33a8.zip |
iota
Diffstat (limited to 'src/i_insert.go')
-rw-r--r-- | src/i_insert.go | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/src/i_insert.go b/src/i_insert.go index d35a1c2..8c91640 100644 --- a/src/i_insert.go +++ b/src/i_insert.go @@ -43,7 +43,7 @@ * POSSIBILITY OF SUCH DAMAGE. * * hardflip: src/i_insert.go - * Wed Mar 27 16:43:21 2024 + * Fri Mar 29 12:15:41 2024 * Joe * * insert a new host @@ -61,12 +61,31 @@ import ( func i_insert_check_ok(data *HardData, insert *HostNode) { if len(insert.Name) == 0 { - data.insert_err = append(data.insert_err, - errors.New("no name")) + data.insert_err = append(data.insert_err, errors.New("no name")) } if len(insert.Host) == 0 { - data.insert_err = append(data.insert_err, - errors.New("no host")) + data.insert_err = append(data.insert_err, errors.New("no host")) + } + if insert.Port == 0 { + data.insert_err = append(data.insert_err, errors.New("port can't be 0")) + } + if insert.Protocol == PROTOCOL_SSH && len(insert.Priv) != 0 { + file := insert.Priv + if file[0] == '~' { + home_dir, err := os.UserHomeDir() + if err != nil { + return + } + file = home_dir + file[1:] + } + if stat, err := os.Stat(file); + err != nil { + data.insert_err = append(data.insert_err, errors.New(file + + ": file does not exist")) + } else if stat.IsDir() == true { + data.insert_err = append(data.insert_err, errors.New(file + + ": file is a directory")) + } } // TODO: here } |