service

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: BSD-3-Clause, GPL-3.0 Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Decoder = &decoder.AbstractDecoder{
	Type:        types.Type_NC_Service,
	Name:        "Service",
	Description: "A network service",
	PostInit: func(d *decoder.AbstractDecoder) error {
		var err error
		serviceLog, _, err = logging.InitZapLogger(
			decoderconfig.Instance.Out,
			"service",
			decoderconfig.Instance.Debug,
		)
		if err != nil {
			return err
		}

		return initServiceProbes()
	},
	DeInit: func(e *decoder.AbstractDecoder) error {
		// flush writer
		var err error

		idents := make([]string, 0, len(Store.Items))
		for ident := range Store.Items {
			idents = append(idents, ident)
		}
		sort.Strings(idents)

		for _, ident := range idents {
			item := Store.Items[ident]
			item.Lock()
			sort.Strings(item.Service.Flows)

			if len(item.applications) > 0 {
				item.Service.Applications = make([]string, 0, len(item.applications))
				for app := range item.applications {
					item.Service.Applications = append(item.Service.Applications, app)
				}

				sort.Strings(item.Service.Applications)
			}

			if len(item.Service.Applications) > 0 {

				item.Service.DetectedProtocolName = item.Service.Applications[0]
			} else if item.Service.Product != "" {

				item.Service.DetectedProtocolName = item.Service.Product
			} else if item.Service.Name != "" {

				item.Service.DetectedProtocolName = item.Service.Name
			}

			err = e.Writer.Write(item.Service)
			if err != nil {
				serviceLog.Error("failed to flush service audit record", zap.Error(err))
			}
			item.Unlock()

			atomic.AddInt64(&e.NumRecordsWritten, 1)
		}

		return serviceLog.Sync()
	},
}

Decoder for protocol analysis and writing audit records to disk.

View Source
var Store = &atomicServiceMap{
	Items: make(map[string]*service),
}

Store ServiceStore holds all tcp service banners.

Functions

func AddApplications

func AddApplications(serviceIdent string, applications []string)

AddApplications adds DPI-detected application protocols to a service. This function is thread-safe and can be called from packet decoders.

func MatchServiceProbes

func MatchServiceProbes(serv *service, banner []byte, ident string)

func NewService

func NewService(ts int64, numBytesServer, numBytesClient int, ip string) *service

NewService creates a new network service.

func ResetProbeEnums

func ResetProbeEnums()

ResetProbeEnums remains for callers resetting capture state. IDs are now stable.

func ResetStore

func ResetStore()

ResetStore clears all services from memory This should be called when resetting state between processing different files

func SignatureInventory

func SignatureInventory() servicesignatures.Inventory

SignatureInventory is the actual decoder initialization result, not a re-read of a catalogue that may have changed since the capture started.

Types

type HyperscanBuildStats

type HyperscanBuildStats struct {
	Categories     int `json:"categories"`
	PatternsTotal  int `json:"patterns_total"`
	PatternsHS     int `json:"patterns_hyperscan"`
	PatternsFallbk int `json:"patterns_fallback"`
}

HyperscanBuildStats is the stub-build twin of the tagged type.

type HyperscanCategory

type HyperscanCategory struct {
	Name        string `json:"name"`
	Patterns    int    `json:"patterns"`
	Rejections  int    `json:"rejections"`
	Matches     uint64 `json:"matches"`
	Scans       uint64 `json:"scans"`
	ScanErrors  uint64 `json:"scan_errors"`
	SampleError string `json:"sample_error,omitempty"`
}

HyperscanCategory is the stub-build twin of the tagged type.

type HyperscanStatus

type HyperscanStatus struct {
	Enabled       bool                `json:"enabled"`
	LibVersion    string              `json:"lib_version"`
	Build         HyperscanBuildStats `json:"build"`
	BuildError    string              `json:"build_error,omitempty"`
	ScanFallbacks uint64              `json:"scan_fallbacks"`
	Categories    []HyperscanCategory `json:"categories,omitempty"`
}

HyperscanStatus is the stub-build twin of the tagged type.

func GetHyperscanStatus

func GetHyperscanStatus() HyperscanStatus

GetHyperscanStatus reports the integration as compiled-out so UI surfaces can render a clear "disabled" badge instead of guessing.

Jump to

Keyboard shortcuts

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