Integrate BACKBEAT SDK and resolve KACHING license validation

Major integrations and fixes:
- Added BACKBEAT SDK integration for P2P operation timing
- Implemented beat-aware status tracking for distributed operations
- Added Docker secrets support for secure license management
- Resolved KACHING license validation via HTTPS/TLS
- Updated docker-compose configuration for clean stack deployment
- Disabled rollback policies to prevent deployment failures
- Added license credential storage (CHORUS-DEV-MULTI-001)

Technical improvements:
- BACKBEAT P2P operation tracking with phase management
- Enhanced configuration system with file-based secrets
- Improved error handling for license validation
- Clean separation of KACHING and CHORUS deployment stacks

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
anthonyrawlins
2025-09-06 07:56:26 +10:00
parent 543ab216f9
commit 9bdcbe0447
4730 changed files with 1480093 additions and 1916 deletions

24
vendor/github.com/mikioh/tcpinfo/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,24 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# Folders
_obj
_test
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
*.exe
*.test
*.prof

16
vendor/github.com/mikioh/tcpinfo/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,16 @@
language: go
os:
- linux
- osx
go:
- 1.11.6
- 1.12.1
- tip
script:
- go test -v -race
notifications:
email: false

23
vendor/github.com/mikioh/tcpinfo/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,23 @@
Copyright (c) 2016, Mikio Hara
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

6
vendor/github.com/mikioh/tcpinfo/README.md generated vendored Normal file
View File

