server

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2023 License: MIT Imports: 39 Imported by: 6

README

server - Godoc License

Publish data to the OPC UA clients in your network.

With this package, you can create a server of the OPC Unified Architecture, see https://reference.opcfoundation.org/v104/Core/docs/Part4/

Usage

To create your OPC UA server, call server.New(). Specify the server's description, certificate, private key, endpoint URL, and various options.

Create a namespace, and add nodes of types Object, Variable, Method and DataType.

Run the server by calling ListenAndServe().

To stop the server, call Close().

package main

import (
	"context"
	"fmt"

	"github.com/awcullen/opcua/server"
	"github.com/awcullen/opcua/ua"
)

func main() {

	// create directory with certificate and key, if not found.
	if err := ensurePKI(); err != nil {
		log.Println("Error creating PKI.")
		return
	}

    // create the endpoint url from hostname and port
	host, _ := os.Hostname()
	port := 46010
	endpointURL := fmt.Sprintf("opc.tcp://%s:%d", host, port)

	// create server
	srv, err := server.New(
		ua.ApplicationDescription{
			ApplicationURI: fmt.Sprintf("urn:%s:testserver", host),
			ProductURI:     "http://github.com/awcullen/opcua",
			ApplicationName: ua.LocalizedText{
				Text:   fmt.Sprintf("testserver@%s", host),
				Locale: "en",
			},
			ApplicationType:     ua.ApplicationTypeServer,
			GatewayServerURI:    "",
			DiscoveryProfileURI: "",
			DiscoveryURLs:       []string{endpointURL},
		},
		"./pki/server.crt",
		"./pki/server.key",
		endpointURL,
		server.WithBuildInfo(
			ua.BuildInfo{
				ProductURI:       "http://github.com/awcullen/opcua",
				ManufacturerName: "awcullen",
				ProductName:      "testserver",
				SoftwareVersion:  "0.3.0",
			}),
		server.WithAnonymousIdentity(true),
		server.WithSecurityPolicyNone(true),
		server.WithInsecureSkipVerify(),
		server.WithServerDiagnostics(true),
	)
	if err != nil {
		os.Exit(1)
	}

	// load nodeset
	nm := srv.NamespaceManager()
	if err := nm.LoadNodeSetFromBuffer([]byte(nodeset)); err != nil {
		os.Exit(2)
	}

	go func() {
		// wait for signal
		log.Println("Press Ctrl-C to exit...")
		waitForSignal()

		log.Println("Stopping server...")
		srv.Close()
	}()

	// start server
	log.Printf("Starting server '%s' at '%s'\n", srv.LocalDescription().ApplicationName.Text, srv.EndpointURL())
	if err := srv.ListenAndServe(); err != ua.BadServerHalted {
		log.Println(errors.Wrap(err, "Error opening server"))
	}
}


Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultRolePermissions returns RolePermissionTypes for the well known roles.
	DefaultRolePermissions []ua.RolePermissionType = []ua.RolePermissionType{
		{RoleID: ua.ObjectIDWellKnownRoleAnonymous, Permissions: (ua.PermissionTypeBrowse | ua.PermissionTypeRead | ua.PermissionTypeReadHistory | ua.PermissionTypeReceiveEvents)},
		{RoleID: ua.ObjectIDWellKnownRoleAuthenticatedUser, Permissions: (ua.PermissionTypeBrowse | ua.PermissionTypeRead | ua.PermissionTypeReadHistory | ua.PermissionTypeReceiveEvents)},
		{RoleID: ua.ObjectIDWellKnownRoleObserver, Permissions: (ua.PermissionTypeBrowse | ua.PermissionTypeRead | ua.PermissionTypeReadHistory | ua.PermissionTypeReceiveEvents)},
		{RoleID: ua.ObjectIDWellKnownRoleOperator, Permissions: (ua.PermissionTypeBrowse | ua.PermissionTypeRead | ua.PermissionTypeWrite | ua.PermissionTypeReadHistory | ua.PermissionTypeReceiveEvents | ua.PermissionTypeCall)},
		{RoleID: ua.ObjectIDWellKnownRoleEngineer, Permissions: (ua.PermissionTypeBrowse | ua.PermissionTypeRead | ua.PermissionTypeWrite | ua.PermissionTypeReadHistory | ua.PermissionTypeReceiveEvents | ua.PermissionTypeCall | ua.PermissionTypeWriteHistorizing)},
		{RoleID: ua.ObjectIDWellKnownRoleSupervisor, Permissions: (ua.PermissionTypeBrowse | ua.PermissionTypeRead | ua.PermissionTypeWrite | ua.PermissionTypeReadHistory | ua.PermissionTypeReceiveEvents | ua.PermissionTypeCall)},
		{RoleID: ua.ObjectIDWellKnownRoleConfigureAdmin, Permissions: (ua.PermissionTypeBrowse | ua.PermissionTypeRead | ua.PermissionTypeWriteAttribute)},
		{RoleID: ua.ObjectIDWellKnownRoleSecurityAdmin, Permissions: (ua.PermissionTypeBrowse | ua.PermissionTypeReadRolePermissions | ua.PermissionTypeWriteRolePermissions)},
	}
	// DefaultIdentityMappingRules ...
	DefaultIdentityMappingRules []IdentityMappingRule = []IdentityMappingRule{

		{
			NodeID: ua.ObjectIDWellKnownRoleAnonymous,
			Identities: []ua.IdentityMappingRuleType{
				{CriteriaType: ua.IdentityCriteriaTypeAnonymous},
			},
			ApplicationsExclude: true,
			EndpointsExclude:    true,
		},

		{
			NodeID: ua.ObjectIDWellKnownRoleAuthenticatedUser,
			Identities: []ua.IdentityMappingRuleType{
				{CriteriaType: ua.IdentityCriteriaTypeAuthenticatedUser},
			},
			ApplicationsExclude: true,
			EndpointsExclude:    true,
		},

		{
			NodeID: ua.ObjectIDWellKnownRoleObserver,
			Identities: []ua.IdentityMappingRuleType{
				{CriteriaType: ua.IdentityCriteriaTypeAuthenticatedUser},
			},
			ApplicationsExclude: true,
			EndpointsExclude:    true,
		},

		{
			NodeID: ua.ObjectIDWellKnownRoleOperator,
			Identities: []ua.IdentityMappingRuleType{
				{CriteriaType: ua.IdentityCriteriaTypeAuthenticatedUser},
			},
			ApplicationsExclude: true,
			EndpointsExclude:    true,
		},

		{
			NodeID:              ua.ObjectIDWellKnownRoleEngineer,
			ApplicationsExclude: true,
			EndpointsExclude:    true,
		},

		{
			NodeID:              ua.ObjectIDWellKnownRoleSupervisor,
			ApplicationsExclude: true,
			EndpointsExclude:    true,
		},

		{
			NodeID:              ua.ObjectIDWellKnownRoleConfigureAdmin,
			ApplicationsExclude: true,
			EndpointsExclude:    true,
		},

		{
			NodeID:              ua.ObjectIDWellKnownRoleSecurityAdmin,
			ApplicationsExclude: true,
			EndpointsExclude:    true,
		},
	}
	// DefaultRolesProvider is a RulesBasedRolesProvider using the DefaultIdentityMappingRules
	DefaultRolesProvider = NewRulesBasedRolesProvider(DefaultIdentityMappingRules)
)

Functions

func Any

func Any(nodes []ua.NodeID, f func(n ua.NodeID) bool) bool

Any returns true if the given function returns true for any of the given nodes.

func Contains

func Contains(nodes []ua.NodeID, node ua.NodeID) bool

Contains returns true if the given node is found to equal any of the given nodes.

func IsUserPermitted

func IsUserPermitted(userRolePermissions []ua.RolePermissionType, permissionType ua.PermissionType) bool

IsUserPermitted returns true if the user's role permissions contain a given permissionType.

Types

type AnonymousIdentityAuthenticator added in v1.0.2

type AnonymousIdentityAuthenticator interface {
	// AuthenticateUserNameIdentity returns nil when user identity is authenticated, or BadUserAccessDenied otherwise.
	AuthenticateAnonymousIdentity(userIdentity ua.AnonymousIdentity, applicationURI string, endpointURL string) error
}

UserNameIdentityAuthenticator authenticates AnonymousIdentity.

type AuthenticateAnonymousIdentityFunc added in v1.0.2

type AuthenticateAnonymousIdentityFunc func(userIdentity ua.AnonymousIdentity, applicationURI string, endpointURL string) error

AuthenticateUserNameIdentityFunc authenticates AnonymousIdentity.

func (AuthenticateAnonymousIdentityFunc) AuthenticateAnonymousIdentity added in v1.0.2

func (f AuthenticateAnonymousIdentityFunc) AuthenticateAnonymousIdentity(userIdentity ua.AnonymousIdentity, applicationURI string, endpointURL string) error

AuthenticateUserNameIdentity ...

type AuthenticateIssuedIdentityFunc

type AuthenticateIssuedIdentityFunc func(userIdentity ua.IssuedIdentity, applicationURI string, endpointURL string) error

AuthenticateIssuedIdentityFunc authenticates user identities.

func (AuthenticateIssuedIdentityFunc) AuthenticateIssuedIdentity

func (f AuthenticateIssuedIdentityFunc) AuthenticateIssuedIdentity(userIdentity ua.IssuedIdentity, applicationURI string, endpointURL string) error

AuthenticateIssuedIdentity ...

type AuthenticateUserNameIdentityFunc

type AuthenticateUserNameIdentityFunc func(userIdentity ua.UserNameIdentity, applicationURI string, endpointURL string) error

AuthenticateUserNameIdentityFunc authenticates UserNameIdentity.

func (AuthenticateUserNameIdentityFunc) AuthenticateUserNameIdentity

func (f AuthenticateUserNameIdentityFunc) AuthenticateUserNameIdentity(userIdentity ua.UserNameIdentity, applicationURI string, endpointURL string) error

AuthenticateUserNameIdentity ...

type AuthenticateX509IdentityFunc

type AuthenticateX509IdentityFunc func(userIdentity ua.X509Identity, applicationURI string, endpointURL string) error

AuthenticateX509IdentityFunc authenticates X509Identity.

func (AuthenticateX509IdentityFunc) AuthenticateX509Identity

func (f AuthenticateX509IdentityFunc) AuthenticateX509Identity(userIdentity ua.X509Identity, applicationURI string, endpointURL string) error

AuthenticateX509Identity ...

type DataChangeMonitoredItem

type DataChangeMonitoredItem struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

DataChangeMonitoredItem specifies the node and attribute that is monitored for data changes.

func NewDataChangeMonitoredItem

func NewDataChangeMonitoredItem(sub *Subscription, node Node, itemToMonitor ua.ReadValueID, monitoringMode ua.MonitoringMode, parameters ua.MonitoringParameters, timestampsToReturn ua.TimestampsToReturn, minSamplingInterval float64) *DataChangeMonitoredItem

NewDataChangeMonitoredItem constructs a new DataChangeMonitoredItem.

func (*DataChangeMonitoredItem) AddTriggeredItem

func (mi *DataChangeMonitoredItem) AddTriggeredItem(item MonitoredItem) bool

AddTriggeredItem adds a item to be triggered by this item.

func (*DataChangeMonitoredItem) ClientHandle

func (mi *DataChangeMonitoredItem) ClientHandle() uint32

ClientHandle returns the client handle of the MonitoredItem.

func (*DataChangeMonitoredItem) Delete

func (mi *DataChangeMonitoredItem) Delete()

Delete deletes the DataMonitoredItem.

func (*DataChangeMonitoredItem) ID

ID returns the identifier of the MonitoredItem.

func (*DataChangeMonitoredItem) ItemToMonitor

func (mi *DataChangeMonitoredItem) ItemToMonitor() ua.ReadValueID

ItemToMonitor returns the ReadValueID of the MonitoredItem.

func (*DataChangeMonitoredItem) Modify

Modify modifies the MonitoredItem.

func (*DataChangeMonitoredItem) MonitoringMode

func (mi *DataChangeMonitoredItem) MonitoringMode() ua.MonitoringMode

MonitoringMode returns the monitoring mode of the MonitoredItem.

func (*DataChangeMonitoredItem) Node

func (mi *DataChangeMonitoredItem) Node() Node

Node returns the Node of the MonitoredItem.

func (*DataChangeMonitoredItem) Poll

func (mi *DataChangeMonitoredItem) Poll()

Poll reads the value of the itemToMonitor.

func (*DataChangeMonitoredItem) QueueSize

func (mi *DataChangeMonitoredItem) QueueSize() uint32

QueueSize returns the queue size of the MonitoredItem.

func (*DataChangeMonitoredItem) RemoveTriggeredItem

func (mi *DataChangeMonitoredItem) RemoveTriggeredItem(item MonitoredItem) bool

RemoveTriggeredItem removes an item to be triggered by this item.

func (*DataChangeMonitoredItem) SamplingInterval

func (mi *DataChangeMonitoredItem) SamplingInterval() float64

SamplingInterval returns the sampling interval in ms of the MonitoredItem.

func (*DataChangeMonitoredItem) SetMonitoringMode

func (mi *DataChangeMonitoredItem) SetMonitoringMode(mode ua.MonitoringMode)

SetMonitoringMode sets the MonitoringMode of the MonitoredItem.

func (*DataChangeMonitoredItem) SetTriggered

func (mi *DataChangeMonitoredItem) SetTriggered(val bool)

SetTriggered sets when the MonitoredItem is triggered.

func (*DataChangeMonitoredItem) Triggered

func (mi *DataChangeMonitoredItem) Triggered() bool

Triggered returns true when the MonitoredItem is triggered.

type DataTypeNode

type DataTypeNode struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

DataTypeNode is a Node class that describes the syntax of a variable's Value.

func NewDataTypeNode

func NewDataTypeNode(server *Server, nodeID ua.NodeID, browseName ua.QualifiedName, displayName ua.LocalizedText, description ua.LocalizedText, rolePermissions []ua.RolePermissionType, references []ua.Reference, isAbstract bool, structureOrEnumDefinition any) *DataTypeNode

NewDataTypeNode creates a new DataTypeNode.

func (*DataTypeNode) BrowseName

func (n *DataTypeNode) BrowseName() ua.QualifiedName

BrowseName returns the BrowseName attribute of this node.

func (*DataTypeNode) DataTypeDefinition

func (n *DataTypeNode) DataTypeDefinition() any

DataTypeDefinition returns the DataTypeDefinition attribute of this node.

func (*DataTypeNode) Description

func (n *DataTypeNode) Description() ua.LocalizedText

Description returns the Description attribute of this node.

func (*DataTypeNode) DisplayName

func (n *DataTypeNode) DisplayName() ua.LocalizedText

DisplayName returns the DisplayName attribute of this node.

func (*DataTypeNode) IsAbstract

func (n *DataTypeNode) IsAbstract() bool

IsAbstract returns the IsAbstract attribute of this node.

func (*DataTypeNode) IsAttributeIDValid

func (n *DataTypeNode) IsAttributeIDValid(attributeID uint32) bool

IsAttributeIDValid returns true if attributeId is supported for the node.

func (*DataTypeNode) NodeClass

func (n *DataTypeNode) NodeClass() ua.NodeClass

NodeClass returns the NodeClass attribute of this node.

func (*DataTypeNode) NodeID

func (n *DataTypeNode) NodeID() ua.NodeID

NodeID returns the NodeID attribute of this node.

func (*DataTypeNode) References

func (n *DataTypeNode) References() []ua.Reference

References returns the References of this node.

func (*DataTypeNode) RolePermissions

func (n *DataTypeNode) RolePermissions() []ua.RolePermissionType

RolePermissions returns the RolePermissions attribute of this node.

func (*DataTypeNode) SetReferences

func (n *DataTypeNode) SetReferences(value []ua.Reference)

SetReferences sets the References of the Variable.

func (*DataTypeNode) UserRolePermissions

func (n *DataTypeNode) UserRolePermissions(userIdentity any) []ua.RolePermissionType

UserRolePermissions returns the RolePermissions attribute of this node for the current user.

type EventListener

type EventListener interface {
	OnEvent(ua.Event)
}

type EventMonitoredItem

type EventMonitoredItem struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

EventMonitoredItem specifies a node that is monitored for events.

func NewEventMonitoredItem

func NewEventMonitoredItem(sub *Subscription, node Node, itemToMonitor ua.ReadValueID, monitoringMode ua.MonitoringMode, parameters ua.MonitoringParameters) *EventMonitoredItem

NewEventMonitoredItem constructs a new EventMonitoredItem.

func (*EventMonitoredItem) AddTriggeredItem

func (mi *EventMonitoredItem) AddTriggeredItem(item MonitoredItem) bool

AddTriggeredItem adds a item to be triggered by this item.

func (*EventMonitoredItem) ClientHandle

func (mi *EventMonitoredItem) ClientHandle() uint32

ClientHandle returns the client handle of the MonitoredItem.

func (*EventMonitoredItem) Delete

func (mi *EventMonitoredItem) Delete()

Delete deletes the DataMonitoredItem.

func (*EventMonitoredItem) ID

func (mi *EventMonitoredItem) ID() uint32

ID returns the identifier of the MonitoredItem.

func (*EventMonitoredItem) ItemToMonitor

func (mi *EventMonitoredItem) ItemToMonitor() ua.ReadValueID

ItemToMonitor returns the ReadValueID of the MonitoredItem.

func (*EventMonitoredItem) Modify

Modify modifies the MonitoredItem.

func (*EventMonitoredItem) MonitoringMode

func (mi *EventMonitoredItem) MonitoringMode() ua.MonitoringMode

MonitoringMode returns the monitoring mode of the MonitoredItem.

func (*EventMonitoredItem) Node

func (mi *EventMonitoredItem) Node() Node

Node returns the Node of the MonitoredItem.

func (*EventMonitoredItem) OnEvent

func (mi *EventMonitoredItem) OnEvent(evt ua.Event)

func (*EventMonitoredItem) QueueSize

func (mi *EventMonitoredItem) QueueSize() uint32

QueueSize returns the queue size of the MonitoredItem.

func (*EventMonitoredItem) RemoveTriggeredItem

func (mi *EventMonitoredItem) RemoveTriggeredItem(item MonitoredItem) bool

RemoveTriggeredItem removes an item to be triggered by this item.

func (*EventMonitoredItem) SamplingInterval

func (mi *EventMonitoredItem) SamplingInterval() float64

SamplingInterval returns the sampling interval in ms of the MonitoredItem.

func (*EventMonitoredItem) SetMonitoringMode

func (mi *EventMonitoredItem) SetMonitoringMode(mode ua.MonitoringMode)

SetMonitoringMode sets the MonitoringMode of the MonitoredItem.

func (*EventMonitoredItem) SetTriggered

func (mi *EventMonitoredItem) SetTriggered(val bool)

SetTriggered sets when the MonitoredItem is triggered.

func (*EventMonitoredItem) Triggered

func (mi *EventMonitoredItem) Triggered() bool

Triggered returns true when the MonitoredItem is triggered.

type GetRolesFunc added in v1.0.2

type GetRolesFunc func(userIdentity any, applicationURI string, endpointURL string) ([]ua.NodeID, error)

GetRolesFunc returns Roles for the given user identity and connection information.

func (GetRolesFunc) GetRoles added in v1.0.2

func (f GetRolesFunc) GetRoles(userIdentity any, applicationURI string, endpointURL string) ([]ua.NodeID, error)

GetRoles ...

type HistoryReadWriter

type HistoryReadWriter interface {
	HistoryReader
	HistoryWriter
}

HistoryReadWriter provides methods to read and write historical data.

type HistoryReader

type HistoryReader interface {

	// ReadEvent reads the events from storage. Implementation returns slice of events for every
	// NodeID provided in 'nodesToRead', given StartTime, EndTime and other parameters in 'details'.
	// Implementation may check context for timeout. Implementation must return desired choice of
	// timestamps. Implementation must return ContinuationPoints if more results are available
	// than can be returned in current call. Implementation must release ContinuationPoints
	// if no further results are desired. See OPC UA Part 11 chapter 6.4.2.2 for Read Event functionality.
	ReadEvent(ctx context.Context, nodesToRead []ua.HistoryReadValueID, details ua.ReadEventDetails,
		timestampsToReturn ua.TimestampsToReturn, releaseContinuationPoints bool) ([]ua.HistoryReadResult, ua.StatusCode)

	// ReadRawModified reads the raw or modified data values from storage. Implementation returns
	// slice of data values for every NodeID provided in 'nodesToRead', given StartTime, EndTime and
	// other parameters in 'details'. Implementation may check context for timeout. Implementation must
	// return desired choice of timestamps. Implementation must return ContinuationPoints if more results
	// are available than can be returned in current call. Implementation must release ContinuationPoints
	// if no further results are desired. See OPC UA Part 11 chapter 6.4.3.2 for Read Raw functionality.
	ReadRawModified(ctx context.Context, nodesToRead []ua.HistoryReadValueID, details ua.ReadRawModifiedDetails,
		timestampsToReturn ua.TimestampsToReturn, releaseContinuationPoints bool) ([]ua.HistoryReadResult, ua.StatusCode)

	// ReadProcessed reads the aggregated values from storage. Implementation returns slice of
	// aggregated data values for every NodeID provided in 'nodesToRead', given StartTime, EndTime and
	// other parameters in 'details'. Implementation may check context for timeout. Implementation must
	// return desired choice of timestamps. Implementation must return ContinuationPoints if more results
	// are available than can be returned in current call. Implementation must release ContinuationPoints
	// if no further results are desired. See OPC UA Part 11 chapter 6.4.4.2 for Read Processed functionality.
	ReadProcessed(ctx context.Context, nodesToRead []ua.HistoryReadValueID, details ua.ReadProcessedDetails,
		timestampsToReturn ua.TimestampsToReturn, releaseContinuationPoints bool) ([]ua.HistoryReadResult, ua.StatusCode)

	// ReadAtTime reads the correlated values from storage. Implementation returns slice of
	// correlated data values for every NodeID provided in 'nodesToRead', given slice of timestamps and
	// other parameters in 'details'. Implementation may check context for timeout. Implementation must
	// return desired choice of timestamps. Implementation must return ContinuationPoints if more results
	// are available than can be returned in current call. Implementation must release ContinuationPoints
	// if no further results are desired. See OPC UA Part 11 chapter 6.4.5.2 for Read At Time functionality.
	ReadAtTime(ctx context.Context, nodesToRead []ua.HistoryReadValueID, details ua.ReadAtTimeDetails,
		timestampsToReturn ua.TimestampsToReturn, releaseContinuationPoints bool) ([]ua.HistoryReadResult, ua.StatusCode)
}

HistoryReader provides methods to read historical data.

type HistoryWriter

type HistoryWriter interface {

	// WriteEvent writes the event to storage. Implementation records object nodeId
	// and event fields (provided as slice of Variants). Implementation may check
	// context for timeout.
	WriteEvent(ctx context.Context, nodeID ua.NodeID, eventFields []ua.Variant) error

	// WriteValue writes the value to storage. Implementation records variable nodeId
	// and DataValue (a struct of value, quality and source timestamp). Implementation
	// may check context for timeout.
	WriteValue(ctx context.Context, nodeID ua.NodeID, value ua.DataValue) error
}

HistoryWriter provides methods to write historical data.

type IdentityMappingRule

type IdentityMappingRule struct {
	NodeID              ua.NodeID
	Identities          []ua.IdentityMappingRuleType
	ApplicationsExclude bool
	Applications        []string
	EndpointsExclude    bool
	Endpoints           []struct {
		EndpointUrl         string
		SecurityMode        string
		SecurityPolicyURI   string
		TransportProfileUri string
	}
}

IdentityMappingRule ...

type IssuedIdentityAuthenticator

type IssuedIdentityAuthenticator interface {
	// AuthenticateIssuedIdentity returns nil when user is authenticated, or BadUserAccessDenied otherwise.
	AuthenticateIssuedIdentity(userIdentity ua.IssuedIdentity, applicationURI string, endpointURL string) error
}

