assorted: documentation and readability fixes
This were intended to be pushed to #4408, but in my excitement I forgot to git push :/ better late than never. Signed-off-by: Tom DNetto <tom@tailscale.com>
This commit is contained in:
parent
9e77660931
commit
7f45734663
|
@ -64,7 +64,7 @@ const reconfigTimeout = time.Second
|
||||||
|
|
||||||
type response struct {
|
type response struct {
|
||||||
pkt []byte
|
pkt []byte
|
||||||
from netaddr.IPPort // where the packet needs to be sent
|
to netaddr.IPPort // response destination (request source)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Manager manages system DNS settings.
|
// Manager manages system DNS settings.
|
||||||
|
@ -282,27 +282,27 @@ func (m *Manager) NextPacket() ([]byte, error) {
|
||||||
|
|
||||||
var buf []byte
|
var buf []byte
|
||||||
switch {
|
switch {
|
||||||
case resp.from.IP().Is4():
|
case resp.to.IP().Is4():
|
||||||
h := packet.UDP4Header{
|
h := packet.UDP4Header{
|
||||||
IP4Header: packet.IP4Header{
|
IP4Header: packet.IP4Header{
|
||||||
Src: magicDNSIP,
|
Src: magicDNSIP,
|
||||||
Dst: resp.from.IP(),
|
Dst: resp.to.IP(),
|
||||||
},
|
},
|
||||||
SrcPort: 53,
|
SrcPort: 53,
|
||||||
DstPort: resp.from.Port(),
|
DstPort: resp.to.Port(),
|
||||||
}
|
}
|
||||||
hlen := h.Len()
|
hlen := h.Len()
|
||||||
buf = make([]byte, offset+hlen+len(resp.pkt))
|
buf = make([]byte, offset+hlen+len(resp.pkt))
|
||||||
copy(buf[offset+hlen:], resp.pkt)
|
copy(buf[offset+hlen:], resp.pkt)
|
||||||
h.Marshal(buf[offset:])
|
h.Marshal(buf[offset:])
|
||||||
case resp.from.IP().Is6():
|
case resp.to.IP().Is6():
|
||||||
h := packet.UDP6Header{
|
h := packet.UDP6Header{
|
||||||
IP6Header: packet.IP6Header{
|
IP6Header: packet.IP6Header{
|
||||||
Src: magicDNSIPv6,
|
Src: magicDNSIPv6,
|
||||||
Dst: resp.from.IP(),
|
Dst: resp.to.IP(),
|
||||||
},
|
},
|
||||||
SrcPort: 53,
|
SrcPort: 53,
|
||||||
DstPort: resp.from.Port(),
|
DstPort: resp.to.Port(),
|
||||||
}
|
}
|
||||||
hlen := h.Len()
|
hlen := h.Len()
|
||||||
buf = make([]byte, offset+hlen+len(resp.pkt))
|
buf = make([]byte, offset+hlen+len(resp.pkt))
|
||||||
|
|
|
@ -692,7 +692,7 @@ func (t *Wrapper) SetFilter(filt *filter.Filter) {
|
||||||
t.filter.Store(filt)
|
t.filter.Store(filt)
|
||||||
}
|
}
|
||||||
|
|
||||||
// InjectInboundDirect makes the Wrapper device behave as if a packet
|
// InjectInboundPacketBuffer makes the Wrapper device behave as if a packet
|
||||||
// with the given contents was received from the network.
|
// with the given contents was received from the network.
|
||||||
// It takes ownership of one reference count on the packet. The injected
|
// It takes ownership of one reference count on the packet. The injected
|
||||||
// packet will not pass through inbound filters.
|
// packet will not pass through inbound filters.
|
||||||
|
@ -706,7 +706,7 @@ func (t *Wrapper) InjectInboundPacketBuffer(pkt *stack.PacketBuffer) error {
|
||||||
n += copy(buf[PacketStartOffset+n:], pkt.TransportHeader().View())
|
n += copy(buf[PacketStartOffset+n:], pkt.TransportHeader().View())
|
||||||
n += copy(buf[PacketStartOffset+n:], pkt.Data().AsRange().AsView())
|
n += copy(buf[PacketStartOffset+n:], pkt.Data().AsRange().AsView())
|
||||||
if n != pkt.Size() {
|
if n != pkt.Size() {
|
||||||
panic("unexpected: revisit assumptions")
|
panic("unexpected packet size after copy")
|
||||||
}
|
}
|
||||||
pkt.DecRef()
|
pkt.DecRef()
|
||||||
|
|
||||||
|
|
|
@ -196,12 +196,12 @@ func (s *Server) start() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
tunDev, magicConn, d, ok := eng.(wgengine.InternalsGetter).GetInternals()
|
tunDev, magicConn, dns, ok := eng.(wgengine.InternalsGetter).GetInternals()
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("%T is not a wgengine.InternalsGetter", eng)
|
return fmt.Errorf("%T is not a wgengine.InternalsGetter", eng)
|
||||||
}
|
}
|
||||||
|
|
||||||
ns, err := netstack.Create(logf, tunDev, eng, magicConn, s.dialer, d)
|
ns, err := netstack.Create(logf, tunDev, eng, magicConn, s.dialer, dns)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("netstack.Create: %w", err)
|
return fmt.Errorf("netstack.Create: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,12 +39,12 @@ func TestInjectInboundLeak(t *testing.T) {
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatal("not an InternalsGetter")
|
t.Fatal("not an InternalsGetter")
|
||||||
}
|
}
|
||||||
tunWrap, magicSock, d, ok := ig.GetInternals()
|
tunWrap, magicSock, dns, ok := ig.GetInternals()
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatal("failed to get internals")
|
t.Fatal("failed to get internals")
|
||||||
}
|
}
|
||||||
|
|
||||||
ns, err := Create(logf, tunWrap, eng, magicSock, dialer, d)
|
ns, err := Create(logf, tunWrap, eng, magicSock, dialer, dns)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue