github.com/pwn-term/docker@v0.0.0-20210616085119-6e977cce2565/libnetwork/drivers/host/host.go (about) 1 package host 2 3 import ( 4 "sync" 5 6 "github.com/docker/libnetwork/datastore" 7 "github.com/docker/libnetwork/discoverapi" 8 "github.com/docker/libnetwork/driverapi" 9 "github.com/docker/libnetwork/types" 10 ) 11 12 const networkType = "host" 13 14 type driver struct { 15 network string 16 sync.Mutex 17 } 18 19 // Init registers a new instance of host driver 20 func Init(dc driverapi.DriverCallback, config map[string]interface{}) error { 21 c := driverapi.Capability{ 22 DataScope: datastore.LocalScope, 23 ConnectivityScope: datastore.LocalScope, 24 } 25 return dc.RegisterDriver(networkType, &driver{}, c) 26 } 27 28 func (d *driver) NetworkAllocate(id string, option map[string]string, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) { 29 return nil, types.NotImplementedErrorf("not implemented") 30 } 31 32 func (d *driver) NetworkFree(id string) error { 33 return types.NotImplementedErrorf("not implemented") 34 } 35 36 func (d *driver) EventNotify(etype driverapi.EventType, nid, tableName, key string, value []byte) { 37 } 38 39 func (d *driver) DecodeTableEntry(tablename string, key string, value []byte) (string, map[string]string) { 40 return "", nil 41 } 42 43 func (d *driver) CreateNetwork(id string, option map[string]interface{}, nInfo driverapi.NetworkInfo, ipV4Data, ipV6Data []driverapi.IPAMData) error { 44 d.Lock() 45 defer d.Unlock() 46 47 if d.network != "" { 48 return types.ForbiddenErrorf("only one instance of \"%s\" network is allowed", networkType) 49 } 50 51 d.network = id 52 53 return nil 54 } 55 56 func (d *driver) DeleteNetwork(nid string) error { 57 return types.ForbiddenErrorf("network of type \"%s\" cannot be deleted", networkType) 58 } 59 60 func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo, epOptions map[string]interface{}) error { 61 return nil 62 } 63 64 func (d *driver) DeleteEndpoint(nid, eid string) error { 65 return nil 66 } 67 68 func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, error) { 69 return make(map[string]interface{}, 0), nil 70 } 71 72 // Join method is invoked when a Sandbox is attached to an endpoint. 73 func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error { 74 return nil 75 } 76 77 // Leave method is invoked when a Sandbox detaches from an endpoint. 78 func (d *driver) Leave(nid, eid string) error { 79 return nil 80 } 81 82 func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error { 83 return nil 84 } 85 86 func (d *driver) RevokeExternalConnectivity(nid, eid string) error { 87 return nil 88 } 89 90 func (d *driver) Type() string { 91 return networkType 92 } 93 94 func (d *driver) IsBuiltIn() bool { 95 return true 96 } 97 98 // DiscoverNew is a notification for a new discovery event, such as a new node joining a cluster 99 func (d *driver) DiscoverNew(dType discoverapi.DiscoveryType, data interface{}) error { 100 return nil 101 } 102 103 // DiscoverDelete is a notification for a discovery delete event, such as a node leaving a cluster 104 func (d *driver) DiscoverDelete(dType discoverapi.DiscoveryType, data interface{}) error { 105 return nil 106 }