Source
func open(address string, localAddr *net.Addr, timeout time.Duration, connect_timeout time.Duration, timeoutMode int,
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
package zbxcomms
import (
"bytes"
"compress/zlib"
"encoding/binary"
"encoding/json"
"errors"
"fmt"
"io"
"net"
"time"
"golang.zabbix.com/agent2/pkg/tls"
"golang.zabbix.com/sdk/log"
)
const (
TimeoutModeFixed = iota
TimeoutModeShift
)
const headerSize = 4 + 1 + 4 + 4
const tcpProtocol = byte(0x01)
const zlibCompress = byte(0x02)
const (
connStateAccept = iota + 1
connStateConnect
connStateEstablished
)
const (
responseFailed = "failed"
)
type Connection struct {
conn net.Conn
tlsConfig *tls.Config
state int
compress bool
timeout time.Duration
timeoutMode int
}
type Listener struct {
listener net.Listener
tlsconfig *tls.Config
}