list interfaces
This commit is contained in:
parent
3fd43f0d18
commit
d940897a55
@ -10,7 +10,7 @@ Realized features:
|
|||||||
- [ ] Rule composer
|
- [ ] Rule composer
|
||||||
- [ ] List loading/watching (temporary)
|
- [ ] List loading/watching (temporary)
|
||||||
- [X] IPSet integration
|
- [X] IPSet integration
|
||||||
- [ ] Listing of interfaces
|
- [X] Listing of interfaces
|
||||||
- [ ] IPTables rules to IPSet [2]
|
- [ ] IPTables rules to IPSet [2]
|
||||||
- [ ] It is not a concept now... REFACTORING TIME!!!
|
- [ ] It is not a concept now... REFACTORING TIME!!!
|
||||||
- [ ] HTTP API
|
- [ ] HTTP API
|
||||||
|
20
kvas2.go
20
kvas2.go
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -130,6 +131,25 @@ func (a *App) AppendGroup(group *models.Group) error {
|
|||||||
return nil
|
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) {
|
func (a *App) processARecord(aRecord dnsProxy.Address) {
|
||||||
ttlDuration := time.Duration(aRecord.TTL) * time.Second
|
ttlDuration := time.Duration(aRecord.TTL) * time.Second
|
||||||
if ttlDuration < a.Config.MinimalTTL {
|
if ttlDuration < a.Config.MinimalTTL {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user