wf icon indicating copy to clipboard operation
wf copied to clipboard

Simple allow app inbound

Open Cacsjep opened this issue 8 months ago • 0 comments

Hey

First thank for these module, could u help me I just want to allow inbound traffic for my app. It returns no error but i dont see the rule in the firewall gui inbound rules.

A short hint or help would be cool thanks

func AddAppFirewallRule() error {
	session, err := wf.New(&wf.Options{
		Name:    "nvmr session",
		Dynamic: false,
	})
	if err != nil {
		return err
	}
	defer session.Close()
	guid, _ := windows.GenerateGUID()
	execPath, _ := os.Executable()
	appID, _ := wf.AppID(execPath)
	err = session.AddRule(&wf.Rule{
		ID:     wf.RuleID(guid),
		Name:   "NVRM",
		Layer:  wf.LayerALEAuthRecvAcceptV4,
		Weight: 800,
		Conditions: []*wf.Match{
			{
				Field: wf.FieldALEAppID,
				Op:    wf.MatchTypeEqual,
				Value: appID,
			},
		},
		Action: wf.ActionPermit,
	})

	if err != nil {
		return err
	}
	return nil
}

Cacsjep avatar Jun 07 '24 09:06 Cacsjep