From d0bc8fd4da3d9c9445013ae50c569d7886cf9800 Mon Sep 17 00:00:00 2001 From: Moses Narrow <36607567+0pcom@users.noreply.github.com> Date: Sun, 23 Jun 2024 13:06:21 -0500 Subject: [PATCH] update dmsg dependency (#70) --- go.mod | 4 +- go.sum | 27 +++------- vendor/github.com/bitfield/script/README.md | 2 +- vendor/github.com/bitfield/script/script.go | 51 ++++++++++--------- .../skycoin/dmsg/pkg/dmsg/client.go | 8 ++- .../github.com/skycoin/dmsg/pkg/dmsg/const.go | 4 +- .../skycoin/dmsg/pkg/dmsg/entity_common.go | 38 ++++++++++++++ .../dmsg/pkg/dmsgctrl/serve_listener.go | 4 +- .../skycoin/dmsg/pkg/dmsgpty/ui_windows.go | 4 +- vendor/modules.txt | 6 +-- 10 files changed, 93 insertions(+), 55 deletions(-) diff --git a/go.mod b/go.mod index a2d705d4..fa849974 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.21 toolchain go1.21.5 require ( - github.com/bitfield/script v0.22.0 + github.com/bitfield/script v0.22.1 github.com/ccding/go-stun/stun v0.0.0-20200514191101-4dc67bcdb029 github.com/dgraph-io/badger/v3 v3.2103.2 github.com/docker/docker v1.13.1 @@ -24,7 +24,7 @@ require ( github.com/json-iterator/go v1.1.12 github.com/rs/cors v1.8.2 github.com/sirupsen/logrus v1.9.3 - github.com/skycoin/dmsg v1.3.20 + github.com/skycoin/dmsg v1.3.22-0.20240622174622-39e439d5679d github.com/skycoin/skywire v1.3.21-0.20240325224529-17f630c7a259 github.com/skycoin/skywire-utilities v1.3.18-0.20240208220612-9f31eda72f33 github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8 diff --git a/go.sum b/go.sum index 4c6d5a05..3ef9f4a5 100644 --- a/go.sum +++ b/go.sum @@ -18,8 +18,8 @@ github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9 github.com/VictoriaMetrics/metrics v1.24.0 h1:ILavebReOjYctAGY5QU2F9X0MYvkcrG3aEn2RKa1Zkw= github.com/VictoriaMetrics/metrics v1.24.0/go.mod h1:eFT25kvsTidQFHb6U0oa0rTrDRdz4xTYjpL8+UPohys= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/bitfield/script v0.22.0 h1:LA7QHuEsXMPD52YLtxWrlqCCy+9FOpzNYfsRHC5Gsrc= -github.com/bitfield/script v0.22.0/go.mod h1:ms4w+9B8f2/W0mbsgWDVTtl7K94bYuZc3AunnJC4Ebs= +github.com/bitfield/script v0.22.1 h1:DphxoC5ssYciwd0ZS+N0Xae46geAD/0mVWh6a2NUxM4= +github.com/bitfield/script v0.22.1/go.mod h1:fv+6x4OzVsRs6qAlc7wiGq8fq1b5orhtQdtW0dwjUHI= github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= @@ -53,7 +53,6 @@ github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwc github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -90,7 +89,6 @@ github.com/flopp/go-staticmaps v0.0.0-20220221183018-c226716bec53 h1:bpgLIxOpmht github.com/flopp/go-staticmaps v0.0.0-20220221183018-c226716bec53/go.mod h1:vGgI6wKa1TTiN9iumpzYZgNc/C7KxqsZbw9OH8O10iQ= github.com/fogleman/gg v1.3.0 h1:/7zJX8F6AaYQc57WQCyN9cAIz+4bCJGO9B+dyW29am8= github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= -github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/frankban/quicktest v1.14.5 h1:dfYrrRyLtiqT9GyKXgdh+k4inNeTvmGbuSgZ3lx3GhA= github.com/frankban/quicktest v1.14.5/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= @@ -206,7 +204,6 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/ github.com/google/pprof v0.0.0-20230821062121-407c9e7a662f h1:pDhu5sgp8yJlEF/g6osliIIpF9K4F5jvkULXa4daRDQ= github.com/google/pprof v0.0.0-20230821062121-407c9e7a662f/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/renameio/v2 v2.0.0/go.mod h1:BtmJXm5YlszgC+TD4HOEEUFgkJP3nLxehU6hfe7jRt4= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -222,7 +219,6 @@ github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbg github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/itchyny/gojq v0.12.12/go.mod h1:j+3sVkjxwd7A7Z5jrbKibgOLn0ZfLWkV+Awxr/pyzJE= github.com/itchyny/gojq v0.12.13 h1:IxyYlHYIlspQHHTE0f3cJF0NKDMfajxViuhBLnHd/QU= github.com/itchyny/gojq v0.12.13/go.mod h1:JzwzAqenfhrPUuwbmEz3nu3JQmFLlQTQMUcOdnu/Sf4= github.com/itchyny/timefmt-go v0.1.5 h1:G0INE2la8S6ru/ZI5JecgyzbbJNs5lG1RcBqa7Jm6GE= @@ -335,10 +331,8 @@ github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI= github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= @@ -367,7 +361,6 @@ github.com/pelletier/go-toml/v2 v2.0.9 h1:uH2qQXheeefCCkuBBSLi7jCiSmj3VRh2+Goq2N github.com/pelletier/go-toml/v2 v2.0.9/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= github.com/pires/go-proxyproto v0.6.2 h1:KAZ7UteSOt6urjme6ZldyFm4wDe/z0ZUP0Yv0Dos0d8= github.com/pires/go-proxyproto v0.6.2/go.mod h1:Odh9VFOZJCf9G8cLW5o435Xf1J95Jw9Gw5rnCjcwzAY= -github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -378,13 +371,9 @@ github.com/quic-go/qtls-go1-20 v0.3.3 h1:17/glZSLI9P9fDAeyCHBFSWSqJcwx1byhLwP5eU github.com/quic-go/qtls-go1-20 v0.3.3/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= github.com/quic-go/quic-go v0.38.1 h1:M36YWA5dEhEeT+slOu/SwMEucbYd0YFidxG3KlGPZaE= github.com/quic-go/quic-go v0.38.1/go.mod h1:ijnZM7JsFIkp4cRyjxJNIzdSfCLmUMg9wdyhGmg+SN4= -github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= -github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= -github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= -github.com/rogpeppe/go-internal v1.10.1-0.20230524175051-ec119421bb97 h1:3RPlVWzZ/PDqmVuf/FKHARG5EMid/tl7cv54Sw/QRVY= -github.com/rogpeppe/go-internal v1.10.1-0.20230524175051-ec119421bb97/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/rs/cors v1.8.2 h1:KCooALfAYGs415Cwu5ABvv9n9509fSiG5SQJn/AQo4U= github.com/rs/cors v1.8.2/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= @@ -401,8 +390,8 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/skycoin/dmsg v1.3.20 h1:iPC+u05Le3sIGKQB2imfPv1eBJpk3lh71c50MkqMylw= -github.com/skycoin/dmsg v1.3.20/go.mod h1:INEDx+ECwCGQWw/Kd0QcLmSWMhbeRRcfkxj+xATQGFg= +github.com/skycoin/dmsg v1.3.22-0.20240622174622-39e439d5679d h1:nop/q3XL7GDMP9QpyuBV1fi5Y0rnI7iZeRdHtLfMNt4= +github.com/skycoin/dmsg v1.3.22-0.20240622174622-39e439d5679d/go.mod h1:QMd7NXzarhpTJrdmJLCnqBqI0hMj0RIou9DI9s1e5mo= github.com/skycoin/noise v0.0.0-20180327030543-2492fe189ae6 h1:1Nc5EBY6pjfw1kwW0duwyG+7WliWz5u9kgk1h5MnLuA= github.com/skycoin/noise v0.0.0-20180327030543-2492fe189ae6/go.mod h1:UXghlricA7J3aRD/k7p/zBObQfmBawwCxIVPVjz2Q3o= github.com/skycoin/skycoin v0.27.1 h1:HatxsRwVSPaV4qxH6290xPBmkH/HgiuAoY2qC+e8C9I= @@ -599,7 +588,6 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -608,7 +596,6 @@ golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= @@ -710,8 +697,6 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= howett.net/plist v1.0.0 h1:7CrbWYbPPO/PyNy38b2EB/+gYbjCe2DXBxgtOOZbSQM= howett.net/plist v1.0.0/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g= -mvdan.cc/editorconfig v0.2.0/go.mod h1:lvnnD3BNdBYkhq+B4uBuFFKatfp02eB6HixDvEz91C0= -mvdan.cc/sh/v3 v3.6.0/go.mod h1:U4mhtBLZ32iWhif5/lD+ygy1zrgaQhUu+XFy7C8+TTA= mvdan.cc/sh/v3 v3.7.0 h1:lSTjdP/1xsddtaKfGg7Myu7DnlHItd3/M2tomOcNNBg= mvdan.cc/sh/v3 v3.7.0/go.mod h1:K2gwkaesF/D7av7Kxl0HbF5kGOd2ArupNTX3X44+8l8= nhooyr.io/websocket v1.8.7 h1:usjR2uOr/zjjkVMy0lW+PPohFok7PCow5sDjLgX4P4g= diff --git a/vendor/github.com/bitfield/script/README.md b/vendor/github.com/bitfield/script/README.md index b57324e7..a06a70c1 100644 --- a/vendor/github.com/bitfield/script/README.md +++ b/vendor/github.com/bitfield/script/README.md @@ -313,7 +313,7 @@ Filters are methods on an existing pipe that also return a pipe, allowing you to | [`SHA256Sums`](https://pkg.go.dev/github.com/bitfield/script#Pipe.SHA256Sums) | SHA-256 hashes of each listed file | | [`Tee`](https://pkg.go.dev/github.com/bitfield/script#Pipe.Tee) | input copied to supplied writers | -Note that filters run concurrently, rather than producing nothing until each stage has fully read its input. This is convenient for executing long-running comands, for example. If you do need to wait for the pipeline to complete, call [`Wait`](https://pkg.go.dev/github.com/bitfield/script#Pipe.Wait). +Note that filters run concurrently, rather than producing nothing until each stage has fully read its input. This is convenient for executing long-running commands, for example. If you do need to wait for the pipeline to complete, call [`Wait`](https://pkg.go.dev/github.com/bitfield/script#Pipe.Wait). ## Sinks diff --git a/vendor/github.com/bitfield/script/script.go b/vendor/github.com/bitfield/script/script.go index da7e2fe5..c471f74b 100644 --- a/vendor/github.com/bitfield/script/script.go +++ b/vendor/github.com/bitfield/script/script.go @@ -104,10 +104,10 @@ func FindFiles(dir string) *Pipe { return Slice(paths) } -// Get creates a pipe that makes an HTTP GET request to URL, and produces the +// Get creates a pipe that makes an HTTP GET request to url, and produces the // response. See [Pipe.Do] for how the HTTP response status is interpreted. -func Get(URL string) *Pipe { - return NewPipe().Get(URL) +func Get(url string) *Pipe { + return NewPipe().Get(url) } // IfExists tests whether path exists, and creates a pipe whose error status @@ -169,11 +169,11 @@ func NewPipe() *Pipe { } } -// Post creates a pipe that makes an HTTP POST request to URL, with an empty +// Post creates a pipe that makes an HTTP POST request to url, with an empty // body, and produces the response. See [Pipe.Do] for how the HTTP response // status is interpreted. -func Post(URL string) *Pipe { - return NewPipe().Post(URL) +func Post(url string) *Pipe { + return NewPipe().Post(url) } // Slice creates a pipe containing each element of s, one per line. @@ -514,7 +514,8 @@ func (p *Pipe) FilterScan(filter func(string, io.Writer)) *Pipe { // First produces only the first n lines of the pipe's contents, or all the // lines if there are less than n. If n is zero or negative, there is no output -// at all. +// at all. When n lines have been produced, First stops reading its input and +// sends EOF to its output. func (p *Pipe) First(n int) *Pipe { if p.Error() != nil { return p @@ -522,13 +523,15 @@ func (p *Pipe) First(n int) *Pipe { if n <= 0 { return NewPipe() } - i := 0 - return p.FilterScan(func(line string, w io.Writer) { - if i >= n { - return + return p.Filter(func(r io.Reader, w io.Writer) error { + scanner := newScanner(r) + for i := 0; i < n && scanner.Scan(); i++ { + _, err := fmt.Fprintln(w, scanner.Text()) + if err != nil { + return err + } } - fmt.Fprintln(w, line) - i++ + return scanner.Err() }) } @@ -584,11 +587,11 @@ func (p *Pipe) Freq() *Pipe { }) } -// Get makes an HTTP GET request to URL, sending the contents of the pipe as +// Get makes an HTTP GET request to url, sending the contents of the pipe as // the request body, and produces the server's response. See [Pipe.Do] for how // the HTTP response status is interpreted. -func (p *Pipe) Get(URL string) *Pipe { - req, err := http.NewRequest(http.MethodGet, URL, p.Reader) +func (p *Pipe) Get(url string) *Pipe { + req, err := http.NewRequest(http.MethodGet, url, p.Reader) if err != nil { return p.WithError(err) } @@ -693,11 +696,11 @@ func (p *Pipe) MatchRegexp(re *regexp.Regexp) *Pipe { }) } -// Post makes an HTTP POST request to URL, using the contents of the pipe as +// Post makes an HTTP POST request to url, using the contents of the pipe as // the request body, and produces the server's response. See [Pipe.Do] for how // the HTTP response status is interpreted. -func (p *Pipe) Post(URL string) *Pipe { - req, err := http.NewRequest(http.MethodPost, URL, p.Reader) +func (p *Pipe) Post(url string) *Pipe { + req, err := http.NewRequest(http.MethodPost, url, p.Reader) if err != nil { return p.WithError(err) } @@ -731,8 +734,8 @@ func (p *Pipe) Replace(search, replace string) *Pipe { } // ReplaceRegexp replaces all matches of the compiled regexp re with the string -// re. $x variables in the replace string are interpreted as by -// [regexp.Expand]; for example, $1 represents the text of the first submatch. +// replace. $x variables in the replace string are interpreted as by +// [regexp#Regexp.Expand]; for example, $1 represents the text of the first submatch. func (p *Pipe) ReplaceRegexp(re *regexp.Regexp, replace string) *Pipe { return p.FilterLine(func(line string) string { return re.ReplaceAllString(line, replace) @@ -849,7 +852,7 @@ func (p *Pipe) Tee(writers ...io.Writer) *Pipe { // useful for waiting until concurrent filters have completed (see // [Pipe.Filter]). func (p *Pipe) Wait() { - _, err := io.ReadAll(p) + _, err := io.Copy(io.Discard, p) if err != nil { p.SetError(err) } @@ -905,7 +908,7 @@ func (p *Pipe) writeOrAppendFile(path string, mode int) (int64, error) { if p.Error() != nil { return 0, p.Error() } - out, err := os.OpenFile(path, mode, 0666) + out, err := os.OpenFile(path, mode, 0o666) if err != nil { p.SetError(err) return 0, err @@ -942,7 +945,7 @@ func (ra ReadAutoCloser) Close() error { if ra.r == nil { return nil } - return ra.r.(io.Closer).Close() + return ra.r.Close() } // Read reads up to len(b) bytes from ra's reader into b. It returns the number diff --git a/vendor/github.com/skycoin/dmsg/pkg/dmsg/client.go b/vendor/github.com/skycoin/dmsg/pkg/dmsg/client.go index 679629a5..0973245a 100644 --- a/vendor/github.com/skycoin/dmsg/pkg/dmsg/client.go +++ b/vendor/github.com/skycoin/dmsg/pkg/dmsg/client.go @@ -60,7 +60,7 @@ func (c *Config) Ensure() { func DefaultConfig() *Config { conf := &Config{ MinSessions: DefaultMinSessions, - UpdateInterval: DefaultUpdateInterval, + UpdateInterval: DefaultUpdateInterval * 5, } return conf } @@ -153,6 +153,8 @@ func (ce *Client) Serve(ctx context.Context) { } }(cancellabelCtx) + updateEntryLoopOnce := new(sync.Once) + for { if isClosed(ce.done) { return @@ -253,6 +255,10 @@ func (ce *Client) Serve(ctx context.Context) { ce.serveWait() } } + + // Only start the update entry loop once we have at least one session established. + updateEntryLoopOnce.Do(func() { go ce.updateClientEntryLoop(cancellabelCtx, ce.done, ce.conf.ClientType) }) + // We dial all servers and wait for error or done signal. select { case <-ce.done: diff --git a/vendor/github.com/skycoin/dmsg/pkg/dmsg/const.go b/vendor/github.com/skycoin/dmsg/pkg/dmsg/const.go index cac2c8b8..731c2bc8 100644 --- a/vendor/github.com/skycoin/dmsg/pkg/dmsg/const.go +++ b/vendor/github.com/skycoin/dmsg/pkg/dmsg/const.go @@ -1,7 +1,9 @@ // Package dmsg pkg/dmsg/const.go package dmsg -import "time" +import ( + "time" +) // Constants. const ( diff --git a/vendor/github.com/skycoin/dmsg/pkg/dmsg/entity_common.go b/vendor/github.com/skycoin/dmsg/pkg/dmsg/entity_common.go index ee0d9843..4779984e 100644 --- a/vendor/github.com/skycoin/dmsg/pkg/dmsg/entity_common.go +++ b/vendor/github.com/skycoin/dmsg/pkg/dmsg/entity_common.go @@ -251,12 +251,50 @@ func (c *EntityCommon) updateClientEntry(ctx context.Context, done chan struct{} } return c.dc.PostEntry(ctx, entry) } + + // Whether the client's CURRENT delegated servers is the same as what would be advertised. + sameSrvPKs := cipher.SamePubKeys(srvPKs, entry.Client.DelegatedServers) + + // No update is needed if delegated servers has no delta, and an entry update is not due. + if _, due := c.updateIsDue(); sameSrvPKs && !due { + return nil + } + entry.ClientType = clientType entry.Client.DelegatedServers = srvPKs c.log.WithField("entry", entry).Debug("Updating entry.") return c.dc.PutEntry(ctx, c.sk, entry) } +func (c *EntityCommon) updateClientEntryLoop(ctx context.Context, done chan struct{}, clientType string) { + t := time.NewTimer(c.updateInterval) + defer t.Stop() + + for { + select { + case <-ctx.Done(): + return + + case <-t.C: + if lastUpdate, due := c.updateIsDue(); !due { + t.Reset(c.updateInterval - time.Since(lastUpdate)) + continue + } + + c.sessionsMx.Lock() + err := c.updateClientEntry(ctx, done, clientType) + c.sessionsMx.Unlock() + + if err != nil { + c.log.WithError(err).Warn("Failed to update discovery entry.") + } + + // Ensure we trigger another update within given 'updateInterval'. + t.Reset(c.updateInterval) + } + } +} + func (c *EntityCommon) delEntry(ctx context.Context) (err error) { entry, err := c.dc.Entry(ctx, c.pk) diff --git a/vendor/github.com/skycoin/dmsg/pkg/dmsgctrl/serve_listener.go b/vendor/github.com/skycoin/dmsg/pkg/dmsgctrl/serve_listener.go index da172181..2fd9b928 100644 --- a/vendor/github.com/skycoin/dmsg/pkg/dmsgctrl/serve_listener.go +++ b/vendor/github.com/skycoin/dmsg/pkg/dmsgctrl/serve_listener.go @@ -1,7 +1,9 @@ // Package dmsgctrl pkg/dmsgctrl/serve_listener.go package dmsgctrl -import "net" +import ( + "net" +) // ServeListener serves a listener with dmsgctrl.Control. // It returns a channel for incoming Controls. diff --git a/vendor/github.com/skycoin/dmsg/pkg/dmsgpty/ui_windows.go b/vendor/github.com/skycoin/dmsg/pkg/dmsgpty/ui_windows.go index 915f553e..2cb3d978 100644 --- a/vendor/github.com/skycoin/dmsg/pkg/dmsgpty/ui_windows.go +++ b/vendor/github.com/skycoin/dmsg/pkg/dmsgpty/ui_windows.go @@ -4,7 +4,9 @@ // Package dmsgpty pkg/dmsgpty/ui_windows.go package dmsgpty -import "golang.org/x/sys/windows" +import ( + "golang.org/x/sys/windows" +) func (ui *UI) uiStartSize(ptyC *PtyClient) error { ws, err := NewWinSize(&windows.Coord{ diff --git a/vendor/modules.txt b/vendor/modules.txt index c59493db..10e3cd8e 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -21,8 +21,8 @@ github.com/StackExchange/wmi # github.com/VictoriaMetrics/metrics v1.24.0 ## explicit; go 1.20 github.com/VictoriaMetrics/metrics -# github.com/bitfield/script v0.22.0 -## explicit; go 1.12 +# github.com/bitfield/script v0.22.1 +## explicit; go 1.18 github.com/bitfield/script # github.com/blang/semver/v4 v4.0.0 ## explicit; go 1.14 @@ -464,7 +464,7 @@ github.com/rs/cors ## explicit; go 1.13 github.com/sirupsen/logrus github.com/sirupsen/logrus/hooks/syslog -# github.com/skycoin/dmsg v1.3.20 +# github.com/skycoin/dmsg v1.3.22-0.20240622174622-39e439d5679d ## explicit; go 1.21 github.com/skycoin/dmsg/internal/servermetrics github.com/skycoin/dmsg/pkg/direct