ss13_se

package module
v0.0.0-...-7924a7d Latest Latest
Warning

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

Go to latest
Published: May 12, 2019 License: MIT Imports: 20 Imported by: 0

README

Space Station 13 Hub

A server hub dedicated to SS13 and possibly a better replacement for the default server page at Byond.

Status

Beta mode live at www.ss13.se

The code has ben run in production for some months now and seems to be stable enough. I guess we're now back in beta?

Features For Players

  • A friendlier server list.

  • Detailed pages for most public servers.

  • Player count stats and graphs.

  • Predict when it's a "good" time for you to play.

Data Source

The data used for the public servers is scraped from the Byond page. Relying on Byond means we're affected by their server downtime (no page, no data), but we will automatically discover any new public servers.

Since bad hosts and owners can spoof a server's reported player count, there's no way to guarantee that the calculated stats and graphs are 100% correct.

But then again it's just some silly numbers for a game.

Missing a server?

Since we're scraping only public servers, we're missing any private that's hidden from the Byond page (I also discarded the poller, so no more polling private servers from a VIP list).

We also see a lot of public servers coming and going, or merely changing names a lot. So any servers that hasn't been seen for 3 days, or more, will be automagically removed from the list.

License

MIT License, see the LICENSE file.

Credits

Todo

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

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

func New

func New(c Conf) (*App, error)

func (*App) Log

func (a *App) Log(msg string, args ...interface{})

func (*App) Run

func (a *App) Run() error

type Conf

type Conf struct {
	// Web stuff
	WebAddr      string
	ReadTimeout  time.Duration
	WriteTimeout time.Duration

	// Scraper stuff
	ScrapeTimeout time.Duration

	// Misc.
	Storage Storage
}

type HttpError

type HttpError struct {
	Status int
	Err    error
}

func (HttpError) Error

func (s HttpError) Error() string

type ServerEntry

type ServerEntry struct {
	ID      string    `db:"id"`
	Title   string    `db:"title"`
	SiteURL string    `db:"site_url"`
	GameURL string    `db:"game_url"`
	Time    time.Time `db:"time"`
	Players int       `db:"players"`
}

func (ServerEntry) ByondURL

func (e ServerEntry) ByondURL() template.URL

func (ServerEntry) IsZero

func (e ServerEntry) IsZero() bool

func (ServerEntry) LastUpdated

func (e ServerEntry) LastUpdated() string

type ServerPoint

type ServerPoint struct {
	Time     time.Time `db:"time"`
	ServerID string    `db:"server_id"`
	Players  int       `db:"players"`
}

func (ServerPoint) IsZero

func (p ServerPoint) IsZero() bool

type Storage

type Storage interface {
	Open() error

	SaveServers([]ServerEntry) error
	GetServer(string) (ServerEntry, error)
	GetServers() ([]ServerEntry, error)
	RemoveServers([]ServerEntry) error

	SaveServerHistory([]ServerPoint) error
	GetServerHistory(int) ([]ServerPoint, error)
	GetSingleServerHistory(string, int) ([]ServerPoint, error)
}

type StorageSqlite

type StorageSqlite struct {
	*sqlx.DB
	Path string
}

func (*StorageSqlite) GetServer

func (store *StorageSqlite) GetServer(id string) (ServerEntry, error)

func (*StorageSqlite) GetServerHistory

func (store *StorageSqlite) GetServerHistory(days int) ([]ServerPoint, error)

func (*StorageSqlite) GetServers

func (store *StorageSqlite) GetServers() ([]ServerEntry, error)

func (*StorageSqlite) GetSingleServerHistory

func (store *StorageSqlite) GetSingleServerHistory(id string, days int) ([]ServerPoint, error)

func (*StorageSqlite) Open

func (store *StorageSqlite) Open() error

func (*StorageSqlite) RemoveServers

func (store *StorageSqlite) RemoveServers(servers []ServerEntry) error

func (*StorageSqlite) SaveServerHistory

func (store *StorageSqlite) SaveServerHistory(points []ServerPoint) error

func (*StorageSqlite) SaveServers

func (store *StorageSqlite) SaveServers(servers []ServerEntry) error

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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