Skip to content

Commit

Permalink
config: gomobile bind to avoid ctor overloads
Browse files Browse the repository at this point in the history
  • Loading branch information
ignoramous committed Nov 9, 2023
1 parent 4b3b879 commit d33ae52
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion intra/dns53/upstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package dns53
import (
"errors"
"fmt"
"net"
"net/netip"
"strings"
"time"
Expand Down Expand Up @@ -58,7 +59,8 @@ func NewTransportFromHostname(id, hostname string, ipcsv string, px ipn.Proxies,

// NewTransport returns a DNS transport, ready for use.
func NewTransport(id, ip, port string, px ipn.Proxies, ctl protect.Controller) (t dnsx.Transport, err error) {
do, err := settings.NewDNSOptions(ip, port)
ipport := net.JoinHostPort(ip, port)
do, err := settings.NewDNSOptions(ipport)
if err != nil {
return
}
Expand Down
6 changes: 5 additions & 1 deletion intra/settings/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,13 @@ func addrport(ip string, port string) (ipp netip.AddrPort, err error) {
}

// NewDNSOptions returns a new DNSOpitons object.
func NewDNSOptions(ip string, port string) (*DNSOptions, error) {
func NewDNSOptions(ipport string) (*DNSOptions, error) {
var ipp netip.AddrPort
var err error
ip, port, err := net.SplitHostPort(ipport)
if err != nil {
return nil, err
}
if ipp, err = addrport(ip, port); err == nil {
return &DNSOptions{
ipp: ipp.String(),
Expand Down

0 comments on commit d33ae52

Please sign in to comment.