list interfaces
This commit is contained in:
parent
3fd43f0d18
commit
d940897a55
@ -10,7 +10,7 @@ Realized features:
|
||||
- [ ] Rule composer
|
||||
- [ ] List loading/watching (temporary)
|
||||
- [X] IPSet integration
|
||||
- [ ] Listing of interfaces
|
||||
- [X] Listing of interfaces
|
||||
- [ ] IPTables rules to IPSet [2]
|
||||
- [ ] It is not a concept now... REFACTORING TIME!!!
|
||||
- [ ] HTTP API
|
||||
|
20
kvas2.go
20
kvas2.go
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@ -130,6 +131,25 @@ func (a *App) AppendGroup(group *models.Group) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) ListInterfaces() ([]net.Interface, error) {
|
||||
interfaceNames := make([]net.Interface, 0)
|
||||
|
||||
interfaces, err := net.Interfaces()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get interfaces: %w", err)
|
||||
}
|
||||
|
||||
for _, iface := range interfaces {
|
||||
if iface.Flags&net.FlagPointToPoint == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
interfaceNames = append(interfaceNames, iface)
|
||||
}
|
||||
|
||||
return interfaceNames, nil
|
||||
}
|
||||
|
||||
func (a *App) processARecord(aRecord dnsProxy.Address) {
|
||||
ttlDuration := time.Duration(aRecord.TTL) * time.Second
|
||||
if ttlDuration < a.Config.MinimalTTL {
|
||||
|
Loading…
x
Reference in New Issue
Block a user