Documentation
¶
Overview ¶
Package tcpin contains the tcpIn node implementation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TCPInConfig ¶
type TCPInConfig struct {
// Mode selects "listen" (accept connections on port) or
// "connect" (dial out to host:port) — legacy alias of the
// Node-RED "server" field; Server wins when set.
Mode string `json:"mode"`
// Server is the Node-RED connection selector: "server" listens
// on Port, "client" dials Host:Port.
Server string `json:"server"`
// Host is the remote host for connect mode (default 127.0.0.1).
Host string `json:"host"`
// Port is the listen port (listen mode) or remote port (connect).
Port int `json:"port"`
// Datamode selects the output framing: "stream" (default —
// emit each chunk, or each delimited part for utf8 with a
// delimiter), "single" (one message with the whole buffer at
// connection close), "length" (emit every Length bytes) or
// "timeout" (flush the buffered data after FlushMS ms idle).
Datamode string `json:"datamode"`
// Datatype selects the payload type: "utf8" (string — default,
// matching the previous always-string behavior), "buffer"
// (raw []byte) or "base64" (base64-encoded string).
Datatype string `json:"datatype"`
// Newline is the stream delimiter for utf8 payloads — a pointer
// so a blank-but-explicit "" (Node-RED 'no delimiter — emit each
// chunk') is distinct from unset (legacy "\n" line mode).
Newline *string `json:"newline"`
// Trim re-attaches the delimiter to each emitted part
// (Node-RED 're-attach' checkbox).
Trim bool `json:"trim"`
// Topic is stamped on emitted messages as metadata "topic".
Topic string `json:"topic"`
// Length is the fixed chunk size for datamode "length".
Length int `json:"length"`
// FlushMS is the idle flush interval (milliseconds) for
// datamode "timeout".
FlushMS int `json:"flushms"`
// Base64 is a deprecated Node-RED field — decoded, unused.
Base64 bool `json:"base64"`
// TLS names a tlsConfig node in the same workflow; in connect
// mode the dialed connection is upgraded to TLS with that material.
TLS string `json:"tls"`
}
TCPInConfig holds configuration for the tcpIn node.
type TCPInNode ¶
TCPInNode receives raw TCP data — either by listening for inbound connections or by connecting to a remote host. Received data is framed per the datamode (stream/single/length/timeout) and emitted downstream with the remote ip/port in Metadata. Accepted connections are registered in the workflow's shared tcpSessions map for tcpOut reply mode.
func NewTCPInNode ¶
func NewTCPInNode(node nodestore.NodeInterface, config *TCPInConfig, host nodebase.NodeHost) *TCPInNode
NewTCPInNode creates a new tcpIn node
func (*TCPInNode) Execute ¶
func (n *TCPInNode) Execute(ctx context.Context, input nodestore.MessageInterface) (nodestore.MessageInterface, error)
Execute activates the node: listen mode binds a socket and spawns an accept loop; connect mode dials and starts one reader goroutine.