IssuedIdentityAuthenticator authenticates user identities.

type MethodNode

type MethodNode struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

MethodNode is a Node class that describes the syntax of a object's Method.

func NewMethodNode

func NewMethodNode(server *Server, nodeID ua.NodeID, browseName ua.QualifiedName, displayName ua.LocalizedText, description ua.LocalizedText, rolePermissions []ua.RolePermissionType, references []ua.Reference, executable bool) *MethodNode

NewMethodNode constructs a new MethodNode.

func (*MethodNode) BrowseName

func (n *MethodNode) BrowseName() ua.QualifiedName

BrowseName returns the BrowseName attribute of this node.

func (*MethodNode) Description

func (n *MethodNode) Description() ua.LocalizedText

Description returns the Description attribute of this node.

func (*MethodNode) DisplayName

func (n *MethodNode) DisplayName() ua.LocalizedText

DisplayName returns the DisplayName attribute of this node.

func (*MethodNode) Executable

func (n *MethodNode) Executable() bool

Executable returns the Executable attribute of this node.

func (*MethodNode) IsAttributeIDValid

func (n *MethodNode) IsAttributeIDValid(attributeID uint32) bool

IsAttributeIDValid returns true if attributeId is supported for the node.

func (*MethodNode) NodeClass

func (n *MethodNode) NodeClass() ua.NodeClass

NodeClass returns the NodeClass attribute of this node.

func (*MethodNode) NodeID

func (n *MethodNode) NodeID() ua.NodeID

NodeID returns the NodeID attribute of this node.

func (*MethodNode) References

func (n *MethodNode) References() []ua.Reference

References returns the References of this node.

func (*MethodNode) RolePermissions

func (n *MethodNode) RolePermissions() []ua.RolePermissionType

RolePermissions returns the RolePermissions attribute of this node.

func (*MethodNode) SetCallMethodHandler

func (n *MethodNode) SetCallMethodHandler(value func(*Session, ua.CallMethodRequest) ua.CallMethodResult)

SetCallMethodHandler sets the CallMethod of the Variable.

func (*MethodNode) SetReferences

func (n *MethodNode) SetReferences(value []ua.Reference)

SetReferences sets the References of the Variable.

func (*MethodNode) UserExecutable

func (n *MethodNode) UserExecutable(userIdentity any) bool

UserExecutable returns the UserExecutable attribute of this node.

func (*MethodNode) UserRolePermissions

func (n *MethodNode) UserRolePermissions(userIdentity any) []ua.RolePermissionType

UserRolePermissions returns the RolePermissions attribute of this node for the current user.

type MonitoredItem

type MonitoredItem interface {
	ID() uint32
	Node() Node
	ItemToMonitor() ua.ReadValueID
	SamplingInterval() float64
	QueueSize() uint32
	MonitoringMode() ua.MonitoringMode
	ClientHandle() uint32
	Triggered() bool
	SetTriggered(bool)
	Modify(req ua.MonitoredItemModifyRequest) ua.MonitoredItemModifyResult
	Delete()
	SetMonitoringMode(mode ua.MonitoringMode)

	AddTriggeredItem(item MonitoredItem) bool
	RemoveTriggeredItem(item MonitoredItem) bool
	// contains filtered or unexported methods
}

MonitoredItem specifies a node that is monitored

type NamespaceManager

type NamespaceManager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

NamespaceManager manages the namespaces for a server.

func NewNamespaceManager

func NewNamespaceManager(server *Server) *NamespaceManager

NewNamespaceManager instantiates a new NamespaceManager.

func (*NamespaceManager) Add

func (m *NamespaceManager) Add(nsu string) uint16

Add adds a namespace to the end of the table and returns the index. If the namespace already exists then returns the index.

func (*NamespaceManager) AddNode

func (m *NamespaceManager) AddNode(node Node) error

AddNode adds the node to the namespace. This method adds the inverse refs as well.

func (*NamespaceManager) AddNodes

func (m *NamespaceManager) AddNodes(nodes ...Node) error

AddNodes adds the nodes to the namespace. This method adds the inverse refs as well.

func (*NamespaceManager) DeleteNode

func (m *NamespaceManager) DeleteNode(node Node, deleteChildren bool) error

DeleteNode removes the node from the namespace. This method removes the inverse refs as well.

func (*NamespaceManager) DeleteNodes

func (m *NamespaceManager) DeleteNodes(nodes []Node, deleteChildren bool) error

DeleteNodes removes the nodes from the namespace. This method removes the inverse refs as well.

func (*NamespaceManager) FindComponent

func (m *NamespaceManager) FindComponent(startNode Node, browseName ua.QualifiedName) (node Node, ok bool)

FindComponent returns the component with the given browseName from the namespace.

func (*NamespaceManager) FindMethod

func (m *NamespaceManager) FindMethod(id ua.NodeID) (node *MethodNode, ok bool)

FindMethod returns the node with the given NodeID from the namespace.

func (*NamespaceManager) FindNode

func (m *NamespaceManager) FindNode(id ua.NodeID) (node Node, ok bool)

FindNode returns the node with the given NodeID from the namespace.

func (*NamespaceManager) FindObject

func (m *NamespaceManager) FindObject(id ua.NodeID) (node *ObjectNode, ok bool)

FindObject returns the node with the given NodeID from the namespace.

func (*NamespaceManager) FindProperty

func (m *NamespaceManager) FindProperty(startNode Node, browseName ua.QualifiedName) (node *VariableNode, ok bool)

FindProperty returns the property with the given browseName from the namespace.

func (*NamespaceManager) FindSuperType

func (m *NamespaceManager) FindSuperType(typeid ua.NodeID) ua.NodeID

FindSuperType returns the immediate supertype for the type.

func (*NamespaceManager) FindVariable

func (m *NamespaceManager) FindVariable(id ua.NodeID) (node *VariableNode, ok bool)

FindVariable returns the node with the given NodeID from the namespace.

func (*NamespaceManager) FindVariantType

func (m *NamespaceManager) FindVariantType(dataType ua.NodeID) byte

FindVariantType gets the variant type for the variable

func (*NamespaceManager) GetChildren

func (m *NamespaceManager) GetChildren(node Node, uris []string, withRefTypes []ua.NodeID) []Node

GetChildren traverses the tree to get all target nodes with the given reference types.

func (*NamespaceManager) GetSubTypes

func (m *NamespaceManager) GetSubTypes(node Node) []Node

GetSubTypes traverses the tree to get all target nodes with HasSubtype reference type.

func (*NamespaceManager) IsSubtype

func (m *NamespaceManager) IsSubtype(subtype, supertype ua.NodeID) bool

IsSubtype returns whether the subtype is derived from the given supertype in the namespace.

func (*NamespaceManager) Len

func (m *NamespaceManager) Len() int

Len returns the number of namespace.

func (*NamespaceManager) LoadNodeSetFromBuffer

func (m *NamespaceManager) LoadNodeSetFromBuffer(buf []byte) error

LoadNodeSetFromBuffer loads the UANodeSet XML from a buffer into the namespace.

func (*NamespaceManager) LoadNodeSetFromFile

func (m *NamespaceManager) LoadNodeSetFromFile(path string) error

LoadNodeSetFromFile loads the UANodeSet XML from a file with the given path into the namespace.

func (*NamespaceManager) NamespaceUris

func (m *NamespaceManager) NamespaceUris() []string

NamespaceUris returns the namespace table of the server.

func (*NamespaceManager) OnEvent

func (m *NamespaceManager) OnEvent(target *ObjectNode, evt ua.Event) error

OnEvent raises the event, starting from the target node, follows HasNotifier references until the Server node.

func (*NamespaceManager) SetAnalogTypeBehavior

func (m *NamespaceManager) SetAnalogTypeBehavior(node *VariableNode) error

SetAnalogTypeBehavior sets the behavoir of a variable of type AnalogType.

func (*NamespaceManager) SetMultiStateValueDiscreteTypeBehavior

func (m *NamespaceManager) SetMultiStateValueDiscreteTypeBehavior(node *VariableNode) error

SetMultiStateValueDiscreteTypeBehavior sets the behavoir of a variable of type MultiStateValueDiscreteType.

type Node

type Node interface {
	NodeID() ua.NodeID
	NodeClass() ua.NodeClass
	BrowseName() ua.QualifiedName
	DisplayName() ua.LocalizedText
	Description() ua.LocalizedText
	RolePermissions() []ua.RolePermissionType
	UserRolePermissions(userIdentity any) []ua.RolePermissionType
	References() []ua.Reference
	SetReferences([]ua.Reference)
	IsAttributeIDValid(uint32) bool
}

Node ...

type ObjectNode

type ObjectNode struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ObjectNode ...

func NewObjectNode

func NewObjectNode(server *Server, nodeID ua.NodeID, browseName ua.QualifiedName, displayName ua.LocalizedText, description ua.LocalizedText, rolePermissions []ua.RolePermissionType, references []ua.Reference, eventNotifier byte) *ObjectNode

NewObjectNode ...

func (*ObjectNode) AddEventListener

func (n *ObjectNode) AddEventListener(listener EventListener)

func (*ObjectNode) BrowseName

func (n *ObjectNode) BrowseName() ua.QualifiedName

BrowseName returns the BrowseName attribute of this node.

func (*ObjectNode) Description

func (n *ObjectNode) Description() ua.LocalizedText

Description returns the Description attribute of this node.

func (*ObjectNode) DisplayName

func (n *ObjectNode) DisplayName() ua.LocalizedText

DisplayName returns the DisplayName attribute of this node.

func (*ObjectNode) EventNotifier

func (n *ObjectNode) EventNotifier() byte

EventNotifier returns the EventNotifier attribute of this node.

func (*ObjectNode) IsAttributeIDValid

func (n *ObjectNode) IsAttributeIDValid(attributeID uint32) bool

IsAttributeIDValid returns true if attributeId is supported for the node.

func (*ObjectNode) NodeClass

func (n *ObjectNode) NodeClass() ua.NodeClass

NodeClass returns the NodeClass attribute of this node.

func (*ObjectNode) NodeID

func (n *ObjectNode) NodeID() ua.NodeID

NodeID returns the NodeID attribute of this node.

func (*ObjectNode) OnEvent

func (n *ObjectNode) OnEvent(evt ua.Event)

OnEvent raises an event from this node.

func (*ObjectNode) References

func (n *ObjectNode) References() []ua.Reference

References returns the References of this node.

func (*ObjectNode) RemoveEventListener

func (n *ObjectNode) RemoveEventListener(listener EventListener)

func (*ObjectNode) RolePermissions

func (n *ObjectNode) RolePermissions() []ua.RolePermissionType

RolePermissions returns the RolePermissions attribute of this node.

func (*ObjectNode) SetReferences

func (n *ObjectNode) SetReferences(value []ua.Reference)

SetReferences sets the References of the Variable.

func (*ObjectNode) UserRolePermissions

func (n *ObjectNode) UserRolePermissions(userIdentity any) []ua.RolePermissionType

UserRolePermissions returns the RolePermissions attribute of this node for the current user.

type ObjectTypeNode

type ObjectTypeNode struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ObjectTypeNode ...

func NewObjectTypeNode

func NewObjectTypeNode(server *Server, nodeID ua.NodeID, browseName ua.QualifiedName, displayName ua.LocalizedText, description ua.LocalizedText, rolePermissions []ua.RolePermissionType, references []ua.Reference, isAbstract bool) *ObjectTypeNode

NewObjectTypeNode ...

func (*ObjectTypeNode) BrowseName

func (n *ObjectTypeNode) BrowseName() ua.QualifiedName

BrowseName returns the BrowseName attribute of this node.

func (*ObjectTypeNode) Description

func (n *ObjectTypeNode) Description() ua.LocalizedText

Description returns the Description attribute of this node.

func (*ObjectTypeNode) DisplayName

func (n *ObjectTypeNode) DisplayName() ua.LocalizedText

DisplayName returns the DisplayName attribute of this node.

func (*ObjectTypeNode) IsAbstract

func (n *ObjectTypeNode) IsAbstract() bool

IsAbstract returns the IsAbstract attribute of this node.

func (*ObjectTypeNode) IsAttributeIDValid

func (n *ObjectTypeNode) IsAttributeIDValid(attributeID uint32) bool

IsAttributeIDValid returns true if attributeId is supported for the node.

func (*ObjectTypeNode) NodeClass

func (n *ObjectTypeNode) NodeClass() ua.NodeClass

NodeClass returns the NodeClass attribute of this node.

func (*ObjectTypeNode) NodeID

func (n *ObjectTypeNode) NodeID() ua.NodeID

NodeID returns the NodeID attribute of this node.

func (*ObjectTypeNode) References

func (n *ObjectTypeNode) References() []ua.Reference

References returns the References of this node.

func (*ObjectTypeNode) RolePermissions

func (n *ObjectTypeNode) RolePermissions() []ua.RolePermissionType

RolePermissions returns the RolePermissions attribute of this node.

func (*ObjectTypeNode) SetReferences

func (n *ObjectTypeNode) SetReferences(value []ua.Reference)

SetReferences sets the References of the Variable.

func (*ObjectTypeNode) UserRolePermissions

func (n *ObjectTypeNode) UserRolePermissions(userIdentity any) []ua.RolePermissionType

UserRolePermissions returns the RolePermissions attribute of this node for the current user.

type Option

type Option func(*Server) error

Option is a functional option to be applied to a server during initialization.

func WithAnonymousIdentity

func WithAnonymousIdentity(value bool) Option

WithAnonymousIdentity sets whether to allow anonymous identity.

func WithAnonymousIdentityAuthenticator added in v1.0.2

func WithAnonymousIdentityAuthenticator(authenticator AnonymousIdentityAuthenticator) Option

WithAnonymousIdentityAuthenticator sets the authenticator for AnonymousIdentity. Provided authenticator can check applicationURI of the client certificate, if provided.

func WithAuthenticateAnonymousIdentityFunc added in v1.0.2

func WithAuthenticateAnonymousIdentityFunc(f AuthenticateAnonymousIdentityFunc) Option

WithAuthenticateAnonymousIdentityFunc sets the authenticate func for AnonymousIdentity. Provided function can check applicationURI of the client certificate, if provided.

func WithAuthenticateUserNameIdentityFunc

func WithAuthenticateUserNameIdentityFunc(f AuthenticateUserNameIdentityFunc) Option

WithAuthenticateUserNameIdentityFunc sets the authenticate func for UserNameIdentity.

func WithAuthenticateX509IdentityFunc

func WithAuthenticateX509IdentityFunc(f AuthenticateX509IdentityFunc) Option

WithAuthenticateX509IdentityFunc sets the authenticate func for X509Identity.

func WithBuildInfo

func WithBuildInfo(value ua.BuildInfo) Option

WithBuildInfo sets the BuildInfo returned by ServerStatus.

func WithGetRolesFunc added in v1.0.2

func WithGetRolesFunc(f GetRolesFunc) Option

WithGetRolesFunc sets the GetRolesFunc that returns the roles for the given user identity.

func WithHistorian

func WithHistorian(historian HistoryReadWriter) Option

WithHistorian sets the HistoryReadWriter.

func WithInsecureSkipVerify

func WithInsecureSkipVerify() Option

WithInsecureSkipVerify skips verification of client certificate. Skips checking HostName, Expiration, and Authority.

func WithIssuerCertificatesPaths added in v1.1.0

func WithIssuerCertificatesPaths(certPath, crlPath string) Option

WithIssuerCertificatesPaths sets the file path of the issuer certificates and revocation lists. Issuer certificates are needed for validation, but are not trusted. Path may be to a file, comma-separated list of files, or directory.

func WithMaxSessionCount

func WithMaxSessionCount(value uint32) Option

WithMaxSessionCount sets the number of sessions that may be active. (default: no limit)

func WithMaxSubscriptionCount

func WithMaxSubscriptionCount(value uint32) Option

WithMaxSubscriptionCount sets the number of subscription that may be active. (default: no limit)

func WithMaxWorkerThreads

func WithMaxWorkerThreads(value int) Option

WithMaxWorkerThreads sets the default number of worker threads that may be created. (default: 4)

func WithRejectedCertificatesPath added in v1.1.0

func WithRejectedCertificatesPath(path string) Option

WithRejectedCertificatesPath sets the file path where rejected certificates are stored. Path must be to a directory.

func WithRolePermissions

func WithRolePermissions(permissions []ua.RolePermissionType) Option

WithRolePermissions sets the permissions for each role.

func WithRolesProvider

func WithRolesProvider(provider RolesProvider) Option

WithRolesProvider sets the RolesProvider.

func WithSecurityPolicyNone

func WithSecurityPolicyNone(value bool) Option

WithSecurityPolicyNone sets whether to allow security policy with no encryption.

func WithServerCapabilities

func WithServerCapabilities(value *ua.ServerCapabilities) Option

WithServerCapabilities sets the ServerCapabilities.

func WithServerDiagnostics

func WithServerDiagnostics(value bool) Option

WithServerDiagnostics sets whether to enable the collection of data used for ServerDiagnostics node.

func WithTrace

func WithTrace() Option

WithTrace logs all ServiceRequests and ServiceResponses to StdOut.

func WithTransportLimits

func WithTransportLimits(maxBufferSize, maxMessageSize, maxChunkCount uint32) Option

WithTransportLimits sets the limits on the size of the buffers and messages. (default: 64Kb, 64Mb, 4096)

func WithTrustedCertificatesPaths added in v1.1.0

func WithTrustedCertificatesPaths(certPath, crlPath string) Option

WithTrustedCertificatesPaths sets the file path of the trusted certificates and revocation lists. Path may be to a file, comma-separated list of files, or directory.

func WithUserNameIdentityAuthenticator

func WithUserNameIdentityAuthenticator(authenticator UserNameIdentityAuthenticator) Option

WithUserNameIdentityAuthenticator sets the authenticator for UserNameIdentity.

func WithX509IdentityAuthenticator

func WithX509IdentityAuthenticator(authenticator X509IdentityAuthenticator) Option

WithX509IdentityAuthenticator sets the authenticator for X509Identity.

type PollGroup

type PollGroup struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewPollGroup

func NewPollGroup(interval time.Duration, cancellationCh chan struct{}) *PollGroup

func (*PollGroup) Subscribe

func (b *PollGroup) Subscribe(listener PollListener)

func (*PollGroup) Unsubscribe

func (b *PollGroup) Unsubscribe(listener PollListener)

type PollListener

type PollListener interface {
	Poll()
}

type ReferenceTypeNode

type ReferenceTypeNode struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ReferenceTypeNode ...

func NewReferenceTypeNode

func NewReferenceTypeNode(server *Server, nodeID ua.NodeID, browseName ua.QualifiedName, displayName ua.LocalizedText, description ua.LocalizedText, rolePermissions []ua.RolePermissionType, references []ua.Reference, isAbstract bool, symmetric bool, inverseName ua.LocalizedText) *ReferenceTypeNode

NewReferenceTypeNode ...

func (*ReferenceTypeNode) BrowseName

func (n *ReferenceTypeNode) BrowseName() ua.QualifiedName

BrowseName returns the BrowseName attribute of this node.

func (*ReferenceTypeNode) Description

func (n *ReferenceTypeNode) Description() ua.LocalizedText

Description returns the Description attribute of this node.

func (*ReferenceTypeNode) DisplayName

func (n *ReferenceTypeNode) DisplayName() ua.LocalizedText

DisplayName returns the DisplayName attribute of this node.

func (*ReferenceTypeNode) InverseName

func (n *ReferenceTypeNode) InverseName() ua.LocalizedText

InverseName returns the InverseName attribute of this node.

func (*ReferenceTypeNode) IsAbstract

func (n *ReferenceTypeNode) IsAbstract() bool

IsAbstract returns the IsAbstract attribute of this node.

func (*ReferenceTypeNode) IsAttributeIDValid

func (n *ReferenceTypeNode) IsAttributeIDValid(attributeID uint32) bool

IsAttributeIDValid returns true if attributeId is supported for the node.

func (*ReferenceTypeNode) NodeClass

func (n *ReferenceTypeNode) NodeClass() ua.NodeClass

NodeClass returns the NodeClass attribute of this node.

func (*ReferenceTypeNode) NodeID

func (n *ReferenceTypeNode) NodeID() ua.NodeID

NodeID returns the NodeID attribute of this node.

func (*ReferenceTypeNode) References

func (n *ReferenceTypeNode) References() []ua.Reference

References returns the References of this node.

func (*ReferenceTypeNode) RolePermissions

func (n *ReferenceTypeNode) RolePermissions() []ua.RolePermissionType

RolePermissions returns the RolePermissions attribute of this node.

func (*ReferenceTypeNode) SetReferences

func (n *ReferenceTypeNode) SetReferences(value []ua.Reference)

SetReferences sets the References of the Variable.

func (*ReferenceTypeNode) Symmetric

func (n *ReferenceTypeNode) Symmetric() bool

Symmetric returns the Symmetric attribute of this node.

func (*ReferenceTypeNode) UserRolePermissions

func (n *ReferenceTypeNode) UserRolePermissions(userIdentity any) []ua.RolePermissionType

UserRolePermissions returns the RolePermissions attribute of this node for the current user.

type RolesProvider

type RolesProvider interface {
	// GetRoles returns the roles for the given user identity and connection information.
	GetRoles(userIdentity any, applicationURI string, endpointURL string) ([]ua.NodeID, error)
}

RolesProvider looks up the roles for the given user identity and connection information. Roles are identified by a NodeID. There are a number of well-known roles. Later, users are granted Permissions to perform actions based on the user's role memberships.

func NewRulesBasedRolesProvider

func NewRulesBasedRolesProvider(rules []IdentityMappingRule) RolesProvider

NewRulesBasedRolesProvider ...

type RulesBasedRolesProvider

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

RulesBasedRolesProvider returns WellKnownRoles given server identity mapping rules.

func (*RulesBasedRolesProvider) GetRoles

func (p *RulesBasedRolesProvider) GetRoles(userIdentity any, applicationURI string, endpointURL string) ([]ua.NodeID, error)

GetRoles ...

type Scheduler

type Scheduler struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewScheduler

func NewScheduler(server *Server) *Scheduler

func (*Scheduler) GetPollGroup

func (s *Scheduler) GetPollGroup(interval time.Duration) *PollGroup

type Server

type Server struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Server implements an OpcUa server for clients.

func New

func New(localDescription ua.ApplicationDescription, certPath, keyPath, endpointURL string, options ...Option) (*Server, error)

New initializes a new instance of the Server. Specify the ApplicationDescription as defined in https://reference.opcfoundation.org/v104/Core/docs/Part4/7.1/ The files must contain PEM encoded data. The endpointURL is in the form opc.tcp://[host]:[port]

func (*Server) Close

func (srv *Server) Close() error

Close server.

func (*Server) Closing

func (srv *Server) Closing() <-chan struct{}

Closing gets a channel that broadcasts the closing of the server.

func (*Server) EndpointURL

func (srv *Server) EndpointURL() string

EndpointURL gets the endpoint url.

func (*Server) Endpoints

func (srv *Server) Endpoints() []ua.EndpointDescription

Endpoints gets the endpoint descriptions.

func (*Server) GetRoles added in v1.1.0

func (srv *Server) GetRoles(userIdentity any, applicationURI string, endpointURL string) ([]ua.NodeID, error)

GetRoles returns the roles for the given user identity and connection information.

func (*Server) Historian

func (srv *Server) Historian() HistoryReadWriter

Historian gets the HistoryReadWriter.

func (*Server) ListenAndServe

func (srv *Server) ListenAndServe() error

ListenAndServe listens on the EndpointURL for incoming connections and then handles service requests. ListenAndServe always returns a non-nil error. After server Close, the returned error is BadServerHalted.

func (*Server) LocalCertificate

func (srv *Server) LocalCertificate() []byte

LocalCertificate gets the certificate for the local application.

func (*Server) LocalDescription

func (srv *Server) LocalDescription() ua.ApplicationDescription

LocalDescription gets the application description.

func (*Server) MaxSessionCount

func (srv *Server) MaxSessionCount() uint32

MaxSessionCount gets the maximum number of sessions.

func (*Server) MaxSubscriptionCount

func (srv *Server) MaxSubscriptionCount() uint32

MaxSubscriptionCount gets the maximum number of subscriptions.

func (*Server) NamespaceManager

func (srv *Server) NamespaceManager() *NamespaceManager

NamespaceManager gets the namespace manager.

func (*Server) NamespaceUris

func (srv *Server) NamespaceUris() []string

NamespaceUris gets the namespace uris.

func (*Server) RolePermissions

func (srv *Server) RolePermissions() []ua.RolePermissionType

RolePermissions gets the RolePermissions.

func (*Server) Scheduler

func (srv *Server) Scheduler() *Scheduler

Scheduler gets the polling scheduler.

func (*Server) ServerCapabilities

func (srv *Server) ServerCapabilities() *ua.ServerCapabilities

ServerCapabilities gets the capabilities of the server.

func (*Server) ServerUris

func (srv *Server) ServerUris() []string

ServerUris gets the server uris.

func (*Server) SessionManager

func (srv *Server) SessionManager() *SessionManager

SessionManager gets the session manager.

func (*Server) State

func (srv *Server) State() ua.ServerState

State gets the ServerState.

func (*Server) SubscriptionManager

func (srv *Server) SubscriptionManager() *SubscriptionManager

SubscriptionManager gets the subscription Manager.

func (*Server) WorkerPool

func (srv *Server) WorkerPool() *workerpool.WorkerPool

WorkerPool gets a pool of workers.

type Session

type Session struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewSession

func NewSession(server *Server, sessionId ua.NodeID, sessionName string, authenticationToken ua.NodeID, sessionNonce ua.ByteString, timeout float64, clientDescription ua.ApplicationDescription, serverUri string, endpointUrl string, clientCertificate ua.ByteString, maxResponseMessageSize uint32) *Session

func (*Session) AuthenticationToken

func (s *Session) AuthenticationToken() ua.NodeID

func (*Session) ClientCertificate added in v1.1.0

func (s *Session) ClientCertificate() ua.ByteString

func (*Session) IsExpired

func (s *Session) IsExpired() bool

func (*Session) LastAccess

func (s *Session) LastAccess() time.Time

func (*Session) SecureChannelId

func (s *Session) SecureChannelId() uint32

func (*Session) SecurityMode added in v1.1.0

func (s *Session) SecurityMode() ua.MessageSecurityMode

func (*Session) SecurityPolicyURI added in v1.1.0

func (s *Session) SecurityPolicyURI() string

func (*Session) SessionId

func (s *Session) SessionId() ua.NodeID

func (*Session) SessionName

func (s *Session) SessionName() string

func (*Session) SessionNonce

func (s *Session) SessionNonce() ua.ByteString

func (*Session) SetLastAccess

func (s *Session) SetLastAccess(value time.Time)

func (*Session) SetSecureChannelId

func (s *Session) SetSecureChannelId(value uint32)

func (*Session) SetSecurityMode added in v1.1.0

func (s *Session) SetSecurityMode(value ua.MessageSecurityMode)

func (*Session) SetSecurityPolicyURI added in v1.1.0

func (s *Session) SetSecurityPolicyURI(value string)

func (*Session) SetSessionNonce

func (s *Session) SetSessionNonce(value ua.ByteString)

func (*Session) SetUserIdentity

func (s *Session) SetUserIdentity(value any)

func (*Session) Timeout

func (s *Session) Timeout() float64

func (*Session) UserIdentity

func (s *Session) UserIdentity() any

type SessionManager

type SessionManager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

SessionManager manages the sessions for a server.

func NewSessionManager

func NewSessionManager(server *Server) *SessionManager

NewSessionManager instantiates a new SessionManager.

func (*SessionManager) Add

func (m *SessionManager) Add(s *Session) error

Add a session to the server.

func (*SessionManager) Delete

func (m *SessionManager) Delete(s *Session)

Delete the session from the server.

func (*SessionManager) Get

func (m *SessionManager) Get(authenticationToken ua.NodeID) (*Session, bool)

Get a session from the server by authenticationToken.

func (*SessionManager) Len

func (m *SessionManager) Len() int

Len returns the number of sessions.

type Subscription

type Subscription struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Subscription organizes MonitoredItems.

func NewSubscription

func NewSubscription(manager *SubscriptionManager, session *Session, publishingInterval float64, lifetimeCount uint32, maxKeepAliveCount uint32, maxNotificationsPerPublish uint32, publishingEnabled bool, priority byte) *Subscription

NewSubscription instantiates a new Subscription.

func (*Subscription) AppendItem

func (s *Subscription) AppendItem(item MonitoredItem) bool

func (*Subscription) Delete

func (s *Subscription) Delete()

func (*Subscription) DeleteItem

func (s *Subscription) DeleteItem(id uint32) bool

func (*Subscription) FindItem

func (s *Subscription) FindItem(id uint32) (MonitoredItem, bool)

func (*Subscription) IsExpired

func (s *Subscription) IsExpired() bool

func (*Subscription) Items

func (s *Subscription) Items() []MonitoredItem

func (*Subscription) Modify

func (s *Subscription) Modify(publishingInterval float64, lifetimeCount uint32, maxKeepAliveCount uint32, maxNotificationsPerPublish uint32, priority byte)

func (*Subscription) SetPublishingMode

func (s *Subscription) SetPublishingMode(publishingEnabled bool)

type SubscriptionManager

type SubscriptionManager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

SubscriptionManager manages the subscriptions for a server.

func NewSubscriptionManager

func NewSubscriptionManager(server *Server) *SubscriptionManager

NewSubscriptionManager instantiates a new SubscriptionManager.

func (*SubscriptionManager) Add

Add a subscription to the server.

func (*SubscriptionManager) Delete

func (m *SubscriptionManager) Delete(s *Subscription)

Delete the subscription from the server.

func (*SubscriptionManager) Get

Get a subscription from the server.

func (*SubscriptionManager) GetBySession

func (m *SubscriptionManager) GetBySession(session *Session) []*Subscription

GetBySession returns subscriptions for the session.

func (*SubscriptionManager) Len

func (m *SubscriptionManager) Len() int

Len returns the number of subscriptions.

type UserNameIdentityAuthenticator

type UserNameIdentityAuthenticator interface {
	// AuthenticateUserNameIdentity returns nil when user identity is authenticated, or BadUserAccessDenied otherwise.
	AuthenticateUserNameIdentity(userIdentity ua.UserNameIdentity, applicationURI string, endpointURL string) error
}

UserNameIdentityAuthenticator authenticates UserNameIdentity.

type VariableNode

type VariableNode struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewVariableNode

func NewVariableNode(server *Server, nodeID ua.NodeID, browseName ua.QualifiedName, displayName ua.LocalizedText, description ua.LocalizedText, rolePermissions []ua.RolePermissionType, references []ua.Reference, value ua.DataValue, dataType ua.NodeID, valueRank int32, arrayDimensions []uint32, accessLevel byte, minimumSamplingInterval float64, historizing bool, historian HistoryReadWriter) *VariableNode

func (*VariableNode) AccessLevel

func (n *VariableNode) AccessLevel() byte

AccessLevel returns the AccessLevel attribute of this node.

func (*VariableNode) ArrayDimensions

func (n *VariableNode) ArrayDimensions() []uint32

ArrayDimensions returns the ArrayDimensions attribute of this node.

func (*VariableNode) BrowseName

func (n *VariableNode) BrowseName() ua.QualifiedName

BrowseName returns the BrowseName attribute of this node.

func (*VariableNode) DataType

func (n *VariableNode) DataType() ua.NodeID

DataType returns the DataType attribute of this node.

func (*VariableNode) Description

func (n *VariableNode) Description() ua.LocalizedText

Description returns the Description attribute of this node.

func (*VariableNode) DisplayName

func (n *VariableNode) DisplayName() ua.LocalizedText

DisplayName returns the DisplayName attribute of this node.

func (*VariableNode) Historizing

func (n *VariableNode) Historizing() bool

Historizing returns the Historizing attribute of this node.

func (*VariableNode) IsAttributeIDValid

func (n *VariableNode) IsAttributeIDValid(attributeID uint32) bool

IsAttributeIDValid returns true if attributeId is supported for the node.

func (*VariableNode) MinimumSamplingInterval

func (n *VariableNode) MinimumSamplingInterval() float64

MinimumSamplingInterval returns the MinimumSamplingInterval attribute of this node.

func (*VariableNode) NodeClass

func (n *VariableNode) NodeClass() ua.NodeClass

NodeClass returns the NodeClass attribute of this node.

func (*VariableNode) NodeID

func (n *VariableNode) NodeID() ua.NodeID

NodeID returns the NodeID attribute of this node.

func (*VariableNode) References

func (n *VariableNode) References() []ua.Reference

References returns the References of this node.

func (*VariableNode) RolePermissions

func (n *VariableNode) RolePermissions() []ua.RolePermissionType

RolePermissions returns the RolePermissions attribute of this node.

func (*VariableNode) SetHistorizing

func (n *VariableNode) SetHistorizing(historizing bool)

SetHistorizing sets the Historizing attribute of this node.

func (*VariableNode) SetReadValueHandler

func (n *VariableNode) SetReadValueHandler(value func(*Session, ua.ReadValueID) ua.DataValue)

SetReadValueHandler sets the ReadValueHandler of this node.

func (*VariableNode) SetReferences

func (n *VariableNode) SetReferences(value []ua.Reference)

SetReferences sets the References of this node.

func (*VariableNode) SetValue

func (n *VariableNode) SetValue(value ua.DataValue)

SetValue sets the value of the Variable.

func (*VariableNode) SetWriteValueHandler

func (n *VariableNode) SetWriteValueHandler(value func(*Session, ua.WriteValue) (ua.DataValue, ua.StatusCode))

SetWriteValueHandler sets the WriteValueHandler of this node.

func (*VariableNode) UserAccessLevel

func (n *VariableNode) UserAccessLevel(userIdentity any) byte

UserAccessLevel returns the AccessLevel attribute of this node for this user.

func (*VariableNode) UserRolePermissions

func (n *VariableNode) UserRolePermissions(userIdentity any) []ua.RolePermissionType

UserRolePermissions returns the RolePermissions attribute of this node for the current user.

func (*VariableNode) Value

func (n *VariableNode) Value() ua.DataValue

Value returns the value of the Variable.

func (*VariableNode) ValueRank

func (n *VariableNode) ValueRank() int32

ValueRank returns the ValueRank attribute of this node.

type VariableTypeNode

type VariableTypeNode struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewVariableTypeNode

func NewVariableTypeNode(server *Server, nodeId ua.NodeID, browseName ua.QualifiedName, displayName ua.LocalizedText, description ua.LocalizedText, rolePermissions []ua.RolePermissionType, references []ua.Reference, value ua.DataValue, dataType ua.NodeID, valueRank int32, arrayDimensions []uint32, isAbstract bool) *VariableTypeNode

func (*VariableTypeNode) ArrayDimensions

func (n *VariableTypeNode) ArrayDimensions() []uint32

ArrayDimensions returns the ArrayDimensions attribute of this node.

func (*VariableTypeNode) BrowseName

func (n *VariableTypeNode) BrowseName() ua.QualifiedName

BrowseName returns the BrowseName attribute of this node.

func (*VariableTypeNode) DataType

func (n *VariableTypeNode) DataType() ua.NodeID

DataType returns the DataType attribute of this node.

func (*VariableTypeNode) Description

func (n *VariableTypeNode) Description() ua.LocalizedText

Description returns the Description attribute of this node.

func (*VariableTypeNode) DisplayName

func (n *VariableTypeNode) DisplayName() ua.LocalizedText

DisplayName returns the DisplayName attribute of this node.

func (*VariableTypeNode) IsAbstract

func (n *VariableTypeNode) IsAbstract() bool

IsAbstract returns the IsAbstract attribute of this node.

func (*VariableTypeNode) IsAttributeIDValid

func (n *VariableTypeNode) IsAttributeIDValid(attributeId uint32) bool

IsAttributeIDValid returns true if attributeId is supported for the node.

func (*VariableTypeNode) NodeClass

func (n *VariableTypeNode) NodeClass() ua.NodeClass

NodeClass returns the NodeClass attribute of this node.

func (*VariableTypeNode) NodeID

func (n *VariableTypeNode) NodeID() ua.NodeID

NodeID returns the NodeID attribute of this node.

func (*VariableTypeNode) References

func (n *VariableTypeNode) References() []ua.Reference

References returns the References of this node.

func (*VariableTypeNode) RolePermissions

func (n *VariableTypeNode) RolePermissions() []ua.RolePermissionType

RolePermissions returns the RolePermissions attribute of this node.

func (*VariableTypeNode) SetReferences

func (n *VariableTypeNode) SetReferences(value []ua.Reference)

SetReferences sets the References of the Variable.

func (*VariableTypeNode) UserRolePermissions

func (n *VariableTypeNode) UserRolePermissions(userIdentity any) []ua.RolePermissionType

UserRolePermissions returns the RolePermissions attribute of this node for the current user.

func (*VariableTypeNode) Value

func (n *VariableTypeNode) Value() ua.DataValue

Value returns the value of the Variable.

func (*VariableTypeNode) ValueRank

func (n *VariableTypeNode) ValueRank() int32

ValueRank returns the ValueRank attribute of this node.

type ViewNode

type ViewNode struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewViewNode

func NewViewNode(server *Server, nodeId ua.NodeID, browseName ua.QualifiedName, displayName ua.LocalizedText, description ua.LocalizedText, rolePermissions []ua.RolePermissionType, references []ua.Reference, containsNoLoops bool, eventNotifier byte) *ViewNode

func (*ViewNode) BrowseName

func (n *ViewNode) BrowseName() ua.QualifiedName

BrowseName returns the BrowseName attribute of this node.

func (*ViewNode) ContainsNoLoops

func (n *ViewNode) ContainsNoLoops() bool

ContainsNoLoops returns the ContainsNoLoops attribute of this node.

func (*ViewNode) Description

func (n *ViewNode) Description() ua.LocalizedText

Description returns the Description attribute of this node.

func (*ViewNode) DisplayName

func (n *ViewNode) DisplayName() ua.LocalizedText

DisplayName returns the DisplayName attribute of this node.

func (*ViewNode) EventNotifier

func (n *ViewNode) EventNotifier() byte

EventNotifier returns the EventNotifier attribute of this node.

func (*ViewNode) IsAttributeIDValid

func (n *ViewNode) IsAttributeIDValid(attributeId uint32) bool

IsAttributeIDValid returns true if attributeId is supported for the node.

func (*ViewNode) NodeClass

func (n *ViewNode) NodeClass() ua.NodeClass

NodeClass returns the NodeClass attribute of this node.

func (*ViewNode) NodeID

func (n *ViewNode) NodeID() ua.NodeID

NodeID returns the NodeID attribute of this node.

func (*ViewNode) References

func (n *ViewNode) References() []ua.Reference

References returns the References of this node.

func (*ViewNode) RolePermissions

func (n *ViewNode) RolePermissions() []ua.RolePermissionType

RolePermissions returns the RolePermissions attribute of this node.

func (*ViewNode) SetReferences

func (n *ViewNode) SetReferences(value []ua.Reference)

SetReferences sets the References of the Variable.

func (*ViewNode) UserRolePermissions

func (n *ViewNode) UserRolePermissions(userIdentity any) []ua.RolePermissionType

UserRolePermissions returns the RolePermissions attribute of this node for the current user.

type X509IdentityAuthenticator

type X509IdentityAuthenticator interface {
	// AuthenticateUser returns nil when user is authenticated, or BadUserAccessDenied otherwise.
	AuthenticateX509Identity(userIdentity ua.X509Identity, applicationURI string, endpointURL string) error
}

X509IdentityAuthenticator authenticates X509Identity.

Jump to

Keyboard shortcuts

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