Documentation ¶
Index ¶
- func BalancePackets(packetsIn chan gopacket.Packet, packetsOut chan *EthPacket, ...)
- func GetAddrByName(name string) (net.IP, error)
- func HandleBackendPackets(conn net.PacketConn, dstIP, srcIP net.IP, srcPort layers.TCPPort, ...)
- func HandleBalancerPackets(packetsIn chan gopacket.Packet, backendPackets chan *TCPPacket, ...)
- func SendToBackend(conn net.PacketConn, backendPackets chan *TCPPacket, srcIP, dstIP net.IP)
- func SendToClient(handle *pcap.Handle, ethPackets chan *EthPacket)
- type DummyPool
- type EthPacket
- type PacketBridgeState
- type PacketBridgeStateTable
- func (s *PacketBridgeStateTable) GetByIP(ip net.IP, port layers.TCPPort) (*PacketBridgeState, bool)
- func (s *PacketBridgeStateTable) GetByPort(port layers.TCPPort) (*PacketBridgeState, bool)
- func (s *PacketBridgeStateTable) NewState(ip net.IP, mac net.HardwareAddr, port layers.TCPPort, lbIndex uint8, ...) *PacketBridgeState
- type PoolBalancer
- type Server
- type State
- type StateTable
- type TCPPacket
- type TCPState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BalancePackets ¶
func BalancePackets(packetsIn chan gopacket.Packet, packetsOut chan *EthPacket, stateTable *StateTable, pool PoolBalancer)
BalancePacket implements the actual load-balance logic on packet level.
func GetAddrByName ¶
GetInterfaceAndAddrByName returns the net.IP for a given interface name.
func HandleBackendPackets ¶
func HandleBackendPackets(conn net.PacketConn, dstIP, srcIP net.IP, srcPort layers.TCPPort, pbIface *net.Interface, backendTCPPackets chan *TCPPacket, ethPackets chan *EthPacket, stateTable *PacketBridgeStateTable, balancers map[uint8]net.IP)
HandleBackendPackets handles incoming packets from the backend. If the connection is known, it will forward these packets to the client.
func HandleBalancerPackets ¶
func HandleBalancerPackets(packetsIn chan gopacket.Packet, backendPackets chan *TCPPacket, stateTable *PacketBridgeStateTable)
HandleBalancerPackets handles the incoming packets from the balancer app. When the connection is known, it will forward it to the backend. If not, it will first start a TCP handshake with the backend.
func SendToBackend ¶
func SendToBackend(conn net.PacketConn, backendPackets chan *TCPPacket, srcIP, dstIP net.IP)
SendToBackend sends packets from the packetbridge to the backend.
func SendToClient ¶
SendToClient sends packets to the client who started the request at the balancer.
Types ¶
type DummyPool ¶
type DummyPool struct {
// contains filtered or unexported fields
}
DummyPool provides a PoolBalancer for a single server.
type EthPacket ¶
type EthPacket struct {
// contains filtered or unexported fields
}
EthPacket represents an ethernet packet.
func NewEthPacket ¶
NewEthPacket creates and initializes a new EthPacket.
func (*EthPacket) MarshalBinary ¶
MarshalBinary returns the binary representation of the packet.
type PacketBridgeState ¶
type PacketBridgeState struct { State TCPState IP net.IP HardwareAddr net.HardwareAddr RandPort layers.TCPPort Port layers.TCPPort LBIndex uint8 SeqOffset uint32 PayloadBuf []byte }
PacketBridgeState represents a single connection state at the packet bridge.
type PacketBridgeStateTable ¶
PacketBridgeStateTable represents a table of tcp connection states.
func NewPacketBridgeStateTable ¶
func NewPacketBridgeStateTable() *PacketBridgeStateTable
NewPacketBridgeStateTable creates and initializes a new PacketBridgeStateTable.
func (*PacketBridgeStateTable) GetByIP ¶
func (s *PacketBridgeStateTable) GetByIP(ip net.IP, port layers.TCPPort) (*PacketBridgeState, bool)
func (*PacketBridgeStateTable) GetByPort ¶
func (s *PacketBridgeStateTable) GetByPort(port layers.TCPPort) (*PacketBridgeState, bool)
func (*PacketBridgeStateTable) NewState ¶
func (s *PacketBridgeStateTable) NewState(ip net.IP, mac net.HardwareAddr, port layers.TCPPort, lbIndex uint8, seqOffset uint32, payload []byte) *PacketBridgeState
type PoolBalancer ¶
PoolBalancer specifies the interface for a balancer backend.
func NewDummyBalancer ¶
func NewDummyBalancer() PoolBalancer
NewDummyBalancers returns a new DummyPool.
type Server ¶
type Server struct { IP net.IP HardwareAddr net.HardwareAddr }
Server contains all the information for a backend server.
type StateTable ¶
StateTable keeps track of the connection states.
func NewStateTable ¶
func NewStateTable() *StateTable
NewStateTable creates and initializes a new StateTable.
type TCPPacket ¶
type TCPPacket struct {
// contains filtered or unexported fields
}
TCPPacket represents a TCP packet.
func NewTCPPacket ¶
NewTCPPacket creates and initializes a new TCP packet. The IP layer is needed to calculate the correct TCP checksum.
func (*TCPPacket) MarshalBinary ¶
MarshalBinary returns the binary representation of the packet.