service

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2021 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SERVICE = Service{
	Zone: &Zone{
		Host: make(map[string]*schema.Host, 32),
	},
	Users: &Users{
		Users: make(map[string]*schema.User, 32),
	},
	Permission: &Permission{
		Guest: RouteMatcher{
			Match: make([]Rule, 0, 32),
		},
	},
	History: &History{
		History: make([]*schema.History, 0, 128),
	},
	Session: &Session{
		Session: make(map[string]*schema.Session, 12),
	},
	Done:   make(chan bool),
	Ticker: time.NewTicker(2 * time.Second),
}

Functions

This section is empty.

Types

type History added in v0.9.1

type History struct {
	Lock    sync.RWMutex
	File    string
	History []*schema.History `json:"history"`
}

func (*History) Add added in v0.9.1

func (h *History) Add(obj *schema.History)

func (*History) List added in v0.9.1

func (h *History) List(user string) <-chan *schema.History

func (*History) Load added in v0.9.1

func (h *History) Load(file string) error

func (*History) Save added in v0.9.1

func (h *History) Save() error

type Permission

type Permission struct {
	Guest RouteMatcher `json:"guest"`
}

func (*Permission) Has

func (p *Permission) Has(req *http.Request) bool

func (*Permission) Load

func (p *Permission) Load(file string) error

type RouteMatcher

type RouteMatcher struct {
	Match []Rule
}

func (*RouteMatcher) Add

func (r *RouteMatcher) Add(m Rule)

type Rule

type Rule struct {
	Path   string      `json:"path"`
	Values []RuleValue `json:"-"`
	Type   string      `json:"type"`   // prefix, suffix or path
	Method string      `json:"method"` // get, post, put, delete
	Action string      `json:"action"` // permit or deny
}

type RuleValue

type RuleValue struct {
	Value string
	Type  string // argument or path
}

type Service

type Service struct {
	Zone       *Zone
	Users      *Users
	Permission *Permission
	History    *History
	Session    *Session
	Done       chan bool
	Ticker     *time.Ticker
}

func (*Service) Flush added in v0.9.1

func (s *Service) Flush()

func (*Service) Load

func (s *Service) Load(path string)

func (*Service) Loop added in v0.9.1

func (s *Service) Loop()

type Session added in v0.9.1

type Session struct {
	Lock    sync.RWMutex
	File    string
	Session map[string]*schema.Session `json:"session"`
}

func (*Session) Add added in v0.9.1

func (s *Session) Add(obj *schema.Session)

func (*Session) AddAndSave added in v0.9.1

func (s *Session) AddAndSave(obj *schema.Session)

func (*Session) Del added in v0.9.1

func (s *Session) Del(key string)

func (*Session) Get added in v0.9.1

func (s *Session) Get(key string) *schema.Session

func (*Session) List added in v0.9.1

func (s *Session) List(user string) <-chan *schema.Session

func (*Session) Load added in v0.9.1

func (s *Session) Load(file string) error

func (*Session) Mod added in v0.9.1

func (s *Session) Mod(obj *schema.Session)

func (*Session) Save added in v0.9.1

func (s *Session) Save() error

type Users

type Users struct {
	Lock  sync.RWMutex
	File  string
	Users map[string]*schema.User `json:"user"`
}

func (*Users) Add

func (u *Users) Add(v *schema.User) error

func (*Users) Del

func (u *Users) Del(name string) error

func (*Users) Get

func (u *Users) Get(name string) (schema.User, bool)

func (*Users) List

func (u *Users) List() <-chan *schema.User

func (*Users) Load

func (u *Users) Load(file string) error

func (*Users) Save

func (u *Users) Save() error

func (*Users) SetPass

func (u *Users) SetPass(name, old, new string) (schema.User, bool)

type Zone

type Zone struct {
	Lock sync.RWMutex
	Name string
	Host map[string]*schema.Host
}

func (*Zone) Add

func (l *Zone) Add(h *schema.Host)

func (*Zone) Get

func (l *Zone) Get(name string) *schema.Host

func (*Zone) List

func (l *Zone) List() <-chan *schema.Host

func (*Zone) Load

func (l *Zone) Load(file string) error

Jump to

Keyboard shortcuts

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