utils

package
Version: v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2019 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STATISTICS       string = "statistics"
	GROUPS           string = "groups"
	USERS            string = "users"
	SESSIONS         string = "sessions"
	SERVICES         string = "services"
	CAPTURES         string = "capture"
	ESSMS            string = "essmServices"
	AUTH_ARI         string = "authARI"
	AUTH_USER        string = "authUser"
	AUTHORIZED_USERS string = "authorizedUsers"
)
View Source
const (
	USERS_KEY       string = "_id"
	USERS_ATTRIBUTE string = "Attribute"
	USERS_VALUE     string = "String"
)
View Source
const (
	SESSION_KEY                   string = "_id"
	SESSION_ACCT_SESSION_ID       string = "AcctSessionId"
	SESSION_USER                  string = "User"
	SESSION_ARI                   string = "ARI"
	SESSION_ACI                   string = "ACI"
	SESSION_NAS_PORT_ID           string = "NasPortId"
	SESSION_SERVICES              string = "Services"
	SESSION_TIMEACCEPT            string = "TimeAccept"
	SESSION_TIMESTART             string = "TimeStart"
	SESSION_TIMEINTERIM           string = "TimeInterim"
	SESSION_TIMESTOP              string = "TimeStop"
	SESSION_TIME                  string = "SessionTime"
	SESSION_FRAMED_IP_ADDRESS     string = "FramedIPAddress"
	SESSION_FRAMED_IPV6_PREFIX    string = "FramedIPv6Prefix"
	SESSION_DELEGATED_IPV6_PREFIX string = "DelegatedIPv6Prefix"
	SESSION_L2BSAVLAN             string = "L2bsaVLAN"
	SESSION_L2BSAIFL              string = "L2bsaIFL"
	SESSION_ANCP_DOWN             string = "ANCPdown"
	SESSION_ANCP_UP               string = "ANCPup"
	SESSION_OCTETS_IN             string = "OctetsIn"
	SESSION_OCTETS_OUT            string = "OctetsOut"
	SESSION_OCTETS_GIGA_IN        string = "OctetsGigaIn"
	SESSION_OCTETS_GIGA_OUT       string = "OctetsGigaOut"
	SESSION_OCTETS_IPV6_IN        string = "OctetsIPv6In"
	SESSION_OCTETS_IPV6_OUT       string = "OctetsIPv6Out"
	SESSION_OCTETS_IPV6_GIGA_IN   string = "OctetsIPv6GigaIn"
	SESSION_OCTETS_IPV6_GIGA_OUT  string = "OctetsIPv6GigaOut"
	SESSION_POOLNAME              string = "PoolName"
)
View Source
const (
	SERVICE_KEY                     string = "_id"
	SERVICE_SESSION_ID              string = "SessionID"
	SERVICE_ACCT_SESSION_ID_SERVICE string = "AcctSessionIdService"
	SERVICE_ACCT_SESSION_ID         string = "AcctSessionId"
	SERVICE_SERVICE_STRING          string = "ServiceString"
	SERVICE_SERVICE_TYPE            string = "ServiceType"
	SERVICE_TIMESTART               string = "TimeStart"
	SERVICE_TIMESTOP                string = "TimeStop"
	SERVICE_TIMEINTERIM             string = "TimeInterim"
	SERVICE_OCTETS_IN               string = "OctetsIn"
	SERVICE_OCTETS_OUT              string = "OctetsOut"
	SERVICE_OCTETS_GIGA_IN          string = "OctetsGigaIn"
	SERVICE_OCTETS_GIGA_OUT         string = "OctetsGigaOut"
	SERVICE_OCTETS_IPV6_IN          string = "OctetsIPv6In"
	SERVICE_OCTETS_IPV6_OUT         string = "OctetsIPv6Out"
	SERVICE_OCTETS_IPV6_GIGA_IN     string = "OctetsIPv6GigaIn"
	SERVICE_OCTETS_IPV6_GIGA_OUT    string = "OctetsIPv6GigaOut"
)
View Source
const (
	ACCPACKET_NOAUTH string = "Non-authenticated accounting packet"
	ACCPACKET_AUTH   string = "Authenticated accounting packet"
	PACKET           string = ""
)
View Source
const (
	SPECIFICATION_MUST        string = "Must"
	SPECIFICATION_MAY         string = "May"
	SPECIFICATION_MUSTNOT     string = "Must Not"
	SKIP_HEADER_LINES         int    = 3
	ATTRIBUTE_TYPE_COLUMN     int    = 0
	ATTRIBUTE_NAME_COLUMN     int    = 1
	ATTRIBUTE_LENGTH_COLUMN   int    = 2
	VALUE_TYPE_COLUMN         int    = 3
	ACCESS_REQUEST_COLUMN     int    = 4
	ACCESS_RESPONSE_COLUMN    int    = 5
	ACCOUNTING_START_COLUMN   int    = 6
	ACCOUNTING_INTERIM_COLUMN int    = 7
	ACCOUNTING_STOP_COLUMN    int    = 8
	ACCOUNTING_ON_COLUMN      int    = 9
)
View Source
const (
	DEFAULT string = "DEFAULT"
	ARI     string = "ARI"
	USER    string = "USER"
	REJECT  string = "REJECT"
	IGNORE  string = "IGNORE"
	FAIL    string = "FAILED"
)
View Source
const (
	FAIL_DEFAULT   string = "FAILED DEFAULT AUTH BECAUSE ARI IS NOT SET"
	PW_PAP         string = "-PW-OK-PAP"
	PW_PAP_FAILED  string = "-PW-FAILED-PAP"
	PW_CHAP        string = "-PW-OK-CHAP"
	PW_CHAP_FAILED string = "-PW-FAILED-CHAP"
	PW_MISSING     string = "-PW-MISSING"
	PW_COLLISION   string = "-PW-COLLISION"
)
View Source
const (
	REASON_IP_ALLOCATION = "Failed to allocate IP address"
	REASON_ATTRIBUTES    = "Failed to adjust Attributes"
	REASON_L2BSA         = "Virtual Router Name does not exist for L2BSA user"
)
View Source
const (
	AUTHARI_KEY string = "_id"
)
View Source
const (
	AUTHUSER_KEY string = "_id"
)
View Source
const (
	AUTH_GROUPNAME string = "GroupName"
)
View Source
const (
	GLOBAL_DB string = "Global"
)
View Source
const (
	GROUP_KEY string = "_id"
)
View Source
const (
	L2BSAUser string = "L2BSA@dt.net"
)
View Source
const (
	STATISTICS_KEY string = "_id"
)

