update config to support more vhd features down the road
This commit is contained in:
parent
99cb61a6ef
commit
ff4b7655c8
|
@ -46,8 +46,8 @@ func newMigrateVHDCommand() *cobra.Command {
|
|||
|
||||
// Run executes the migration command.
|
||||
func (m *MigrateVHDCommand) Run(ctx context.Context) error {
|
||||
if !config.Get().System.UseVirtualDisks {
|
||||
return errors.New("cannot migrate to vhd: configuration file \"system.use_virtual_disks\" value is set to \"false\"")
|
||||
if !vhd.Enabled() {
|
||||
return errors.New("cannot migrate to vhd: the underlying driver must be set to \"vhd\"")
|
||||
}
|
||||
for _, s := range m.manager.All() {
|
||||
s.Log().Debug("starting migration of server contents to virtual disk...")
|
||||
|
|
|
@ -120,14 +120,6 @@ type RemoteQueryConfiguration struct {
|
|||
|
||||
// SystemConfiguration defines basic system configuration settings.
|
||||
type SystemConfiguration struct {
|
||||
// UseVirtualDisks sets Wings to use virtual hard-disks when storing server
|
||||
// files. This allows for more enforced disk space limits, at a slight performance
|
||||
// cost.
|
||||
//
|
||||
// Generally this only needs to be enabled on systems with a large untrusted
|
||||
// user presence, it is not necessary for self-hosting instances.
|
||||
UseVirtualDisks bool `json:"use_virtual_disks" yaml:"use_virtual_disks"`
|
||||
|
||||
// The root directory where all of the pterodactyl data is stored at.
|
||||
RootDirectory string `default:"/var/lib/pterodactyl" yaml:"root_directory"`
|
||||
|
||||
|
@ -313,6 +305,11 @@ type Configuration struct {
|
|||
// is only required by users running Wings without SSL certificates and using internal IP
|
||||
// addresses in order to connect. Most users should NOT enable this setting.
|
||||
AllowCORSPrivateNetwork bool `json:"allow_cors_private_network" yaml:"allow_cors_private_network"`
|
||||
|
||||
// Servers contains all of the settings that are used when configuring individual servers
|
||||
// on the system. This is a global configuration for all server instances, not to be confused
|
||||
// with the per-server configurations provided by the Panel API.
|
||||
Servers Servers `json:"servers" yaml:"servers"`
|
||||
}
|
||||
|
||||
// NewAtPath creates a new struct and set the path where it should be stored.
|
||||
|
|
28
config/config_servers.go
Normal file
28
config/config_servers.go
Normal file
|
@ -0,0 +1,28 @@
|
|||
package config
|
||||
|
||||
type FSDriver string
|
||||
|
||||
const (
|
||||
FSDriverLocal FSDriver = "local"
|
||||
FSDriverVHD FSDriver = "vhd"
|
||||
)
|
||||
|
||||
type Servers struct {
|
||||
// Filesystem defines all of the filesystem specific settings used for servers.
|
||||
Filesystem Filesystem `json:"filesystem" yaml:"filesystem"`
|
||||
}
|
||||
|
||||
type Filesystem struct {
|
||||
// Driver defines the underlying filesystem driver that is used when a server is
|
||||
// created on the system. This currently supports either of the following drivers:
|
||||
//
|
||||
// local: the local driver is the default one used by Wings. This offloads all of the
|
||||
// disk limit enforcement to Wings itself. This has a performance impact but is
|
||||
// the most compatiable with all systems.
|
||||
// vhd: the vhd driver uses "virtual" disks on the host system to enforce disk limits
|
||||
// on the server. This is more performant since calculations do not need to be made
|
||||
// by Wings itself when enforcing limits. It also avoids vulnerabilities that exist
|
||||
// in the local driver which allow malicious processes to quickly create massive files
|
||||
// before Wings is able to detect and stop them from being written.
|
||||
Driver FSDriver `default:"local" json:"driver" yaml:"driver"`
|
||||
}
|
2
go.sum
2
go.sum
|
@ -803,7 +803,6 @@ github.com/smartystreets/gunit v1.0.0/go.mod h1:qwPWnhz6pn0NnRBP++URONOVyNkPyr4S
|
|||
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
||||
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||
github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc=
|
||||
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
|
||||
github.com/spf13/afero v1.9.2 h1:j49Hj62F0n+DaZ1dDCvhABaPNSGNkt32oRFxI33IEMw=
|
||||
github.com/spf13/afero v1.9.2/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y=
|
||||
|
@ -1147,7 +1146,6 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
|||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY=
|
||||
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
|
||||
|
|
|
@ -68,6 +68,11 @@ func DiskPath(uuid string) string {
|
|||
return filepath.Join(config.Get().System.Data, ".vhd/", uuid+".img")
|
||||
}
|
||||
|
||||
// Enabled returns true when VHD support is enabled on the instance.
|
||||
func Enabled() bool {
|
||||
return config.Get().Servers.Filesystem.Driver == config.FSDriverVHD
|
||||
}
|
||||
|
||||
// New returns a new Disk instance. The "size" parameter should be provided in
|
||||
// bytes of space allowed for the disk. An additional slice of option callbacks
|
||||
// can be provided to programatically swap out the underlying filesystem
|
||||
|
|
|
@ -54,7 +54,7 @@ func New(uuid string, size int64, denylist []string) *Filesystem {
|
|||
denylist: ignore.CompileIgnoreLines(denylist...),
|
||||
}
|
||||
|
||||
if config.Get().System.UseVirtualDisks {
|
||||
if vhd.Enabled() {
|
||||
fs.vhd = vhd.New(size, vhd.DiskPath(uuid), fs.root)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user