tcpipStackOf returns ns's unexported gVisor *stack.Stack. TODO(bradfitz): add an exported accessor to wgengine/netstack.Impl upstream and delete this reflect+unsafe cheat.
(ns *netstack.Impl)
| 582 | // TODO(bradfitz): add an exported accessor to wgengine/netstack.Impl |
| 583 | // upstream and delete this reflect+unsafe cheat. |
| 584 | func tcpipStackOf(ns *netstack.Impl) *stack.Stack { |
| 585 | v := reflect.ValueOf(ns).Elem().FieldByName("ipstack") |
| 586 | if !v.IsValid() { |
| 587 | panic("netstack.Impl has no ipstack field; tailscale.com dep changed?") |
| 588 | } |
| 589 | return reflect.NewAt(v.Type(), unsafe.Pointer(v.UnsafeAddr())).Elem().Interface().(*stack.Stack) |
| 590 | } |
| 591 | |
| 592 | // AddAllowedClient adds k as an allowed client. |
| 593 | // |