Documentation ¶
Index ¶
- Constants
- Variables
- func GetAuthorizedFilePublicKeyString(pk *PrivateKey) ([]byte, error)
- func GetPrivateKeyString(pk *PrivateKey) []byte
- func GetSecretKey() []byte
- func InitializeBot(ctx context.Context, initializeConfig InitializeConfig) (*discordgo.Session, error)
- func RunEphemeral(ctx context.Context, kvConn store.IKVStore, action EphemeralAction, ...)
- func SendError(s *discordgo.Session, channelId string, err string)
- type Action
- type AwsCreds
- type Config
- type ConfigMap
- type ConfigStateMachine
- type DigitalOceanCreds
- type EphemeralAction
- type InitializeConfig
- type PrivateKey
- type State
Constants ¶
const AWS_SIZE_SOURCE = "https://www.ec2instances.info/"
list of Size slug, hourly cost
const DATA_SECURITY_NOTE = "(Note: All credentials are encrypted in transit and at rest)"
const DIGITALOCEAN_SIZE_SOURCE = "https://slugs.do-api.dev/"
list of Size slug, hourly cost
const ISSUE_LINK = "https://github.com/jack-michaud/ephemeral-server/issues/new"
Variables ¶
var AWS_VALID_REGIONS = []string{
"us-east-1",
"us-west-2",
}
var AWS_VALID_SIZES = [][]string{
{"t3a.nano", "$0.004700"},
{"t3a.micro", "$0.009400"},
{"t3a.small", "$0.018800"},
{"t3a.medium", "$0.037600"},
{"t3a.large", "$0.075200"},
{"t3a.xlarge", "$0.150400"},
{"t3a.2xlarge", "$0.300800"},
}
var DIGITALOCEAN_VALID_REGIONS = []string{
"nyc1",
"sfo1",
"nyc2",
"ams2",
"sgp1",
"lon1",
"nyc3",
"ams3",
"fra1",
"tor1",
"sfo2",
"blr1",
"sfo3",
}
var DIGITALOCEAN_VALID_SIZES = [][]string{
{"s-8vcpu-16gb", "$0.11905"},
{"s-4vcpu-8gb", "$0.05952"},
{"s-2vcpu-4gb", "$0.02976"},
{"s-2vcpu-2gb", "$0.02232"},
{"s-1vcpu-2gb", "$0.01488"},
{"s-1vcpu-1gb", "$0.00744"},
}
var NilAction = func(s *discordgo.Session, m *discordgo.MessageCreate, config *Config, args []string) (error, *State) { return nil, nil }
var SERVER_TYPES = []string{
"vanilla-1.16.4",
"skyfactory-4.2.2",
"ftb-revelation-3.4.0",
}
Functions ¶
func GetAuthorizedFilePublicKeyString ¶
func GetAuthorizedFilePublicKeyString(pk *PrivateKey) ([]byte, error)
func GetPrivateKeyString ¶
func GetPrivateKeyString(pk *PrivateKey) []byte
func GetSecretKey ¶
func GetSecretKey() []byte
func InitializeBot ¶
func RunEphemeral ¶
Types ¶
type Action ¶
type Action = func(s *discordgo.Session, m *discordgo.MessageCreate, config *Config, args []string) (error, *State)
Returns an error and optionally a state that should be next.
type Config ¶
type Config struct { ServerId string ServerIpAddress *string CloudProvider string DigitalOceanCreds *DigitalOceanCreds `json:",omitempty"` Region string Size string // Aws. AwsCreds *AwsCreds `json:",omitempty"` // Private key to access the VPS. PrivateKey *PrivateKey `json:",omitempty"` ManagingRoleId string ServerType string }
func GetConfigForServerId ¶
Gets existing config from store or creates new config for server
func (*Config) HasBeenConfigured ¶ added in v1.3.1
type ConfigMap ¶
type ConfigMap struct {
// contains filtered or unexported fields
}
func NewConfigMap ¶
func NewConfigMap() *ConfigMap
type ConfigStateMachine ¶
type ConfigStateMachine struct {
// contains filtered or unexported fields
}
ConfigStateMachine stores the state of each guild ID. guildId -> State
func NewConfigStateMachine ¶
func NewConfigStateMachine() *ConfigStateMachine
func (*ConfigStateMachine) Set ¶
func (cm *ConfigStateMachine) Set(key string, state State)
type DigitalOceanCreds ¶
type DigitalOceanCreds struct {
AccessKey string
}
type EphemeralAction ¶
type EphemeralAction int
Ephemeralctl actions
const ( NO_OP EphemeralAction = iota DESTROY_ALL DESTROY_VPC // Idempotent CREATE GET_IP ANSIBLE_PROVISION )
type InitializeConfig ¶
type PrivateKey ¶
type PrivateKey = rsa.PrivateKey
func GeneratePrivateKey ¶
func GeneratePrivateKey() (*PrivateKey, error)
I'd like to use elliptic curve keys, but that's pending this issue: https://github.com/golang/go/issues/33564
type State ¶
type State struct { Action Action // contains filtered or unexported fields }
func (*State) GetNextStateFromMessage ¶
func (s *State) GetNextStateFromMessage(session *discordgo.Session, message *discordgo.MessageCreate, config *Config) State
Takes in a discord session, discord message, and server specific config.
Iterates through all possible next States on this state to see if there's a regex match in the message. If a message matches the next state, the next state's action is run. If the next state's action returns a new state, that state is returned. If there was an error from running the action, the initial state is returned. otherwise, the next state is returned.