@@ -0,0 +1,6 @@
Package tcpinfo implements encoding and decoding of TCP-level socket options regarding connection information.
[![GoDoc](https://godoc.org/github.com/mikioh/tcpinfo?status.png)](https://godoc.org/github.com/mikioh/tcpinfo)
[![Build Status](https://travis-ci.org/mikioh/tcpinfo.svg?branch=master)](https://travis-ci.org/mikioh/tcpinfo)
[![Build status](https://ci.appveyor.com/api/projects/status/7x72aqqg95d3qe57?svg=true)](https://ci.appveyor.com/project/mikioh/tcpinfo)
[![Go Report Card](https://goreportcard.com/badge/github.com/mikioh/tcpinfo)](https://goreportcard.com/report/github.com/mikioh/tcpinfo)

18
vendor/github.com/mikioh/tcpinfo/appveyor.yml generated vendored Normal file
View File

@@ -0,0 +1,18 @@
version: "{build}"
branches:
only:
- master
environment:
GOPATH: c:\gopath
install:
- set PATH=%GOPATH%\bin;c:\go\bin;%PATH%
- mkdir c:\gopath
- go get github.com/mikioh/tcp
- go get github.com/mikioh/tcpopt
- go get github.com/mikioh/tcpinfo
build_script:
- go test -v -race

20
vendor/github.com/mikioh/tcpinfo/doc.go generated vendored Normal file
View File

@@ -0,0 +1,20 @@
// Copyright 2016 Mikio Hara. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package tcpinfo implements encoding and decoding of TCP-level
// socket options regarding connection information.
//
// The Transmission Control Protocol (TCP) is defined in RFC 793.
// TCP Selective Acknowledgment Options is defined in RFC 2018.
// Management Information Base for the Transmission Control Protocol
// (TCP) is defined in RFC 4022.
// TCP Congestion Control is defined in RFC 5681.
// Computing TCP's Retransmission Timer is described in RFC 6298.
// TCP Options and Maximum Segment Size (MSS) is defined in RFC 6691.
// Shared Use of Experimental TCP Options is defined in RFC 6994.
// TCP Extensions for High Performance is defined in RFC 7323.
//
// NOTE: Older Linux kernels may not support extended TCP statistics
// described in RFC 4898.
package tcpinfo

157
vendor/github.com/mikioh/tcpinfo/option.go generated vendored Normal file
View File

@@ -0,0 +1,157 @@
// Copyright 2016 Mikio Hara. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package tcpinfo
import (
"encoding/json"
"time"
"github.com/mikioh/tcpopt"
)
var (
_ json.Marshaler = &Info{}
_ tcpopt.Option = &Info{}
)
// An Info represents connection information.
//
// Only supported on Darwin, FreeBSD, Linux and NetBSD.
type Info struct {
State State `json:"state"` // connection state
Options []Option `json:"opts,omitempty"` // requesting options
PeerOptions []Option `json:"peer_opts,omitempty"` // options requested from peer
SenderMSS MaxSegSize `json:"snd_mss"` // maximum segment size for sender in bytes
ReceiverMSS MaxSegSize `json:"rcv_mss"` // maximum segment size for receiver in bytes
RTT time.Duration `json:"rtt"` // round-trip time
RTTVar time.Duration `json:"rttvar"` // round-trip time variation
RTO time.Duration `json:"rto"` // retransmission timeout
ATO time.Duration `json:"ato"` // delayed acknowledgement timeout [Linux only]
LastDataSent time.Duration `json:"last_data_sent"` // since last data sent [Linux only]
LastDataReceived time.Duration `json:"last_data_rcvd"` // since last data received [FreeBSD and Linux]
LastAckReceived time.Duration `json:"last_ack_rcvd"` // since last ack received [Linux only]
FlowControl *FlowControl `json:"flow_ctl,omitempty"` // flow control information
CongestionControl *CongestionControl `json:"cong_ctl,omitempty"` // congestion control information
Sys *SysInfo `json:"sys,omitempty"` // platform-specific information
}
// A FlowControl represents flow control information.
type FlowControl struct {
ReceiverWindow uint `json:"rcv_wnd"` // advertised receiver window in bytes
}
// A CongestionControl represents congestion control information.
type CongestionControl struct {
SenderSSThreshold uint `json:"snd_ssthresh"` // slow start threshold for sender in bytes or # of segments
ReceiverSSThreshold uint `json:"rcv_ssthresh"` // slow start threshold for receiver in bytes [Linux only]
SenderWindowBytes uint `json:"snd_cwnd_bytes"` // congestion window for sender in bytes [Darwin and FreeBSD]
SenderWindowSegs uint `json:"snd_cwnd_segs"` // congestion window for sender in # of segments [Linux and NetBSD]
}
// Level implements the Level method of tcpopt.Option interface.
func (i *Info) Level() int { return options[soInfo].level }
// Name implements the Name method of tcpopt.Option interface.
func (i *Info) Name() int { return options[soInfo].name }
// MarshalJSON implements the MarshalJSON method of json.Marshaler
// interface.
func (i *Info) MarshalJSON() ([]byte, error) {
raw := make(map[string]interface{})
raw["state"] = i.State.String()
if len(i.Options) > 0 {
opts := make(map[string]interface{})
for _, opt := range i.Options {
opts[opt.Kind().String()] = opt
}
raw["opts"] = opts
}
if len(i.PeerOptions) > 0 {
opts := make(map[string]interface{})
for _, opt := range i.PeerOptions {
opts[opt.Kind().String()] = opt
}
raw["peer_opts"] = opts
}
raw["snd_mss"] = i.SenderMSS
raw["rcv_mss"] = i.ReceiverMSS
raw["rtt"] = i.RTT
raw["rttvar"] = i.RTTVar
raw["rto"] = i.RTO
raw["ato"] = i.ATO
raw["last_data_sent"] = i.LastDataSent
raw["last_data_rcvd"] = i.LastDataReceived
raw["last_ack_rcvd"] = i.LastAckReceived
if i.FlowControl != nil {
raw["flow_ctl"] = i.FlowControl
}
if i.CongestionControl != nil {
raw["cong_ctl"] = i.CongestionControl
}
if i.Sys != nil {
raw["sys"] = i.Sys
}
return json.Marshal(&raw)
}
// A CCInfo represents raw information of congestion control
// algorithm.
//
// Only supported on Linux.
type CCInfo struct {
Raw []byte `json:"raw,omitempty"`
}
// Level implements the Level method of tcpopt.Option interface.
func (cci *CCInfo) Level() int { return options[soCCInfo].level }
// Name implements the Name method of tcpopt.Option interface.
func (cci *CCInfo) Name() int { return options[soCCInfo].name }
// Marshal implements the Marshal method of tcpopt.Option interface.
func (cci *CCInfo) Marshal() ([]byte, error) { return cci.Raw, nil }
func parseCCInfo(b []byte) (tcpopt.Option, error) { return &CCInfo{Raw: b}, nil }
// A CCAlgorithm represents a name of congestion control algorithm.
//
// Only supported on Linux.
type CCAlgorithm string
// Level implements the Level method of tcpopt.Option interface.
func (cca CCAlgorithm) Level() int { return options[soCCAlgo].level }
// Name implements the Name method of tcpopt.Option interface.
func (cca CCAlgorithm) Name() int { return options[soCCAlgo].name }
// Marshal implements the Marshal method of tcpopt.Option interface.
func (cca CCAlgorithm) Marshal() ([]byte, error) {
if cca == "" {
return nil, nil
}
return []byte(cca), nil
}
func parseCCAlgorithm(b []byte) (tcpopt.Option, error) { return CCAlgorithm(b), nil }
// A CCAlgorithmInfo represents congestion control algorithm
// information.
//
// Only supported on Linux.
type CCAlgorithmInfo interface {
Algorithm() string
}
// ParseCCAlgorithmInfo parses congestion control algorithm
// information.
//
// Only supported on Linux.
func ParseCCAlgorithmInfo(name string, b []byte) (CCAlgorithmInfo, error) {
ccai, err := parseCCAlgorithmInfo(name, b)
if err != nil {
return nil, err
}
return ccai, nil
}

34
vendor/github.com/mikioh/tcpinfo/sys.go generated vendored Normal file
View File

@@ -0,0 +1,34 @@
// Copyright 2016 Mikio Hara. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package tcpinfo
import "github.com/mikioh/tcpopt"
func init() {
for _, o := range options {
if o.name == 0 || o.parseFn == nil {
continue
}
tcpopt.Register(o.level, o.name, o.parseFn)
}
}
const (
ianaProtocolTCP = 0x6
)
const (
soInfo = iota
soCCInfo
soCCAlgo
soMax
)
// An option represents a binding for socket option.
type option struct {
level int // option level
name int // option name, must be equal or greater than 1
parseFn func([]byte) (tcpopt.Option, error)
}

96
vendor/github.com/mikioh/tcpinfo/sys_bsd.go generated vendored Normal file
View File

@@ -0,0 +1,96 @@
// Copyright 2016 Mikio Hara. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build freebsd netbsd
package tcpinfo
import (
"errors"
"runtime"
"time"
"unsafe"
"github.com/mikioh/tcpopt"
)
var options = [soMax]option{
soInfo: {ianaProtocolTCP, sysTCP_INFO, parseInfo},
}
// Marshal implements the Marshal method of tcpopt.Option interface.
func (i *Info) Marshal() ([]byte, error) { return (*[sizeofTCPInfo]byte)(unsafe.Pointer(i))[:], nil }
// A SysInfo represents platform-specific information.
type SysInfo struct {
SenderWindowBytes uint `json:"snd_wnd_bytes"` // advertised sender window in bytes [FreeBSD]
SenderWindowSegs uint `json:"snd_wnd_segs"` // advertised sender window in # of segments [NetBSD]
NextEgressSeq uint `json:"egress_seq"` // next egress seq. number
NextIngressSeq uint `json:"ingress_seq"` // next ingress seq. number
RetransSegs uint `json:"retrans_segs"` // # of retransmit segments sent
OutOfOrderSegs uint `json:"ooo_segs"` // # of out-of-order segments received
ZeroWindowUpdates uint `json:"zerownd_updates"` // # of zero-window updates sent
Offloading bool `json:"offloading"` // TCP offload processing
}
var sysStates = [11]State{Closed, Listen, SynSent, SynReceived, Established, CloseWait, FinWait1, Closing, LastAck, FinWait2, TimeWait}
func parseInfo(b []byte) (tcpopt.Option, error) {
if len(b) < sizeofTCPInfo {
return nil, errors.New("short buffer")
}
ti := (*tcpInfo)(unsafe.Pointer(&b[0]))
i := &Info{State: sysStates[ti.State]}
if ti.Options&sysTCPI_OPT_WSCALE != 0 {
i.Options = append(i.Options, WindowScale(ti.Pad_cgo_0[0]>>4))
i.PeerOptions = append(i.PeerOptions, WindowScale(ti.Pad_cgo_0[0]&0x0f))
}
if ti.Options&sysTCPI_OPT_SACK != 0 {
i.Options = append(i.Options, SACKPermitted(true))
i.PeerOptions = append(i.PeerOptions, SACKPermitted(true))
}
if ti.Options&sysTCPI_OPT_TIMESTAMPS != 0 {
i.Options = append(i.Options, Timestamps(true))
i.PeerOptions = append(i.PeerOptions, Timestamps(true))
}
i.SenderMSS = MaxSegSize(ti.Snd_mss)
i.ReceiverMSS = MaxSegSize(ti.Rcv_mss)
i.RTT = time.Duration(ti.Rtt) * time.Microsecond
i.RTTVar = time.Duration(ti.Rttvar) * time.Microsecond
i.RTO = time.Duration(ti.Rto) * time.Microsecond
i.ATO = time.Duration(ti.X__tcpi_ato) * time.Microsecond
i.LastDataSent = time.Duration(ti.X__tcpi_last_data_sent) * time.Microsecond
i.LastDataReceived = time.Duration(ti.Last_data_recv) * time.Microsecond
i.LastAckReceived = time.Duration(ti.X__tcpi_last_ack_recv) * time.Microsecond
i.FlowControl = &FlowControl{
ReceiverWindow: uint(ti.Rcv_space),
}
i.CongestionControl = &CongestionControl{
SenderSSThreshold: uint(ti.Snd_ssthresh),
ReceiverSSThreshold: uint(ti.X__tcpi_rcv_ssthresh),
}
i.Sys = &SysInfo{
NextEgressSeq: uint(ti.Snd_nxt),
NextIngressSeq: uint(ti.Rcv_nxt),
RetransSegs: uint(ti.Snd_rexmitpack),
OutOfOrderSegs: uint(ti.Rcv_ooopack),
ZeroWindowUpdates: uint(ti.Snd_zerowin),
}
if ti.Options&sysTCPI_OPT_TOE != 0 {
i.Sys.Offloading = true
}
switch runtime.GOOS {
case "freebsd":
i.CongestionControl.SenderWindowBytes = uint(ti.Snd_cwnd)
i.Sys.SenderWindowBytes = uint(ti.Snd_wnd)
case "netbsd":
i.CongestionControl.SenderWindowSegs = uint(ti.Snd_cwnd)
i.Sys.SenderWindowSegs = uint(ti.Snd_wnd)
}
return i, nil
}
func parseCCAlgorithmInfo(name string, b []byte) (CCAlgorithmInfo, error) {
return nil, errors.New("operation not supported")
}

114
vendor/github.com/mikioh/tcpinfo/sys_darwin.go generated vendored Normal file
View File

@@ -0,0 +1,114 @@
// Copyright 2016 Mikio Hara. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package tcpinfo
import (
"errors"
"time"
"unsafe"
"github.com/mikioh/tcpopt"
)
var options = [soMax]option{
soInfo: {ianaProtocolTCP, sysTCP_CONNECTION_INFO, parseInfo},
}
// Marshal implements the Marshal method of tcpopt.Option interface.
func (i *Info) Marshal() ([]byte, error) {
return (*[sizeofTCPConnectionInfo]byte)(unsafe.Pointer(i))[:], nil
}
type SysFlags uint
func (f SysFlags) String() string {
s := ""
for i, name := range []string{
"loss recovery",
"reordering detected",
} {
if f&(1<<uint(i)) != 0 {
if s != "" {
s += "|"
}
s += name
}
}
if s == "" {
s = "0"
}
return s
}
// A SysInfo represents platform-specific information.
type SysInfo struct {
Flags SysFlags `json:"flags"` // flags
SenderWindow uint `json:"snd_wnd"` // advertised sender window in bytes
SenderInUse uint `json:"snd_inuse"` // bytes in send buffer including inflight data
SRTT time.Duration `json:"srtt"` // smoothed round-trip time
SegsSent uint64 `json:"segs_sent"` // # of segements sent
BytesSent uint64 `json:"bytes_sent"` // # of bytes sent
RetransBytes uint64 `json:"retrans_bytes"` // # of retransmitted bytes
SegsReceived uint64 `json:"segs_rcvd"` // # of segments received
BytesReceived uint64 `json:"bytes_rcvd"` // # of bytes received
OutOfOrderBytesReceived uint64 `json:"ooo_bytes_rcvd"` // # of our-of-order bytes received
RetransSegs uint64 `json:"retrans_segs"` // # of retransmitted segments
}
var sysStates = [11]State{Closed, Listen, SynSent, SynReceived, Established, CloseWait, FinWait1, Closing, LastAck, FinWait2, TimeWait}
const sizeofTCPConnectionInfoV15 = 0x68
func parseInfo(b []byte) (tcpopt.Option, error) {
if len(b) < sizeofTCPConnectionInfoV15 {
return nil, errors.New("short buffer")
}
tci := (*tcpConnectionInfo)(unsafe.Pointer(&b[0]))
i := &Info{State: sysStates[tci.State]}
if tci.Options&sysTCPCI_OPT_WSCALE != 0 {
i.Options = append(i.Options, WindowScale(tci.Snd_wscale))
i.PeerOptions = append(i.PeerOptions, WindowScale(tci.Rcv_wscale))
}
if tci.Options&sysTCPCI_OPT_SACK != 0 {
i.Options = append(i.Options, SACKPermitted(true))
i.PeerOptions = append(i.PeerOptions, SACKPermitted(true))
}
if tci.Options&sysTCPCI_OPT_TIMESTAMPS != 0 {
i.Options = append(i.Options, Timestamps(true))
i.PeerOptions = append(i.PeerOptions, Timestamps(true))
}
i.SenderMSS = MaxSegSize(tci.Maxseg)
i.ReceiverMSS = MaxSegSize(tci.Maxseg)
i.RTT = time.Duration(tci.Rttcur) * time.Millisecond
i.RTTVar = time.Duration(tci.Rttvar) * time.Millisecond
i.RTO = time.Duration(tci.Rto) * time.Millisecond
i.FlowControl = &FlowControl{
ReceiverWindow: uint(tci.Rcv_wnd),
}
i.CongestionControl = &CongestionControl{
SenderSSThreshold: uint(tci.Snd_ssthresh),
SenderWindowBytes: uint(tci.Snd_cwnd),
}
i.Sys = &SysInfo{
Flags: SysFlags(tci.Flags),
SenderWindow: uint(tci.Snd_wnd),
SenderInUse: uint(tci.Snd_sbbytes),
SRTT: time.Duration(tci.Srtt) * time.Millisecond,
SegsSent: uint64(tci.Txpackets),
BytesSent: uint64(tci.Txbytes),
RetransBytes: uint64(tci.Txretransmitbytes),
SegsReceived: uint64(tci.Rxpackets),
BytesReceived: uint64(tci.Rxbytes),
OutOfOrderBytesReceived: uint64(tci.Rxoutoforderbytes),
}
if len(b) > sizeofTCPConnectionInfoV15 {
i.Sys.RetransSegs = uint64(tci.Txretransmitpackets)
}
return i, nil
}
func parseCCAlgorithmInfo(name string, b []byte) (CCAlgorithmInfo, error) {
return nil, errors.New("operation not supported")
}

331
vendor/github.com/mikioh/tcpinfo/sys_linux.go generated vendored Normal file
View File

@@ -0,0 +1,331 @@
// Copyright 2016 Mikio Hara. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package tcpinfo
import (
"errors"
"strings"
"time"
"unsafe"
"github.com/mikioh/tcpopt"
)
var options = [soMax]option{
soInfo: {ianaProtocolTCP, sysTCP_INFO, parseInfo},
soCCInfo: {ianaProtocolTCP, sysTCP_CC_INFO, parseCCInfo},
soCCAlgo: {ianaProtocolTCP, sysTCP_CONGESTION, parseCCAlgorithm},
}
// Marshal implements the Marshal method of tcpopt.Option interface.
func (i *Info) Marshal() ([]byte, error) { return (*[sizeofTCPInfo]byte)(unsafe.Pointer(i))[:], nil }
// A CAState represents a state of congestion avoidance.
type CAState int
var caStates = map[CAState]string{
CAOpen: "open",
CADisorder: "disorder",
CACWR: "congestion window reduced",
CARecovery: "recovery",
CALoss: "loss",
}
func (st CAState) String() string {
s, ok := caStates[st]
if !ok {
return "<nil>"
}
return s
}
// A SysInfo represents platform-specific information.
type SysInfo struct {
PathMTU uint `json:"path_mtu"` // path maximum transmission unit
AdvertisedMSS MaxSegSize `json:"adv_mss"` // advertised maximum segment size
CAState CAState `json:"ca_state"` // state of congestion avoidance
Retransmissions uint `json:"rexmits"` // # of retranmissions on timeout invoked
Backoffs uint `json:"backoffs"` // # of times retransmission backoff timer invoked
WindowOrKeepAliveProbes uint `json:"wnd_ka_probes"` // # of window or keep alive probes sent
UnackedSegs uint `json:"unacked_segs"` // # of unack'd segments
SackedSegs uint `json:"sacked_segs"` // # of sack'd segments
LostSegs uint `json:"lost_segs"` // # of lost segments
RetransSegs uint `json:"retrans_segs"` // # of retransmitting segments in transmission queue
ForwardAckSegs uint `json:"fack_segs"` // # of forward ack segments in transmission queue
ReorderedSegs uint `json:"reord_segs"` // # of reordered segments allowed
ReceiverRTT time.Duration `json:"rcv_rtt"` // current RTT for receiver
TotalRetransSegs uint `json:"total_retrans_segs"` // # of retransmitted segments
PacingRate uint64 `json:"pacing_rate"` // pacing rate
ThruBytesAcked uint64 `json:"thru_bytes_acked"` // # of bytes for which cumulative acknowledgments have been received
ThruBytesReceived uint64 `json:"thru_bytes_rcvd"` // # of bytes for which cumulative acknowledgments have been sent
SegsOut uint `json:"segs_out"` // # of segments sent
SegsIn uint `json:"segs_in"` // # of segments received
NotSentBytes uint `json:"not_sent_bytes"` // # of bytes not sent yet
MinRTT time.Duration `json:"min_rtt"` // current measured minimum RTT; zero means not available
DataSegsOut uint `json:"data_segs_out"` // # of segments sent containing a positive length data segment
DataSegsIn uint `json:"data_segs_in"` // # of segments received containing a positive length data segment
}
var sysStates = [12]State{Unknown, Established, SynSent, SynReceived, FinWait1, FinWait2, TimeWait, Closed, CloseWait, LastAck, Listen, Closing}
const (
sizeofTCPInfoV4_9 = 0xa0
sizeofTCPInfoV3_19 = 0x78
sizeofTCPInfoV2_6_10 = 0x57
)
func parseInfo(b []byte) (tcpopt.Option, error) {
if len(b) < sizeofTCPInfoV4_9 {
return parseInfo3_19(b)
}
ti := (*tcpInfo)(unsafe.Pointer(&b[0]))
i := &Info{State: sysStates[ti.State]}
if ti.Options&sysTCPI_OPT_WSCALE != 0 {
i.Options = append(i.Options, WindowScale(ti.Pad_cgo_0[0]>>4))
i.PeerOptions = append(i.PeerOptions, WindowScale(ti.Pad_cgo_0[0]&0x0f))
}
if ti.Options&sysTCPI_OPT_SACK != 0 {
i.Options = append(i.Options, SACKPermitted(true))
i.PeerOptions = append(i.PeerOptions, SACKPermitted(true))
}
if ti.Options&sysTCPI_OPT_TIMESTAMPS != 0 {
i.Options = append(i.Options, Timestamps(true))
i.PeerOptions = append(i.PeerOptions, Timestamps(true))
}
i.SenderMSS = MaxSegSize(ti.Snd_mss)
i.ReceiverMSS = MaxSegSize(ti.Rcv_mss)
i.RTT = time.Duration(ti.Rtt) * time.Microsecond
i.RTTVar = time.Duration(ti.Rttvar) * time.Microsecond
i.RTO = time.Duration(ti.Rto) * time.Microsecond
i.ATO = time.Duration(ti.Ato) * time.Microsecond
i.LastDataSent = time.Duration(ti.Last_data_sent) * time.Millisecond
i.LastDataReceived = time.Duration(ti.Last_data_recv) * time.Millisecond
i.LastAckReceived = time.Duration(ti.Last_ack_recv) * time.Millisecond
i.FlowControl = &FlowControl{
ReceiverWindow: uint(ti.Rcv_space),
}
i.CongestionControl = &CongestionControl{
SenderSSThreshold: uint(ti.Snd_ssthresh),
ReceiverSSThreshold: uint(ti.Rcv_ssthresh),
SenderWindowSegs: uint(ti.Snd_cwnd),
}
i.Sys = &SysInfo{
PathMTU: uint(ti.Pmtu),
AdvertisedMSS: MaxSegSize(ti.Advmss),
CAState: CAState(ti.Ca_state),
Retransmissions: uint(ti.Retransmits),
Backoffs: uint(ti.Backoff),
WindowOrKeepAliveProbes: uint(ti.Probes),
UnackedSegs: uint(ti.Unacked),
SackedSegs: uint(ti.Sacked),
LostSegs: uint(ti.Lost),
RetransSegs: uint(ti.Retrans),
ForwardAckSegs: uint(ti.Fackets),
ReorderedSegs: uint(ti.Reordering),
ReceiverRTT: time.Duration(ti.Rcv_rtt) * time.Microsecond,
TotalRetransSegs: uint(ti.Total_retrans),
PacingRate: uint64(ti.Pacing_rate),
ThruBytesAcked: uint64(ti.Bytes_acked),
ThruBytesReceived: uint64(ti.Bytes_received),
SegsIn: uint(ti.Segs_in),
SegsOut: uint(ti.Segs_out),
NotSentBytes: uint(ti.Notsent_bytes),
MinRTT: time.Duration(ti.Min_rtt) * time.Microsecond,
DataSegsIn: uint(ti.Data_segs_in),
DataSegsOut: uint(ti.Data_segs_out),
}
return i, nil
}
func parseInfo3_19(b []byte) (tcpopt.Option, error) {
if len(b) < sizeofTCPInfoV3_19 {
return parseInfo2_6_10(b)
}
ti := (*tcpInfo3_19)(unsafe.Pointer(&b[0]))
i := &Info{State: sysStates[ti.State]}
if ti.Options&sysTCPI_OPT_WSCALE != 0 {
i.Options = append(i.Options, WindowScale(ti.Pad_cgo_0[0]>>4))
i.PeerOptions = append(i.PeerOptions, WindowScale(ti.Pad_cgo_0[0]&0x0f))
}
if ti.Options&sysTCPI_OPT_SACK != 0 {
i.Options = append(i.Options, SACKPermitted(true))
i.PeerOptions = append(i.PeerOptions, SACKPermitted(true))
}
if ti.Options&sysTCPI_OPT_TIMESTAMPS != 0 {
i.Options = append(i.Options, Timestamps(true))
i.PeerOptions = append(i.PeerOptions, Timestamps(true))
}
i.SenderMSS = MaxSegSize(ti.Snd_mss)
i.ReceiverMSS = MaxSegSize(ti.Rcv_mss)
i.RTT = time.Duration(ti.Rtt) * time.Microsecond
i.RTTVar = time.Duration(ti.Rttvar) * time.Microsecond
i.RTO = time.Duration(ti.Rto) * time.Microsecond
i.ATO = time.Duration(ti.Ato) * time.Microsecond
i.LastDataSent = time.Duration(ti.Last_data_sent) * time.Millisecond
i.LastDataReceived = time.Duration(ti.Last_data_recv) * time.Millisecond
i.LastAckReceived = time.Duration(ti.Last_ack_recv) * time.Millisecond
i.FlowControl = &FlowControl{
ReceiverWindow: uint(ti.Rcv_space),
}
i.CongestionControl = &CongestionControl{
SenderSSThreshold: uint(ti.Snd_ssthresh),
ReceiverSSThreshold: uint(ti.Rcv_ssthresh),
SenderWindowSegs: uint(ti.Snd_cwnd),
}
i.Sys = &SysInfo{
PathMTU: uint(ti.Pmtu),
AdvertisedMSS: MaxSegSize(ti.Advmss),
CAState: CAState(ti.Ca_state),
Retransmissions: uint(ti.Retransmits),
Backoffs: uint(ti.Backoff),
WindowOrKeepAliveProbes: uint(ti.Probes),
UnackedSegs: uint(ti.Unacked),
SackedSegs: uint(ti.Sacked),
LostSegs: uint(ti.Lost),
RetransSegs: uint(ti.Retrans),
ForwardAckSegs: uint(ti.Fackets),
ReorderedSegs: uint(ti.Reordering),
ReceiverRTT: time.Duration(ti.Rcv_rtt) * time.Microsecond,
TotalRetransSegs: uint(ti.Total_retrans),
PacingRate: uint64(ti.Pacing_rate),
}
return i, nil
}
func parseInfo2_6_10(b []byte) (tcpopt.Option, error) {
if len(b) < sizeofTCPInfoV2_6_10 {
return nil, errors.New("short buffer")
}
ti := (*tcpInfo2_6_10)(unsafe.Pointer(&b[0]))
i := &Info{State: sysStates[ti.State]}
if ti.Options&sysTCPI_OPT_WSCALE != 0 {
i.Options = append(i.Options, WindowScale(ti.Pad_cgo_0[0]>>4))
i.PeerOptions = append(i.PeerOptions, WindowScale(ti.Pad_cgo_0[0]&0x0f))
}
if ti.Options&sysTCPI_OPT_SACK != 0 {
i.Options = append(i.Options, SACKPermitted(true))
i.PeerOptions = append(i.PeerOptions, SACKPermitted(true))
}
if ti.Options&sysTCPI_OPT_TIMESTAMPS != 0 {
i.Options = append(i.Options, Timestamps(true))
i.PeerOptions = append(i.PeerOptions, Timestamps(true))
}
i.SenderMSS = MaxSegSize(ti.Snd_mss)
i.ReceiverMSS = MaxSegSize(ti.Rcv_mss)
i.RTT = time.Duration(ti.Rtt) * time.Microsecond
i.RTTVar = time.Duration(ti.Rttvar) * time.Microsecond
i.RTO = time.Duration(ti.Rto) * time.Microsecond
i.ATO = time.Duration(ti.Ato) * time.Microsecond
i.LastDataSent = time.Duration(ti.Last_data_sent) * time.Millisecond
i.LastDataReceived = time.Duration(ti.Last_data_recv) * time.Millisecond
i.LastAckReceived = time.Duration(ti.Last_ack_recv) * time.Millisecond
i.FlowControl = &FlowControl{
ReceiverWindow: uint(ti.Rcv_space),
}
i.CongestionControl = &CongestionControl{
SenderSSThreshold: uint(ti.Snd_ssthresh),
ReceiverSSThreshold: uint(ti.Rcv_ssthresh),
SenderWindowSegs: uint(ti.Snd_cwnd),
}
i.Sys = &SysInfo{
PathMTU: uint(ti.Pmtu),
AdvertisedMSS: MaxSegSize(ti.Advmss),
CAState: CAState(ti.Ca_state),
Retransmissions: uint(ti.Retransmits),
Backoffs: uint(ti.Backoff),
WindowOrKeepAliveProbes: uint(ti.Probes),
UnackedSegs: uint(ti.Unacked),
SackedSegs: uint(ti.Sacked),
LostSegs: uint(ti.Lost),
RetransSegs: uint(ti.Retrans),
ForwardAckSegs: uint(ti.Fackets),
ReorderedSegs: uint(ti.Reordering),
ReceiverRTT: time.Duration(ti.Rcv_rtt) * time.Microsecond,
TotalRetransSegs: uint(ti.Total_retrans),
}
return i, nil
}
// A VegasInfo represents Vegas congestion control information.
type VegasInfo struct {
Enabled bool `json:"enabled"`
RoundTrips uint `json:"rnd_trips"` // # of round-trips
RTT time.Duration `json:"rtt"` // round-trip time
MinRTT time.Duration `json:"min_rtt"` // minimum round-trip time
}
// Algorithm implements the Algorithm method of CCAlgorithmInfo
// interface.
func (vi *VegasInfo) Algorithm() string { return "vegas" }
// A CEState represents a state of ECN congestion encountered (CE)
// codepoint.
type CEState int
// A DCTCPInfo represents Datacenter TCP congestion control
// information.
type DCTCPInfo struct {
Enabled bool `json:"enabled"`
CEState CEState `json:"ce_state"` // state of ECN CE codepoint
Alpha uint `json:"alpha"` // fraction of bytes sent
ECNAckedBytes uint `json:"ecn_acked"` // # of acked bytes with ECN
TotalAckedBytes uint `json:"total_acked"` // total # of acked bytes
}
// Algorithm implements the Algorithm method of CCAlgorithmInfo
// interface.
func (di *DCTCPInfo) Algorithm() string { return "dctcp" }
// A BBRInfo represents Bottleneck Bandwidth and Round-trip
// propagation time-based congestion control information.
type BBRInfo struct {
MaxBW uint64 `json:"max_bw"` // maximum-filtered bandwidth in bps
MinRTT time.Duration `json:"min_rtt"` // minimum-filtered round-trip time
PacingGain uint `json:"pacing_gain"` // pacing gain shifted left 8 bits
CongWindowGain uint `json:"cwnd_gain"` // congestion window gain shifted left 8 bits
}
// Algorithm implements the Algorithm method of CCAlgorithmInfo
// interface.
func (bi *BBRInfo) Algorithm() string { return "bbr" }
func parseCCAlgorithmInfo(name string, b []byte) (CCAlgorithmInfo, error) {
if strings.HasPrefix(name, "dctcp") {
if len(b) < sizeofTCPDCTCPInfo {
return nil, errors.New("short buffer")
}
sdi := (*tcpDCTCPInfo)(unsafe.Pointer(&b[0]))
di := &DCTCPInfo{Alpha: uint(sdi.Alpha)}
if sdi.Enabled != 0 {
di.Enabled = true
}
return di, nil
}
if strings.HasPrefix(name, "bbr") {
if len(b) < sizeofTCPBBRInfo {
return nil, errors.New("short buffer")
}
sbi := (*tcpBBRInfo)(unsafe.Pointer(&b[0]))
return &BBRInfo{
MaxBW: uint64(sbi.Bw_hi)<<32 | uint64(sbi.Bw_lo),
MinRTT: time.Duration(sbi.Min_rtt) * time.Microsecond,
PacingGain: uint(sbi.Pacing_gain),
CongWindowGain: uint(sbi.Cwnd_gain),
}, nil
}
if len(b) < sizeofTCPVegasInfo {
return nil, errors.New("short buffer")
}
svi := (*tcpVegasInfo)(unsafe.Pointer(&b[0]))
vi := &VegasInfo{
RoundTrips: uint(svi.Rttcnt),
RTT: time.Duration(svi.Rtt) * time.Microsecond,
MinRTT: time.Duration(svi.Minrtt) * time.Microsecond,
}
if svi.Enabled != 0 {
vi.Enabled = true
}
return vi, nil
}

31
vendor/github.com/mikioh/tcpinfo/sys_stub.go generated vendored Normal file
View File

@@ -0,0 +1,31 @@
// Copyright 2016 Mikio Hara. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build !darwin,!freebsd,!linux,!netbsd
package tcpinfo
import (
"errors"
"github.com/mikioh/tcpopt"
)
var options [soMax]option
// Marshal implements the Marshal method of tcpopt.Option interface.
func (i *Info) Marshal() ([]byte, error) {
return nil, errors.New("operation not supported")
}
// A SysInfo represents platform-specific information.
type SysInfo struct{}
func parseInfo(b []byte) (tcpopt.Option, error) {
return nil, errors.New("operation not supported")
}
func parseCCAlgorithmInfo(name string, b []byte) (CCAlgorithmInfo, error) {
return nil, errors.New("operation not supported")
}

101
vendor/github.com/mikioh/tcpinfo/tcp.go generated vendored Normal file
View File

@@ -0,0 +1,101 @@
// Copyright 2016 Mikio Hara. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package tcpinfo
// A State represents a state of connection.
type State int
const (
Unknown State = iota
Closed
Listen
SynSent
SynReceived
Established
FinWait1
FinWait2
CloseWait
LastAck
Closing
TimeWait
)
var states = map[State]string{
Unknown: "unknown",
Closed: "closed",
Listen: "listen",
SynSent: "syn-sent",
SynReceived: "syn-received",
Established: "established",
FinWait1: "fin-wait-1",
FinWait2: "fin-wait-2",
CloseWait: "close-wait",
LastAck: "last-ack",
Closing: "closing",
TimeWait: "time-wait",
}
func (st State) String() string {
s, ok := states[st]
if !ok {
return "<nil>"
}
return s
}
// An OptionKind represents an option kind.
type OptionKind int
const (
KindMaxSegSize OptionKind = 2
KindWindowScale OptionKind = 3
KindSACKPermitted OptionKind = 4
KindTimestamps OptionKind = 8
)
var optionKinds = map[OptionKind]string{
KindMaxSegSize: "mss",
KindWindowScale: "wscale",
KindSACKPermitted: "sack",
KindTimestamps: "tmstamps",
}
func (k OptionKind) String() string {
s, ok := optionKinds[k]
if !ok {
return "<nil>"
}
return s
}
// An Option represents an option.
type Option interface {
Kind() OptionKind
}
// A MaxSegSize represents a maxiumum segment size option.
type MaxSegSize uint
// Kind returns an option kind field.
func (mss MaxSegSize) Kind() OptionKind { return KindMaxSegSize }
// A WindowScale represents a windows scale option.
type WindowScale int
// Kind returns an option kind field.
func (ws WindowScale) Kind() OptionKind { return KindWindowScale }
// A SACKPermitted reports whether a selective acknowledgment
// permitted option is enabled.
type SACKPermitted bool
// Kind returns an option kind field.
func (sp SACKPermitted) Kind() OptionKind { return KindSACKPermitted }
// A Timestamps reports whether a timestamps option is enabled.
type Timestamps bool
// Kind returns an option kind field.
func (ts Timestamps) Kind() OptionKind { return KindTimestamps }

35
vendor/github.com/mikioh/tcpinfo/zsys_2_6_10_linux.go generated vendored Normal file
View File

@@ -0,0 +1,35 @@
package tcpinfo
type tcpInfo2_6_10 struct {
State uint8
Ca_state uint8
Retransmits uint8
Probes uint8
Backoff uint8
Options uint8
Pad_cgo_0 [2]byte
Rto uint32
Ato uint32
Snd_mss uint32
Rcv_mss uint32
Unacked uint32
Sacked uint32
Lost uint32
Retrans uint32
Fackets uint32
Last_data_sent uint32
Last_ack_sent uint32
Last_data_recv uint32
Last_ack_recv uint32
Pmtu uint32
Rcv_ssthresh uint32
Rtt uint32
Rttvar uint32
Snd_ssthresh uint32
Snd_cwnd uint32
Advmss uint32
Reordering uint32
Rcv_rtt uint32
Rcv_space uint32
Total_retrans uint32
}

42
vendor/github.com/mikioh/tcpinfo/zsys_3_19_linux.go generated vendored Normal file
View File

@@ -0,0 +1,42 @@
// Created by cgo -godefs - DO NOT EDIT
// go tool cgo -godefs defs_linux.go
// it was edited to remove duplicated code. Also removed last field (tcpi_last_new_data_recv)
// because we do not use it and getsockopt does not fill it anyway
package tcpinfo
type tcpInfo3_19 struct {
State uint8
Ca_state uint8
Retransmits uint8
Probes uint8
Backoff uint8
Options uint8
Pad_cgo_0 [2]byte
Rto uint32
Ato uint32
Snd_mss uint32
Rcv_mss uint32
Unacked uint32
Sacked uint32
Lost uint32
Retrans uint32
Fackets uint32
Last_data_sent uint32
Last_ack_sent uint32
Last_data_recv uint32
Last_ack_recv uint32
Pmtu uint32
Rcv_ssthresh uint32
Rtt uint32
Rttvar uint32
Snd_ssthresh uint32
Snd_cwnd uint32
Advmss uint32
Reordering uint32
Rcv_rtt uint32
Rcv_space uint32
Total_retrans uint32
Pacing_rate uint64
Max_pacing_rate uint64
}

45
vendor/github.com/mikioh/tcpinfo/zsys_darwin.go generated vendored Normal file
View File

@@ -0,0 +1,45 @@
// Created by cgo -godefs - DO NOT EDIT
// cgo -godefs defs_darwin.go
package tcpinfo
const (
sysTCP_CONNECTION_INFO = 0x106
sysTCPCI_OPT_TIMESTAMPS = 0x1
sysTCPCI_OPT_SACK = 0x2
sysTCPCI_OPT_WSCALE = 0x4
sysTCPCI_OPT_ECN = 0x8
SysFlagLossRecovery SysFlags = 0x1
SysFlagReorderingDetected SysFlags = 0x2
sizeofTCPConnectionInfo = 0x70
)
type tcpConnectionInfo struct {
State uint8
Snd_wscale uint8
Rcv_wscale uint8
X__pad1 uint8
Options uint32
Flags uint32
Rto uint32
Maxseg uint32
Snd_ssthresh uint32
Snd_cwnd uint32
Snd_wnd uint32
Snd_sbbytes uint32
Rcv_wnd uint32
Rttcur uint32
Srtt uint32
Rttvar uint32
Pad_cgo_0 [4]byte
Txpackets uint64
Txbytes uint64
Txretransmitbytes uint64
Rxpackets uint64
Rxbytes uint64
Rxoutoforderbytes uint64
Txretransmitpackets uint64
}

58
vendor/github.com/mikioh/tcpinfo/zsys_freebsd.go generated vendored Normal file
View File

@@ -0,0 +1,58 @@
// Created by cgo -godefs - DO NOT EDIT
// cgo -godefs defs_freebsd.go
package tcpinfo
const (
sysTCP_INFO = 0x20
sysTCPI_OPT_TIMESTAMPS = 0x1
sysTCPI_OPT_SACK = 0x2
sysTCPI_OPT_WSCALE = 0x4
sysTCPI_OPT_ECN = 0x8
sysTCPI_OPT_TOE = 0x10
sizeofTCPInfo = 0xec
)
type tcpInfo struct {
State uint8
X__tcpi_ca_state uint8
X__tcpi_retransmits uint8
X__tcpi_probes uint8
X__tcpi_backoff uint8
Options uint8
Pad_cgo_0 [2]byte
Rto uint32
X__tcpi_ato uint32
Snd_mss uint32
Rcv_mss uint32
X__tcpi_unacked uint32
X__tcpi_sacked uint32
X__tcpi_lost uint32
X__tcpi_retrans uint32
X__tcpi_fackets uint32
X__tcpi_last_data_sent uint32
X__tcpi_last_ack_sent uint32
Last_data_recv uint32
X__tcpi_last_ack_recv uint32
X__tcpi_pmtu uint32
X__tcpi_rcv_ssthresh uint32
Rtt uint32
Rttvar uint32
Snd_ssthresh uint32
Snd_cwnd uint32
X__tcpi_advmss uint32
X__tcpi_reordering uint32
X__tcpi_rcv_rtt uint32
Rcv_space uint32
Snd_wnd uint32
Snd_bwnd uint32
Snd_nxt uint32
Rcv_nxt uint32
Toe_tid uint32
Snd_rexmitpack uint32
Rcv_ooopack uint32
Snd_zerowin uint32
X__tcpi_pad [26]uint32
}

103
vendor/github.com/mikioh/tcpinfo/zsys_linux.go generated vendored Normal file
View File

@@ -0,0 +1,103 @@
// Created by cgo -godefs - DO NOT EDIT
// cgo -godefs defs_linux.go
package tcpinfo
const (
sysTCP_INFO = 0xb
sysTCP_CONGESTION = 0xd
sysTCP_CC_INFO = 0x1a
sysTCPI_OPT_TIMESTAMPS = 0x1
sysTCPI_OPT_SACK = 0x2
sysTCPI_OPT_WSCALE = 0x4
sysTCPI_OPT_ECN = 0x8
sysTCPI_OPT_ECN_SEEN = 0x10
sysTCPI_OPT_SYN_DATA = 0x20
CAOpen CAState = 0x0
CADisorder CAState = 0x1
CACWR CAState = 0x2
CARecovery CAState = 0x3
CALoss CAState = 0x4
sizeofTCPInfo = 0xc0
sizeofTCPCCInfo = 0x14
sizeofTCPVegasInfo = 0x10
sizeofTCPDCTCPInfo = 0x10
sizeofTCPBBRInfo = 0x14
)
type tcpInfo struct {
State uint8
Ca_state uint8
Retransmits uint8
Probes uint8
Backoff uint8
Options uint8
Pad_cgo_0 [1]byte
Pad_cgo_1 [1]byte
Rto uint32
Ato uint32
Snd_mss uint32
Rcv_mss uint32
Unacked uint32
Sacked uint32
Lost uint32
Retrans uint32
Fackets uint32
Last_data_sent uint32
Last_ack_sent uint32
Last_data_recv uint32
Last_ack_recv uint32
Pmtu uint32
Rcv_ssthresh uint32
Rtt uint32
Rttvar uint32
Snd_ssthresh uint32
Snd_cwnd uint32
Advmss uint32
Reordering uint32
Rcv_rtt uint32
Rcv_space uint32
Total_retrans uint32
Pacing_rate uint64
Max_pacing_rate uint64
Bytes_acked uint64
Bytes_received uint64
Segs_out uint32
Segs_in uint32
Notsent_bytes uint32
Min_rtt uint32
Data_segs_in uint32
Data_segs_out uint32
Delivery_rate uint64
Busy_time uint64
Rwnd_limited uint64
Sndbuf_limited uint64
}
type tcpCCInfo [20]byte
type tcpVegasInfo struct {
Enabled uint32
Rttcnt uint32
Rtt uint32
Minrtt uint32
}
type tcpDCTCPInfo struct {
Enabled uint16
Ce_state uint16
Alpha uint32
Ab_ecn uint32
Ab_tot uint32
}
type tcpBBRInfo struct {
Bw_lo uint32
Bw_hi uint32
Min_rtt uint32
Pacing_gain uint32
Cwnd_gain uint32
}

58
vendor/github.com/mikioh/tcpinfo/zsys_netbsd.go generated vendored Normal file
View File

@@ -0,0 +1,58 @@
// Created by cgo -godefs - DO NOT EDIT
// cgo -godefs defs_netbsd.go
package tcpinfo
const (
sysTCP_INFO = 0x9
sysTCPI_OPT_TIMESTAMPS = 0x1
sysTCPI_OPT_SACK = 0x2
sysTCPI_OPT_WSCALE = 0x4
sysTCPI_OPT_ECN = 0x8
sysTCPI_OPT_TOE = 0x10
sizeofTCPInfo = 0xec
)
type tcpInfo struct {
State uint8
X__tcpi_ca_state uint8
X__tcpi_retransmits uint8
X__tcpi_probes uint8
X__tcpi_backoff uint8
Options uint8
Pad_cgo_0 [2]byte
Rto uint32
X__tcpi_ato uint32
Snd_mss uint32
Rcv_mss uint32
X__tcpi_unacked uint32
X__tcpi_sacked uint32
X__tcpi_lost uint32
X__tcpi_retrans uint32
X__tcpi_fackets uint32
X__tcpi_last_data_sent uint32
X__tcpi_last_ack_sent uint32
Last_data_recv uint32
X__tcpi_last_ack_recv uint32
X__tcpi_pmtu uint32
X__tcpi_rcv_ssthresh uint32
Rtt uint32
Rttvar uint32
Snd_ssthresh uint32
Snd_cwnd uint32
X__tcpi_advmss uint32
X__tcpi_reordering uint32
X__tcpi_rcv_rtt uint32
Rcv_space uint32
Snd_wnd uint32
Snd_bwnd uint32
Snd_nxt uint32
Rcv_nxt uint32
Toe_tid uint32
Snd_rexmitpack uint32
Rcv_ooopack uint32
Snd_zerowin uint32
X__tcpi_pad [26]uint32
}

24
vendor/github.com/mikioh/tcpopt/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,24 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# Folders
_obj
_test
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
*.exe
*.test
*.prof

16
vendor/github.com/mikioh/tcpopt/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,16 @@
language: go
os:
- linux
- osx
go:
- 1.11.6
- 1.12.1
- tip
script:
- go test -v -race
notifications:
email: false

23
vendor/github.com/mikioh/tcpopt/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,23 @@
Copyright (c) 2016, Mikio Hara
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

6
vendor/github.com/mikioh/tcpopt/README.md generated vendored Normal file
View File

@@ -0,0 +1,6 @@
Package tcpopt implements encoding and decoding of TCP-level socket options.
[![GoDoc](https://godoc.org/github.com/mikioh/tcpopt?status.png)](https://godoc.org/github.com/mikioh/tcpopt)
[![Build Status](https://travis-ci.org/mikioh/tcpopt.svg?branch=master)](https://travis-ci.org/mikioh/tcpopt)
[![Build status](https://ci.appveyor.com/api/projects/status/yljh492jsenpi0nd?svg=true)](https://ci.appveyor.com/project/mikioh/tcpopt)
[![Go Report Card](https://goreportcard.com/badge/github.com/mikioh/tcpopt)](https://goreportcard.com/report/github.com/mikioh/tcpopt)

18
vendor/github.com/mikioh/tcpopt/appveyor.yml generated vendored Normal file
View File

@@ -0,0 +1,18 @@
version: "{build}"
branches:
only:
- master
environment:
GOPATH: c:\gopath
install:
- set PATH=%GOPATH%\bin;c:\go\bin;%PATH%
- mkdir c:\gopath
- go get github.com/mikioh/tcp
- go get github.com/mikioh/tcpopt
- go get github.com/mikioh/tcpinfo
build_script:
- go test -v -race

7
vendor/github.com/mikioh/tcpopt/doc.go generated vendored Normal file
View File

@@ -0,0 +1,7 @@
// Copyright 2016 Mikio Hara. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package tcpopt implements encoding and decoding of TCP-level socket
// options.
package tcpopt

150
vendor/github.com/mikioh/tcpopt/option.go generated vendored Normal file
View File

@@ -0,0 +1,150 @@
// Copyright 2016 Mikio Hara. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package tcpopt
import "time"
// An Option represents a socket option.
type Option interface {
// Level returns the platform-specific socket option level.
Level() int
// Name returns the platform-specific socket option name.
Name() int
// Marshal returns the binary encoding of socket option.
Marshal() ([]byte, error)
}
// NoDelay specifies the use of Nagle's algorithm.
type NoDelay bool
// Level implements the Level method of Option interface.
func (nd NoDelay) Level() int { return options[soNodelay].level }
// Name implements the Name method of Option interface.
func (nd NoDelay) Name() int { return options[soNodelay].name }
// MSS specifies the maximum segment size.
type MSS int
// Level implements the Level method of Option interface.
func (mss MSS) Level() int { return options[soMaxseg].level }
// Name implements the Name method of Option interface.
func (mss MSS) Name() int { return options[soMaxseg].name }
// SendBuffer specifies the size of send buffer.
type SendBuffer int
// Level implements the Level method of Option interface.
func (sb SendBuffer) Level() int { return options[soSndbuf].level }
// Name implements the Name method of Option interface.
func (sb SendBuffer) Name() int { return options[soSndbuf].name }
// ReceiveBuffer specifies the size of receive buffer.
type ReceiveBuffer int
// Level implements the Level method of Option interface.
func (rb ReceiveBuffer) Level() int { return options[soRcvbuf].level }
// Name implements the Name method of Option interface.
func (rb ReceiveBuffer) Name() int { return options[soRcvbuf].name }
// KeepAlive specifies the use of keep alive.
type KeepAlive bool
// Level implements the Level method of Option interface.
func (ka KeepAlive) Level() int { return options[soKeepalive].level }
// Name implements the Name method of Option interface.
func (ka KeepAlive) Name() int { return options[soKeepalive].name }
// KeepAliveIdleInterval is the idle interval until the first probe is
// sent.
//
// OpenBSD doesn't support this option.
// See TCP_KEEPIDLE or TCP_KEEPALIVE for further information.
type KeepAliveIdleInterval time.Duration
// Level implements the Level method of Option interface.
func (ka KeepAliveIdleInterval) Level() int { return options[soKeepidle].level }
// Name implements the Name method of Option interface.
func (ka KeepAliveIdleInterval) Name() int { return options[soKeepidle].name }
// KeepAliveProbeInterval is the interval between keepalive probes.
//
// OpenBSD doesn't support this option.
// See TCP_KEEPINTVL for further information.
type KeepAliveProbeInterval time.Duration
// Level implements the Level method of Option interface.
func (ka KeepAliveProbeInterval) Level() int { return options[soKeepintvl].level }
// Name implements the Name method of Option interface.
func (ka KeepAliveProbeInterval) Name() int { return options[soKeepintvl].name }
// KeepAliveProbeCount is the number of keepalive probes should be
// repeated when the peer is not responding.
//
// OpenBSD and Windows don't support this option.
// See TCP_KEEPCNT for further information.
type KeepAliveProbeCount int
// Level implements the Level method of Option interface.
func (ka KeepAliveProbeCount) Level() int { return options[soKeepcnt].level }
// Name implements the Name method of Option interface.
func (ka KeepAliveProbeCount) Name() int { return options[soKeepcnt].name }
// Cork specifies the use of TCP_CORK or TCP_NOPUSH option.
//
// On DragonFly BSD, the caller may need to adjust the
// net.inet.tcp.disable_nopush kernel state.
// NetBSD and Windows don't support this option.
type Cork bool
// Level implements the Level method of Option interface.
func (ck Cork) Level() int { return options[soCork].level }
// Name implements the Name method of Option interface.
func (ck Cork) Name() int { return options[soCork].name }
// NotSentLowWMK specifies the amount of unsent bytes in transmission
// queue. The network poller such as kqueue or epoll doesn't report
// that the connection is writable while the amount of unsent data
// size is greater than NotSentLowWMK.
//
// Only Darwin and Linux support this option.
// See TCP_NOTSENT_LOWAT for further information.
type NotSentLowWMK int
// Level implements the Level method of Option interface.
func (ns NotSentLowWMK) Level() int { return options[soNotsentLOWAT].level }
// Name implements the Name method of Option interface.
func (ns NotSentLowWMK) Name() int { return options[soNotsentLOWAT].name }
// Error represents an error on the socket.
type Error int
// Level implements the Level method of Option interface.
func (e Error) Level() int { return options[soError].level }
// Name implements the Name method of Option interface.
func (e Error) Name() int { return options[soError].name }
// ECN specifies the use of ECN.
//
// Only Darwin supports this option.
type ECN bool
// Level implements the Level method of Option interface.
func (cn ECN) Level() int { return options[soECN].level }
// Name implements the Name method of Option interface.
func (cn ECN) Name() int { return options[soECN].name }

37
vendor/github.com/mikioh/tcpopt/parse.go generated vendored Normal file
View File

@@ -0,0 +1,37 @@
// Copyright 2016 Mikio Hara. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package tcpopt
import (
"fmt"
"sync"
)
var parserMu sync.RWMutex
// Register registers a socket option parser.
func Register(level, name int, fn func([]byte) (Option, error)) {
parserMu.Lock()
parsers[int64(level)<<32|int64(name)] = fn
parserMu.Unlock()
}
// Unregister unregisters a socket option parser.
func Unregister(level, name int) {
parserMu.Lock()
delete(parsers, int64(level)<<32|int64(name))
parserMu.Unlock()
}
// Parse parses a socket option.
func Parse(level, name int, b []byte) (Option, error) {
parserMu.RLock()
defer parserMu.RUnlock()
fn, ok := parsers[int64(level)<<32|int64(name)]
if !ok {
return nil, fmt.Errorf("parser for level=%#x name=%#x not found", level, name)
}
return fn(b)
}

66
vendor/github.com/mikioh/tcpopt/sys.go generated vendored Normal file
View File

@@ -0,0 +1,66 @@
// Copyright 2016 Mikio Hara. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package tcpopt
import (
"encoding/binary"
"time"
"unsafe"
)
var nativeEndian binary.ByteOrder
func init() {
i := uint32(1)
b := (*[4]byte)(unsafe.Pointer(&i))
if b[0] == 1 {
nativeEndian = binary.LittleEndian
} else {
nativeEndian = binary.BigEndian
}
}
func boolint32(b bool) int32 {
if b {
return 1
}
return 0
}
func uint32bool(n uint32) bool {
if n != 0 {
return true
}
return false
}
const (
ianaProtocolIP = 0x0
ianaProtocolTCP = 0x6
ianaProtocolIPv6 = 0x29
)
const (
soNodelay = iota
soSndbuf
soRcvbuf
soKeepalive
soKeepidle
soKeepintvl
soKeepcnt
soCork
soNotsentLOWAT
soError
soECN
soMaxseg
soMax
)
// An option represents a binding for socket option.
type option struct {
level int // option level
name int // option name, must be equal or greater than 1
uot time.Duration // unit of time
}

37
vendor/github.com/mikioh/tcpopt/sys_darwin.go generated vendored Normal file
View File

@@ -0,0 +1,37 @@
// Copyright 2016 Mikio Hara. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package tcpopt
import "time"
var options = [soMax]option{
soNodelay: {ianaProtocolTCP, sysTCP_NODELAY, 0},
soMaxseg: {ianaProtocolTCP, sysTCP_MAXSEG, 0},
soSndbuf: {sysSOL_SOCKET, sysSO_SNDBUF, 0},
soRcvbuf: {sysSOL_SOCKET, sysSO_RCVBUF, 0},
soKeepalive: {sysSOL_SOCKET, sysSO_KEEPALIVE, 0},
soKeepidle: {ianaProtocolTCP, sysTCP_KEEPALIVE, time.Second},
soKeepintvl: {ianaProtocolTCP, sysTCP_KEEPINTVL, time.Second},
soKeepcnt: {ianaProtocolTCP, sysTCP_KEEPCNT, 0},
soCork: {ianaProtocolTCP, sysTCP_NOPUSH, 0},
soNotsentLOWAT: {ianaProtocolTCP, sysTCP_NOTSENT_LOWAT, 0},
soError: {sysSOL_SOCKET, sysSO_ERROR, 0},
soECN: {ianaProtocolTCP, sysTCP_ENABLE_ECN, 0},
}
var parsers = map[int64]func([]byte) (Option, error){
ianaProtocolTCP<<32 | sysTCP_NODELAY: parseNoDelay,
ianaProtocolTCP<<32 | sysTCP_MAXSEG: parseMSS,
sysSOL_SOCKET<<32 | sysSO_SNDBUF: parseSendBuffer,
sysSOL_SOCKET<<32 | sysSO_RCVBUF: parseReceiveBuffer,
sysSOL_SOCKET<<32 | sysSO_KEEPALIVE: parseKeepAlive,
ianaProtocolTCP<<32 | sysTCP_KEEPALIVE: parseKeepAliveIdleInterval,
ianaProtocolTCP<<32 | sysTCP_KEEPINTVL: parseKeepAliveProbeInterval,
ianaProtocolTCP<<32 | sysTCP_KEEPCNT: parseKeepAliveProbeCount,
ianaProtocolTCP<<32 | sysTCP_NOPUSH: parseCork,
ianaProtocolTCP<<32 | sysTCP_NOTSENT_LOWAT: parseNotSentLowWMK,
sysSOL_SOCKET<<32 | sysSO_ERROR: parseError,
ianaProtocolTCP<<32 | sysTCP_ENABLE_ECN: parseECN,
}

35
vendor/github.com/mikioh/tcpopt/sys_dragonfly.go generated vendored Normal file
View File

@@ -0,0 +1,35 @@
// Copyright 2016 Mikio Hara. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build dragonfly
package tcpopt
import "time"
var options = [soMax]option{
soNodelay: {ianaProtocolTCP, sysTCP_NODELAY, 0},
soMaxseg: {ianaProtocolTCP, sysTCP_MAXSEG, 0},
soSndbuf: {sysSOL_SOCKET, sysSO_SNDBUF, 0},
soRcvbuf: {sysSOL_SOCKET, sysSO_RCVBUF, 0},
soKeepalive: {sysSOL_SOCKET, sysSO_KEEPALIVE, 0},
soKeepidle: {ianaProtocolTCP, sysTCP_KEEPIDLE, time.Millisecond},
soKeepintvl: {ianaProtocolTCP, sysTCP_KEEPINTVL, time.Millisecond},
soKeepcnt: {ianaProtocolTCP, sysTCP_KEEPCNT, 0},
soCork: {ianaProtocolTCP, sysTCP_NOPUSH, 0},
soError: {sysSOL_SOCKET, sysSO_ERROR, 0},
}
var parsers = map[int64]func([]byte) (Option, error){
ianaProtocolTCP<<32 | sysTCP_NODELAY: parseNoDelay,
ianaProtocolTCP<<32 | sysTCP_MAXSEG: parseMSS,
sysSOL_SOCKET<<32 | sysSO_SNDBUF: parseSendBuffer,
sysSOL_SOCKET<<32 | sysSO_RCVBUF: parseReceiveBuffer,
sysSOL_SOCKET<<32 | sysSO_KEEPALIVE: parseKeepAlive,
ianaProtocolTCP<<32 | sysTCP_KEEPIDLE: parseKeepAliveIdleInterval,
ianaProtocolTCP<<32 | sysTCP_KEEPINTVL: parseKeepAliveProbeInterval,
ianaProtocolTCP<<32 | sysTCP_KEEPCNT: parseKeepAliveProbeCount,
ianaProtocolTCP<<32 | sysTCP_NOPUSH: parseCork,
sysSOL_SOCKET<<32 | sysSO_ERROR: parseError,
}

33
vendor/github.com/mikioh/tcpopt/sys_freebsd.go generated vendored Normal file
View File

@@ -0,0 +1,33 @@
// Copyright 2016 Mikio Hara. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package tcpopt
import "time"
var options = [soMax]option{
soNodelay: {ianaProtocolTCP, sysTCP_NODELAY, 0},
soMaxseg: {ianaProtocolTCP, sysTCP_MAXSEG, 0},
soSndbuf: {sysSOL_SOCKET, sysSO_SNDBUF, 0},
soRcvbuf: {sysSOL_SOCKET, sysSO_RCVBUF, 0},
soKeepalive: {sysSOL_SOCKET, sysSO_KEEPALIVE, 0},
soKeepidle: {ianaProtocolTCP, sysTCP_KEEPIDLE, time.Second},
soKeepintvl: {ianaProtocolTCP, sysTCP_KEEPINTVL, time.Second},
soKeepcnt: {ianaProtocolTCP, sysTCP_KEEPCNT, 0},
soCork: {ianaProtocolTCP, sysTCP_NOPUSH, 0},
soError: {sysSOL_SOCKET, sysSO_ERROR, 0},
}
var parsers = map[int64]func([]byte) (Option, error){
ianaProtocolTCP<<32 | sysTCP_NODELAY: parseNoDelay,
ianaProtocolTCP<<32 | sysTCP_MAXSEG: parseMSS,
sysSOL_SOCKET<<32 | sysSO_SNDBUF: parseSendBuffer,
sysSOL_SOCKET<<32 | sysSO_RCVBUF: parseReceiveBuffer,
sysSOL_SOCKET<<32 | sysSO_KEEPALIVE: parseKeepAlive,
ianaProtocolTCP<<32 | sysTCP_KEEPIDLE: parseKeepAliveIdleInterval,
ianaProtocolTCP<<32 | sysTCP_KEEPINTVL: parseKeepAliveProbeInterval,
ianaProtocolTCP<<32 | sysTCP_KEEPCNT: parseKeepAliveProbeCount,
ianaProtocolTCP<<32 | sysTCP_NOPUSH: parseCork,
sysSOL_SOCKET<<32 | sysSO_ERROR: parseError,
}

35
vendor/github.com/mikioh/tcpopt/sys_linux.go generated vendored Normal file
View File

@@ -0,0 +1,35 @@
// Copyright 2016 Mikio Hara. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package tcpopt
import "time"
var options = [soMax]option{
soNodelay: {ianaProtocolTCP, sysTCP_NODELAY, 0},
soMaxseg: {ianaProtocolTCP, sysTCP_MAXSEG, 0},
soSndbuf: {sysSOL_SOCKET, sysSO_SNDBUF, 0},
soRcvbuf: {sysSOL_SOCKET, sysSO_RCVBUF, 0},
soKeepalive: {sysSOL_SOCKET, sysSO_KEEPALIVE, 0},
soKeepidle: {ianaProtocolTCP, sysTCP_KEEPIDLE, time.Second},
soKeepintvl: {ianaProtocolTCP, sysTCP_KEEPINTVL, time.Second},
soKeepcnt: {ianaProtocolTCP, sysTCP_KEEPCNT, 0},
soCork: {ianaProtocolTCP, sysTCP_CORK, 0},
soNotsentLOWAT: {ianaProtocolTCP, sysTCP_NOTSENT_LOWAT, 0},
soError: {sysSOL_SOCKET, sysSO_ERROR, 0},
}
var parsers = map[int64]func([]byte) (Option, error){
ianaProtocolTCP<<32 | sysTCP_NODELAY: parseNoDelay,
ianaProtocolTCP<<32 | sysTCP_MAXSEG: parseMSS,
sysSOL_SOCKET<<32 | sysSO_SNDBUF: parseSendBuffer,
sysSOL_SOCKET<<32 | sysSO_RCVBUF: parseReceiveBuffer,
sysSOL_SOCKET<<32 | sysSO_KEEPALIVE: parseKeepAlive,
ianaProtocolTCP<<32 | sysTCP_KEEPIDLE: parseKeepAliveIdleInterval,
ianaProtocolTCP<<32 | sysTCP_KEEPINTVL: parseKeepAliveProbeInterval,
ianaProtocolTCP<<32 | sysTCP_KEEPCNT: parseKeepAliveProbeCount,
ianaProtocolTCP<<32 | sysTCP_CORK: parseCork,
ianaProtocolTCP<<32 | sysTCP_NOTSENT_LOWAT: parseNotSentLowWMK,
sysSOL_SOCKET<<32 | sysSO_ERROR: parseError,
}

31
vendor/github.com/mikioh/tcpopt/sys_netbsd.go generated vendored Normal file
View File

@@ -0,0 +1,31 @@
// Copyright 2016 Mikio Hara. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package tcpopt
import "time"
var options = [soMax]option{
soNodelay: {ianaProtocolTCP, sysTCP_NODELAY, 0},
soMaxseg: {ianaProtocolTCP, sysTCP_MAXSEG, 0},
soSndbuf: {sysSOL_SOCKET, sysSO_SNDBUF, 0},
soRcvbuf: {sysSOL_SOCKET, sysSO_RCVBUF, 0},
soKeepalive: {sysSOL_SOCKET, sysSO_KEEPALIVE, 0},
soKeepidle: {ianaProtocolTCP, sysTCP_KEEPIDLE, time.Second},
soKeepintvl: {ianaProtocolTCP, sysTCP_KEEPINTVL, time.Second},
soKeepcnt: {ianaProtocolTCP, sysTCP_KEEPCNT, 0},
soError: {sysSOL_SOCKET, sysSO_ERROR, 0},
}
var parsers = map[int64]func([]byte) (Option, error){
ianaProtocolTCP<<32 | sysTCP_NODELAY: parseNoDelay,
ianaProtocolTCP<<32 | sysTCP_MAXSEG: parseMSS,
sysSOL_SOCKET<<32 | sysSO_SNDBUF: parseSendBuffer,
sysSOL_SOCKET<<32 | sysSO_RCVBUF: parseReceiveBuffer,
sysSOL_SOCKET<<32 | sysSO_KEEPALIVE: parseKeepAlive,
ianaProtocolTCP<<32 | sysTCP_KEEPIDLE: parseKeepAliveIdleInterval,
ianaProtocolTCP<<32 | sysTCP_KEEPINTVL: parseKeepAliveProbeInterval,
ianaProtocolTCP<<32 | sysTCP_KEEPCNT: parseKeepAliveProbeCount,
sysSOL_SOCKET<<32 | sysSO_ERROR: parseError,
}

25
vendor/github.com/mikioh/tcpopt/sys_openbsd.go generated vendored Normal file
View File

@@ -0,0 +1,25 @@
// Copyright 2016 Mikio Hara. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package tcpopt
var options = [soMax]option{
soNodelay: {ianaProtocolTCP, sysTCP_NODELAY, 0},
soMaxseg: {ianaProtocolTCP, sysTCP_MAXSEG, 0},
soSndbuf: {sysSOL_SOCKET, sysSO_SNDBUF, 0},
soRcvbuf: {sysSOL_SOCKET, sysSO_RCVBUF, 0},
soKeepalive: {sysSOL_SOCKET, sysSO_KEEPALIVE, 0},
soCork: {ianaProtocolTCP, sysTCP_NOPUSH, 0},
soError: {sysSOL_SOCKET, sysSO_ERROR, 0},
}
var parsers = map[int64]func([]byte) (Option, error){
ianaProtocolTCP<<32 | sysTCP_NODELAY: parseNoDelay,
ianaProtocolTCP<<32 | sysTCP_MAXSEG: parseMSS,
sysSOL_SOCKET<<32 | sysSO_SNDBUF: parseSendBuffer,
sysSOL_SOCKET<<32 | sysSO_RCVBUF: parseReceiveBuffer,
sysSOL_SOCKET<<32 | sysSO_KEEPALIVE: parseKeepAlive,
ianaProtocolTCP<<32 | sysTCP_NOPUSH: parseCork,
sysSOL_SOCKET<<32 | sysSO_ERROR: parseError,
}

54
vendor/github.com/mikioh/tcpopt/sys_solaris.go generated vendored Normal file
View File

@@ -0,0 +1,54 @@
// Copyright 2016 Mikio Hara. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build solaris
package tcpopt
import "time"
const (
sysSOL_SOCKET = 0xffff
sysSO_SNDBUF = 0x1001
sysSO_RCVBUF = 0x1002
sysSO_KEEPALIVE = 0x8
sysTCP_NODELAY = 0x1
sysTCP_MAXSEG = 0x2
sysTCP_KEEPALIVE = 0x8
sysTCP_KEEPALIVE_THRESHOLD = 0x16
sysTCP_KEEPALIVE_ABORT_THRESHOLD = 0x17
sysTCP_KEEPIDLE = 0x22
sysTCP_KEEPCNT = 0x23
sysTCP_KEEPINTVL = 0x24
sysTCP_CORK = 0x18
sysSO_ERROR = 0x1007
)
var options = [soMax]option{
soNodelay: {ianaProtocolTCP, sysTCP_NODELAY, 0},
soMaxseg: {ianaProtocolTCP, sysTCP_MAXSEG, 0},
soSndbuf: {sysSOL_SOCKET, sysSO_SNDBUF, 0},
soRcvbuf: {sysSOL_SOCKET, sysSO_RCVBUF, 0},
soKeepalive: {sysSOL_SOCKET, sysSO_KEEPALIVE, 0},
soKeepidle: {ianaProtocolTCP, sysTCP_KEEPIDLE, time.Second},
soKeepintvl: {ianaProtocolTCP, sysTCP_KEEPINTVL, time.Second},
soKeepcnt: {ianaProtocolTCP, sysTCP_KEEPCNT, 0},
soCork: {ianaProtocolTCP, sysTCP_CORK, 0},
soError: {sysSOL_SOCKET, sysSO_ERROR, 0},
}
var parsers = map[int64]func([]byte) (Option, error){
ianaProtocolTCP<<32 | sysTCP_NODELAY: parseNoDelay,
ianaProtocolTCP<<32 | sysTCP_MAXSEG: parseMSS,
sysSOL_SOCKET<<32 | sysSO_SNDBUF: parseSendBuffer,
sysSOL_SOCKET<<32 | sysSO_RCVBUF: parseReceiveBuffer,
sysSOL_SOCKET<<32 | sysSO_KEEPALIVE: parseKeepAlive,
ianaProtocolTCP<<32 | sysTCP_KEEPIDLE: parseKeepAliveIdleInterval,
ianaProtocolTCP<<32 | sysTCP_KEEPINTVL: parseKeepAliveProbeInterval,
ianaProtocolTCP<<32 | sysTCP_KEEPCNT: parseKeepAliveProbeCount,
ianaProtocolTCP<<32 | sysTCP_CORK: parseCork,
sysSOL_SOCKET<<32 | sysSO_ERROR: parseError,
}

73
vendor/github.com/mikioh/tcpopt/sys_stub.go generated vendored Normal file
View File

@@ -0,0 +1,73 @@
// Copyright 2016 Mikio Hara. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows
package tcpopt
import "errors"
var options [soMax]option
var parsers = map[int64]func([]byte) (Option, error){}
// Marshal implements the Marshal method of Option interface.
func (nd NoDelay) Marshal() ([]byte, error) {
return nil, errors.New("operation not supported")
}
// Marshal implements the Marshal method of Option interface.
func (mss MSS) Marshal() ([]byte, error) {
return nil, errors.New("operation not supported")
}
// Marshal implements the Marshal method of Option interface.
func (sb SendBuffer) Marshal() ([]byte, error) {
return nil, errors.New("operation not supported")
}
// Marshal implements the Marshal method of Option interface.
func (rb ReceiveBuffer) Marshal() ([]byte, error) {
return nil, errors.New("operation not supported")
}
// Marshal implements the Marshal method of Option interface.
func (ka KeepAlive) Marshal() ([]byte, error) {
return nil, errors.New("operation not supported")
}
// Marshal implements the Marshal method of Option interface.
func (ka KeepAliveIdleInterval) Marshal() ([]byte, error) {
return nil, errors.New("operation not supported")
}
// Marshal implements the Marshal method of Option interface.
func (ka KeepAliveProbeInterval) Marshal() ([]byte, error) {
return nil, errors.New("operation not supported")
}
// Marshal implements the Marshal method of Option interface.
func (ka KeepAliveProbeCount) Marshal() ([]byte, error) {
return nil, errors.New("operation not supported")
}
// Marshal implements the Marshal method of Option interface.
func (ck Cork) Marshal() ([]byte, error) {
return nil, errors.New("operation not supported")
}
// Marshal implements the Marshal method of Option interface.
func (ns NotSentLowWMK) Marshal() ([]byte, error) {
return nil, errors.New("operation not supported")
}
// Marshal implements the Marshal method of Option interface.
func (e Error) Marshal() ([]byte, error) {
return nil, errors.New("operation not supported")
}
// Marshal implements the Marshal method of Option interface.
func (cn ECN) Marshal() ([]byte, error) {
return nil, errors.New("operation not supported")
}

173
vendor/github.com/mikioh/tcpopt/sys_unix.go generated vendored Normal file
View File

@@ -0,0 +1,173 @@
// Copyright 2016 Mikio Hara. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
package tcpopt
import (
"errors"
"time"
"unsafe"
)
// Marshal implements the Marshal method of Option interface.
func (nd NoDelay) Marshal() ([]byte, error) {
v := boolint32(bool(nd))
return (*[4]byte)(unsafe.Pointer(&v))[:], nil
}
// Marshal implements the Marshal method of Option interface.
func (mss MSS) Marshal() ([]byte, error) {
v := int32(mss)
return (*[4]byte)(unsafe.Pointer(&v))[:], nil
}
// Marshal implements the Marshal method of Option interface.
func (sb SendBuffer) Marshal() ([]byte, error) {
v := int32(sb)
return (*[4]byte)(unsafe.Pointer(&v))[:], nil
}
// Marshal implements the Marshal method of Option interface.
func (rb ReceiveBuffer) Marshal() ([]byte, error) {
v := int32(rb)
return (*[4]byte)(unsafe.Pointer(&v))[:], nil
}
// Marshal implements the Marshal method of Option interface.
func (ka KeepAlive) Marshal() ([]byte, error) {
v := boolint32(bool(ka))
return (*[4]byte)(unsafe.Pointer(&v))[:], nil
}
// Marshal implements the Marshal method of Option interface.
func (ka KeepAliveIdleInterval) Marshal() ([]byte, error) {
ka += KeepAliveIdleInterval(options[soKeepidle].uot - time.Nanosecond)
v := int32(time.Duration(ka) / options[soKeepidle].uot)
return (*[4]byte)(unsafe.Pointer(&v))[:], nil
}
// Marshal implements the Marshal method of Option interface.
func (ka KeepAliveProbeInterval) Marshal() ([]byte, error) {
ka += KeepAliveProbeInterval(options[soKeepintvl].uot - time.Nanosecond)
v := int32(time.Duration(ka) / options[soKeepintvl].uot)
return (*[4]byte)(unsafe.Pointer(&v))[:], nil
}
// Marshal implements the Marshal method of Option interface.
func (ka KeepAliveProbeCount) Marshal() ([]byte, error) {
v := int32(ka)
return (*[4]byte)(unsafe.Pointer(&v))[:], nil
}
// Marshal implements the Marshal method of Option interface.
func (ck Cork) Marshal() ([]byte, error) {
v := boolint32(bool(ck))
return (*[4]byte)(unsafe.Pointer(&v))[:], nil
}
// Marshal implements the Marshal method of Option interface.
func (ns NotSentLowWMK) Marshal() ([]byte, error) {
v := int32(ns)
return (*[4]byte)(unsafe.Pointer(&v))[:], nil
}
// Marshal implements the Marshal method of Option interface.
func (e Error) Marshal() ([]byte, error) {
v := int32(e)
return (*[4]byte)(unsafe.Pointer(&v))[:], nil
}
// Marshal implements the Marshal method of Option interface.
func (cn ECN) Marshal() ([]byte, error) {
v := boolint32(bool(cn))
return (*[4]byte)(unsafe.Pointer(&v))[:], nil
}
func parseNoDelay(b []byte) (Option, error) {
if len(b) < 4 {
return nil, errors.New("short buffer")
}
return NoDelay(uint32bool(nativeEndian.Uint32(b))), nil
}
func parseMSS(b []byte) (Option, error) {
if len(b) < 4 {
return nil, errors.New("short buffer")
}
return MSS(nativeEndian.Uint32(b)), nil
}
func parseSendBuffer(b []byte) (Option, error) {
if len(b) < 4 {
return nil, errors.New("short buffer")
}
return SendBuffer(nativeEndian.Uint32(b)), nil
}
func parseReceiveBuffer(b []byte) (Option, error) {
if len(b) < 4 {
return nil, errors.New("short buffer")
}
return ReceiveBuffer(nativeEndian.Uint32(b)), nil
}
func parseKeepAlive(b []byte) (Option, error) {
if len(b) < 4 {
return nil, errors.New("short buffer")
}
return KeepAlive(uint32bool(nativeEndian.Uint32(b))), nil
}
func parseKeepAliveIdleInterval(b []byte) (Option, error) {
if len(b) < 4 {
return nil, errors.New("short buffer")
}
v := time.Duration(nativeEndian.Uint32(b)) * options[soKeepidle].uot
return KeepAliveIdleInterval(v), nil
}
func parseKeepAliveProbeInterval(b []byte) (Option, error) {
if len(b) < 4 {
return nil, errors.New("short buffer")
}
v := time.Duration(nativeEndian.Uint32(b)) * options[soKeepintvl].uot
return KeepAliveProbeInterval(v), nil
}
func parseKeepAliveProbeCount(b []byte) (Option, error) {
if len(b) < 4 {
return nil, errors.New("short buffer")
}
return KeepAliveProbeCount(nativeEndian.Uint32(b)), nil
}
func parseCork(b []byte) (Option, error) {
if len(b) < 4 {
return nil, errors.New("short buffer")
}
return Cork(uint32bool(nativeEndian.Uint32(b))), nil
}
func parseNotSentLowWMK(b []byte) (Option, error) {
if len(b) < 4 {
return nil, errors.New("short buffer")
}
return NotSentLowWMK(nativeEndian.Uint32(b)), nil
}
func parseError(b []byte) (Option, error) {
if len(b) < 4 {
return nil, errors.New("short buffer")
}
return Error(nativeEndian.Uint32(b)), nil
}
func parseECN(b []byte) (Option, error) {
if len(b) < 4 {
return nil, errors.New("short buffer")
}
return ECN(uint32bool(nativeEndian.Uint32(b))), nil
}

144
vendor/github.com/mikioh/tcpopt/sys_windows.go generated vendored Normal file
View File

@@ -0,0 +1,144 @@
// Copyright 2016 Mikio Hara. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package tcpopt
import (
"errors"
"time"
"unsafe"
)
const (
sysSOL_SOCKET = 0xffff
sysSO_SNDBUF = 0x1001
sysSO_RCVBUF = 0x1002
sysSO_KEEPALIVE = 0x8
sysTCP_NODELAY = 0x1
sysIOC_OUT = 0x40000000
sysIOC_IN = 0x80000000
sysIOC_VENDOR = 0x18000000
)
var sysSIO_KEEPALIVE_VALS uint = sysIOC_IN | sysIOC_VENDOR | 4
var options = [soMax]option{
soNodelay: {ianaProtocolTCP, sysTCP_NODELAY, 0},
soSndbuf: {sysSOL_SOCKET, sysSO_SNDBUF, 0},
soRcvbuf: {sysSOL_SOCKET, sysSO_RCVBUF, 0},
soKeepalive: {sysSOL_SOCKET, sysSO_KEEPALIVE, 0},
soKeepidle: {ianaProtocolTCP, int(sysSIO_KEEPALIVE_VALS), time.Millisecond},
soKeepintvl: {ianaProtocolTCP, int(sysSIO_KEEPALIVE_VALS), time.Millisecond},
}
var parsers = map[int64]func([]byte) (Option, error){
ianaProtocolTCP<<32 | sysTCP_NODELAY: parseNoDelay,
sysSOL_SOCKET<<32 | sysSO_SNDBUF: parseSendBuffer,
sysSOL_SOCKET<<32 | sysSO_RCVBUF: parseReceiveBuffer,
sysSOL_SOCKET<<32 | sysSO_KEEPALIVE: parseKeepAlive,
ianaProtocolTCP<<32 | int64(sysSIO_KEEPALIVE_VALS): parseKeepAliveValues,
}
// Marshal implements the Marshal method of Option interface.
func (nd NoDelay) Marshal() ([]byte, error) {
v := boolint32(bool(nd))
return (*[4]byte)(unsafe.Pointer(&v))[:], nil
}
// Marshal implements the Marshal method of Option interface.
func (mss MSS) Marshal() ([]byte, error) {
return nil, errors.New("operation not supported")
}
// Marshal implements the Marshal method of Option interface.
func (sb SendBuffer) Marshal() ([]byte, error) {
v := int32(sb)
return (*[4]byte)(unsafe.Pointer(&v))[:], nil
}
// Marshal implements the Marshal method of Option interface.
func (rb ReceiveBuffer) Marshal() ([]byte, error) {
v := int32(rb)
return (*[4]byte)(unsafe.Pointer(&v))[:], nil
}
// Marshal implements the Marshal method of Option interface.
func (ka KeepAlive) Marshal() ([]byte, error) {
v := boolint32(bool(ka))
return (*[4]byte)(unsafe.Pointer(&v))[:], nil
}
// Marshal implements the Marshal method of Option interface.
func (ka KeepAliveIdleInterval) Marshal() ([]byte, error) {
ka += KeepAliveIdleInterval(options[soKeepidle].uot - time.Nanosecond)
v := uint32(time.Duration(ka) / options[soKeepidle].uot)
return (*[4]byte)(unsafe.Pointer(&v))[:], nil
}
// Marshal implements the Marshal method of Option interface.
func (ka KeepAliveProbeInterval) Marshal() ([]byte, error) {
ka += KeepAliveProbeInterval(options[soKeepintvl].uot - time.Nanosecond)
v := uint32(time.Duration(ka) / options[soKeepintvl].uot)
return (*[4]byte)(unsafe.Pointer(&v))[:], nil
}
// Marshal implements the Marshal method of Option interface.
func (ka KeepAliveProbeCount) Marshal() ([]byte, error) {
return nil, errors.New("operation not supported")
}
// Marshal implements the Marshal method of Option interface.
func (ck Cork) Marshal() ([]byte, error) {
return nil, errors.New("operation not supported")
}
// Marshal implements the Marshal method of Option interface.
func (ns NotSentLowWMK) Marshal() ([]byte, error) {
return nil, errors.New("operation not supported")
}
// Marshal implements the Marshal method of Option interface.
func (e Error) Marshal() ([]byte, error) {
return nil, errors.New("operation not supported")
}
// Marshal implements the Marshal method of Option interface.
func (cn ECN) Marshal() ([]byte, error) {
return nil, errors.New("operation not supported")
}
func parseNoDelay(b []byte) (Option, error) {
if len(b) < 4 {
return nil, errors.New("short buffer")
}
return NoDelay(uint32bool(nativeEndian.Uint32(b))), nil
}
func parseSendBuffer(b []byte) (Option, error) {
if len(b) < 4 {
return nil, errors.New("short buffer")
}
return SendBuffer(nativeEndian.Uint32(b)), nil
}
func parseReceiveBuffer(b []byte) (Option, error) {
if len(b) < 4 {
return nil, errors.New("short buffer")
}
return ReceiveBuffer(nativeEndian.Uint32(b)), nil
}
func parseKeepAlive(b []byte) (Option, error) {
if len(b) < 4 {
return nil, errors.New("short buffer")
}
return KeepAlive(uint32bool(nativeEndian.Uint32(b))), nil
}
func parseKeepAliveValues(b []byte) (Option, error) {
return nil, errors.New("operation not supported")
}

22
vendor/github.com/mikioh/tcpopt/zsys_darwin.go generated vendored Normal file
View File

@@ -0,0 +1,22 @@
// Created by cgo -godefs - DO NOT EDIT
// cgo -godefs defs_darwin.go
package tcpopt
const (
sysSOL_SOCKET = 0xffff
sysSO_KEEPALIVE = 0x8
sysSO_SNDBUF = 0x1001
sysSO_RCVBUF = 0x1002
sysSO_ERROR = 0x1007
sysTCP_NODELAY = 0x1
sysTCP_MAXSEG = 0x2
sysTCP_KEEPALIVE = 0x10
sysTCP_KEEPINTVL = 0x101
sysTCP_KEEPCNT = 0x102
sysTCP_NOPUSH = 0x4
sysTCP_ENABLE_ECN = 0x104
sysTCP_NOTSENT_LOWAT = 0x201
)

20
vendor/github.com/mikioh/tcpopt/zsys_dragonfly.go generated vendored Normal file
View File

@@ -0,0 +1,20 @@
// Created by cgo -godefs - DO NOT EDIT
// cgo -godefs defs_dragonfly.go
package tcpopt
const (
sysSOL_SOCKET = 0xffff
sysSO_KEEPALIVE = 0x8
sysSO_SNDBUF = 0x1001
sysSO_RCVBUF = 0x1002
sysSO_ERROR = 0x1007
sysTCP_NODELAY = 0x1
sysTCP_MAXSEG = 0x2
sysTCP_KEEPIDLE = 0x100
sysTCP_KEEPINTVL = 0x200
sysTCP_KEEPCNT = 0x400
sysTCP_NOPUSH = 0x4
)

20
vendor/github.com/mikioh/tcpopt/zsys_freebsd.go generated vendored Normal file
View File

@@ -0,0 +1,20 @@
// Created by cgo -godefs - DO NOT EDIT
// cgo -godefs defs_freebsd.go
package tcpopt
const (
sysSOL_SOCKET = 0xffff
sysSO_KEEPALIVE = 0x8
sysSO_SNDBUF = 0x1001
sysSO_RCVBUF = 0x1002
sysSO_ERROR = 0x1007
sysTCP_NODELAY = 0x1
sysTCP_MAXSEG = 0x2
sysTCP_KEEPIDLE = 0x100
sysTCP_KEEPINTVL = 0x200
sysTCP_KEEPCNT = 0x400
sysTCP_NOPUSH = 0x4
)

25
vendor/github.com/mikioh/tcpopt/zsys_linux_generic.go generated vendored Normal file
View File

@@ -0,0 +1,25 @@
// Created by cgo -godefs - DO NOT EDIT
// cgo -godefs defs_linux.go
// +build !mips64
// +build !mips64le
// +build linux
package tcpopt
const (
sysSOL_SOCKET = 0x1
sysSO_KEEPALIVE = 0x9
sysSO_SNDBUF = 0x7
sysSO_RCVBUF = 0x8
sysSO_ERROR = 0x4
sysTCP_NODELAY = 0x1
sysTCP_MAXSEG = 0x2
sysTCP_KEEPIDLE = 0x4
sysTCP_KEEPINTVL = 0x5
sysTCP_KEEPCNT = 0x6
sysTCP_CORK = 0x3
sysTCP_NOTSENT_LOWAT = 0x19
)

24
vendor/github.com/mikioh/tcpopt/zsys_linux_mips64x.go generated vendored Normal file
View File

@@ -0,0 +1,24 @@
// Created by cgo -godefs - DO NOT EDIT
// cgo -godefs defs_linux.go
// +build mips64 mips64le
// +build linux
package tcpopt
const (
sysSOL_SOCKET = 0x1
sysSO_KEEPALIVE = 0x8
sysSO_SNDBUF = 0x1001
sysSO_RCVBUF = 0x1002
sysSO_ERROR = 0x1007
sysTCP_NODELAY = 0x1
sysTCP_MAXSEG = 0x2
sysTCP_KEEPIDLE = 0x4
sysTCP_KEEPINTVL = 0x5
sysTCP_KEEPCNT = 0x6
sysTCP_CORK = 0x3
sysTCP_NOTSENT_LOWAT = 0x19
)

19
vendor/github.com/mikioh/tcpopt/zsys_netbsd.go generated vendored Normal file
View File

@@ -0,0 +1,19 @@
// Created by cgo -godefs - DO NOT EDIT
// cgo -godefs defs_netbsd.go
package tcpopt
const (
sysSOL_SOCKET = 0xffff
sysSO_KEEPALIVE = 0x8
sysSO_SNDBUF = 0x1001
sysSO_RCVBUF = 0x1002
sysSO_ERROR = 0x1007
sysTCP_NODELAY = 0x1
sysTCP_MAXSEG = 0x2
sysTCP_KEEPIDLE = 0x3
sysTCP_KEEPINTVL = 0x5
sysTCP_KEEPCNT = 0x6
)

17
vendor/github.com/mikioh/tcpopt/zsys_openbsd.go generated vendored Normal file
View File

@@ -0,0 +1,17 @@
// Created by cgo -godefs - DO NOT EDIT
// cgo -godefs defs_openbsd.go
package tcpopt
const (
sysSOL_SOCKET = 0xffff
sysSO_KEEPALIVE = 0x8
sysSO_SNDBUF = 0x1001
sysSO_RCVBUF = 0x1002
sysSO_ERROR = 0x1007
sysTCP_NODELAY = 0x1
sysTCP_MAXSEG = 0x2
sysTCP_NOPUSH = 0x10
)