Skip to content

Commit 5849f3d

Browse files
committed
backend/ipn_proxies: m go bind errs on int32
1 parent f430897 commit 5849f3d

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

intra/backend/ipn_proxies.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ type Router interface {
7575
// MTU returns the MTU of this router.
7676
MTU() (int, error)
7777
// Stats returns the stats of this router.
78-
Stats() Stats
78+
Stat() *Stats
7979
// Contains returns true if this router can route ipprefix.
8080
Contains(ipprefix string) bool
8181
}
@@ -97,8 +97,8 @@ type Stats struct {
9797
Addr string // address of the router
9898
Rx int64 // bytes received
9999
Tx int64 // bytes transmitted
100-
ErrRx int32 // receive errors
101-
ErrTx int32 // transmit errors
100+
ErrRx int64 // receive errors
101+
ErrTx int64 // transmit errors
102102
LastRx int64 // last receive in millis
103103
LastTx int64 // last transmit in millis
104104
LastOK int64 // last handshake or ping or connect millis

intra/ipn/proxies.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func (nofwd) Accept(network, local string) (protect.Listener, error) {
145145
func (w *gw) IP4() bool { return w.ok }
146146
func (w *gw) IP6() bool { return w.ok }
147147
func (w *gw) MTU() (int, error) { return NOMTU, errNoMtu }
148-
func (w *gw) Stats() x.Stats { return w.stats }
148+
func (w *gw) Stat() *x.Stats { return &w.stats }
149149
func (w *gw) Contains(string) bool { return w.ok }
150150

151151
func NewProxifier(c protect.Controller, o x.ProxyListener) Proxies {
@@ -309,23 +309,24 @@ func (px *proxifier) MTU() (out int, err error) {
309309
}
310310

311311
// Implements Router.
312-
func (px *proxifier) Stats() x.Stats {
312+
func (px *proxifier) Stat() *x.Stats {
313313
px.RLock()
314314
defer px.RUnlock()
315315

316-
var s x.Stats
316+
var s *x.Stats
317317
for _, p := range px.p {
318318
if local(p.ID()) {
319319
continue
320320
}
321321
if r := p.Router(); r != nil {
322-
s = accStats(s, r.Stats())
322+
s = accStats(s, r.Stat())
323323
}
324324
}
325325
return s
326326
}
327327

328-
func accStats(a, b x.Stats) (c x.Stats) {
328+
func accStats(a, b *x.Stats) (c *x.Stats) {
329+
c = new(x.Stats)
329330
c.Tx = a.Tx + b.Tx
330331
c.Rx = a.Rx + b.Rx
331332
c.ErrRx = a.ErrRx + b.ErrRx

intra/ipn/wgproxy.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ type wgtun struct {
8989
since int64 // uptime in unix millis
9090
latestRx int64 // last rx time in unix millis
9191
latestTx int64 // last tx time in unix millis
92-
errRx int32 // rx error count
93-
errTx int32 // tx error count
92+
errRx int64 // rx error count
93+
errTx int64 // tx error count
9494
}
9595

9696
type wgconn interface {
@@ -665,7 +665,7 @@ func (tun *wgtun) Close() error {
665665

666666
// Implements Router.
667667
// TODO: use wgtun as a receiver for Stats()
668-
func (w *wgproxy) Stats() (out x.Stats) {
668+
func (w *wgproxy) Stat() (out *x.Stats) {
669669
if w.status == END {
670670
return
671671
}
@@ -677,6 +677,7 @@ func (w *wgproxy) Stats() (out x.Stats) {
677677
}
678678

679679
stat := wg.ReadStats(w.id, cfg)
680+
out = new(x.Stats)
680681
out.Rx = stat.TotalRx()
681682
out.Tx = stat.TotalTx()
682683
out.LastOK = stat.LatestRecentHandshake()

0 commit comments

Comments
 (0)