sshpiper/sshpiperd/upstream/database/model.go
Boshi Lian ea9357ff6c Add more database support (#19)
* mysql
* sqlite
* pg
2018-12-29 06:13:16 +00:00

79 lines
1.2 KiB
Go

package database
import (
"github.com/jinzhu/gorm"
)
type authMapType int
const (
authMapTypeNone = iota
authMapTypePassword
authMapTypePrivateKey
)
type keydata struct {
gorm.Model
Name string `gorm:"type:varchar(45)"`
Data string `gorm:"type:varchar(3000)"`
Type string `gorm:"type:varchar(45)"`
}
type privateKey struct {
Key keydata
KeyId int
UpstreamID int
}
type hostKey struct {
Key keydata
KeyId int
ServerID int
}
type server struct {
gorm.Model
Name string `gorm:"type:varchar(45)"`
Address string `gorm:"type:varchar(100)"`
HostKeyID int
HostKey hostKey
IgnoreHostKey bool
}
type upstream struct {
gorm.Model
Name string `gorm:"type:varchar(45)"`
ServerID int
Server server
Username string `gorm:"type:varchar(45)"`
Password string `gorm:"type:varchar(60)"`
PrivateKeyID int
PrivateKey privateKey
AuthMapType authMapType
}
type authorizedKey struct {
Key keydata
KeyId int
DownstreamID int
}
type downstream struct {
gorm.Model
Name string `gorm:"type:varchar(45)"`
Username string `gorm:"type:varchar(45);unique_index"`
UpstreamID int
Upstream upstream
AuthorizedKeys []authorizedKey
}