captive

package module
v0.0.0-...-6967fe9 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2015 License: BSD-3-Clause Imports: 15 Imported by: 0

README

Captive Portal

=== Lightweight dockerized (maybe in the future) Captive Portal based on GO and iptables.

Event if it seams to work ... it's far from to be production ready

Implementation note:

  • Identification:

User identification is made binding IP&MAC with an UID (User ID).

  • Authentication:

The authentication module can be easly extended as needed. Captive provide two function Grant and Revoke to manage the connectivity of the user.
All the rest is pure html and sql call, no dark magic I promise, that can be modified without pain ;)

  • Modes:
    • Same thing as Authentication.
    • Currently implementation:
      • Activation for N hours/days
      • One device per account a time
Requirements
  • arp
  • iptables
  • golang
ACK

Based on the idea of: http://www.andybev.com/index.php/Using_iptables_and_PHP_to_create_a_captive_portal

Documentation

Index

Constants

View Source
const (
	MAC_STD_REGEXP = "([0-9A-Fa-f]{2}:{5,7})[0-9A-Fa-f]{2}"
	IP_REGEXP      = "([0-9]{1,3}\\.){3}[0-9]{1,3}"

	USER_REGEXP     = "[a-Z0-9\\.]{2,}"
	PASSWORD_REGEXP = "[a-Z0-9]{8}"
)
View Source
const (
	MAC_REGEXP = "(([0-9A-Fa-f]{1,2}(:|-)){5,7}[0-9A-Fa-f]{1,2}|([0-9A-Fa-f]{1,4}\\.){2,3}[0-9A-Fa-f]{1,4})"
)
View Source
const (
	// Manage the possibility to use the same account on more device
	SimulaneousConnection = false
)

Variables

View Source
var (
	E_AUTH_Deny      = errors.New("Wrong username password combination")
	E_AUTH_Expired   = errors.New("Your account has beeen expired")
	E_AUTH_Blacklist = errors.New("Your account is blacklisted")
)
View Source
var (
	E_ARP_NotInCache   error
	E_ARP_ParsingError error
)
View Source
var (
	ARP          string
	IPTABLES     string
	TEMPLATE     string
	REDIRECT_URL string
)
View Source
var (
	// String used to connect to postgresql
	ConnString string = "dbname=captive sslmode=disable encoding=utf-8"
)
View Source
var (
	FFLogin = forms.FormFields{
		"mac": fields.NewRegexField(fields.Defaults{
			"Required":    true,
			"MatchString": MAC_STD_REGEXP,
		}),
		"ip": fields.NewRegexField(fields.Defaults{
			"Required":    true,
			"MatchString": IP_REGEXP,
		}),
		"username": fields.NewRegexField(fields.Defaults{
			"Required":    true,
			"MatchString": USER_REGEXP,
		}),
		"password": fields.NewRegexField(fields.Defaults{
			"Required":    true,
			"MatchString": PASSWORD_REGEXP,
		}),
	}
)

Functions

func Block

func Block(uid int, ip, mac string)

Do not allow (anymore) the user to navigate

func Grant

func Grant(uid int, ip, mac string)

Allow an user to navigate

func IPtoMAC

func IPtoMAC(ip string) (net.HardwareAddr, error)

func InitDB

func InitDB()

func NormalizeMac

func NormalizeMac(mac string) (net.HardwareAddr, error)

Supports standard and not formats: 01:23:45:67:89:ab 01:23:45:67:89:ab:cd:ef 01-23-45-67-89-ab 01-23-45-67-89-ab-cd-ef 0123.4567.89ab 0123.4567.89ab.cdef 0:a:e4:13:f9:1c 0-a-e4-13-f9-1c 0::e4::f9:1c 0--e4--f9-1c

Types

This section is empty.

Jump to

Keyboard shortcuts

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