@@ -432,13 +432,18 @@ func (w *wgproxy) Refresh() (err error) {
432432}
433433
434434func (w * wgproxy ) redoPeers () {
435- if cfg := w .wgtun .uapicfg .Load (); len (cfg ) > 0 {
435+ w .wgtun .ipcset (w .Device )
436+ }
437+
438+ func (h * wgtun ) ipcset (d * device.Device ) {
439+ if cfg := h .uapicfg .Load (); len (cfg ) > 0 {
436440 cpcfg := cfg // copies string
437- _ , _ = wgIfConfigOf (w .id , & cpcfg ) // removes non-uapi fields
438- if ipcerr := w . Device . IpcSet (cpcfg ); ipcerr != nil {
439- log . W ( "proxy: wg: %s: refresh : re-apply ipcset failed ; err %v" , w .tag (), ipcerr )
440- }
441+ _ , _ = wgIfConfigOf (h .id , & cpcfg ) // removes non-uapi fields
442+ ipcerr := d . IpcSet (cpcfg )
443+ logei ( ipcerr )( "proxy: wg: %s: ipcset : re-apply; err %v" , h .tag (), ipcerr )
444+ return
441445 }
446+ log .E ("proxy: wg: %s: ipcset: missing uapicfg" , h .tag ())
442447}
443448
444449func (h * wgproxy ) Dialer () protect.RDialer {
@@ -786,13 +791,7 @@ func NewWgProxy(id string, ctl protect.Controller, px ProxyProvider, lp LinkProp
786791func newdevice (wgtun * wgtun , wgep wgconn ) (* device.Device , error ) {
787792 wgdev := device .NewDevice (wgtun , wgep , wglogger (wgtun ))
788793
789- uapicfg := wgtun .uapicfg .Load ()
790- err := wgdev .IpcSet (uapicfg )
791- if err != nil {
792- defer wgdev .Close ()
793- log .E ("proxy: wg: %s:%s failed to ipc-set %v" , wgtun .tag (), err )
794- return nil , err
795- }
794+ wgtun .ipcset (wgdev ) // apply initial config to device
796795
797796 // github.com/WireGuard/wireguard-android/blob/713947e432/tunnel/tools/libwg-go/api-android.go#L99
798797 wgdev .DisableSomeRoamingForBrokenMobileSemantics ()
0 commit comments