Documentation ¶
Index ¶
- Constants
- Variables
- func BigIntToIP(ipInt *big.Int, version uint8) net.IP
- func IPToBigInt(ip net.IP) *big.Int
- func IsIPv4(addr net.IP) bool
- func IsIPv6(addr net.IP) bool
- type Block
- func (*Block) Descriptor() ([]byte, []int)
- func (m *Block) GetLabels() map[string]string
- func (m *Block) GetZones() []*Zone
- func (m *Block) Marshal() (dAtA []byte, err error)
- func (m *Block) MarshalTo(dAtA []byte) (int, error)
- func (m *Block) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*Block) ProtoMessage()
- func (m *Block) Reset()
- func (m *Block) Size() (n int)
- func (m *Block) String() string
- func (m *Block) Unmarshal(dAtA []byte) error
- func (m *Block) XXX_DiscardUnknown()
- func (m *Block) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Block) XXX_Merge(src proto.Message)
- func (m *Block) XXX_Size() int
- func (m *Block) XXX_Unmarshal(b []byte) error
- type Bucket
- func (*Bucket) Descriptor() ([]byte, []int)
- func (m *Bucket) GetUsed() map[string]*Descriptor
- func (m *Bucket) Marshal() (dAtA []byte, err error)
- func (m *Bucket) MarshalTo(dAtA []byte) (int, error)
- func (m *Bucket) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*Bucket) ProtoMessage()
- func (m *Bucket) Reset()
- func (m *Bucket) Size() (n int)
- func (m *Bucket) String() string
- func (m *Bucket) Unmarshal(dAtA []byte) error
- func (m *Bucket) XXX_DiscardUnknown()
- func (m *Bucket) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Bucket) XXX_Merge(src proto.Message)
- func (m *Bucket) XXX_Size() int
- func (m *Bucket) XXX_Unmarshal(b []byte) error
- type Descriptor
- func (*Descriptor) Descriptor() ([]byte, []int)
- func (m *Descriptor) GetLabels() map[string]string
- func (m *Descriptor) GetRefCount() uint32
- func (m *Descriptor) Marshal() (dAtA []byte, err error)
- func (m *Descriptor) MarshalTo(dAtA []byte) (int, error)
- func (m *Descriptor) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*Descriptor) ProtoMessage()
- func (m *Descriptor) Reset()
- func (m *Descriptor) Size() (n int)
- func (m *Descriptor) String() string
- func (m *Descriptor) Unmarshal(dAtA []byte) error
- func (m *Descriptor) XXX_DiscardUnknown()
- func (m *Descriptor) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Descriptor) XXX_Merge(src proto.Message)
- func (m *Descriptor) XXX_Size() int
- func (m *Descriptor) XXX_Unmarshal(b []byte) error
- type IPAM
- type LabelMap
- type Zone
- func (*Zone) Descriptor() ([]byte, []int)
- func (m *Zone) GetBuckets() map[string]*Bucket
- func (m *Zone) GetLabels() map[string]string
- func (m *Zone) GetLiteral() string
- func (m *Zone) GetReserved() map[string]*Descriptor
- func (m *Zone) Marshal() (dAtA []byte, err error)
- func (m *Zone) MarshalTo(dAtA []byte) (int, error)
- func (m *Zone) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*Zone) ProtoMessage()
- func (m *Zone) Reset()
- func (m *Zone) Size() (n int)
- func (m *Zone) String() string
- func (m *Zone) Unmarshal(dAtA []byte) error
- func (m *Zone) XXX_DiscardUnknown()
- func (m *Zone) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Zone) XXX_Merge(src proto.Message)
- func (m *Zone) XXX_Size() int
- func (m *Zone) XXX_Unmarshal(b []byte) error
Constants ¶
View Source
const BucketSize = (512 + 1024) * 1024
Variables ¶
View Source
var ( ErrInvalidLengthStorage = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowStorage = fmt.Errorf("proto: integer overflow") ErrUnexpectedEndOfGroupStorage = fmt.Errorf("proto: unexpected end of group") )
View Source
var AddrNumPerBucket = 4096
Functions ¶
Types ¶
type Block ¶
type Block struct { Labels map[string]string `` /* 153-byte string literal not displayed */ Zones []*Zone `protobuf:"bytes,2,rep,name=zones,proto3" json:"zones,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*Block) Descriptor ¶
func (*Block) ProtoMessage ¶
func (*Block) ProtoMessage()
func (*Block) XXX_DiscardUnknown ¶
func (m *Block) XXX_DiscardUnknown()
func (*Block) XXX_Marshal ¶
func (*Block) XXX_Unmarshal ¶
type Bucket ¶
type Bucket struct { Used map[string]*Descriptor `` /* 149-byte string literal not displayed */ XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
IP地址桶,用于多个IP独立存储,最大IP容量上限
func (*Bucket) Descriptor ¶
func (*Bucket) GetUsed ¶
func (m *Bucket) GetUsed() map[string]*Descriptor
func (*Bucket) MarshalToSizedBuffer ¶
func (*Bucket) ProtoMessage ¶
func (*Bucket) ProtoMessage()
func (*Bucket) XXX_DiscardUnknown ¶
func (m *Bucket) XXX_DiscardUnknown()
func (*Bucket) XXX_Marshal ¶
func (*Bucket) XXX_Unmarshal ¶
type Descriptor ¶
type Descriptor struct { Labels map[string]string `` /* 153-byte string literal not displayed */ RefCount uint32 `protobuf:"varint,2,opt,name=ref_count,json=refCount,proto3" json:"ref_count,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
IP地址描述符
func (*Descriptor) Descriptor ¶
func (*Descriptor) Descriptor() ([]byte, []int)
func (*Descriptor) GetLabels ¶
func (m *Descriptor) GetLabels() map[string]string
func (*Descriptor) GetRefCount ¶
func (m *Descriptor) GetRefCount() uint32
func (*Descriptor) Marshal ¶
func (m *Descriptor) Marshal() (dAtA []byte, err error)
func (*Descriptor) MarshalToSizedBuffer ¶
func (m *Descriptor) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*Descriptor) ProtoMessage ¶
func (*Descriptor) ProtoMessage()
func (*Descriptor) Reset ¶
func (m *Descriptor) Reset()
func (*Descriptor) Size ¶
func (m *Descriptor) Size() (n int)
func (*Descriptor) String ¶
func (m *Descriptor) String() string
func (*Descriptor) Unmarshal ¶
func (m *Descriptor) Unmarshal(dAtA []byte) error
func (*Descriptor) XXX_DiscardUnknown ¶
func (m *Descriptor) XXX_DiscardUnknown()
func (*Descriptor) XXX_Marshal ¶
func (m *Descriptor) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*Descriptor) XXX_Merge ¶
func (m *Descriptor) XXX_Merge(src proto.Message)
func (*Descriptor) XXX_Size ¶
func (m *Descriptor) XXX_Size() int
func (*Descriptor) XXX_Unmarshal ¶
func (m *Descriptor) XXX_Unmarshal(b []byte) error
type IPAM ¶
type IPAM interface { // 设置IPAM自己的标签 SetLabel(ctx context.Context, key, value string) // 移除IPAM的标签,返回被移除的key的value与key是否存在,若key不存在则默认value为空字符串 RemoveLabel(ctx context.Context, key string) (string, bool) // 列出指定IPAM的所有标签 Labels(ctx context.Context) LabelMap // 添加Zone,即IP地址段 // // literal支持以下几种IP地址格式: // // 1. 单个IPv4/IPv6地址(如192.168.0.1,或FE80::12) // // 2. 连字符(闭)区间(如192.168.0.1-192.168.3.2,或FE80::12-FE80::1:12) // // 3. CIDR网络地址(如192.168.0..0/24,或FE80::/64) // // 注意:当使用CIDR网络地址时,该网络的0地址和广播地址不会被计入可用地址内,若需要使用这些地址,请使用连字符区间格式 // // lazy: 目前无效 AddZone(ctx context.Context, literal string, lazy bool) error // 设置Zone的标签 SetZoneLabel(ctx context.Context, literal, key, value string) error // 移除由literal指定的Zone RemoveZone(ctx context.Context, literal string) error // 移除Zone的标签,返回被移除的key的value与zone/key是否存在,若zone/key不存在则默认value为空字符串 RemoveZoneLabel(ctx context.Context, literal, key string) (string, bool) // 列出指定Zone的所有标签并返回Zone是否存在 ZoneLabels(ctx context.Context, literal string) (LabelMap, bool) // 以string表示的当前空闲的地址数量,即`全部地址数量 - 已用地址数量 - 保留地址数量` IdleCount(ctx context.Context) string // 全部已使用的IP地址 UsedAddrs(ctx context.Context) []string // 全部已保留的IP地址 ReservedAddrs(ctx context.Context) []string // 分配一个指定的IP,允许指定已使用的IP(内部引用计数加1),若有标签,则一并填写(覆盖)标签 AllocAddrSpecific(ctx context.Context, specific string, labels LabelMap) error // 从随机Zone的未使用IP中分配一个,若有标签,则一并填写标签 AllocAddrNext(ctx context.Context, labels LabelMap) (net.IP, error) // 保留一个IP,该IP必须未分配 ReserveAddr(ctx context.Context, specific string, labels LabelMap) error // 释放一个IP,该IP应当已分配或已保留,允许多次释放一个被多次申请的IP(内部引用计数减1) ReleaseAddr(ctx context.Context, specific string) error // 设置IP地址的标签,若IP格式错误或地址未分配/未保留则报错 SetAddrLabel(ctx context.Context, specific, key, value string) error // 移除IP地址的标签,若IP格式错误或地址未分配/未保留则报错 RemoveAddrLabel(ctx context.Context, specific, key string) error // 列出指定IP地址的所有标签,若IP格式错误或地址未分配/未保留则报错 AddrLabels(ctx context.Context, specific string) (LabelMap, error) // 从IP地址查找所属Zone的literal,由于zone的literal不可能为空字符串,因此无需返回布尔值 FindLiteral(ctx context.Context, specific string) string // 列出当前所有Zone的literal Literals(ctx context.Context) []string // 导出所有Zone为字节码,默认情况下不导出已分配的IP信息 // // fat为true时,将会包含已分配的IP信息 Dump(ctx context.Context, fat bool) ([]byte, error) // 将Zone中已分配的IP导出为分散的字节码映射 DumpZoneAddrs(ctx context.Context, literal string, onlyKeys bool) (map[string][]byte, error) // 从Dump导出的字节码中加载全部Zone,IPAM中已有的同名Zone将会被覆盖 Load(ctx context.Context, raw []byte) error // 从DumpZoneAddrs导出的字节码映射中加载Zone的已分配地址 // // 若addrs的key不包含在该Zone中,则该key与其对应的地址将被忽略 // // 若force为true,即使addrs的key在Zone中找不到,也仍会加载 LoadZoneAddrs(ctx context.Context, literal string, addrs map[string][]byte, force bool) error }
支持IPv4与IPv6的地址管理与持久化
type Zone ¶
type Zone struct { Literal string `protobuf:"bytes,1,opt,name=literal,proto3" json:"literal,omitempty"` Labels map[string]string `` /* 153-byte string literal not displayed */ // bucket的索引映射,其中key为bucket的索引 Buckets map[string]*Bucket `` /* 155-byte string literal not displayed */ Reserved map[string]*Descriptor `` /* 157-byte string literal not displayed */ XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*Zone) Descriptor ¶
func (*Zone) GetBuckets ¶
func (*Zone) GetLiteral ¶
func (*Zone) GetReserved ¶
func (m *Zone) GetReserved() map[string]*Descriptor
func (*Zone) ProtoMessage ¶
func (*Zone) ProtoMessage()
func (*Zone) XXX_DiscardUnknown ¶
func (m *Zone) XXX_DiscardUnknown()
func (*Zone) XXX_Unmarshal ¶
Click to show internal directories.
Click to hide internal directories.