@@ -65,6 +65,7 @@ import (
65
65
"github.com/NordSecurity/nordvpn-linux/request"
66
66
"github.com/NordSecurity/nordvpn-linux/sharedctx"
67
67
"github.com/NordSecurity/nordvpn-linux/snapconf"
68
+ "github.com/vishvananda/netlink"
68
69
69
70
"google.golang.org/grpc"
70
71
)
@@ -127,7 +128,7 @@ func main() {
127
128
128
129
// Config
129
130
configEvents := daemonevents .NewConfigEvents ()
130
- fsystem := config .NewFilesystemConfigManager (
131
+ cfgMgr := config .NewFilesystemConfigManager (
131
132
config .SettingsDataFilePath ,
132
133
config .InstallFilePath ,
133
134
Salt ,
@@ -136,9 +137,9 @@ func main() {
136
137
configEvents .Config ,
137
138
)
138
139
var cfg config.Config
139
- if err := fsystem .Load (& cfg ); err != nil {
140
+ if err := cfgMgr .Load (& cfg ); err != nil {
140
141
log .Println (err )
141
- if err := fsystem .Reset (); err != nil {
142
+ if err := cfgMgr .Reset (); err != nil {
142
143
log .Fatalln (err )
143
144
}
144
145
}
@@ -234,7 +235,7 @@ func main() {
234
235
httpClientWithRotator ,
235
236
validator ,
236
237
)
237
- meshAPIex := registry .NewRegistry (
238
+ meshRegistry := registry .NewRegistry (
238
239
defaultAPI ,
239
240
meshnetEvents .SelfRemoved ,
240
241
)
@@ -282,17 +283,17 @@ func main() {
282
283
// obfuscated machineID
283
284
deviceID := fmt .Sprintf ("%x" , sha256 .Sum256 ([]byte (cfg .MachineID .String ()+ Salt )))
284
285
285
- analytics := newAnalytics (eventsDbPath , fsystem , defaultAPI , Version , Environment , deviceID )
286
+ analytics := newAnalytics (eventsDbPath , cfgMgr , defaultAPI , Version , Environment , deviceID )
286
287
heartBeatSubject .Subscribe (analytics .NotifyHeartBeat )
287
288
daemonEvents .Subscribe (analytics )
288
289
daemonEvents .Service .Connect .Subscribe (loggerSubscriber .NotifyConnect )
289
290
daemonEvents .Settings .Publish (cfg )
290
291
291
- if fsystem .NewInstallation {
292
+ if cfgMgr .NewInstallation {
292
293
daemonEvents .Service .UiItemsClick .Publish (events.UiItemsAction {ItemName : "first_open" , ItemType : "button" , ItemValue : "first_open" , FormReference : "daemon" })
293
294
}
294
295
295
- vpnLibConfigGetter := vpnLibConfigGetterImplementation (fsystem )
296
+ vpnLibConfigGetter := vpnLibConfigGetterImplementation (cfgMgr )
296
297
297
298
internalVpnEvents := vpn .NewInternalVPNEvents ()
298
299
@@ -394,17 +395,17 @@ func main() {
394
395
norduserClient := norduserservice .NewNorduserGRPCClient ()
395
396
396
397
meshnetChecker := meshnet .NewRegisteringChecker (
397
- fsystem ,
398
+ cfgMgr ,
398
399
keygen ,
399
- meshAPIex ,
400
+ meshRegistry ,
400
401
)
401
402
402
403
meshnetEvents .PeerUpdate .Subscribe (refresher .NewMeshnet (
403
- meshAPIex , meshnetChecker , fsystem , netw ,
404
+ meshRegistry , meshnetChecker , cfgMgr , netw ,
404
405
).NotifyPeerUpdate )
405
406
406
407
meshUnsetter := meshunsetter .NewMeshnet (
407
- fsystem ,
408
+ cfgMgr ,
408
409
netw ,
409
410
errSubject ,
410
411
norduserClient ,
@@ -414,7 +415,7 @@ func main() {
414
415
accountUpdateEvents := daemonevents .NewAccountUpdateEvents ()
415
416
accountUpdateEvents .Subscribe (statePublisher )
416
417
authChecker := auth .NewRenewingChecker (
417
- fsystem ,
418
+ cfgMgr ,
418
419
defaultAPI ,
419
420
daemonEvents .User .MFA ,
420
421
errSubject ,
@@ -426,7 +427,7 @@ func main() {
426
427
infoSubject ,
427
428
errSubject ,
428
429
meshnetEvents .PeerUpdate ,
429
- nc .NewCredsFetcher (defaultAPI , fsystem ))
430
+ nc .NewCredsFetcher (defaultAPI , cfgMgr ))
430
431
431
432
dataUpdateEvents := daemonevents .NewDataUpdateEvents ()
432
433
dataUpdateEvents .Subscribe (statePublisher )
@@ -442,7 +443,7 @@ func main() {
442
443
rpc := daemon .NewRPC (
443
444
internal .Environment (Environment ),
444
445
authChecker ,
445
- fsystem ,
446
+ cfgMgr ,
446
447
dm ,
447
448
defaultAPI ,
448
449
defaultAPI ,
@@ -460,22 +461,30 @@ func main() {
460
461
notificationClient ,
461
462
analytics ,
462
463
norduserService ,
463
- meshAPIex ,
464
+ meshRegistry ,
464
465
statePublisher ,
465
466
sharedContext ,
466
467
)
468
+
469
+ filesharePortController := meshnet .NewPortAccessController (cfgMgr , netw , meshRegistry )
470
+ fileshareProcMonitor := meshnet .NewProcMonitor (
471
+ & filesharePortController ,
472
+ netlinkMonitorSetupFn ,
473
+ )
474
+
467
475
meshService := meshnet .NewServer (
468
476
authChecker ,
469
- fsystem ,
477
+ cfgMgr ,
470
478
meshnetChecker ,
471
479
defaultAPI ,
472
480
netw ,
473
- meshAPIex ,
481
+ meshRegistry ,
474
482
threatProtectionLiteServers ,
475
483
errSubject ,
476
484
meshnetEvents .PeerUpdate ,
477
485
daemonEvents ,
478
486
norduserClient ,
487
+ fileshareProcMonitor ,
479
488
sharedContext ,
480
489
)
481
490
@@ -573,11 +582,11 @@ func main() {
573
582
go rpc .StartAutoConnect (network .ExponentialBackoff )
574
583
}
575
584
576
- monitor , err := netstate .NewNetlinkMonitor ([]string {openvpn .InterfaceName , nordlynx .InterfaceName })
585
+ netMonitor , err := netstate .NewNetlinkMonitor ([]string {openvpn .InterfaceName , nordlynx .InterfaceName })
577
586
if err != nil {
578
587
log .Fatalln (err )
579
588
}
580
- monitor .Start (netw )
589
+ netMonitor .Start (netw )
581
590
582
591
if authChecker .IsLoggedIn () {
583
592
go daemon .StartNC ("[startup]" , notificationClient )
@@ -606,3 +615,17 @@ func main() {
606
615
log .Println (internal .ErrorPrefix , "stopping KillSwitch:" , err )
607
616
}
608
617
}
618
+
619
+ func netlinkMonitorSetupFn () (meshnet.MonitorChannels , error ) {
620
+ eventCh := make (chan netlink.ProcEvent , 128 )
621
+ doneCh := make (chan struct {})
622
+ errCh := make (chan error )
623
+ if err := netlink .ProcEventMonitor (eventCh , doneCh , errCh ); err != nil {
624
+ return meshnet.MonitorChannels {}, err
625
+ }
626
+ return meshnet.MonitorChannels {
627
+ EventCh : eventCh ,
628
+ DoneCh : doneCh ,
629
+ ErrCh : errCh ,
630
+ }, nil
631
+ }
0 commit comments