Skip to content

Commit a760197

Browse files
committed
Remove dependency on comshim
1 parent 8a4a81b commit a760197

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ require (
88
github.com/sagernet/gvisor v0.0.0-20240315080113-799fb6b6d311
99
github.com/sagernet/netlink v0.0.0-20220905062125-8043b4a9aa97
1010
github.com/sagernet/sing v0.3.6
11-
github.com/scjalliance/comshim v0.0.0-20230315213746-5e51f40bd3b9
1211
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba
1312
golang.org/x/net v0.22.0
1413
golang.org/x/sys v0.18.0

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ github.com/sagernet/netlink v0.0.0-20220905062125-8043b4a9aa97 h1:iL5gZI3uFp0X6E
1212
github.com/sagernet/netlink v0.0.0-20220905062125-8043b4a9aa97/go.mod h1:xLnfdiJbSp8rNqYEdIW/6eDO4mVoogml14Bh2hSiFpM=
1313
github.com/sagernet/sing v0.3.6 h1:dsEdYLKBQlrxUfw1a92x0VdPvR1/BOxQ+HIMyaoEJsQ=
1414
github.com/sagernet/sing v0.3.6/go.mod h1:+60H3Cm91RnL9dpVGWDPHt0zTQImO9Vfqt9a4rSambI=
15-
github.com/scjalliance/comshim v0.0.0-20230315213746-5e51f40bd3b9 h1:rc/CcqLH3lh8n+csdOuDfP+NuykE0U6AeYSJJHKDgSg=
16-
github.com/scjalliance/comshim v0.0.0-20230315213746-5e51f40bd3b9/go.mod h1:a/83NAfUXvEuLpmxDssAXxgUgrEy12MId3Wd7OTs76s=
1715
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
1816
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74 h1:gga7acRE695APm9hlsSMoOoE65U4/TcqNj90mc69Rlg=
1917
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=

internal/winfw/winfw.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212

1313
"github.com/go-ole/go-ole"
1414
"github.com/go-ole/go-ole/oleutil"
15-
"github.com/scjalliance/comshim"
1615
)
1716

1817
// Firewall related API constants.
@@ -250,7 +249,10 @@ func FirewallRuleExistsByName(rules *ole.IDispatch, name string) (bool, error) {
250249
// then:
251250
// dispatch firewallAPIRelease(u, fwp)
252251
func firewallAPIInit() (*ole.IUnknown, *ole.IDispatch, error) {
253-
comshim.Add(1)
252+
err := ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
253+
if err != nil {
254+
return nil, nil, fmt.Errorf("Failed to initialize COM: %s", err)
255+
}
254256

255257
unknown, err := oleutil.CreateObject("HNetCfg.FwPolicy2")
256258
if err != nil {
@@ -270,5 +272,5 @@ func firewallAPIInit() (*ole.IUnknown, *ole.IDispatch, error) {
270272
func firewallAPIRelease(u *ole.IUnknown, fwp *ole.IDispatch) {
271273
fwp.Release()
272274
u.Release()
273-
comshim.Done()
275+
ole.CoUninitialize()
274276
}

0 commit comments

Comments
 (0)