start implementation of report
This commit is contained in:
parent
f8eeda36f9
commit
e7fe33fe76
@ -29,6 +29,7 @@ func main() {
|
||||
dsnet.Sync()
|
||||
|
||||
case "report":
|
||||
dsnet.report()
|
||||
|
||||
case "down":
|
||||
dsnet.Down()
|
||||
|
19
report.go
Normal file
19
report.go
Normal file
@ -0,0 +1,19 @@
|
||||
package dsnet
|
||||
|
||||
import (
|
||||
"net"
|
||||
|
||||
"github.com/vishvananda/netlink"
|
||||
"golang.zx2c4.com/wireguard/wgctrl"
|
||||
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
||||
)
|
||||
|
||||
func Up() {
|
||||
conf := MustLoadDsnetConfig()
|
||||
|
||||
dev, err := wgctrl.Device(conf.InterfaceName)
|
||||
check(err)
|
||||
|
||||
report := Report(dev, conf)
|
||||
report.MustSave()
|
||||
}
|
@ -3,6 +3,8 @@ package dsnet
|
||||
import (
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
||||
)
|
||||
|
||||
type Status int
|
||||
@ -52,6 +54,16 @@ type DsnetReport struct {
|
||||
Peers []PeerReport
|
||||
}
|
||||
|
||||
func Report(*wgtypes.Device, conf *DsnetConfig) DsnetReport {
|
||||
|
||||
}
|
||||
|
||||
func (report *DsnetReport) MustSave() {
|
||||
_json, _ := json.MarshalIndent(report, "", " ")
|
||||
err := ioutil.WriteFile(CONFIG_FILE, _json, 0644)
|
||||
check(err)
|
||||
}
|
||||
|
||||
type PeerReport struct {
|
||||
// Used to update DNS
|
||||
Hostname string
|
||||
|
Loading…
Reference in New Issue
Block a user