implement ICMP ping

This commit is contained in:
pufferffish 2024-04-11 01:46:08 +01:00
parent 4cf68c94dd
commit efc7e62704
4 changed files with 129 additions and 10 deletions

View file

@ -22,12 +22,14 @@ type PeerConfig struct {
// DeviceConfig contains the information to initiate a wireguard connection
type DeviceConfig struct {
SecretKey string
Endpoint []netip.Addr
Peers []PeerConfig
DNS []netip.Addr
MTU int
ListenPort *int
SecretKey string
Endpoint []netip.Addr
Peers []PeerConfig
DNS []netip.Addr
MTU int
ListenPort *int
CheckAlive []netip.Addr
CheckAliveInterval int
}
type TCPClientTunnelConfig struct {
@ -237,6 +239,25 @@ func ParseInterface(cfg *ini.File, device *DeviceConfig) error {
device.ListenPort = &value
}
checkAlive, err := parseNetIP(section, "CheckAlive")
if err != nil {
return err
}
device.CheckAlive = checkAlive
device.CheckAliveInterval = 5
if sectionKey, err := section.GetKey("CheckAliveInterval"); err == nil {
value, err := sectionKey.Int()
if err != nil {
return err
}
if len(checkAlive) == 0 {
return errors.New("CheckAliveInterval is only valid when CheckAlive is set")
}
device.CheckAliveInterval = value
}
return nil
}