Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only start the resolver if tproxy mode #2715

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions router/xgress_edge_tunnel_v2/tunneler.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,22 @@ func newTunneler(factory *Factory) *tunneler {

func (self *tunneler) Start(notifyClose <-chan struct{}) error {
var err error
var resolver dns.Resolver

log := pfxlog.Logger()
log.WithField("mode", self.listenOptions.mode).Info("creating interceptor")

resolver, err := dns.NewResolver(self.listenOptions.resolver)
if err != nil {
pfxlog.Logger().WithError(err).Error("failed to start DNS resolver. using dummy resolver")
resolver = dns.NewDummyResolver()
}
if strings.HasPrefix(self.listenOptions.mode, "tproxy") {
log.WithField("mode", self.listenOptions.mode).Info("creating interceptor")
resolver, err = dns.NewResolver(self.listenOptions.resolver)
if err != nil {
pfxlog.Logger().WithError(err).Error("failed to start DNS resolver. using dummy resolver")
resolver = dns.NewDummyResolver()
}

if err = intercept.SetDnsInterceptIpRange(self.listenOptions.dnsSvcIpRange); err != nil {
pfxlog.Logger().Errorf("invalid dns service IP range %s: %v", self.listenOptions.dnsSvcIpRange, err)
return err
}
if err = intercept.SetDnsInterceptIpRange(self.listenOptions.dnsSvcIpRange); err != nil {
pfxlog.Logger().Errorf("invalid dns service IP range %s: %v", self.listenOptions.dnsSvcIpRange, err)
return err
}

if strings.HasPrefix(self.listenOptions.mode, "tproxy") {
tproxyConfig := tproxy.Config{
LanIf: self.listenOptions.lanIf,
UDPIdleTimeout: self.listenOptions.udpIdleTimeout,
Expand Down
Loading