MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / AddSet

Method AddSet

internal/firewalls/nftables/table.go:106–138  ·  view source on GitHub ↗
(name string, options *SetOptions)

Source from the content-addressed store, hash-verified

104}
105
106func (this *Table) AddSet(name string, options *SetOptions) (*Set, error) {
107 if len(name) > MaxSetNameLength {
108 return nil, errors.New("set name too long (max " + types.String(MaxSetNameLength) + ")")
109 }
110
111 if options == nil {
112 options = &SetOptions{}
113 }
114 var rawSet = &nft.Set{
115 Table: this.rawTable,
116 ID: options.Id,
117 Name: name,
118 Anonymous: options.Anonymous,
119 Constant: options.Constant,
120 Interval: options.Interval,
121 IsMap: options.IsMap,
122 HasTimeout: options.HasTimeout,
123 Timeout: options.Timeout,
124 KeyType: options.KeyType,
125 DataType: options.DataType,
126 }
127 err := this.conn.Raw().AddSet(rawSet, nil)
128 if err != nil {
129 return nil, err
130 }
131
132 err = this.conn.Commit()
133 if err != nil {
134 return nil, err
135 }
136
137 return NewSet(this.conn, rawSet), nil
138}
139
140func (this *Table) DeleteSet(name string) error {
141 set, err := this.GetSet(name)

Callers 3

initMethod · 0.80
TestTable_AddSetFunction · 0.80
getIPv4SetFunction · 0.80

Calls 4

NewSetFunction · 0.85
StringMethod · 0.45
RawMethod · 0.45
CommitMethod · 0.45

Tested by 2

TestTable_AddSetFunction · 0.64
getIPv4SetFunction · 0.64