Variables

This section is empty.

Functions

func AddAttributesToPacket

func AddAttributesToPacket(responsePacket *radius.Packet, attributes map[string][]interface{}, logger *logs.Logger)

func AdjustAttributes

func AdjustAttributes(dbAttributes []Attribute, acctSessionID, userName string, attributes map[string][]interface{}, packetAttributes PacketAttributes, logger *logs.Logger) (bool, goradius.AcctTerminateCause, string)

func ApplyXAscendFilter

func ApplyXAscendFilter(attributes map[string][]interface{}, nasIpAddress, nasIpv6Address string, oldAttributes []Attribute, logger *logs.Logger)

func AuthenticationFailed

func AuthenticationFailed(a string) bool

func CastInterfaceToBool

func CastInterfaceToBool(value interface{}, logger *logs.Logger, attributeName string) bool

func CastInterfaceToInt

func CastInterfaceToInt(value interface{}, logger *logs.Logger, attributeName string) int

func CastInterfaceToSliceInterface

func CastInterfaceToSliceInterface(value interface{}, logger *logs.Logger, attributeName string) []interface{}

func CastInterfaceToString

func CastInterfaceToString(value interface{}, logger *logs.Logger, attributeName string) string

func CastInterfaceToTime

func CastInterfaceToTime(value interface{}, logger *logs.Logger, attributeName string) time.Time

func CreateValueForAttribute

func CreateValueForAttribute(value interface{}, hasTag bool, tag byte) (attributeValue interface{})

func CreateXAscendObject

func CreateXAscendObject(attributes map[string][]interface{}, nasIP, nasIPv6 string) map[string]string

func DetermineAriAci

func DetermineAriAci(attributes PacketAttributes) (ari string, aci string)

userARI, _ = goradius.ADSLAgentRemoteID_LookupString(packet) userACI, _ = goradius.ADSLAgentCircuitID_LookupString(packet) userARIerx, _ = goradius.ERXAccLoopRemoteID_LookupString(packet) userACIerx, _ = goradius.ERXAccLoopCirID_LookupString(packet)

func DetermineIds

func DetermineIds(acctSessionID string) (int, string)

func DetermineService

func DetermineService(attributes PacketAttributes) (string, string, bool)

func DetermineStatusType

func DetermineStatusType(attributes PacketAttributes) goradius.AcctStatusType

func ExtractAttributeValue

func ExtractAttributeValue(attributeName string, attributeValue interface{}) (value interface{}, hasTag bool, tag byte)

func ExtractIdentifiers

func ExtractIdentifiers(attributes PacketAttributes) (nasIdentifier, portId, acctSessionID, userName string)

func ExtractVendorAttributes

func ExtractVendorAttributes(attributes []radius.Attribute, logger *logs.Logger) map[VendorAttributeID]radius.Attribute

func GenerateResponseFromJSON

func GenerateResponseFromJSON(jsonToSend Json) (responseCode int, responseMessage []byte)

func GetAttributeSpecification

func GetAttributeSpecification(csvFilepath string, packetType radius.Code, statusType goradius.AcctStatusType) (map[radius.Type]AttributeSpecification, error)

func GetBase64Encoding

func GetBase64Encoding(key interface{}) ([]byte, error)

func GetIpStringFromRemoteAddress

func GetIpStringFromRemoteAddress(address net.Addr) string

GetIpStringFromRemoteAddress returns only the IP part of an IP & Port combination

func GetPrettyValue

func GetPrettyValue(attributeValue radius.Attribute, attributeValueType dictionary.AttributeType) string

