package
0.0.0-20240701071450-45e2431495c8
Repository: https://github.com/docker/go-plugins-helpers.git
Documentation: pkg.go.dev
# README
Docker network extension API
Go handler to create external network extensions for Docker.
Usage
This library is designed to be integrated in your program.
- Implement the
network.Driver
interface. - Initialize a
network.Handler
with your implementation. - Call either
ServeTCP
,ServeUnix
orServeWindows
from thenetwork.Handler
. - On Windows, docker daemon data dir must be provided for ServeTCP and ServeWindows functions. On Unix, this parameter is ignored.
Example using TCP sockets:
import "github.com/docker/go-plugins-helpers/network"
d := MyNetworkDriver{}
h := network.NewHandler(d)
h.ServeTCP("test_network", ":8080", "")
// on windows:
h.ServeTCP("test_network", ":8080", WindowsDefaultDaemonRootDir())
Example using Unix sockets:
import "github.com/docker/go-plugins-helpers/network"
d := MyNetworkDriver{}
h := network.NewHandler(d)
h.ServeUnix("test_network", 0)
Example using Windows named pipes:
import "github.com/docker/go-plugins-helpers/network"
import "github.com/docker/go-plugins-helpers/sdk"
d := MyNetworkDriver{}
h := network.NewHandler(d)
config := sdk.WindowsPipeConfig{
// open, read, write permissions for everyone
// (uses Windows Security Descriptor Definition Language)
SecurityDescriptor: AllowServiceSystemAdmin,
InBufferSize: 4096,
OutBufferSize: 4096,
}
h.ServeWindows("//./pipe/testpipe", "test_network", WindowsDefaultDaemonRootDir(), &config)
Full example plugins
- docker-ovs-plugin - An Open vSwitch Networking Plugin
# Functions
NewErrorResponse creates an ErrorResponse with the provided message.
NewHandler initializes the request handler with a driver implementation.
# Constants
GlobalScope is the correct scope response for a global scope driver.
LocalScope is the correct scope response for a local scope driver.
# Structs
AllocateNetworkRequest requests allocation of new network by manager.
AllocateNetworkResponse is the response to the AllocateNetworkRequest.
CapabilitiesResponse returns whether or not this network is global or local.
CreateEndpointRequest is sent by the daemon when an endpoint should be created.
CreateEndpointResponse is sent as a response to a CreateEndpointRequest.
CreateNetworkRequest is sent by the daemon when a network needs to be created.
DeleteEndpointRequest is sent by the daemon when an endpoint needs to be removed.
DeleteNetworkRequest is sent by the daemon when a network needs to be removed.
DiscoveryNotification is sent by the daemon when a new discovery event occurs.
EndpointInterface contains endpoint interface information.
ErrorResponse is a formatted error message that libnetwork can understand.
FreeNetworkRequest is the request to free allocated network in the manager.
Handler forwards requests and responses between the docker daemon and the plugin.
InfoRequest is send by the daemon when querying endpoint information.
InfoResponse is endpoint information sent in response to an InfoRequest.
InterfaceName consists of the name of the interface in the global netns and the desired prefix to be appended to the interface inside the container netns.
IPAMData contains IPv4 or IPv6 addressing information.
JoinRequest is sent by the Daemon when an endpoint needs be joined to a network.
JoinResponse is sent in response to a JoinRequest.
LeaveRequest is send by the daemon when a endpoint is leaving a network.
ProgramExternalConnectivityRequest specifies the L4 data and the endpoint for which programming has to be done.
RevokeExternalConnectivityRequest specifies the endpoint for which the L4 programming has to be removed.
StaticRoute contains static route information.
# Interfaces
Driver represent the interface a driver must fulfill.