MCPcopy Create free account
hub / github.com/eventure/hide.client.linux / ipAddrsAdd

Method ipAddrsAdd

wireguard/ipAddress.go:11–23  ·  view source on GitHub ↗

Add the addresses to the wireguard interface

( addrs []net.IP )

Source from the content-addressed store, hash-verified

9
10// Add the addresses to the wireguard interface
11func (l *Link) ipAddrsAdd( addrs []net.IP ) ( err error ) {
12 l.ips = []net.IP{}
13 for _, addr := range addrs {
14 if addr.To4() != nil { if !l.Config.IPv4 { continue } } else { if !l.Config.IPv6 { continue } }
15 if err = netlink.AddrAdd( l.wireguardLink, &netlink.Addr{ IPNet: netlink.NewIPNet( addr ) } ); err != nil {
16 log.Println( "Link: [ERR] Addition of", addr.String(), "to interface", l.wireguardLink.Attrs().Name, "failed:", err )
17 return
18 }
19 log.Println( "Link: Address", addr.String(), "added to interface", l.wireguardLink.Attrs().Name )
20 l.ips = append( l.ips, addr )
21 }
22 return
23}
24
25// Remove addresses from the wireguard interface
26func (l *Link) ipAddrsDel() ( err error ) {

Callers 1

UpMethod · 0.95

Calls 1

StringMethod · 0.80

Tested by

no test coverage detected