func GetRandomValue

func GetRandomValue(randInit []string) (int, error)

func HandleErrorCriticalError

func HandleErrorCriticalError(err error, logger *logs.Logger)

func HandleErrorDetection

func HandleErrorDetection(err error, logger *logs.Logger) bool

func HandleErrorError

func HandleErrorError(err error, logger *logs.Logger) bool

func IsOnOff

func IsOnOff(statusType goradius.AcctStatusType) bool

func MaybeCastInterfaceToIntSlice

func MaybeCastInterfaceToIntSlice(value interface{}) ([]int, bool)

func MaybeCastInterfaceToSliceInterface

func MaybeCastInterfaceToSliceInterface(value interface{}) ([]interface{}, bool)

func MaybeCastInterfaceToString

func MaybeCastInterfaceToString(value interface{}) (string, bool)

func MaybeCastInterfaceToTime

func MaybeCastInterfaceToTime(value interface{}) (time.Time, bool)

func PacketLogging

func PacketLogging(attributes PacketAttributes, request *radius.Request, logger *logs.Logger, logMessage string)

func ReplaceServiceActivateByCalculation

func ReplaceServiceActivateByCalculation(value string, userDownstream, userUpstream int, logger *logs.Logger) string

func ReplaceServiceActivateWithRandom

func ReplaceServiceActivateWithRandom(value string, logger *logs.Logger) string

func TrimSpace

func TrimSpace(s string) string

func VerifyAttributeCorrectness

func VerifyAttributeCorrectness(attributes PacketAttributes, specificationPath string, packetType radius.Code, statusType goradius.AcctStatusType, sessionID string, logger *logs.Logger)

func VerifyChap

func VerifyChap(chap []byte, databaseChap string, request *radius.Request) bool

Types

type Attribute

type Attribute struct {
	AttributeTypeName string
	AttributeValue    interface{}
}

func ExtractAndAppendAttributesFromDbEntries

func ExtractAndAppendAttributesFromDbEntries(entry Json, logger *logs.Logger, attributes []Attribute) []Attribute

type AttributeSpecification

type AttributeSpecification struct {
	AttributeName   string
	AttributeType   string
	AttributeLength string
	ValueType       string
	Specification   string
}

RADIUS CSV Definitions

type AuthenticationInformation

type AuthenticationInformation struct {
	Timestamp       time.Time
	AuthenticatedBy string
	Capture         bool
	Essm            bool
	History         bool
	Password        string
	PoolIPv4        bool
	PoolIPv6        bool
	PoolIPv6PD      bool
	PoolName        string
	Attributes      []Attribute
}

type BngSecretSource

type BngSecretSource struct {
	SecretBngMapping map[string][]byte
	Logger           *logs.Logger
}

func (*BngSecretSource) RADIUSSecret

func (secretSource *BngSecretSource) RADIUSSecret(ctx context.Context, remoteAddress net.Addr) ([]byte, error)

type Json

type Json map[string]interface{}

func CastInterfaceToJson

func CastInterfaceToJson(value interface{}, logger *logs.Logger, attributeName string) Json

func CreateJsonValueForService

func CreateJsonValueForService(statusType goradius.AcctStatusType, request *radius.Request, serviceType, service string, serviceId int, acctSessionId string) (newValuesJson Json)

func CreateJsonValueForSession

func CreateJsonValueForSession(statusType goradius.AcctStatusType, request *radius.Request) (newValuesJson Json)

func GenerateJsonForAttributeIncrease

func GenerateJsonForAttributeIncrease(attribute string) Json

func GenerateResetStatisticsJson

func GenerateResetStatisticsJson() Json

type JsonIPPool

type JsonIPPool map[string]string

type PacketAttributes

type PacketAttributes struct {
	VendorSpecific   map[VendorAttributeID]radius.Attribute
	NormalAttributes map[radius.Type]radius.Attribute
}

func ExtractAllAttributesFromPacket

func ExtractAllAttributesFromPacket(request *radius.Request, logger *logs.Logger) PacketAttributes

func (*PacketAttributes) VendorAttribute

func (attributes *PacketAttributes) VendorAttribute(attributeName string) (radius.Attribute, bool)

func (*PacketAttributes) VendorAttributeInt

func (attributes *PacketAttributes) VendorAttributeInt(attributeName string) (uint32, error)

type ServerFlagConfig

type ServerFlagConfig struct {
	ServerType ServerType
	SkipVerify bool
	LogPackets bool
}

type ServerType

type ServerType string
const (
	AccountingServer     ServerType = "accounting_Server"
	AuthenticationServer ServerType = "authentication_Server"
)

type TagValuePair

type TagValuePair struct {
	Tag            byte
	AttributeValue interface{}
}

func CastInterfaceToTagValuePair

func CastInterfaceToTagValuePair(value interface{}, logger *logs.Logger, attributeName string) TagValuePair

type VendorAttributeID

type VendorAttributeID struct {
	VendorID uint32
	OID      int
}

Jump to

Keyboard shortcuts

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