forked from SagerNet/sing-box
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2373281
commit 189f02c
Showing
16 changed files
with
123 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
//go:build with_quic | ||
|
||
package include | ||
|
||
import _ "github.com/sagernet/sing-dns/quic" | ||
|
||
const WithQUIC = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//go:build !with_quic | ||
|
||
package include | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/sagernet/sing-dns" | ||
E "github.com/sagernet/sing/common/exceptions" | ||
N "github.com/sagernet/sing/common/network" | ||
) | ||
|
||
const WithQUIC = false | ||
|
||
var ErrQUICNotIncluded = E.New(`QUIC is not included in this build, rebuild with -tags with_quic`) | ||
|
||
func init() { | ||
dns.RegisterTransport([]string{"quic", "h3"}, func(ctx context.Context, dialer N.Dialer, link string) (dns.Transport, error) { | ||
return nil, ErrQUICNotIncluded | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package route | ||
|
||
import ( | ||
"net" | ||
|
||
"github.com/sagernet/sing/common/control" | ||
) | ||
|
||
var _ control.InterfaceFinder = (*myInterfaceFinder)(nil) | ||
|
||
type myInterfaceFinder struct { | ||
ifs []net.Interface | ||
} | ||
|
||
func (f *myInterfaceFinder) update() error { | ||
ifs, err := net.Interfaces() | ||
if err != nil { | ||
return err | ||
} | ||
f.ifs = ifs | ||
return nil | ||
} | ||
|
||
func (f *myInterfaceFinder) InterfaceIndexByName(name string) (interfaceIndex int, err error) { | ||
for _, netInterface := range f.ifs { | ||
if netInterface.Name == name { | ||
return netInterface.Index, nil | ||
} | ||
} | ||
netInterface, err := net.InterfaceByName(name) | ||
if err != nil { | ||
return | ||
} | ||
f.update() | ||
return netInterface.Index, nil | ||
} | ||
|
||
func (f *myInterfaceFinder) InterfaceNameByIndex(index int) (interfaceName string, err error) { | ||
for _, netInterface := range f.ifs { | ||
if netInterface.Index == index { | ||
return netInterface.Name, nil | ||
} | ||
} | ||
netInterface, err := net.InterfaceByIndex(index) | ||
if err != nil { | ||
return | ||
} | ||
f.update() | ||
return netInterface.Name, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters