sun

package
v0.0.0-...-27fe9b7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2021 License: MIT Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenKey

func GenKey() string

func LoadResourcePacks

func LoadResourcePacks(path string) []*resource.Pack

Types

type Balancer

type Balancer interface {
	Balance(ray *ray.Ray) ip_addr.IpAddr
}

type Config

type Config struct {
	Status minecraft.ServerStatus

	/*
		The First Server the proxy will redirect players too (after @see LoadBalancer)
	*/
	Hub ip_addr.IpAddr

	Proxy struct {

		/*
			The port the Sun Proxy should run on.
		*/
		Port uint16

		/*
			A boolean representing wether or not the proxy should use Xbox Auth.
		*/
		XboxAuthentication bool

		/*
			Unused as of now.
		*/
		IpForwarding bool

		TransferCommand struct {

			/*
				A boolean value representing if sun should enable the transfer command.
			*/
			Enabled bool

			/*
				An array of servers that the transfer command should be using.
			*/
			Servers map[string]ip_addr.IpAddr
		}

		/*
			Used to redirect players to a new server after the hub is unusable.
		*/
		LoadBalancer struct {

			/*
				A boolean value representing if sun should use LoadBalancing
			*/
			Enabled bool

			/*
				A list of servers to try to balance too after the hub is unusable.
			*/
			Balancers []ip_addr.IpAddr
		}

		/*
			A boolean value representing if the /status command should be overridden.
		*/
		StatusCommand bool

		/*
			A struct used to indicate if the proxy should enable ppof profiling and what port the webserver should run on.
		*/
		Ppof struct {

			/*
			   A boolean representing whether or not the ppof webserver should be started.
			*/
			Enabled bool

			/*
			   The port at which the ppof webserver should run on.
			*/
			Port uint16
		}

		Logger struct {

			/*
				The path to the file which the logger entries should be written to
			*/
			File string

			/*
				Represents if the logger should display debug messages!
			*/
			Debug bool
		}

		/*
			A boolean representing whether or not to forward the motd to the hub or the first open LoadBalancer
		*/
		MOTDForward bool
	}

	/*
		The configuration for the tcp server in sun
	*/
	Tcp struct {

		/*
			Specifies if the proxy should run the tcp server
		*/
		Enabled bool

		/*
			Used to login into the tcp server
		*/
		Key string
	}
}

* The basic Config file struct.

func LoadConfig

func LoadConfig() (Config, error)

func LoadGobConfig

func LoadGobConfig() (Config, error)

func LoadJsonConfig

func LoadJsonConfig() (Config, error)

func LoadTomlConfig

func LoadTomlConfig() (Config, error)

func LoadXmlConfig

func LoadXmlConfig() (Config, error)

func LoadYamlConfig

func LoadYamlConfig() (Config, error)

type Handler

type Handler interface {
	HandleRayJoin(ctx *event.Context, ray *ray.Ray)
	HandlePlanetConnect(ctx *event.Context, planet *planet.Planet)
}

type LoadBalancer

type LoadBalancer struct {
	Servers  []ip_addr.IpAddr
	Overflow *OverflowBalancer
	Enabled  bool
}

func (LoadBalancer) Balance

func (l LoadBalancer) Balance(ray *ray.Ray) ip_addr.IpAddr

type NopHandler

type NopHandler struct{}

func (NopHandler) HandlePlanetConnect

func (n NopHandler) HandlePlanetConnect(*event.Context, *planet.Planet)

func (NopHandler) HandleRayJoin

func (n NopHandler) HandleRayJoin(*event.Context, *ray.Ray)

type OverflowBalancer

type OverflowBalancer struct {
	// contains filtered or unexported fields
}

func NewOverflowBalancer

func NewOverflowBalancer(servers []ip_addr.IpAddr) *OverflowBalancer

func (*OverflowBalancer) Balance

func (r *OverflowBalancer) Balance(ray *ray.Ray) ip_addr.IpAddr

type StatusProvider

type StatusProvider struct {
	// contains filtered or unexported fields
}

func (StatusProvider) ServerStatus

func (s StatusProvider) ServerStatus(_ int, _ int) minecraft.ServerStatus

type Sun

type Sun struct {
	Listener        *minecraft.Listener
	Rays            map[string]*ray.Ray
	Hub             ip_addr.IpAddr
	Planets         map[uuid.UUID]*planet.Planet
	PListener       net.Listener
	Status          StatusProvider
	Key             string
	PWarnings       map[string]int
	PCooldowns      map[string]time.Time
	Servers         map[string]ip_addr.IpAddr
	TransferCommand bool
	LoadBalancer    LoadBalancer
	StatusCommand   bool
	Logger          logger.Logger
	PluginManager   *plugin.Manager

	CmdProcessor command.Processor
	// contains filtered or unexported fields
}

func NewSun

func NewSun() (*Sun, error)

Returns a new sun with a auto detected config

func NewSunW

func NewSunW(config Config) (*Sun, error)

Returns a new sun with config the specified config hence W

func (*Sun) AddPlanet

func (s *Sun) AddPlanet(planet *planet.Planet)

func (*Sun) BreakRay

func (s *Sun) BreakRay(ray *ray.Ray)

Closes a players session cleanly with a nice disconnection message!

func (*Sun) ConnectToHub

func (s *Sun) ConnectToHub(ray *ray.Ray) (*minecraft.Conn, error)

* ConnectToHub will attempt to connect a ray to the hub server. If the said hub server rejects the connection for any reason the proxy will then go through the overflow Balancer to find the next usable ip until it runs out.

func (*Sun) Dial

func (s *Sun) Dial(ray *ray.Ray, addr ip_addr.IpAddr) (*minecraft.Conn, error)

func (*Sun) Handle

func (s *Sun) Handle(handler Handler)

func (*Sun) Handler

func (s *Sun) Handler() Handler

func (*Sun) MakeRay

func (s *Sun) MakeRay(ray *ray.Ray)

Adds a player to the sun and readies them

func (*Sun) MotdForward

func (s *Sun) MotdForward() (*minecraft.ForeignStatusProvider, error)

func (*Sun) SendMessage

func (s *Sun) SendMessage(Message string)

SendMessage is used for sending a Sun wide message to all the connected clients

func (*Sun) SendMessageToServers

func (s *Sun) SendMessageToServers(Message string, Servers []string)

func (*Sun) Start

func (s *Sun) Start()

Starts the proxy.

func (*Sun) TransferRay

func (s *Sun) TransferRay(ray *ray.Ray, addr ip_addr.IpAddr) error

Changes a players remote and readies the connection

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL