Documentation
¶
Index ¶
- Constants
- type ADDR_ENTRY
- type NBNSHeader
- type NBNSPacket
- type NBNSQuestion
- type NBNSResourceRecord
- type NameChallenger
- type NameRecord
- type NameStatus
- type NameType
- type NetBIOSName
- type NetBIOSNameServer
- func (n *NetBIOSNameServer) CleanExpiredNames()
- func (n *NetBIOSNameServer) MarkNameConflict(name string) error
- func (n *NetBIOSNameServer) QueryName(name string) ([]net.IP, NameType, error)
- func (n *NetBIOSNameServer) RefreshName(name string, owner net.IP) error
- func (n *NetBIOSNameServer) RegisterName(name string, nameType NameType, owner net.IP, ttl time.Duration) error
- func (n *NetBIOSNameServer) ReleaseName(name string, owner net.IP) error
- type PacketHandler
- type RedirectInfo
- type RedirectManager
- type Server
- type TCPServer
- type UDPServer
Constants ¶
const ( // Challenge timeouts and retries ChallengeTimeout = 2 * time.Second ChallengeRetries = 3 )
const ( NetBIOSNameLength = 16 // NetBIOS names are exactly 16 bytes EncodedNameLength = 32 // Each half-byte becomes a byte in encoded form ASCII_A = 0x41 )
Constants for name encoding
const ( // Operation codes OpNameQuery uint16 = 0x0000 OpRegistration uint16 = 0x2800 OpRelease uint16 = 0x3000 OpWACK uint16 = 0x3800 OpRefresh uint16 = 0x4000 OpRedirect uint16 = 0x4800 OpConflict uint16 = 0x5000 OpNodeStatus uint16 = 0x2100 // Response codes RcodeSuccess uint16 = 0x0000 RcodeFormatError uint16 = 0x0001 RcodeServerError uint16 = 0x0002 RcodeNameError uint16 = 0x0003 RcodeNotImpl uint16 = 0x0004 RcodeRefused uint16 = 0x0005 RcodeActive uint16 = 0x0006 RcodeConflict uint16 = 0x0007 // Flags FlagResponse uint16 = 0x8000 FlagAuthoritative uint16 = 0x0400 FlagTruncated uint16 = 0x0200 FlagRecursion uint16 = 0x0100 FlagBroadcast uint16 = 0x0010 // Question Type QuestionTypeNB uint16 = 0x0020 QuestionTypeNBSTAT uint16 = 0x0021 // Question Class QuestionClassIn uint16 = 0x0001 // Internet class )
Constants for packet types and flags
const ( // Default ports for NetBIOS name service DefaultNBNSPort = 137 // Timeouts and retry counts ReadTimeout = 5 * time.Second WriteTimeout = 5 * time.Second )
const ( // Default TCP port for NetBIOS name service DefaultNBNSTCPPort = 137 // TCP timeouts TCPReadTimeout = 30 * time.Second TCPWriteTimeout = 30 * time.Second // Maximum message size MaxTCPMessageSize = 65535 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ADDR_ENTRY ¶
POSITIVE NAME QUERY RESPONSE
type NBNSHeader ¶
type NBNSHeader struct {
TransactionID uint16
Flags uint16
Questions uint16
Answers uint16
Authority uint16
Additional uint16
}
NBNSHeader represents the header of a NetBIOS name service packet
type NBNSPacket ¶
type NBNSPacket struct {
Header NBNSHeader
Questions []NBNSQuestion
Answers []NBNSResourceRecord
Authority []NBNSResourceRecord
Additional []NBNSResourceRecord
}
NBNSPacket represents a complete NetBIOS name service packet
func (*NBNSPacket) Marshal ¶
func (p *NBNSPacket) Marshal() ([]byte, error)
Marshal encodes an NBNSPacket into a byte slice
type NBNSQuestion ¶
type NBNSQuestion struct {
Name *NetBIOSName
Type uint16
Class uint16
}
NBNSQuestion represents a question section in a NetBIOS name service packet
type NBNSResourceRecord ¶
type NBNSResourceRecord struct {
Name *NetBIOSName
Type uint16
Class uint16
TTL uint32
RDLength uint16
RData []byte
}
NBNSResourceRecord represents a resource record in a NetBIOS name service packet
type NameChallenger ¶
type NameChallenger struct {
// contains filtered or unexported fields
}
NameChallenger handles name conflict detection and resolution
func NewNameChallenger ¶
func NewNameChallenger(nbns *NetBIOSNameServer, handlers *PacketHandler) *NameChallenger
NewNameChallenger creates a new name challenger instance
func (*NameChallenger) ChallengeOwnership ¶
ChallengeOwnership verifies if a node still owns a name
func (*NameChallenger) DefendName ¶
func (c *NameChallenger) DefendName(packet *NBNSPacket, response *NBNSPacket)
DefendName actively defends a name against challenges
type NameRecord ¶
type NameRecord struct {
Name string
Type NameType
Status NameStatus
Owners []net.IP // IP addresses of nodes that own this name
TTL time.Time // Time-to-live for name registration
RefreshInterval time.Duration
ScopeID string // NetBIOS scope identifier
}
NameRecord represents a registered NetBIOS name and its attributes
type NameStatus ¶
type NameStatus uint8
NameStatus represents the current state of a name
const ( Active NameStatus = iota Conflict Releasing )
type NetBIOSName ¶
NetBIOSName represents a NetBIOS name with its scope
func FirstLevelDecode ¶
func FirstLevelDecode(encoded string) (*NetBIOSName, error)
FirstLevelDecode decodes a first level encoded NetBIOS name
func (*NetBIOSName) FirstLevelEncode ¶
func (n *NetBIOSName) FirstLevelEncode() (string, error)
FirstLevelEncode performs the first level encoding of a NetBIOS name as specified in RFC 1001 section 14.1
func (*NetBIOSName) Validate ¶
func (n *NetBIOSName) Validate() error
Validate checks if a NetBIOS name is valid
type NetBIOSNameServer ¶
type NetBIOSNameServer struct {
// contains filtered or unexported fields
}
NetBIOSNameServer represents a NetBIOS Name Server
func NewNetBIOSNameServer ¶
func NewNetBIOSNameServer(secured bool) *NetBIOSNameServer
NewNetBIOSNameServer creates a new NetBIOS Name Server instance
func (*NetBIOSNameServer) CleanExpiredNames ¶
func (n *NetBIOSNameServer) CleanExpiredNames()
CleanExpiredNames removes names that have exceeded their TTL
func (*NetBIOSNameServer) MarkNameConflict ¶
func (n *NetBIOSNameServer) MarkNameConflict(name string) error
MarkNameConflict marks a name as being in conflict
func (*NetBIOSNameServer) RefreshName ¶
func (n *NetBIOSNameServer) RefreshName(name string, owner net.IP) error
RefreshName updates the TTL for a name registration
func (*NetBIOSNameServer) RegisterName ¶
func (n *NetBIOSNameServer) RegisterName(name string, nameType NameType, owner net.IP, ttl time.Duration) error
RegisterName attempts to register a name with the name server
func (*NetBIOSNameServer) ReleaseName ¶
func (n *NetBIOSNameServer) ReleaseName(name string, owner net.IP) error
ReleaseName removes a name registration for a specific owner
type PacketHandler ¶
type PacketHandler struct {
// contains filtered or unexported fields
}
PacketHandler provides common packet handling methods for both TCP and UDP servers
func NewPacketHandler ¶
func NewPacketHandler(nbns *NetBIOSNameServer) *PacketHandler
NewPacketHandler creates a new packet handler instance
type RedirectInfo ¶
RedirectInfo contains information about where to redirect a client
type RedirectManager ¶
type RedirectManager struct {
// contains filtered or unexported fields
}
RedirectManager handles NBNS redirection
func NewRedirectManager ¶
func NewRedirectManager() *RedirectManager
NewRedirectManager creates a new redirect manager
func (*RedirectManager) AddRedirect ¶
func (r *RedirectManager) AddRedirect(scope string, serverIP net.IP, port uint16)
AddRedirect adds or updates a redirect mapping
func (*RedirectManager) GetRedirect ¶
func (r *RedirectManager) GetRedirect(scope string) (RedirectInfo, bool)
GetRedirect returns redirect information for a scope
func (*RedirectManager) HandleRedirect ¶
func (r *RedirectManager) HandleRedirect(request *NBNSPacket, response *NBNSPacket) bool
HandleRedirect modifies a response packet for redirection if needed
func (*RedirectManager) RemoveRedirect ¶
func (r *RedirectManager) RemoveRedirect(scope string)
RemoveRedirect removes a redirect mapping
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents a NetBIOS Name Server
type TCPServer ¶
type TCPServer struct {
// contains filtered or unexported fields
}
TCPServer represents a NetBIOS Name Server TCP component
func NewTCPServer ¶
func NewTCPServer(addr string, nbns *NetBIOSNameServer) (*TCPServer, error)
NewTCPServer creates a new NBNS TCP server instance
type UDPServer ¶
type UDPServer struct {
// contains filtered or unexported fields
}
UDPServer represents a NetBIOS Name Server UDP component
func NewUDPServer ¶
func NewUDPServer(addr string, nbns *NetBIOSNameServer) (*UDPServer, error)
NewUDPServer creates a new NBNS UDP server instance