-
-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(netlink): detect IPv6 using query to address
- If a default IPv6 route is found, query the ip:port defined by `IPV6_CHECK_ADDRESS` to check for internet access
- Loading branch information
Showing
13 changed files
with
384 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package cli | ||
|
||
import ( | ||
"context" | ||
"net/netip" | ||
) | ||
|
||
type noopFirewall struct{} | ||
|
||
func (f *noopFirewall) AcceptOutput(_ context.Context, _, _ string, _ netip.Addr, | ||
_ uint16, _ bool, | ||
) (err error) { | ||
return 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package settings | ||
|
||
import ( | ||
"net/netip" | ||
|
||
"github.com/qdm12/gosettings" | ||
"github.com/qdm12/gosettings/reader" | ||
"github.com/qdm12/gotree" | ||
) | ||
|
||
// IPv6 contains settings regarding IPv6 configuration. | ||
type IPv6 struct { | ||
// CheckAddress is the TCP ip:port address to dial to check | ||
// IPv6 is supported, in case a default IPv6 route is found. | ||
// It defaults to cloudflare.com address [2606:4700::6810:84e5]:443 | ||
CheckAddress netip.AddrPort | ||
} | ||
|
||
func (i IPv6) validate() (err error) { | ||
return nil | ||
} | ||
|
||
func (i *IPv6) copy() (copied IPv6) { | ||
return IPv6{ | ||
CheckAddress: i.CheckAddress, | ||
} | ||
} | ||
|
||
func (i *IPv6) overrideWith(other IPv6) { | ||
i.CheckAddress = gosettings.OverrideWithValidator(i.CheckAddress, other.CheckAddress) | ||
} | ||
|
||
func (i *IPv6) setDefaults() { | ||
defaultCheckAddress := netip.MustParseAddrPort("[2606:4700::6810:84e5]:443") | ||
i.CheckAddress = gosettings.DefaultComparable(i.CheckAddress, defaultCheckAddress) | ||
} | ||
|
||
func (i IPv6) String() string { | ||
return i.toLinesNode().String() | ||
} | ||
|
||
func (i IPv6) toLinesNode() (node *gotree.Node) { | ||
node = gotree.New("IPv6 settings:") | ||
node.Appendf("Check address: %s", i.CheckAddress) | ||
return node | ||
} | ||
|
||
func (i *IPv6) read(r *reader.Reader) (err error) { | ||
i.CheckAddress, err = r.NetipAddrPort("IPV6_CHECK_ADDRESS") | ||
return err | ||
} |
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 |
---|---|---|
@@ -1,9 +1,19 @@ | ||
package netlink | ||
|
||
import "github.com/qdm12/log" | ||
import ( | ||
"context" | ||
"net/netip" | ||
|
||
"github.com/qdm12/log" | ||
) | ||
|
||
type DebugLogger interface { | ||
Debug(message string) | ||
Debugf(format string, args ...any) | ||
Patch(options ...log.Option) | ||
} | ||
|
||
type Firewall interface { | ||
AcceptOutput(ctx context.Context, protocol, intf string, ip netip.Addr, | ||
port uint16, remove bool) (err error) | ||
} |
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
Oops, something went wrong.