github.com/apernet/sing-tun@v0.2.6-0.20240323130332-b9f6511036ad/stack_system_windows.go (about) 1 package tun 2 3 import ( 4 "os" 5 "path/filepath" 6 7 "github.com/apernet/sing-tun/internal/winfw" 8 ) 9 10 func fixWindowsFirewall() error { 11 absPath, err := filepath.Abs(os.Args[0]) 12 if err != nil { 13 return err 14 } 15 rule := winfw.FWRule{ 16 Name: "sing-tun (" + absPath + ")", 17 ApplicationName: absPath, 18 Enabled: true, 19 Protocol: winfw.NET_FW_IP_PROTOCOL_TCP, 20 Direction: winfw.NET_FW_RULE_DIR_IN, 21 Action: winfw.NET_FW_ACTION_ALLOW, 22 } 23 _, err = winfw.FirewallRuleAddAdvanced(rule) 24 return err 25 }