2020-04-25 19:18:18 +00:00
|
|
|
package config
|
|
|
|
|
2020-08-01 00:28:40 +00:00
|
|
|
import (
|
|
|
|
"encoding/base64"
|
|
|
|
"encoding/json"
|
|
|
|
"github.com/docker/docker/api/types"
|
|
|
|
)
|
|
|
|
|
2020-04-25 19:18:18 +00:00
|
|
|
type dockerNetworkInterfaces struct {
|
|
|
|
V4 struct {
|
|
|
|
Subnet string `default:"172.18.0.0/16"`
|
|
|
|
Gateway string `default:"172.18.0.1"`
|
|
|
|
}
|
|
|
|
|
|
|
|
V6 struct {
|
|
|
|
Subnet string `default:"fdba:17c8:6c94::/64"`
|
|
|
|
Gateway string `default:"fdba:17c8:6c94::1011"`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type DockerNetworkConfiguration struct {
|
|
|
|
// The interface that should be used to create the network. Must not conflict
|
|
|
|
// with any other interfaces in use by Docker or on the system.
|
2020-05-18 00:25:53 +00:00
|
|
|
Interface string `default:"172.18.0.1" json:"interface" yaml:"interface"`
|
2020-04-25 19:18:18 +00:00
|
|
|
|
|
|
|
// The DNS settings for containers.
|
|
|
|
Dns []string `default:"[\"1.1.1.1\", \"1.0.0.1\"]"`
|
|
|
|
|
|
|
|
// The name of the network to use. If this network already exists it will not
|
|
|
|
// be created. If it is not found, a new network will be created using the interface
|
|
|
|
// defined.
|
|
|
|
Name string `default:"pterodactyl_nw"`
|
|
|
|
ISPN bool `default:"false" yaml:"ispn"`
|
|
|
|
Driver string `default:"bridge"`
|
2020-05-10 01:29:56 +00:00
|
|
|
Mode string `default:"pterodactyl_nw" yaml:"network_mode"`
|
2020-04-25 19:18:18 +00:00
|
|
|
IsInternal bool `default:"false" yaml:"is_internal"`
|
|
|
|
EnableICC bool `default:"true" yaml:"enable_icc"`
|
|
|
|
Interfaces dockerNetworkInterfaces `yaml:"interfaces"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// Defines the docker configuration used by the daemon when interacting with
|
|
|
|
// containers and networks on the system.
|
|
|
|
type DockerConfiguration struct {
|
|
|
|
// Network configuration that should be used when creating a new network
|
|
|
|
// for containers run through the daemon.
|
|
|
|
Network DockerNetworkConfiguration `json:"network" yaml:"network"`
|
|
|
|
|
2020-07-04 21:14:22 +00:00
|
|
|
// Domainname is the Docker domainname for all containers.
|
|
|
|
Domainname string `default:"" json:"domainname" yaml:"domainname"`
|
|
|
|
|
2020-08-01 00:28:40 +00:00
|
|
|
// Registries .
|
|
|
|
Registries map[string]RegistryConfiguration `json:"registries" yaml:"registries"`
|
2020-08-13 03:38:02 +00:00
|
|
|
|
|
|
|
// The size of the /tmp directory when mounted into a container. Please be aware that Docker
|
|
|
|
// utilizes host memory for this value, and that we do not keep track of the space used here
|
|
|
|
// so avoid allocating too much to a server.
|
|
|
|
TmpfsSize uint `default:"100" json:"tmpfs_size" yaml:"tmpfs_size"`
|
2020-08-01 00:28:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// RegistryConfiguration .
|
|
|
|
type RegistryConfiguration struct {
|
|
|
|
Username string `yaml:"username"`
|
|
|
|
Password string `yaml:"password"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// Base64 .
|
|
|
|
func (c RegistryConfiguration) Base64() (string, error) {
|
|
|
|
authConfig := types.AuthConfig{
|
|
|
|
Username: c.Username,
|
|
|
|
Password: c.Password,
|
|
|
|
}
|
|
|
|
|
|
|
|
b, err := json.Marshal(authConfig)
|
|
|
|
if err != nil {
|
2020-11-28 23:57:10 +00:00
|
|
|
return "", err
|
2020-08-01 00:28:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return base64.URLEncoding.EncodeToString(b), nil
|
2020-04-25 19:18:18 +00:00
|
|
|
}
|