Skip to content

Commit a69033f

Browse files
committed
ipn/wg: unexpose IpcSet api
1 parent 3d6915e commit a69033f

2 files changed

Lines changed: 9 additions & 22 deletions

File tree

intra/ipn/proxy.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -162,24 +162,6 @@ func (pxr *proxifier) addProxy(id, txt string) (p Proxy, err error) {
162162
pxr.Unlock()
163163
if p, _ = pxr.ProxyFor(id); p != nil {
164164
if wgp, ok := p.(WgProxy); ok && wgp.update(id, txt) {
165-
opts, err0 := wgIfConfigOf(id, &txt) // removes wg ifconfig from txt
166-
167-
logev(err0)("proxy: updating wg(%s); ifaddrs(%v), dns(%v), mtu(%d); err? %v",
168-
id, opts.ifaddrs, opts.dns, opts.mtu, err)
169-
170-
if err0 != nil {
171-
return nil, err0
172-
}
173-
174-
err1 := wgp.IpcSet(txt)
175-
if err1 != nil {
176-
log.W("proxy: err1 updating wg(%s); %v", id, err1)
177-
return nil, err1
178-
} else {
179-
// sensitive log: peercfg contains private key
180-
log.P("proxy: updating wg(%s) len(peercfg(%d))", id, len(txt))
181-
}
182-
183165
newcfg, readd := wgp.OnProtoChange(lp)
184166
if readd || len(newcfg) > 0 {
185167
log.W("proxy: cannot update wg(%s); readd it!", id)

intra/ipn/wgproxy.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ type WgProxy interface {
153153
Proxy
154154
tun.Device
155155
update(id, txt string) bool
156-
IpcSet(txt string) error
157156
}
158157

159158
// Handle implements Proxy.
@@ -359,8 +358,8 @@ func stripPrefixIfNeeded(id string) string {
359358
// that is, incoming interface config is compatible with the existing tunnel,
360359
// regardless of whether peer config has changed (which can be updated in-place).
361360
func (w *wgproxy) update(id, txt string) bool {
362-
const reuse = true // can update in-place; reuse existing tunnel
363-
const anew = false // cannot update in-place; create new tunnel
361+
const reused = true // can update in-place; reuse existing tunnel
362+
const anew = false // cannot update in-place; create new tunnel
364363
if w.status.Load() == END {
365364
log.W("proxy: wg: update(%s<>%s): END; status(%d)", id, w.id, w.status)
366365
return anew
@@ -411,7 +410,13 @@ func (w *wgproxy) update(id, txt string) bool {
411410
w.amnezia.Store(opts.amnezia)
412411
w.resetMtu(w.getVia())
413412

414-
return reuse
413+
ipcerr := w.IpcSet(cptxt)
414+
if ipcerr != nil {
415+
log.W("proxy: updating wg(%s) ipcset; err %v", id, ipcerr)
416+
return anew
417+
}
418+
419+
return reused
415420
}
416421

417422
func (w *wgtun) allowedIPs(allowed []netip.Prefix) {

0 commit comments

Comments
 (0)