captiveportal

package module
v0.0.0-...-34fa420 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2021 License: AGPL-3.0 Imports: 7 Imported by: 0

README

go-captiveportal

Go Reference

Librairie utilitaire permettant d'implémenter des fonctionnalités de portail captif en Go.

Licence

AGPL-3.0

Documentation

Index

Constants

View Source
const (
	ServiceName service.Name = "captiveportal"
)

Variables

View Source
var (
	ErrClientIdentificationFailed = errors.New("client identification failed")
)

Functions

func DefaultLiar

func DefaultLiar(os OS, w http.ResponseWriter, r *http.Request)

func HandleAndroid

func HandleAndroid(w http.ResponseWriter, r *http.Request)

func HandleApple

func HandleApple(w http.ResponseWriter, r *http.Request)

func HandleWindows

func HandleWindows(w http.ResponseWriter, r *http.Request)

func MatchAndroid

func MatchAndroid(r *http.Request) (bool, error)

func MatchApple

func MatchApple(r *http.Request) (bool, error)

func MatchLinux

func MatchLinux(r *http.Request) (bool, error)

func MatchWindows

func MatchWindows(r *http.Request) (bool, error)

func ServiceProvider

func ServiceProvider(redirectURL string, identifier Identifier, opts ...OptionsFunc) service.Provider

Types

type Client

type Client struct {
	ID      string
	Captive bool
	Lying   bool
	OS      OS
}

type Identifier

type Identifier interface {
	Identify(r *http.Request) (string, error)
	OnOffline(func(id string))
}

type Liar

type Liar interface {
	Handle(os OS, w http.ResponseWriter, r *http.Request)
}

type LiarFunc

type LiarFunc func(os OS, w http.ResponseWriter, r *http.Request)

func (LiarFunc) Handle

func (f LiarFunc) Handle(os OS, w http.ResponseWriter, r *http.Request)

type MatchFunc

type MatchFunc func(r *http.Request) (bool, OS, error)

func (MatchFunc) Match

func (f MatchFunc) Match(r *http.Request) (bool, OS, error)

type Matcher

type Matcher interface {
	Match(r *http.Request) (bool, OS, error)
}

type OS

type OS int
const (
	OSUnknown OS = iota
	OSAndroid
	OSApple
	OSWindows
	OSLinux
)

func DefaultMatch

func DefaultMatch(r *http.Request) (bool, OS, error)

type Options

type Options struct {
	Matcher Matcher
	Liar    Liar
}

func DefaultOptions

func DefaultOptions() *Options

type OptionsFunc

type OptionsFunc func(*Options)

type Registry

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

func NewRegistry

func NewRegistry() *Registry

func (*Registry) ClientOS

func (r *Registry) ClientOS(id string) OS

func (*Registry) Clients

func (r *Registry) Clients() []Client

func (*Registry) Delete

func (r *Registry) Delete(id string)

func (*Registry) IsCaptive

func (r *Registry) IsCaptive(id string) bool

func (*Registry) IsLying

func (r *Registry) IsLying(id string) bool

func (*Registry) Lie

func (r *Registry) Lie(id string)

func (*Registry) Release

func (r *Registry) Release(id string)

func (*Registry) Touch

func (r *Registry) Touch(id string, os OS)

type Service

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

func From

func From(container *service.Container) (*Service, error)

From retrieves the service in the given container

func Must

func Must(container *service.Container) *Service

Must retrieves the service in the given container or panic otherwise

func New

func New(redirectURL string, identifier Identifier, opts ...OptionsFunc) *Service

func (*Service) ClientID

func (s *Service) ClientID(r *http.Request) (string, error)

func (*Service) ClientOS

func (s *Service) ClientOS(r *http.Request) (OS, error)

func (*Service) IsCaptive

func (s *Service) IsCaptive(r *http.Request) (bool, error)

func (*Service) Lie

func (s *Service) Lie(r *http.Request) error

func (*Service) Middleware

func (s *Service) Middleware() func(next http.Handler) http.Handler

func (*Service) Release

func (s *Service) Release(r *http.Request) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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