From 118588e5bb6aacb6deceb3e71aa20b572304f9ac Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Sun, 5 Mar 2023 22:30:42 +0100 Subject: [PATCH 01/23] added initial websocket feature / remove zeromq --- go.mod | 12 +- go.sum | 15 + src/models/cfg.go | 16 + src/models/ip.go | 46 +- src/models/models.go | 1 + src/routers/funcs.go | 8 + src/ws/main.go | 1 + src/ws/pubsub.go | 27 + src/ws/reqrep.go | 31 + src/zmqrouter/main.go | 30 +- .../github.com/labstack/echo/v4/.travis.yml | 21 - .../github.com/labstack/echo/v4/CHANGELOG.md | 27 + vendor/github.com/labstack/echo/v4/README.md | 37 +- vendor/github.com/labstack/echo/v4/echo.go | 67 +- vendor/github.com/labstack/echo/v4/router.go | 1 - vendor/golang.org/x/net/websocket/client.go | 106 ++++ vendor/golang.org/x/net/websocket/dial.go | 24 + vendor/golang.org/x/net/websocket/hybi.go | 583 ++++++++++++++++++ vendor/golang.org/x/net/websocket/server.go | 113 ++++ .../golang.org/x/net/websocket/websocket.go | 449 ++++++++++++++ vendor/golang.org/x/sys/unix/ioctl.go | 17 +- vendor/golang.org/x/sys/unix/ioctl_zos.go | 8 +- vendor/golang.org/x/sys/unix/ptrace_darwin.go | 6 + vendor/golang.org/x/sys/unix/ptrace_ios.go | 6 + vendor/golang.org/x/sys/unix/syscall_aix.go | 5 +- vendor/golang.org/x/sys/unix/syscall_bsd.go | 3 +- .../golang.org/x/sys/unix/syscall_darwin.go | 12 +- .../x/sys/unix/syscall_darwin_amd64.go | 1 + .../x/sys/unix/syscall_darwin_arm64.go | 1 + .../x/sys/unix/syscall_dragonfly.go | 1 + .../golang.org/x/sys/unix/syscall_freebsd.go | 43 +- .../x/sys/unix/syscall_freebsd_386.go | 17 +- .../x/sys/unix/syscall_freebsd_amd64.go | 17 +- .../x/sys/unix/syscall_freebsd_arm.go | 15 +- .../x/sys/unix/syscall_freebsd_arm64.go | 15 +- .../x/sys/unix/syscall_freebsd_riscv64.go | 15 +- vendor/golang.org/x/sys/unix/syscall_hurd.go | 8 + vendor/golang.org/x/sys/unix/syscall_linux.go | 36 +- .../golang.org/x/sys/unix/syscall_netbsd.go | 5 +- .../golang.org/x/sys/unix/syscall_openbsd.go | 1 + .../golang.org/x/sys/unix/syscall_solaris.go | 21 +- .../x/sys/unix/syscall_zos_s390x.go | 4 +- vendor/golang.org/x/sys/unix/zerrors_linux.go | 10 +- .../x/sys/unix/zptrace_armnn_linux.go | 8 +- .../x/sys/unix/zptrace_linux_arm64.go | 4 +- .../x/sys/unix/zptrace_mipsnn_linux.go | 8 +- .../x/sys/unix/zptrace_mipsnnle_linux.go | 8 +- .../x/sys/unix/zptrace_x86_linux.go | 8 +- .../golang.org/x/sys/unix/zsyscall_aix_ppc.go | 10 + .../x/sys/unix/zsyscall_aix_ppc64.go | 10 + .../x/sys/unix/zsyscall_aix_ppc64_gc.go | 7 + .../x/sys/unix/zsyscall_aix_ppc64_gccgo.go | 8 + .../x/sys/unix/zsyscall_darwin_amd64.go | 16 + .../x/sys/unix/zsyscall_darwin_arm64.go | 16 + .../x/sys/unix/zsyscall_dragonfly_amd64.go | 10 + .../x/sys/unix/zsyscall_freebsd_386.go | 20 + .../x/sys/unix/zsyscall_freebsd_amd64.go | 20 + .../x/sys/unix/zsyscall_freebsd_arm.go | 20 + .../x/sys/unix/zsyscall_freebsd_arm64.go | 20 + .../x/sys/unix/zsyscall_freebsd_riscv64.go | 20 + .../golang.org/x/sys/unix/zsyscall_linux.go | 10 + .../x/sys/unix/zsyscall_netbsd_386.go | 10 + .../x/sys/unix/zsyscall_netbsd_amd64.go | 10 + .../x/sys/unix/zsyscall_netbsd_arm.go | 10 + .../x/sys/unix/zsyscall_netbsd_arm64.go | 10 + .../x/sys/unix/zsyscall_openbsd_386.go | 8 + .../x/sys/unix/zsyscall_openbsd_amd64.go | 8 + .../x/sys/unix/zsyscall_openbsd_arm.go | 8 + .../x/sys/unix/zsyscall_openbsd_arm64.go | 8 + .../x/sys/unix/zsyscall_openbsd_mips64.go | 8 + .../x/sys/unix/zsyscall_openbsd_ppc64.go | 8 + .../x/sys/unix/zsyscall_openbsd_riscv64.go | 8 + .../x/sys/unix/zsyscall_solaris_amd64.go | 11 + .../x/sys/unix/zsyscall_zos_s390x.go | 10 + .../x/sys/unix/ztypes_freebsd_386.go | 2 +- .../x/sys/unix/ztypes_freebsd_amd64.go | 2 +- .../x/sys/unix/ztypes_freebsd_arm.go | 2 +- .../x/sys/unix/ztypes_freebsd_arm64.go | 2 +- .../x/sys/unix/ztypes_freebsd_riscv64.go | 2 +- vendor/golang.org/x/sys/unix/ztypes_linux.go | 140 +++-- .../golang.org/x/sys/unix/ztypes_linux_386.go | 2 +- .../x/sys/unix/ztypes_linux_amd64.go | 2 +- .../golang.org/x/sys/unix/ztypes_linux_arm.go | 2 +- .../x/sys/unix/ztypes_linux_arm64.go | 2 +- .../x/sys/unix/ztypes_linux_loong64.go | 2 +- .../x/sys/unix/ztypes_linux_mips.go | 2 +- .../x/sys/unix/ztypes_linux_mips64.go | 2 +- .../x/sys/unix/ztypes_linux_mips64le.go | 2 +- .../x/sys/unix/ztypes_linux_mipsle.go | 2 +- .../golang.org/x/sys/unix/ztypes_linux_ppc.go | 2 +- .../x/sys/unix/ztypes_linux_ppc64.go | 2 +- .../x/sys/unix/ztypes_linux_ppc64le.go | 2 +- .../x/sys/unix/ztypes_linux_riscv64.go | 2 +- .../x/sys/unix/ztypes_linux_s390x.go | 2 +- .../x/sys/unix/ztypes_linux_sparc64.go | 2 +- .../x/text/unicode/norm/forminfo.go | 2 +- vendor/modules.txt | 15 +- 97 files changed, 2119 insertions(+), 300 deletions(-) create mode 100644 src/ws/main.go create mode 100644 src/ws/pubsub.go create mode 100644 src/ws/reqrep.go delete mode 100644 vendor/github.com/labstack/echo/v4/.travis.yml create mode 100644 vendor/golang.org/x/net/websocket/client.go create mode 100644 vendor/golang.org/x/net/websocket/dial.go create mode 100644 vendor/golang.org/x/net/websocket/hybi.go create mode 100644 vendor/golang.org/x/net/websocket/server.go create mode 100644 vendor/golang.org/x/net/websocket/websocket.go diff --git a/go.mod b/go.mod index c79e5a9..f0b3d7c 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,9 @@ module git.paulbsd.com/paulbsd/ipbl go 1.19 require ( - github.com/labstack/echo/v4 v4.10.0 + github.com/labstack/echo/v4 v4.10.2 github.com/lib/pq v1.10.7 + golang.org/x/net v0.8.0 gopkg.in/ini.v1 v1.67.0 gopkg.in/zeromq/goczmq.v4 v4.1.0 xorm.io/xorm v1.3.2 @@ -12,6 +13,7 @@ require ( require ( github.com/goccy/go-json v0.10.0 // indirect + github.com/golang-jwt/jwt v3.2.2+incompatible // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/json-iterator/go v1.1.12 // indirect @@ -25,9 +27,9 @@ require ( github.com/syndtr/goleveldb v1.0.0 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasttemplate v1.2.2 // indirect - golang.org/x/crypto v0.6.0 // indirect - golang.org/x/net v0.7.0 // indirect - golang.org/x/sys v0.5.0 // indirect - golang.org/x/text v0.7.0 // indirect + golang.org/x/crypto v0.7.0 // indirect + golang.org/x/sys v0.6.0 // indirect + golang.org/x/text v0.8.0 // indirect + golang.org/x/time v0.3.0 // indirect xorm.io/builder v0.3.12 // indirect ) diff --git a/go.sum b/go.sum index 5237cd5..c869924 100644 --- a/go.sum +++ b/go.sum @@ -84,6 +84,8 @@ github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFG github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= +github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= +github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -217,6 +219,8 @@ github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/labstack/echo/v4 v4.10.0 h1:5CiyngihEO4HXsz3vVsJn7f8xAlWwRr3aY6Ih280ZKA= github.com/labstack/echo/v4 v4.10.0/go.mod h1:S/T/5fy/GigaXnHTkh0ZGe4LpkkQysvRjFMSUTkDRNQ= +github.com/labstack/echo/v4 v4.10.2 h1:n1jAhnq/elIFTHr1EYpiYtyKgx4RW9ccVgkqByZaN2M= +github.com/labstack/echo/v4 v4.10.2/go.mod h1:OEyqf2//K1DFdE57vw2DRgWY0M7s65IVQO2FzvI4J5k= github.com/labstack/gommon v0.4.0 h1:y7cvthEAEbU0yHOf4axH8ZG2NH8knB9iNSoTO8dyIk8= github.com/labstack/gommon v0.4.0/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= @@ -414,6 +418,8 @@ golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE= golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= +golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= @@ -424,6 +430,7 @@ golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKG golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s= +golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -447,6 +454,8 @@ golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw= golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -496,6 +505,8 @@ golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18= golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -507,8 +518,12 @@ golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k= golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= +golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/src/models/cfg.go b/src/models/cfg.go index f00253b..3cf8fc5 100644 --- a/src/models/cfg.go +++ b/src/models/cfg.go @@ -103,6 +103,15 @@ func GetZMQ(cfg config.Config) (res []CfgZMQ, err error) { return } +func GetWS(cfg config.Config) (res []CfgWS, err error) { + var w = []CfgWS{} + + if err = cfg.Db.Find(&w); err == nil { + return w, err + } + return +} + func DiscoverURLS(cfg config.Config, routes []*echo.Route) (Discovery, error) { var disc Discovery var urls = make(map[string]Url) @@ -148,6 +157,13 @@ type CfgZMQ struct { Subscription string `json:"subscription"` } +type CfgWS struct { + ID int `xorm:"pk autoincr" json:"-"` + Type string `xorm:"text notnull" json:"type"` + Endpoint string `xorm:"text notnull" json:"endpoint"` + Subscription string `json:"subscription"` +} + type Discovery struct { Version string `json:"version"` URLs map[string]Url `json:"urls"` diff --git a/src/models/ip.go b/src/models/ip.go index bb875eb..32e4d32 100644 --- a/src/models/ip.go +++ b/src/models/ip.go @@ -202,7 +202,9 @@ func ScanOrphan(wg *sync.WaitGroup, orphans chan IP, done chan bool, thr int, cf } orphan.Rdns = sql.NullString{String: query.Rdns, Valid: true} - log.Printf("%s -> \"%s\"\n", orphan.IP, query.Rdns) + if cfg.Switchs.Debug { + log.Printf("%s -> \"%s\"\n", orphan.IP, query.Rdns) + } orphan.GetOrCreate(session) @@ -225,40 +227,28 @@ func ScanOrphan(wg *sync.WaitGroup, orphans chan IP, done chan bool, thr int, cf func QueryInfo(client *http.Client, ip string) (query QueryIP, err error) { var url = fmt.Sprintf("%s/%s", IPINFO_WS, ip) - req, _ := http.NewRequest("GET", url, nil) + req, err := http.NewRequest("GET", url, nil) + if err != nil { + log.Println(err) + } req.Header.Add("Accept", "*/*") req.Header.Add("User-Agent", "ipbl") - res, _ := client.Do(req) - data, _ := io.ReadAll(res.Body) + res, err := client.Do(req) + if err != nil { + log.Println(err) + } + data, err := io.ReadAll(res.Body) + if err != nil { + log.Println(err) + } err = json.Unmarshal(data, &query) + if err != nil { + log.Println(err) + } return } func Cleanup(session *xorm.Session) (err error) { - results, _ := session.Query(` - SELECT * - FROM ip - WHERE ip IN ( - SELECT ip - FROM ip - GROUP BY ip - HAVING COUNT(ip) > 1) - AND hostname IS NULL - ORDER BY updated DESC;`) - if len(results) > 0 { - _, err := session.Query(` - DELETE FROM ip - WHERE ip IN ( - SELECT ip - FROM ip - GROUP by ip - HAVING COUNT(ip) > 1) - AND hostname IS NULL;`) - if err != nil { - log.Println("error deleting orphans") - } - } - session.Commit() return } diff --git a/src/models/models.go b/src/models/models.go index 2b2b752..e39a3f3 100644 --- a/src/models/models.go +++ b/src/models/models.go @@ -24,6 +24,7 @@ func init() { new(CfgSet), new(CfgTrustlist), new(CfgZMQ), + new(CfgWS), new(City), new(Country), new(Event), diff --git a/src/routers/funcs.go b/src/routers/funcs.go index 5133b21..1d8e2b4 100644 --- a/src/routers/funcs.go +++ b/src/routers/funcs.go @@ -9,6 +9,7 @@ import ( "git.paulbsd.com/paulbsd/ipbl/src/config" "git.paulbsd.com/paulbsd/ipbl/src/models" + "git.paulbsd.com/paulbsd/ipbl/src/ws" "github.com/labstack/echo/v4" ) @@ -145,8 +146,15 @@ func RegisterRoutes(e *echo.Echo, ctx *context.Context, cfg *config.Config) { folders, err := models.GetZMQ(*cfg) return Result(c, err, folders) }) + e.GET("/config/ws", func(c echo.Context) (err error) { + folders, err := models.GetWS(*cfg) + return Result(c, err, folders) + }) e.GET("/discovery", func(c echo.Context) (err error) { disc, err := models.DiscoverURLS(*cfg, e.Routes()) return Result(c, err, disc) }) + e.File("/test.html", "/home/paul/test.html") + e.GET("/wsps", ws.HandleWSPubSub) + e.GET("/wsrr", ws.HandleWSReqRep) } diff --git a/src/ws/main.go b/src/ws/main.go new file mode 100644 index 0000000..9859295 --- /dev/null +++ b/src/ws/main.go @@ -0,0 +1 @@ +package ws diff --git a/src/ws/pubsub.go b/src/ws/pubsub.go new file mode 100644 index 0000000..fdacd55 --- /dev/null +++ b/src/ws/pubsub.go @@ -0,0 +1,27 @@ +package ws + +import ( + "github.com/labstack/echo/v4" + "golang.org/x/net/websocket" +) + +func HandleWSPubSub(c echo.Context) error { + websocket.Handler(func(ws *websocket.Conn) { + defer ws.Close() + for { + // Write + err := websocket.Message.Send(ws, "Hello, Client!") + if err != nil { + return + } + + // Read + msg := "" + err = websocket.Message.Receive(ws, &msg) + if err != nil { + return + } + } + }).ServeHTTP(c.Response(), c.Request()) + return nil +} diff --git a/src/ws/reqrep.go b/src/ws/reqrep.go new file mode 100644 index 0000000..89e0e27 --- /dev/null +++ b/src/ws/reqrep.go @@ -0,0 +1,31 @@ +package ws + +import ( + "fmt" + + "github.com/labstack/echo/v4" + "golang.org/x/net/websocket" +) + +func HandleWSReqRep(c echo.Context) error { + websocket.Handler(func(ws *websocket.Conn) { + defer ws.Close() + for { + // Read + msg := "" + err := websocket.Message.Receive(ws, &msg) + if err != nil { + return + } + fmt.Println(msg) + + // Write + err = websocket.Message.Send(ws, "OK") + if err != nil { + return + } + + } + }).ServeHTTP(c.Response(), c.Request()) + return nil +} diff --git a/src/zmqrouter/main.go b/src/zmqrouter/main.go index 77ba7c5..e884728 100644 --- a/src/zmqrouter/main.go +++ b/src/zmqrouter/main.go @@ -12,19 +12,27 @@ import ( ) func Init(cfg *config.Config) (err error) { - log.Println("Initiating ZMQ sockets") + for { + log.Println("Initiating ZMQ sockets") - reqsock, err := InitRep() - if err != nil { - return + reqsock, err := InitRep() + if err != nil { + break + } + + pubsock, err := InitPub() + if err != nil { + break + } + + err = Handle(cfg, reqsock, pubsock, cfg.Options.ZMQChannel) + if err != nil { + reqsock.Destroy() + pubsock.Destroy() + time.Sleep(1 * time.Second) + break + } } - - pubsock, err := InitPub() - if err != nil { - return - } - - Handle(cfg, reqsock, pubsock, cfg.Options.ZMQChannel) return } diff --git a/vendor/github.com/labstack/echo/v4/.travis.yml b/vendor/github.com/labstack/echo/v4/.travis.yml deleted file mode 100644 index 67d45ad..0000000 --- a/vendor/github.com/labstack/echo/v4/.travis.yml +++ /dev/null @@ -1,21 +0,0 @@ -arch: - - amd64 - - ppc64le - -language: go -go: - - 1.14.x - - 1.15.x - - tip -env: - - GO111MODULE=on -install: - - go get -v golang.org/x/lint/golint -script: - - golint -set_exit_status ./... - - go test -race -coverprofile=coverage.txt -covermode=atomic ./... -after_success: - - bash <(curl -s https://codecov.io/bash) -matrix: - allow_failures: - - go: tip diff --git a/vendor/github.com/labstack/echo/v4/CHANGELOG.md b/vendor/github.com/labstack/echo/v4/CHANGELOG.md index c1c3c10..8318424 100644 --- a/vendor/github.com/labstack/echo/v4/CHANGELOG.md +++ b/vendor/github.com/labstack/echo/v4/CHANGELOG.md @@ -1,5 +1,32 @@ # Changelog +## v4.10.2 - 2023-02-22 + +**Security** + +* `filepath.Clean` behaviour has changed in Go 1.20 - adapt to it [#2406](https://github.com/labstack/echo/pull/2406) +* Add `middleware.CORSConfig.UnsafeWildcardOriginWithAllowCredentials` to make UNSAFE usages of wildcard origin + allow cretentials less likely [#2405](https://github.com/labstack/echo/pull/2405) + +**Enhancements** + +* Add more HTTP error values [#2277](https://github.com/labstack/echo/pull/2277) + + +## v4.10.1 - 2023-02-19 + +**Security** + +* Upgrade deps due to the latest golang.org/x/net vulnerability [#2402](https://github.com/labstack/echo/pull/2402) + + +**Enhancements** + +* Add new JWT repository to the README [#2377](https://github.com/labstack/echo/pull/2377) +* Return an empty string for ctx.path if there is no registered path [#2385](https://github.com/labstack/echo/pull/2385) +* Add context timeout middleware [#2380](https://github.com/labstack/echo/pull/2380) +* Update link to jaegertracing [#2394](https://github.com/labstack/echo/pull/2394) + + ## v4.10.0 - 2022-12-27 **Security** diff --git a/vendor/github.com/labstack/echo/v4/README.md b/vendor/github.com/labstack/echo/v4/README.md index 509b973..fe78b6e 100644 --- a/vendor/github.com/labstack/echo/v4/README.md +++ b/vendor/github.com/labstack/echo/v4/README.md @@ -11,12 +11,12 @@ ## Supported Go versions -Latest version of Echo supports last four Go major [releases](https://go.dev/doc/devel/release) and might work with older versions. +Latest version of Echo supports last four Go major [releases](https://go.dev/doc/devel/release) and might work with +older versions. As of version 4.0.0, Echo is available as a [Go module](https://github.com/golang/go/wiki/Modules). Therefore a Go version capable of understanding /vN suffixed imports is required: - Any of these versions will allow you to import Echo as `github.com/labstack/echo/v4` which is the recommended way of using Echo going forward. @@ -90,18 +90,29 @@ func hello(c echo.Context) error { } ``` -# Third-party middlewares +# Official middleware repositories -| Repository | Description | -|------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [github.com/labstack/echo-contrib](https://github.com/labstack/echo-contrib) | (by Echo team) [casbin](https://github.com/casbin/casbin), [gorilla/sessions](https://github.com/gorilla/sessions), [jaegertracing](github.com/uber/jaeger-client-go), [prometheus](https://github.com/prometheus/client_golang/), [pprof](https://pkg.go.dev/net/http/pprof), [zipkin](https://github.com/openzipkin/zipkin-go) middlewares | -| [deepmap/oapi-codegen](https://github.com/deepmap/oapi-codegen) | Automatically generate RESTful API documentation with [OpenAPI](https://swagger.io/specification/) Client and Server Code Generator | -| [github.com/swaggo/echo-swagger](https://github.com/swaggo/echo-swagger) | Automatically generate RESTful API documentation with [Swagger](https://swagger.io/) 2.0. | -| [github.com/ziflex/lecho](https://github.com/ziflex/lecho) | [Zerolog](https://github.com/rs/zerolog) logging library wrapper for Echo logger interface. | -| [github.com/brpaz/echozap](https://github.com/brpaz/echozap) | Uber´s [Zap](https://github.com/uber-go/zap) logging library wrapper for Echo logger interface. | -| [github.com/darkweak/souin/plugins/echo](https://github.com/darkweak/souin/tree/master/plugins/echo) | HTTP cache system based on [Souin](https://github.com/darkweak/souin) to automatically get your endpoints cached. It supports some distributed and non-distributed storage systems depending your needs. | -| [github.com/mikestefanello/pagoda](https://github.com/mikestefanello/pagoda) | Rapid, easy full-stack web development starter kit built with Echo. | -| [github.com/go-woo/protoc-gen-echo](https://github.com/go-woo/protoc-gen-echo) | ProtoBuf generate Echo server side code | +Following list of middleware is maintained by Echo team. + +| Repository | Description | +|------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [github.com/labstack/echo-jwt](https://github.com/labstack/echo-jwt) | [JWT](https://github.com/golang-jwt/jwt) middleware | +| [github.com/labstack/echo-contrib](https://github.com/labstack/echo-contrib) | [casbin](https://github.com/casbin/casbin), [gorilla/sessions](https://github.com/gorilla/sessions), [jaegertracing](https://github.com/uber/jaeger-client-go), [prometheus](https://github.com/prometheus/client_golang/), [pprof](https://pkg.go.dev/net/http/pprof), [zipkin](https://github.com/openzipkin/zipkin-go) middlewares | + +# Third-party middleware repositories + +Be careful when adding 3rd party middleware. Echo teams does not have time or manpower to guarantee safety and quality +of middlewares in this list. + +| Repository | Description | +|------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [deepmap/oapi-codegen](https://github.com/deepmap/oapi-codegen) | Automatically generate RESTful API documentation with [OpenAPI](https://swagger.io/specification/) Client and Server Code Generator | +| [github.com/swaggo/echo-swagger](https://github.com/swaggo/echo-swagger) | Automatically generate RESTful API documentation with [Swagger](https://swagger.io/) 2.0. | +| [github.com/ziflex/lecho](https://github.com/ziflex/lecho) | [Zerolog](https://github.com/rs/zerolog) logging library wrapper for Echo logger interface. | +| [github.com/brpaz/echozap](https://github.com/brpaz/echozap) | Uber´s [Zap](https://github.com/uber-go/zap) logging library wrapper for Echo logger interface. | +| [github.com/darkweak/souin/plugins/echo](https://github.com/darkweak/souin/tree/master/plugins/echo) | HTTP cache system based on [Souin](https://github.com/darkweak/souin) to automatically get your endpoints cached. It supports some distributed and non-distributed storage systems depending your needs. | +| [github.com/mikestefanello/pagoda](https://github.com/mikestefanello/pagoda) | Rapid, easy full-stack web development starter kit built with Echo. | +| [github.com/go-woo/protoc-gen-echo](https://github.com/go-woo/protoc-gen-echo) | ProtoBuf generate Echo server side code | Please send a PR to add your own library here. diff --git a/vendor/github.com/labstack/echo/v4/echo.go b/vendor/github.com/labstack/echo/v4/echo.go index f6d89b9..085a3a7 100644 --- a/vendor/github.com/labstack/echo/v4/echo.go +++ b/vendor/github.com/labstack/echo/v4/echo.go @@ -258,7 +258,7 @@ const ( const ( // Version of Echo - Version = "4.10.0" + Version = "4.10.2" website = "https://echo.labstack.com" // http://patorjk.com/software/taag/#p=display&f=Small%20Slant&t=Echo banner = ` @@ -291,24 +291,53 @@ var ( // Errors var ( - ErrUnsupportedMediaType = NewHTTPError(http.StatusUnsupportedMediaType) - ErrNotFound = NewHTTPError(http.StatusNotFound) - ErrUnauthorized = NewHTTPError(http.StatusUnauthorized) - ErrForbidden = NewHTTPError(http.StatusForbidden) - ErrMethodNotAllowed = NewHTTPError(http.StatusMethodNotAllowed) - ErrStatusRequestEntityTooLarge = NewHTTPError(http.StatusRequestEntityTooLarge) - ErrTooManyRequests = NewHTTPError(http.StatusTooManyRequests) - ErrBadRequest = NewHTTPError(http.StatusBadRequest) - ErrBadGateway = NewHTTPError(http.StatusBadGateway) - ErrInternalServerError = NewHTTPError(http.StatusInternalServerError) - ErrRequestTimeout = NewHTTPError(http.StatusRequestTimeout) - ErrServiceUnavailable = NewHTTPError(http.StatusServiceUnavailable) - ErrValidatorNotRegistered = errors.New("validator not registered") - ErrRendererNotRegistered = errors.New("renderer not registered") - ErrInvalidRedirectCode = errors.New("invalid redirect status code") - ErrCookieNotFound = errors.New("cookie not found") - ErrInvalidCertOrKeyType = errors.New("invalid cert or key type, must be string or []byte") - ErrInvalidListenerNetwork = errors.New("invalid listener network") + ErrBadRequest = NewHTTPError(http.StatusBadRequest) // HTTP 400 Bad Request + ErrUnauthorized = NewHTTPError(http.StatusUnauthorized) // HTTP 401 Unauthorized + ErrPaymentRequired = NewHTTPError(http.StatusPaymentRequired) // HTTP 402 Payment Required + ErrForbidden = NewHTTPError(http.StatusForbidden) // HTTP 403 Forbidden + ErrNotFound = NewHTTPError(http.StatusNotFound) // HTTP 404 Not Found + ErrMethodNotAllowed = NewHTTPError(http.StatusMethodNotAllowed) // HTTP 405 Method Not Allowed + ErrNotAcceptable = NewHTTPError(http.StatusNotAcceptable) // HTTP 406 Not Acceptable + ErrProxyAuthRequired = NewHTTPError(http.StatusProxyAuthRequired) // HTTP 407 Proxy AuthRequired + ErrRequestTimeout = NewHTTPError(http.StatusRequestTimeout) // HTTP 408 Request Timeout + ErrConflict = NewHTTPError(http.StatusConflict) // HTTP 409 Conflict + ErrGone = NewHTTPError(http.StatusGone) // HTTP 410 Gone + ErrLengthRequired = NewHTTPError(http.StatusLengthRequired) // HTTP 411 Length Required + ErrPreconditionFailed = NewHTTPError(http.StatusPreconditionFailed) // HTTP 412 Precondition Failed + ErrStatusRequestEntityTooLarge = NewHTTPError(http.StatusRequestEntityTooLarge) // HTTP 413 Payload Too Large + ErrRequestURITooLong = NewHTTPError(http.StatusRequestURITooLong) // HTTP 414 URI Too Long + ErrUnsupportedMediaType = NewHTTPError(http.StatusUnsupportedMediaType) // HTTP 415 Unsupported Media Type + ErrRequestedRangeNotSatisfiable = NewHTTPError(http.StatusRequestedRangeNotSatisfiable) // HTTP 416 Range Not Satisfiable + ErrExpectationFailed = NewHTTPError(http.StatusExpectationFailed) // HTTP 417 Expectation Failed + ErrTeapot = NewHTTPError(http.StatusTeapot) // HTTP 418 I'm a teapot + ErrMisdirectedRequest = NewHTTPError(http.StatusMisdirectedRequest) // HTTP 421 Misdirected Request + ErrUnprocessableEntity = NewHTTPError(http.StatusUnprocessableEntity) // HTTP 422 Unprocessable Entity + ErrLocked = NewHTTPError(http.StatusLocked) // HTTP 423 Locked + ErrFailedDependency = NewHTTPError(http.StatusFailedDependency) // HTTP 424 Failed Dependency + ErrTooEarly = NewHTTPError(http.StatusTooEarly) // HTTP 425 Too Early + ErrUpgradeRequired = NewHTTPError(http.StatusUpgradeRequired) // HTTP 426 Upgrade Required + ErrPreconditionRequired = NewHTTPError(http.StatusPreconditionRequired) // HTTP 428 Precondition Required + ErrTooManyRequests = NewHTTPError(http.StatusTooManyRequests) // HTTP 429 Too Many Requests + ErrRequestHeaderFieldsTooLarge = NewHTTPError(http.StatusRequestHeaderFieldsTooLarge) // HTTP 431 Request Header Fields Too Large + ErrUnavailableForLegalReasons = NewHTTPError(http.StatusUnavailableForLegalReasons) // HTTP 451 Unavailable For Legal Reasons + ErrInternalServerError = NewHTTPError(http.StatusInternalServerError) // HTTP 500 Internal Server Error + ErrNotImplemented = NewHTTPError(http.StatusNotImplemented) // HTTP 501 Not Implemented + ErrBadGateway = NewHTTPError(http.StatusBadGateway) // HTTP 502 Bad Gateway + ErrServiceUnavailable = NewHTTPError(http.StatusServiceUnavailable) // HTTP 503 Service Unavailable + ErrGatewayTimeout = NewHTTPError(http.StatusGatewayTimeout) // HTTP 504 Gateway Timeout + ErrHTTPVersionNotSupported = NewHTTPError(http.StatusHTTPVersionNotSupported) // HTTP 505 HTTP Version Not Supported + ErrVariantAlsoNegotiates = NewHTTPError(http.StatusVariantAlsoNegotiates) // HTTP 506 Variant Also Negotiates + ErrInsufficientStorage = NewHTTPError(http.StatusInsufficientStorage) // HTTP 507 Insufficient Storage + ErrLoopDetected = NewHTTPError(http.StatusLoopDetected) // HTTP 508 Loop Detected + ErrNotExtended = NewHTTPError(http.StatusNotExtended) // HTTP 510 Not Extended + ErrNetworkAuthenticationRequired = NewHTTPError(http.StatusNetworkAuthenticationRequired) // HTTP 511 Network Authentication Required + + ErrValidatorNotRegistered = errors.New("validator not registered") + ErrRendererNotRegistered = errors.New("renderer not registered") + ErrInvalidRedirectCode = errors.New("invalid redirect status code") + ErrCookieNotFound = errors.New("cookie not found") + ErrInvalidCertOrKeyType = errors.New("invalid cert or key type, must be string or []byte") + ErrInvalidListenerNetwork = errors.New("invalid listener network") ) // Error handlers diff --git a/vendor/github.com/labstack/echo/v4/router.go b/vendor/github.com/labstack/echo/v4/router.go index 86a986a..597660d 100644 --- a/vendor/github.com/labstack/echo/v4/router.go +++ b/vendor/github.com/labstack/echo/v4/router.go @@ -524,7 +524,6 @@ func optionsMethodHandler(allowMethods string) func(c Context) error { // - Return it `Echo#ReleaseContext()`. func (r *Router) Find(method, path string, c Context) { ctx := c.(*context) - ctx.path = path currentNode := r.tree // Current node as root var ( diff --git a/vendor/golang.org/x/net/websocket/client.go b/vendor/golang.org/x/net/websocket/client.go new file mode 100644 index 0000000..69a4ac7 --- /dev/null +++ b/vendor/golang.org/x/net/websocket/client.go @@ -0,0 +1,106 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package websocket + +import ( + "bufio" + "io" + "net" + "net/http" + "net/url" +) + +// DialError is an error that occurs while dialling a websocket server. +type DialError struct { + *Config + Err error +} + +func (e *DialError) Error() string { + return "websocket.Dial " + e.Config.Location.String() + ": " + e.Err.Error() +} + +// NewConfig creates a new WebSocket config for client connection. +func NewConfig(server, origin string) (config *Config, err error) { + config = new(Config) + config.Version = ProtocolVersionHybi13 + config.Location, err = url.ParseRequestURI(server) + if err != nil { + return + } + config.Origin, err = url.ParseRequestURI(origin) + if err != nil { + return + } + config.Header = http.Header(make(map[string][]string)) + return +} + +// NewClient creates a new WebSocket client connection over rwc. +func NewClient(config *Config, rwc io.ReadWriteCloser) (ws *Conn, err error) { + br := bufio.NewReader(rwc) + bw := bufio.NewWriter(rwc) + err = hybiClientHandshake(config, br, bw) + if err != nil { + return + } + buf := bufio.NewReadWriter(br, bw) + ws = newHybiClientConn(config, buf, rwc) + return +} + +// Dial opens a new client connection to a WebSocket. +func Dial(url_, protocol, origin string) (ws *Conn, err error) { + config, err := NewConfig(url_, origin) + if err != nil { + return nil, err + } + if protocol != "" { + config.Protocol = []string{protocol} + } + return DialConfig(config) +} + +var portMap = map[string]string{ + "ws": "80", + "wss": "443", +} + +func parseAuthority(location *url.URL) string { + if _, ok := portMap[location.Scheme]; ok { + if _, _, err := net.SplitHostPort(location.Host); err != nil { + return net.JoinHostPort(location.Host, portMap[location.Scheme]) + } + } + return location.Host +} + +// DialConfig opens a new client connection to a WebSocket with a config. +func DialConfig(config *Config) (ws *Conn, err error) { + var client net.Conn + if config.Location == nil { + return nil, &DialError{config, ErrBadWebSocketLocation} + } + if config.Origin == nil { + return nil, &DialError{config, ErrBadWebSocketOrigin} + } + dialer := config.Dialer + if dialer == nil { + dialer = &net.Dialer{} + } + client, err = dialWithDialer(dialer, config) + if err != nil { + goto Error + } + ws, err = NewClient(config, client) + if err != nil { + client.Close() + goto Error + } + return + +Error: + return nil, &DialError{config, err} +} diff --git a/vendor/golang.org/x/net/websocket/dial.go b/vendor/golang.org/x/net/websocket/dial.go new file mode 100644 index 0000000..2dab943 --- /dev/null +++ b/vendor/golang.org/x/net/websocket/dial.go @@ -0,0 +1,24 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package websocket + +import ( + "crypto/tls" + "net" +) + +func dialWithDialer(dialer *net.Dialer, config *Config) (conn net.Conn, err error) { + switch config.Location.Scheme { + case "ws": + conn, err = dialer.Dial("tcp", parseAuthority(config.Location)) + + case "wss": + conn, err = tls.DialWithDialer(dialer, "tcp", parseAuthority(config.Location), config.TlsConfig) + + default: + err = ErrBadScheme + } + return +} diff --git a/vendor/golang.org/x/net/websocket/hybi.go b/vendor/golang.org/x/net/websocket/hybi.go new file mode 100644 index 0000000..48a069e --- /dev/null +++ b/vendor/golang.org/x/net/websocket/hybi.go @@ -0,0 +1,583 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package websocket + +// This file implements a protocol of hybi draft. +// http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-17 + +import ( + "bufio" + "bytes" + "crypto/rand" + "crypto/sha1" + "encoding/base64" + "encoding/binary" + "fmt" + "io" + "io/ioutil" + "net/http" + "net/url" + "strings" +) + +const ( + websocketGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" + + closeStatusNormal = 1000 + closeStatusGoingAway = 1001 + closeStatusProtocolError = 1002 + closeStatusUnsupportedData = 1003 + closeStatusFrameTooLarge = 1004 + closeStatusNoStatusRcvd = 1005 + closeStatusAbnormalClosure = 1006 + closeStatusBadMessageData = 1007 + closeStatusPolicyViolation = 1008 + closeStatusTooBigData = 1009 + closeStatusExtensionMismatch = 1010 + + maxControlFramePayloadLength = 125 +) + +var ( + ErrBadMaskingKey = &ProtocolError{"bad masking key"} + ErrBadPongMessage = &ProtocolError{"bad pong message"} + ErrBadClosingStatus = &ProtocolError{"bad closing status"} + ErrUnsupportedExtensions = &ProtocolError{"unsupported extensions"} + ErrNotImplemented = &ProtocolError{"not implemented"} + + handshakeHeader = map[string]bool{ + "Host": true, + "Upgrade": true, + "Connection": true, + "Sec-Websocket-Key": true, + "Sec-Websocket-Origin": true, + "Sec-Websocket-Version": true, + "Sec-Websocket-Protocol": true, + "Sec-Websocket-Accept": true, + } +) + +// A hybiFrameHeader is a frame header as defined in hybi draft. +type hybiFrameHeader struct { + Fin bool + Rsv [3]bool + OpCode byte + Length int64 + MaskingKey []byte + + data *bytes.Buffer +} + +// A hybiFrameReader is a reader for hybi frame. +type hybiFrameReader struct { + reader io.Reader + + header hybiFrameHeader + pos int64 + length int +} + +func (frame *hybiFrameReader) Read(msg []byte) (n int, err error) { + n, err = frame.reader.Read(msg) + if frame.header.MaskingKey != nil { + for i := 0; i < n; i++ { + msg[i] = msg[i] ^ frame.header.MaskingKey[frame.pos%4] + frame.pos++ + } + } + return n, err +} + +func (frame *hybiFrameReader) PayloadType() byte { return frame.header.OpCode } + +func (frame *hybiFrameReader) HeaderReader() io.Reader { + if frame.header.data == nil { + return nil + } + if frame.header.data.Len() == 0 { + return nil + } + return frame.header.data +} + +func (frame *hybiFrameReader) TrailerReader() io.Reader { return nil } + +func (frame *hybiFrameReader) Len() (n int) { return frame.length } + +// A hybiFrameReaderFactory creates new frame reader based on its frame type. +type hybiFrameReaderFactory struct { + *bufio.Reader +} + +// NewFrameReader reads a frame header from the connection, and creates new reader for the frame. +// See Section 5.2 Base Framing protocol for detail. +// http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-17#section-5.2 +func (buf hybiFrameReaderFactory) NewFrameReader() (frame frameReader, err error) { + hybiFrame := new(hybiFrameReader) + frame = hybiFrame + var header []byte + var b byte + // First byte. FIN/RSV1/RSV2/RSV3/OpCode(4bits) + b, err = buf.ReadByte() + if err != nil { + return + } + header = append(header, b) + hybiFrame.header.Fin = ((header[0] >> 7) & 1) != 0 + for i := 0; i < 3; i++ { + j := uint(6 - i) + hybiFrame.header.Rsv[i] = ((header[0] >> j) & 1) != 0 + } + hybiFrame.header.OpCode = header[0] & 0x0f + + // Second byte. Mask/Payload len(7bits) + b, err = buf.ReadByte() + if err != nil { + return + } + header = append(header, b) + mask := (b & 0x80) != 0 + b &= 0x7f + lengthFields := 0 + switch { + case b <= 125: // Payload length 7bits. + hybiFrame.header.Length = int64(b) + case b == 126: // Payload length 7+16bits + lengthFields = 2 + case b == 127: // Payload length 7+64bits + lengthFields = 8 + } + for i := 0; i < lengthFields; i++ { + b, err = buf.ReadByte() + if err != nil { + return + } + if lengthFields == 8 && i == 0 { // MSB must be zero when 7+64 bits + b &= 0x7f + } + header = append(header, b) + hybiFrame.header.Length = hybiFrame.header.Length*256 + int64(b) + } + if mask { + // Masking key. 4 bytes. + for i := 0; i < 4; i++ { + b, err = buf.ReadByte() + if err != nil { + return + } + header = append(header, b) + hybiFrame.header.MaskingKey = append(hybiFrame.header.MaskingKey, b) + } + } + hybiFrame.reader = io.LimitReader(buf.Reader, hybiFrame.header.Length) + hybiFrame.header.data = bytes.NewBuffer(header) + hybiFrame.length = len(header) + int(hybiFrame.header.Length) + return +} + +// A HybiFrameWriter is a writer for hybi frame. +type hybiFrameWriter struct { + writer *bufio.Writer + + header *hybiFrameHeader +} + +func (frame *hybiFrameWriter) Write(msg []byte) (n int, err error) { + var header []byte + var b byte + if frame.header.Fin { + b |= 0x80 + } + for i := 0; i < 3; i++ { + if frame.header.Rsv[i] { + j := uint(6 - i) + b |= 1 << j + } + } + b |= frame.header.OpCode + header = append(header, b) + if frame.header.MaskingKey != nil { + b = 0x80 + } else { + b = 0 + } + lengthFields := 0 + length := len(msg) + switch { + case length <= 125: + b |= byte(length) + case length < 65536: + b |= 126 + lengthFields = 2 + default: + b |= 127 + lengthFields = 8 + } + header = append(header, b) + for i := 0; i < lengthFields; i++ { + j := uint((lengthFields - i - 1) * 8) + b = byte((length >> j) & 0xff) + header = append(header, b) + } + if frame.header.MaskingKey != nil { + if len(frame.header.MaskingKey) != 4 { + return 0, ErrBadMaskingKey + } + header = append(header, frame.header.MaskingKey...) + frame.writer.Write(header) + data := make([]byte, length) + for i := range data { + data[i] = msg[i] ^ frame.header.MaskingKey[i%4] + } + frame.writer.Write(data) + err = frame.writer.Flush() + return length, err + } + frame.writer.Write(header) + frame.writer.Write(msg) + err = frame.writer.Flush() + return length, err +} + +func (frame *hybiFrameWriter) Close() error { return nil } + +type hybiFrameWriterFactory struct { + *bufio.Writer + needMaskingKey bool +} + +func (buf hybiFrameWriterFactory) NewFrameWriter(payloadType byte) (frame frameWriter, err error) { + frameHeader := &hybiFrameHeader{Fin: true, OpCode: payloadType} + if buf.needMaskingKey { + frameHeader.MaskingKey, err = generateMaskingKey() + if err != nil { + return nil, err + } + } + return &hybiFrameWriter{writer: buf.Writer, header: frameHeader}, nil +} + +type hybiFrameHandler struct { + conn *Conn + payloadType byte +} + +func (handler *hybiFrameHandler) HandleFrame(frame frameReader) (frameReader, error) { + if handler.conn.IsServerConn() { + // The client MUST mask all frames sent to the server. + if frame.(*hybiFrameReader).header.MaskingKey == nil { + handler.WriteClose(closeStatusProtocolError) + return nil, io.EOF + } + } else { + // The server MUST NOT mask all frames. + if frame.(*hybiFrameReader).header.MaskingKey != nil { + handler.WriteClose(closeStatusProtocolError) + return nil, io.EOF + } + } + if header := frame.HeaderReader(); header != nil { + io.Copy(ioutil.Discard, header) + } + switch frame.PayloadType() { + case ContinuationFrame: + frame.(*hybiFrameReader).header.OpCode = handler.payloadType + case TextFrame, BinaryFrame: + handler.payloadType = frame.PayloadType() + case CloseFrame: + return nil, io.EOF + case PingFrame, PongFrame: + b := make([]byte, maxControlFramePayloadLength) + n, err := io.ReadFull(frame, b) + if err != nil && err != io.EOF && err != io.ErrUnexpectedEOF { + return nil, err + } + io.Copy(ioutil.Discard, frame) + if frame.PayloadType() == PingFrame { + if _, err := handler.WritePong(b[:n]); err != nil { + return nil, err + } + } + return nil, nil + } + return frame, nil +} + +func (handler *hybiFrameHandler) WriteClose(status int) (err error) { + handler.conn.wio.Lock() + defer handler.conn.wio.Unlock() + w, err := handler.conn.frameWriterFactory.NewFrameWriter(CloseFrame) + if err != nil { + return err + } + msg := make([]byte, 2) + binary.BigEndian.PutUint16(msg, uint16(status)) + _, err = w.Write(msg) + w.Close() + return err +} + +func (handler *hybiFrameHandler) WritePong(msg []byte) (n int, err error) { + handler.conn.wio.Lock() + defer handler.conn.wio.Unlock() + w, err := handler.conn.frameWriterFactory.NewFrameWriter(PongFrame) + if err != nil { + return 0, err + } + n, err = w.Write(msg) + w.Close() + return n, err +} + +// newHybiConn creates a new WebSocket connection speaking hybi draft protocol. +func newHybiConn(config *Config, buf *bufio.ReadWriter, rwc io.ReadWriteCloser, request *http.Request) *Conn { + if buf == nil { + br := bufio.NewReader(rwc) + bw := bufio.NewWriter(rwc) + buf = bufio.NewReadWriter(br, bw) + } + ws := &Conn{config: config, request: request, buf: buf, rwc: rwc, + frameReaderFactory: hybiFrameReaderFactory{buf.Reader}, + frameWriterFactory: hybiFrameWriterFactory{ + buf.Writer, request == nil}, + PayloadType: TextFrame, + defaultCloseStatus: closeStatusNormal} + ws.frameHandler = &hybiFrameHandler{conn: ws} + return ws +} + +// generateMaskingKey generates a masking key for a frame. +func generateMaskingKey() (maskingKey []byte, err error) { + maskingKey = make([]byte, 4) + if _, err = io.ReadFull(rand.Reader, maskingKey); err != nil { + return + } + return +} + +// generateNonce generates a nonce consisting of a randomly selected 16-byte +// value that has been base64-encoded. +func generateNonce() (nonce []byte) { + key := make([]byte, 16) + if _, err := io.ReadFull(rand.Reader, key); err != nil { + panic(err) + } + nonce = make([]byte, 24) + base64.StdEncoding.Encode(nonce, key) + return +} + +// removeZone removes IPv6 zone identifier from host. +// E.g., "[fe80::1%en0]:8080" to "[fe80::1]:8080" +func removeZone(host string) string { + if !strings.HasPrefix(host, "[") { + return host + } + i := strings.LastIndex(host, "]") + if i < 0 { + return host + } + j := strings.LastIndex(host[:i], "%") + if j < 0 { + return host + } + return host[:j] + host[i:] +} + +// getNonceAccept computes the base64-encoded SHA-1 of the concatenation of +// the nonce ("Sec-WebSocket-Key" value) with the websocket GUID string. +func getNonceAccept(nonce []byte) (expected []byte, err error) { + h := sha1.New() + if _, err = h.Write(nonce); err != nil { + return + } + if _, err = h.Write([]byte(websocketGUID)); err != nil { + return + } + expected = make([]byte, 28) + base64.StdEncoding.Encode(expected, h.Sum(nil)) + return +} + +// Client handshake described in draft-ietf-hybi-thewebsocket-protocol-17 +func hybiClientHandshake(config *Config, br *bufio.Reader, bw *bufio.Writer) (err error) { + bw.WriteString("GET " + config.Location.RequestURI() + " HTTP/1.1\r\n") + + // According to RFC 6874, an HTTP client, proxy, or other + // intermediary must remove any IPv6 zone identifier attached + // to an outgoing URI. + bw.WriteString("Host: " + removeZone(config.Location.Host) + "\r\n") + bw.WriteString("Upgrade: websocket\r\n") + bw.WriteString("Connection: Upgrade\r\n") + nonce := generateNonce() + if config.handshakeData != nil { + nonce = []byte(config.handshakeData["key"]) + } + bw.WriteString("Sec-WebSocket-Key: " + string(nonce) + "\r\n") + bw.WriteString("Origin: " + strings.ToLower(config.Origin.String()) + "\r\n") + + if config.Version != ProtocolVersionHybi13 { + return ErrBadProtocolVersion + } + + bw.WriteString("Sec-WebSocket-Version: " + fmt.Sprintf("%d", config.Version) + "\r\n") + if len(config.Protocol) > 0 { + bw.WriteString("Sec-WebSocket-Protocol: " + strings.Join(config.Protocol, ", ") + "\r\n") + } + // TODO(ukai): send Sec-WebSocket-Extensions. + err = config.Header.WriteSubset(bw, handshakeHeader) + if err != nil { + return err + } + + bw.WriteString("\r\n") + if err = bw.Flush(); err != nil { + return err + } + + resp, err := http.ReadResponse(br, &http.Request{Method: "GET"}) + if err != nil { + return err + } + if resp.StatusCode != 101 { + return ErrBadStatus + } + if strings.ToLower(resp.Header.Get("Upgrade")) != "websocket" || + strings.ToLower(resp.Header.Get("Connection")) != "upgrade" { + return ErrBadUpgrade + } + expectedAccept, err := getNonceAccept(nonce) + if err != nil { + return err + } + if resp.Header.Get("Sec-WebSocket-Accept") != string(expectedAccept) { + return ErrChallengeResponse + } + if resp.Header.Get("Sec-WebSocket-Extensions") != "" { + return ErrUnsupportedExtensions + } + offeredProtocol := resp.Header.Get("Sec-WebSocket-Protocol") + if offeredProtocol != "" { + protocolMatched := false + for i := 0; i < len(config.Protocol); i++ { + if config.Protocol[i] == offeredProtocol { + protocolMatched = true + break + } + } + if !protocolMatched { + return ErrBadWebSocketProtocol + } + config.Protocol = []string{offeredProtocol} + } + + return nil +} + +// newHybiClientConn creates a client WebSocket connection after handshake. +func newHybiClientConn(config *Config, buf *bufio.ReadWriter, rwc io.ReadWriteCloser) *Conn { + return newHybiConn(config, buf, rwc, nil) +} + +// A HybiServerHandshaker performs a server handshake using hybi draft protocol. +type hybiServerHandshaker struct { + *Config + accept []byte +} + +func (c *hybiServerHandshaker) ReadHandshake(buf *bufio.Reader, req *http.Request) (code int, err error) { + c.Version = ProtocolVersionHybi13 + if req.Method != "GET" { + return http.StatusMethodNotAllowed, ErrBadRequestMethod + } + // HTTP version can be safely ignored. + + if strings.ToLower(req.Header.Get("Upgrade")) != "websocket" || + !strings.Contains(strings.ToLower(req.Header.Get("Connection")), "upgrade") { + return http.StatusBadRequest, ErrNotWebSocket + } + + key := req.Header.Get("Sec-Websocket-Key") + if key == "" { + return http.StatusBadRequest, ErrChallengeResponse + } + version := req.Header.Get("Sec-Websocket-Version") + switch version { + case "13": + c.Version = ProtocolVersionHybi13 + default: + return http.StatusBadRequest, ErrBadWebSocketVersion + } + var scheme string + if req.TLS != nil { + scheme = "wss" + } else { + scheme = "ws" + } + c.Location, err = url.ParseRequestURI(scheme + "://" + req.Host + req.URL.RequestURI()) + if err != nil { + return http.StatusBadRequest, err + } + protocol := strings.TrimSpace(req.Header.Get("Sec-Websocket-Protocol")) + if protocol != "" { + protocols := strings.Split(protocol, ",") + for i := 0; i < len(protocols); i++ { + c.Protocol = append(c.Protocol, strings.TrimSpace(protocols[i])) + } + } + c.accept, err = getNonceAccept([]byte(key)) + if err != nil { + return http.StatusInternalServerError, err + } + return http.StatusSwitchingProtocols, nil +} + +// Origin parses the Origin header in req. +// If the Origin header is not set, it returns nil and nil. +func Origin(config *Config, req *http.Request) (*url.URL, error) { + var origin string + switch config.Version { + case ProtocolVersionHybi13: + origin = req.Header.Get("Origin") + } + if origin == "" { + return nil, nil + } + return url.ParseRequestURI(origin) +} + +func (c *hybiServerHandshaker) AcceptHandshake(buf *bufio.Writer) (err error) { + if len(c.Protocol) > 0 { + if len(c.Protocol) != 1 { + // You need choose a Protocol in Handshake func in Server. + return ErrBadWebSocketProtocol + } + } + buf.WriteString("HTTP/1.1 101 Switching Protocols\r\n") + buf.WriteString("Upgrade: websocket\r\n") + buf.WriteString("Connection: Upgrade\r\n") + buf.WriteString("Sec-WebSocket-Accept: " + string(c.accept) + "\r\n") + if len(c.Protocol) > 0 { + buf.WriteString("Sec-WebSocket-Protocol: " + c.Protocol[0] + "\r\n") + } + // TODO(ukai): send Sec-WebSocket-Extensions. + if c.Header != nil { + err := c.Header.WriteSubset(buf, handshakeHeader) + if err != nil { + return err + } + } + buf.WriteString("\r\n") + return buf.Flush() +} + +func (c *hybiServerHandshaker) NewServerConn(buf *bufio.ReadWriter, rwc io.ReadWriteCloser, request *http.Request) *Conn { + return newHybiServerConn(c.Config, buf, rwc, request) +} + +// newHybiServerConn returns a new WebSocket connection speaking hybi draft protocol. +func newHybiServerConn(config *Config, buf *bufio.ReadWriter, rwc io.ReadWriteCloser, request *http.Request) *Conn { + return newHybiConn(config, buf, rwc, request) +} diff --git a/vendor/golang.org/x/net/websocket/server.go b/vendor/golang.org/x/net/websocket/server.go new file mode 100644 index 0000000..0895dea --- /dev/null +++ b/vendor/golang.org/x/net/websocket/server.go @@ -0,0 +1,113 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package websocket + +import ( + "bufio" + "fmt" + "io" + "net/http" +) + +func newServerConn(rwc io.ReadWriteCloser, buf *bufio.ReadWriter, req *http.Request, config *Config, handshake func(*Config, *http.Request) error) (conn *Conn, err error) { + var hs serverHandshaker = &hybiServerHandshaker{Config: config} + code, err := hs.ReadHandshake(buf.Reader, req) + if err == ErrBadWebSocketVersion { + fmt.Fprintf(buf, "HTTP/1.1 %03d %s\r\n", code, http.StatusText(code)) + fmt.Fprintf(buf, "Sec-WebSocket-Version: %s\r\n", SupportedProtocolVersion) + buf.WriteString("\r\n") + buf.WriteString(err.Error()) + buf.Flush() + return + } + if err != nil { + fmt.Fprintf(buf, "HTTP/1.1 %03d %s\r\n", code, http.StatusText(code)) + buf.WriteString("\r\n") + buf.WriteString(err.Error()) + buf.Flush() + return + } + if handshake != nil { + err = handshake(config, req) + if err != nil { + code = http.StatusForbidden + fmt.Fprintf(buf, "HTTP/1.1 %03d %s\r\n", code, http.StatusText(code)) + buf.WriteString("\r\n") + buf.Flush() + return + } + } + err = hs.AcceptHandshake(buf.Writer) + if err != nil { + code = http.StatusBadRequest + fmt.Fprintf(buf, "HTTP/1.1 %03d %s\r\n", code, http.StatusText(code)) + buf.WriteString("\r\n") + buf.Flush() + return + } + conn = hs.NewServerConn(buf, rwc, req) + return +} + +// Server represents a server of a WebSocket. +type Server struct { + // Config is a WebSocket configuration for new WebSocket connection. + Config + + // Handshake is an optional function in WebSocket handshake. + // For example, you can check, or don't check Origin header. + // Another example, you can select config.Protocol. + Handshake func(*Config, *http.Request) error + + // Handler handles a WebSocket connection. + Handler +} + +// ServeHTTP implements the http.Handler interface for a WebSocket +func (s Server) ServeHTTP(w http.ResponseWriter, req *http.Request) { + s.serveWebSocket(w, req) +} + +func (s Server) serveWebSocket(w http.ResponseWriter, req *http.Request) { + rwc, buf, err := w.(http.Hijacker).Hijack() + if err != nil { + panic("Hijack failed: " + err.Error()) + } + // The server should abort the WebSocket connection if it finds + // the client did not send a handshake that matches with protocol + // specification. + defer rwc.Close() + conn, err := newServerConn(rwc, buf, req, &s.Config, s.Handshake) + if err != nil { + return + } + if conn == nil { + panic("unexpected nil conn") + } + s.Handler(conn) +} + +// Handler is a simple interface to a WebSocket browser client. +// It checks if Origin header is valid URL by default. +// You might want to verify websocket.Conn.Config().Origin in the func. +// If you use Server instead of Handler, you could call websocket.Origin and +// check the origin in your Handshake func. So, if you want to accept +// non-browser clients, which do not send an Origin header, set a +// Server.Handshake that does not check the origin. +type Handler func(*Conn) + +func checkOrigin(config *Config, req *http.Request) (err error) { + config.Origin, err = Origin(config, req) + if err == nil && config.Origin == nil { + return fmt.Errorf("null origin") + } + return err +} + +// ServeHTTP implements the http.Handler interface for a WebSocket +func (h Handler) ServeHTTP(w http.ResponseWriter, req *http.Request) { + s := Server{Handler: h, Handshake: checkOrigin} + s.serveWebSocket(w, req) +} diff --git a/vendor/golang.org/x/net/websocket/websocket.go b/vendor/golang.org/x/net/websocket/websocket.go new file mode 100644 index 0000000..90a2257 --- /dev/null +++ b/vendor/golang.org/x/net/websocket/websocket.go @@ -0,0 +1,449 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package websocket implements a client and server for the WebSocket protocol +// as specified in RFC 6455. +// +// This package currently lacks some features found in an alternative +// and more actively maintained WebSocket package: +// +// https://pkg.go.dev/nhooyr.io/websocket +package websocket // import "golang.org/x/net/websocket" + +import ( + "bufio" + "crypto/tls" + "encoding/json" + "errors" + "io" + "io/ioutil" + "net" + "net/http" + "net/url" + "sync" + "time" +) + +const ( + ProtocolVersionHybi13 = 13 + ProtocolVersionHybi = ProtocolVersionHybi13 + SupportedProtocolVersion = "13" + + ContinuationFrame = 0 + TextFrame = 1 + BinaryFrame = 2 + CloseFrame = 8 + PingFrame = 9 + PongFrame = 10 + UnknownFrame = 255 + + DefaultMaxPayloadBytes = 32 << 20 // 32MB +) + +// ProtocolError represents WebSocket protocol errors. +type ProtocolError struct { + ErrorString string +} + +func (err *ProtocolError) Error() string { return err.ErrorString } + +var ( + ErrBadProtocolVersion = &ProtocolError{"bad protocol version"} + ErrBadScheme = &ProtocolError{"bad scheme"} + ErrBadStatus = &ProtocolError{"bad status"} + ErrBadUpgrade = &ProtocolError{"missing or bad upgrade"} + ErrBadWebSocketOrigin = &ProtocolError{"missing or bad WebSocket-Origin"} + ErrBadWebSocketLocation = &ProtocolError{"missing or bad WebSocket-Location"} + ErrBadWebSocketProtocol = &ProtocolError{"missing or bad WebSocket-Protocol"} + ErrBadWebSocketVersion = &ProtocolError{"missing or bad WebSocket Version"} + ErrChallengeResponse = &ProtocolError{"mismatch challenge/response"} + ErrBadFrame = &ProtocolError{"bad frame"} + ErrBadFrameBoundary = &ProtocolError{"not on frame boundary"} + ErrNotWebSocket = &ProtocolError{"not websocket protocol"} + ErrBadRequestMethod = &ProtocolError{"bad method"} + ErrNotSupported = &ProtocolError{"not supported"} +) + +// ErrFrameTooLarge is returned by Codec's Receive method if payload size +// exceeds limit set by Conn.MaxPayloadBytes +var ErrFrameTooLarge = errors.New("websocket: frame payload size exceeds limit") + +// Addr is an implementation of net.Addr for WebSocket. +type Addr struct { + *url.URL +} + +// Network returns the network type for a WebSocket, "websocket". +func (addr *Addr) Network() string { return "websocket" } + +// Config is a WebSocket configuration +type Config struct { + // A WebSocket server address. + Location *url.URL + + // A Websocket client origin. + Origin *url.URL + + // WebSocket subprotocols. + Protocol []string + + // WebSocket protocol version. + Version int + + // TLS config for secure WebSocket (wss). + TlsConfig *tls.Config + + // Additional header fields to be sent in WebSocket opening handshake. + Header http.Header + + // Dialer used when opening websocket connections. + Dialer *net.Dialer + + handshakeData map[string]string +} + +// serverHandshaker is an interface to handle WebSocket server side handshake. +type serverHandshaker interface { + // ReadHandshake reads handshake request message from client. + // Returns http response code and error if any. + ReadHandshake(buf *bufio.Reader, req *http.Request) (code int, err error) + + // AcceptHandshake accepts the client handshake request and sends + // handshake response back to client. + AcceptHandshake(buf *bufio.Writer) (err error) + + // NewServerConn creates a new WebSocket connection. + NewServerConn(buf *bufio.ReadWriter, rwc io.ReadWriteCloser, request *http.Request) (conn *Conn) +} + +// frameReader is an interface to read a WebSocket frame. +type frameReader interface { + // Reader is to read payload of the frame. + io.Reader + + // PayloadType returns payload type. + PayloadType() byte + + // HeaderReader returns a reader to read header of the frame. + HeaderReader() io.Reader + + // TrailerReader returns a reader to read trailer of the frame. + // If it returns nil, there is no trailer in the frame. + TrailerReader() io.Reader + + // Len returns total length of the frame, including header and trailer. + Len() int +} + +// frameReaderFactory is an interface to creates new frame reader. +type frameReaderFactory interface { + NewFrameReader() (r frameReader, err error) +} + +// frameWriter is an interface to write a WebSocket frame. +type frameWriter interface { + // Writer is to write payload of the frame. + io.WriteCloser +} + +// frameWriterFactory is an interface to create new frame writer. +type frameWriterFactory interface { + NewFrameWriter(payloadType byte) (w frameWriter, err error) +} + +type frameHandler interface { + HandleFrame(frame frameReader) (r frameReader, err error) + WriteClose(status int) (err error) +} + +// Conn represents a WebSocket connection. +// +// Multiple goroutines may invoke methods on a Conn simultaneously. +type Conn struct { + config *Config + request *http.Request + + buf *bufio.ReadWriter + rwc io.ReadWriteCloser + + rio sync.Mutex + frameReaderFactory + frameReader + + wio sync.Mutex + frameWriterFactory + + frameHandler + PayloadType byte + defaultCloseStatus int + + // MaxPayloadBytes limits the size of frame payload received over Conn + // by Codec's Receive method. If zero, DefaultMaxPayloadBytes is used. + MaxPayloadBytes int +} + +// Read implements the io.Reader interface: +// it reads data of a frame from the WebSocket connection. +// if msg is not large enough for the frame data, it fills the msg and next Read +// will read the rest of the frame data. +// it reads Text frame or Binary frame. +func (ws *Conn) Read(msg []byte) (n int, err error) { + ws.rio.Lock() + defer ws.rio.Unlock() +again: + if ws.frameReader == nil { + frame, err := ws.frameReaderFactory.NewFrameReader() + if err != nil { + return 0, err + } + ws.frameReader, err = ws.frameHandler.HandleFrame(frame) + if err != nil { + return 0, err + } + if ws.frameReader == nil { + goto again + } + } + n, err = ws.frameReader.Read(msg) + if err == io.EOF { + if trailer := ws.frameReader.TrailerReader(); trailer != nil { + io.Copy(ioutil.Discard, trailer) + } + ws.frameReader = nil + goto again + } + return n, err +} + +// Write implements the io.Writer interface: +// it writes data as a frame to the WebSocket connection. +func (ws *Conn) Write(msg []byte) (n int, err error) { + ws.wio.Lock() + defer ws.wio.Unlock() + w, err := ws.frameWriterFactory.NewFrameWriter(ws.PayloadType) + if err != nil { + return 0, err + } + n, err = w.Write(msg) + w.Close() + return n, err +} + +// Close implements the io.Closer interface. +func (ws *Conn) Close() error { + err := ws.frameHandler.WriteClose(ws.defaultCloseStatus) + err1 := ws.rwc.Close() + if err != nil { + return err + } + return err1 +} + +// IsClientConn reports whether ws is a client-side connection. +func (ws *Conn) IsClientConn() bool { return ws.request == nil } + +// IsServerConn reports whether ws is a server-side connection. +func (ws *Conn) IsServerConn() bool { return ws.request != nil } + +// LocalAddr returns the WebSocket Origin for the connection for client, or +// the WebSocket location for server. +func (ws *Conn) LocalAddr() net.Addr { + if ws.IsClientConn() { + return &Addr{ws.config.Origin} + } + return &Addr{ws.config.Location} +} + +// RemoteAddr returns the WebSocket location for the connection for client, or +// the Websocket Origin for server. +func (ws *Conn) RemoteAddr() net.Addr { + if ws.IsClientConn() { + return &Addr{ws.config.Location} + } + return &Addr{ws.config.Origin} +} + +var errSetDeadline = errors.New("websocket: cannot set deadline: not using a net.Conn") + +// SetDeadline sets the connection's network read & write deadlines. +func (ws *Conn) SetDeadline(t time.Time) error { + if conn, ok := ws.rwc.(net.Conn); ok { + return conn.SetDeadline(t) + } + return errSetDeadline +} + +// SetReadDeadline sets the connection's network read deadline. +func (ws *Conn) SetReadDeadline(t time.Time) error { + if conn, ok := ws.rwc.(net.Conn); ok { + return conn.SetReadDeadline(t) + } + return errSetDeadline +} + +// SetWriteDeadline sets the connection's network write deadline. +func (ws *Conn) SetWriteDeadline(t time.Time) error { + if conn, ok := ws.rwc.(net.Conn); ok { + return conn.SetWriteDeadline(t) + } + return errSetDeadline +} + +// Config returns the WebSocket config. +func (ws *Conn) Config() *Config { return ws.config } + +// Request returns the http request upgraded to the WebSocket. +// It is nil for client side. +func (ws *Conn) Request() *http.Request { return ws.request } + +// Codec represents a symmetric pair of functions that implement a codec. +type Codec struct { + Marshal func(v interface{}) (data []byte, payloadType byte, err error) + Unmarshal func(data []byte, payloadType byte, v interface{}) (err error) +} + +// Send sends v marshaled by cd.Marshal as single frame to ws. +func (cd Codec) Send(ws *Conn, v interface{}) (err error) { + data, payloadType, err := cd.Marshal(v) + if err != nil { + return err + } + ws.wio.Lock() + defer ws.wio.Unlock() + w, err := ws.frameWriterFactory.NewFrameWriter(payloadType) + if err != nil { + return err + } + _, err = w.Write(data) + w.Close() + return err +} + +// Receive receives single frame from ws, unmarshaled by cd.Unmarshal and stores +// in v. The whole frame payload is read to an in-memory buffer; max size of +// payload is defined by ws.MaxPayloadBytes. If frame payload size exceeds +// limit, ErrFrameTooLarge is returned; in this case frame is not read off wire +// completely. The next call to Receive would read and discard leftover data of +// previous oversized frame before processing next frame. +func (cd Codec) Receive(ws *Conn, v interface{}) (err error) { + ws.rio.Lock() + defer ws.rio.Unlock() + if ws.frameReader != nil { + _, err = io.Copy(ioutil.Discard, ws.frameReader) + if err != nil { + return err + } + ws.frameReader = nil + } +again: + frame, err := ws.frameReaderFactory.NewFrameReader() + if err != nil { + return err + } + frame, err = ws.frameHandler.HandleFrame(frame) + if err != nil { + return err + } + if frame == nil { + goto again + } + maxPayloadBytes := ws.MaxPayloadBytes + if maxPayloadBytes == 0 { + maxPayloadBytes = DefaultMaxPayloadBytes + } + if hf, ok := frame.(*hybiFrameReader); ok && hf.header.Length > int64(maxPayloadBytes) { + // payload size exceeds limit, no need to call Unmarshal + // + // set frameReader to current oversized frame so that + // the next call to this function can drain leftover + // data before processing the next frame + ws.frameReader = frame + return ErrFrameTooLarge + } + payloadType := frame.PayloadType() + data, err := ioutil.ReadAll(frame) + if err != nil { + return err + } + return cd.Unmarshal(data, payloadType, v) +} + +func marshal(v interface{}) (msg []byte, payloadType byte, err error) { + switch data := v.(type) { + case string: + return []byte(data), TextFrame, nil + case []byte: + return data, BinaryFrame, nil + } + return nil, UnknownFrame, ErrNotSupported +} + +func unmarshal(msg []byte, payloadType byte, v interface{}) (err error) { + switch data := v.(type) { + case *string: + *data = string(msg) + return nil + case *[]byte: + *data = msg + return nil + } + return ErrNotSupported +} + +/* +Message is a codec to send/receive text/binary data in a frame on WebSocket connection. +To send/receive text frame, use string type. +To send/receive binary frame, use []byte type. + +Trivial usage: + + import "websocket" + + // receive text frame + var message string + websocket.Message.Receive(ws, &message) + + // send text frame + message = "hello" + websocket.Message.Send(ws, message) + + // receive binary frame + var data []byte + websocket.Message.Receive(ws, &data) + + // send binary frame + data = []byte{0, 1, 2} + websocket.Message.Send(ws, data) +*/ +var Message = Codec{marshal, unmarshal} + +func jsonMarshal(v interface{}) (msg []byte, payloadType byte, err error) { + msg, err = json.Marshal(v) + return msg, TextFrame, err +} + +func jsonUnmarshal(msg []byte, payloadType byte, v interface{}) (err error) { + return json.Unmarshal(msg, v) +} + +/* +JSON is a codec to send/receive JSON data in a frame from a WebSocket connection. + +Trivial usage: + + import "websocket" + + type T struct { + Msg string + Count int + } + + // receive JSON type T + var data T + websocket.JSON.Receive(ws, &data) + + // send JSON type T + websocket.JSON.Send(ws, data) +*/ +var JSON = Codec{jsonMarshal, jsonUnmarshal} diff --git a/vendor/golang.org/x/sys/unix/ioctl.go b/vendor/golang.org/x/sys/unix/ioctl.go index 1c51b0e..7ce8dd4 100644 --- a/vendor/golang.org/x/sys/unix/ioctl.go +++ b/vendor/golang.org/x/sys/unix/ioctl.go @@ -8,7 +8,6 @@ package unix import ( - "runtime" "unsafe" ) @@ -27,7 +26,7 @@ func IoctlSetInt(fd int, req uint, value int) error { // passing the integer value directly. func IoctlSetPointerInt(fd int, req uint, value int) error { v := int32(value) - return ioctl(fd, req, uintptr(unsafe.Pointer(&v))) + return ioctlPtr(fd, req, unsafe.Pointer(&v)) } // IoctlSetWinsize performs an ioctl on fd with a *Winsize argument. @@ -36,9 +35,7 @@ func IoctlSetPointerInt(fd int, req uint, value int) error { func IoctlSetWinsize(fd int, req uint, value *Winsize) error { // TODO: if we get the chance, remove the req parameter and // hardcode TIOCSWINSZ. - err := ioctl(fd, req, uintptr(unsafe.Pointer(value))) - runtime.KeepAlive(value) - return err + return ioctlPtr(fd, req, unsafe.Pointer(value)) } // IoctlSetTermios performs an ioctl on fd with a *Termios. @@ -46,9 +43,7 @@ func IoctlSetWinsize(fd int, req uint, value *Winsize) error { // The req value will usually be TCSETA or TIOCSETA. func IoctlSetTermios(fd int, req uint, value *Termios) error { // TODO: if we get the chance, remove the req parameter. - err := ioctl(fd, req, uintptr(unsafe.Pointer(value))) - runtime.KeepAlive(value) - return err + return ioctlPtr(fd, req, unsafe.Pointer(value)) } // IoctlGetInt performs an ioctl operation which gets an integer value @@ -58,18 +53,18 @@ func IoctlSetTermios(fd int, req uint, value *Termios) error { // for those, IoctlRetInt should be used instead of this function. func IoctlGetInt(fd int, req uint) (int, error) { var value int - err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) + err := ioctlPtr(fd, req, unsafe.Pointer(&value)) return value, err } func IoctlGetWinsize(fd int, req uint) (*Winsize, error) { var value Winsize - err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) + err := ioctlPtr(fd, req, unsafe.Pointer(&value)) return &value, err } func IoctlGetTermios(fd int, req uint) (*Termios, error) { var value Termios - err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) + err := ioctlPtr(fd, req, unsafe.Pointer(&value)) return &value, err } diff --git a/vendor/golang.org/x/sys/unix/ioctl_zos.go b/vendor/golang.org/x/sys/unix/ioctl_zos.go index 5384e7d..6532f09 100644 --- a/vendor/golang.org/x/sys/unix/ioctl_zos.go +++ b/vendor/golang.org/x/sys/unix/ioctl_zos.go @@ -27,9 +27,7 @@ func IoctlSetInt(fd int, req uint, value int) error { func IoctlSetWinsize(fd int, req uint, value *Winsize) error { // TODO: if we get the chance, remove the req parameter and // hardcode TIOCSWINSZ. - err := ioctl(fd, req, uintptr(unsafe.Pointer(value))) - runtime.KeepAlive(value) - return err + return ioctlPtr(fd, req, unsafe.Pointer(value)) } // IoctlSetTermios performs an ioctl on fd with a *Termios. @@ -51,13 +49,13 @@ func IoctlSetTermios(fd int, req uint, value *Termios) error { // for those, IoctlRetInt should be used instead of this function. func IoctlGetInt(fd int, req uint) (int, error) { var value int - err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) + err := ioctlPtr(fd, req, unsafe.Pointer(&value)) return value, err } func IoctlGetWinsize(fd int, req uint) (*Winsize, error) { var value Winsize - err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) + err := ioctlPtr(fd, req, unsafe.Pointer(&value)) return &value, err } diff --git a/vendor/golang.org/x/sys/unix/ptrace_darwin.go b/vendor/golang.org/x/sys/unix/ptrace_darwin.go index 463c3ef..39dba6c 100644 --- a/vendor/golang.org/x/sys/unix/ptrace_darwin.go +++ b/vendor/golang.org/x/sys/unix/ptrace_darwin.go @@ -7,6 +7,12 @@ package unix +import "unsafe" + func ptrace(request int, pid int, addr uintptr, data uintptr) error { return ptrace1(request, pid, addr, data) } + +func ptracePtr(request int, pid int, addr uintptr, data unsafe.Pointer) error { + return ptrace1Ptr(request, pid, addr, data) +} diff --git a/vendor/golang.org/x/sys/unix/ptrace_ios.go b/vendor/golang.org/x/sys/unix/ptrace_ios.go index ed0509a..9ea6633 100644 --- a/vendor/golang.org/x/sys/unix/ptrace_ios.go +++ b/vendor/golang.org/x/sys/unix/ptrace_ios.go @@ -7,6 +7,12 @@ package unix +import "unsafe" + func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { return ENOTSUP } + +func ptracePtr(request int, pid int, addr uintptr, data unsafe.Pointer) (err error) { + return ENOTSUP +} diff --git a/vendor/golang.org/x/sys/unix/syscall_aix.go b/vendor/golang.org/x/sys/unix/syscall_aix.go index 2db1b51..d9f5544 100644 --- a/vendor/golang.org/x/sys/unix/syscall_aix.go +++ b/vendor/golang.org/x/sys/unix/syscall_aix.go @@ -292,9 +292,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { break } } - - bytes := (*[len(pp.Path)]byte)(unsafe.Pointer(&pp.Path[0]))[0:n] - sa.Name = string(bytes) + sa.Name = string(unsafe.Slice((*byte)(unsafe.Pointer(&pp.Path[0])), n)) return sa, nil case AF_INET: @@ -411,6 +409,7 @@ func (w WaitStatus) CoreDump() bool { return w&0x80 == 0x80 } func (w WaitStatus) TrapCause() int { return -1 } //sys ioctl(fd int, req uint, arg uintptr) (err error) +//sys ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) = ioctl // fcntl must never be called with cmd=F_DUP2FD because it doesn't work on AIX // There is no way to create a custom fcntl and to keep //sys fcntl easily, diff --git a/vendor/golang.org/x/sys/unix/syscall_bsd.go b/vendor/golang.org/x/sys/unix/syscall_bsd.go index eda4267..7705c32 100644 --- a/vendor/golang.org/x/sys/unix/syscall_bsd.go +++ b/vendor/golang.org/x/sys/unix/syscall_bsd.go @@ -245,8 +245,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { break } } - bytes := (*[len(pp.Path)]byte)(unsafe.Pointer(&pp.Path[0]))[0:n] - sa.Name = string(bytes) + sa.Name = string(unsafe.Slice((*byte)(unsafe.Pointer(&pp.Path[0])), n)) return sa, nil case AF_INET: diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin.go b/vendor/golang.org/x/sys/unix/syscall_darwin.go index 192b071..7064d6e 100644 --- a/vendor/golang.org/x/sys/unix/syscall_darwin.go +++ b/vendor/golang.org/x/sys/unix/syscall_darwin.go @@ -14,7 +14,6 @@ package unix import ( "fmt" - "runtime" "syscall" "unsafe" ) @@ -376,11 +375,10 @@ func Flistxattr(fd int, dest []byte) (sz int, err error) { func Kill(pid int, signum syscall.Signal) (err error) { return kill(pid, int(signum), 1) } //sys ioctl(fd int, req uint, arg uintptr) (err error) +//sys ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) = SYS_IOCTL func IoctlCtlInfo(fd int, ctlInfo *CtlInfo) error { - err := ioctl(fd, CTLIOCGINFO, uintptr(unsafe.Pointer(ctlInfo))) - runtime.KeepAlive(ctlInfo) - return err + return ioctlPtr(fd, CTLIOCGINFO, unsafe.Pointer(ctlInfo)) } // IfreqMTU is struct ifreq used to get or set a network device's MTU. @@ -394,16 +392,14 @@ type IfreqMTU struct { func IoctlGetIfreqMTU(fd int, ifname string) (*IfreqMTU, error) { var ifreq IfreqMTU copy(ifreq.Name[:], ifname) - err := ioctl(fd, SIOCGIFMTU, uintptr(unsafe.Pointer(&ifreq))) + err := ioctlPtr(fd, SIOCGIFMTU, unsafe.Pointer(&ifreq)) return &ifreq, err } // IoctlSetIfreqMTU performs the SIOCSIFMTU ioctl operation on fd to set the MTU // of the network device specified by ifreq.Name. func IoctlSetIfreqMTU(fd int, ifreq *IfreqMTU) error { - err := ioctl(fd, SIOCSIFMTU, uintptr(unsafe.Pointer(ifreq))) - runtime.KeepAlive(ifreq) - return err + return ioctlPtr(fd, SIOCSIFMTU, unsafe.Pointer(ifreq)) } //sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS_SYSCTL diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go b/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go index b37310c..9fa8798 100644 --- a/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go @@ -47,5 +47,6 @@ func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, //sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT64 //sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64 //sys ptrace1(request int, pid int, addr uintptr, data uintptr) (err error) = SYS_ptrace +//sys ptrace1Ptr(request int, pid int, addr unsafe.Pointer, data uintptr) (err error) = SYS_ptrace //sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64 //sys Statfs(path string, stat *Statfs_t) (err error) = SYS_STATFS64 diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go b/vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go index d51ec99..f17b8c5 100644 --- a/vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go @@ -47,5 +47,6 @@ func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, //sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT //sys Lstat(path string, stat *Stat_t) (err error) //sys ptrace1(request int, pid int, addr uintptr, data uintptr) (err error) = SYS_ptrace +//sys ptrace1Ptr(request int, pid int, addr unsafe.Pointer, data uintptr) (err error) = SYS_ptrace //sys Stat(path string, stat *Stat_t) (err error) //sys Statfs(path string, stat *Statfs_t) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_dragonfly.go b/vendor/golang.org/x/sys/unix/syscall_dragonfly.go index a41111a..221efc2 100644 --- a/vendor/golang.org/x/sys/unix/syscall_dragonfly.go +++ b/vendor/golang.org/x/sys/unix/syscall_dragonfly.go @@ -172,6 +172,7 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { } //sys ioctl(fd int, req uint, arg uintptr) (err error) +//sys ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) = SYS_IOCTL //sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd.go b/vendor/golang.org/x/sys/unix/syscall_freebsd.go index d50b9dc..5bdde03 100644 --- a/vendor/golang.org/x/sys/unix/syscall_freebsd.go +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd.go @@ -161,7 +161,8 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { return } -//sys ioctl(fd int, req uint, arg uintptr) (err error) +//sys ioctl(fd int, req uint, arg uintptr) (err error) = SYS_IOCTL +//sys ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) = SYS_IOCTL //sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL @@ -253,6 +254,7 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e } //sys ptrace(request int, pid int, addr uintptr, data int) (err error) +//sys ptracePtr(request int, pid int, addr unsafe.Pointer, data int) (err error) = SYS_PTRACE func PtraceAttach(pid int) (err error) { return ptrace(PT_ATTACH, pid, 0, 0) @@ -267,19 +269,36 @@ func PtraceDetach(pid int) (err error) { } func PtraceGetFpRegs(pid int, fpregsout *FpReg) (err error) { - return ptrace(PT_GETFPREGS, pid, uintptr(unsafe.Pointer(fpregsout)), 0) + return ptracePtr(PT_GETFPREGS, pid, unsafe.Pointer(fpregsout), 0) } func PtraceGetRegs(pid int, regsout *Reg) (err error) { - return ptrace(PT_GETREGS, pid, uintptr(unsafe.Pointer(regsout)), 0) + return ptracePtr(PT_GETREGS, pid, unsafe.Pointer(regsout), 0) +} + +func PtraceIO(req int, pid int, offs uintptr, out []byte, countin int) (count int, err error) { + ioDesc := PtraceIoDesc{ + Op: int32(req), + Offs: offs, + } + if countin > 0 { + _ = out[:countin] // check bounds + ioDesc.Addr = &out[0] + } else if out != nil { + ioDesc.Addr = (*byte)(unsafe.Pointer(&_zero)) + } + ioDesc.SetLen(countin) + + err = ptracePtr(PT_IO, pid, unsafe.Pointer(&ioDesc), 0) + return int(ioDesc.Len), err } func PtraceLwpEvents(pid int, enable int) (err error) { return ptrace(PT_LWP_EVENTS, pid, 0, enable) } -func PtraceLwpInfo(pid int, info uintptr) (err error) { - return ptrace(PT_LWPINFO, pid, info, int(unsafe.Sizeof(PtraceLwpInfoStruct{}))) +func PtraceLwpInfo(pid int, info *PtraceLwpInfoStruct) (err error) { + return ptracePtr(PT_LWPINFO, pid, unsafe.Pointer(info), int(unsafe.Sizeof(*info))) } func PtracePeekData(pid int, addr uintptr, out []byte) (count int, err error) { @@ -299,13 +318,25 @@ func PtracePokeText(pid int, addr uintptr, data []byte) (count int, err error) { } func PtraceSetRegs(pid int, regs *Reg) (err error) { - return ptrace(PT_SETREGS, pid, uintptr(unsafe.Pointer(regs)), 0) + return ptracePtr(PT_SETREGS, pid, unsafe.Pointer(regs), 0) } func PtraceSingleStep(pid int) (err error) { return ptrace(PT_STEP, pid, 1, 0) } +func Dup3(oldfd, newfd, flags int) error { + if oldfd == newfd || flags&^O_CLOEXEC != 0 { + return EINVAL + } + how := F_DUP2FD + if flags&O_CLOEXEC != 0 { + how = F_DUP2FD_CLOEXEC + } + _, err := fcntl(oldfd, how, newfd) + return err +} + /* * Exposed directly */ diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd_386.go b/vendor/golang.org/x/sys/unix/syscall_freebsd_386.go index 6a91d47..b8da510 100644 --- a/vendor/golang.org/x/sys/unix/syscall_freebsd_386.go +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd_386.go @@ -42,6 +42,10 @@ func (cmsg *Cmsghdr) SetLen(length int) { cmsg.Len = uint32(length) } +func (d *PtraceIoDesc) SetLen(length int) { + d.Len = uint32(length) +} + func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { var writtenOut uint64 = 0 _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) @@ -57,16 +61,5 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) func PtraceGetFsBase(pid int, fsbase *int64) (err error) { - return ptrace(PT_GETFSBASE, pid, uintptr(unsafe.Pointer(fsbase)), 0) -} - -func PtraceIO(req int, pid int, offs uintptr, out []byte, countin int) (count int, err error) { - ioDesc := PtraceIoDesc{ - Op: int32(req), - Offs: offs, - Addr: uintptr(unsafe.Pointer(&out[0])), // TODO(#58351): this is not safe. - Len: uint32(countin), - } - err = ptrace(PT_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) - return int(ioDesc.Len), err + return ptracePtr(PT_GETFSBASE, pid, unsafe.Pointer(fsbase), 0) } diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go b/vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go index 48110a0..47155c4 100644 --- a/vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go @@ -42,6 +42,10 @@ func (cmsg *Cmsghdr) SetLen(length int) { cmsg.Len = uint32(length) } +func (d *PtraceIoDesc) SetLen(length int) { + d.Len = uint64(length) +} + func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { var writtenOut uint64 = 0 _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) @@ -57,16 +61,5 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) func PtraceGetFsBase(pid int, fsbase *int64) (err error) { - return ptrace(PT_GETFSBASE, pid, uintptr(unsafe.Pointer(fsbase)), 0) -} - -func PtraceIO(req int, pid int, offs uintptr, out []byte, countin int) (count int, err error) { - ioDesc := PtraceIoDesc{ - Op: int32(req), - Offs: offs, - Addr: uintptr(unsafe.Pointer(&out[0])), // TODO(#58351): this is not safe. - Len: uint64(countin), - } - err = ptrace(PT_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) - return int(ioDesc.Len), err + return ptracePtr(PT_GETFSBASE, pid, unsafe.Pointer(fsbase), 0) } diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go b/vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go index 52f1d4b..0893209 100644 --- a/vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go @@ -42,6 +42,10 @@ func (cmsg *Cmsghdr) SetLen(length int) { cmsg.Len = uint32(length) } +func (d *PtraceIoDesc) SetLen(length int) { + d.Len = uint32(length) +} + func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { var writtenOut uint64 = 0 _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) @@ -55,14 +59,3 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e } func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) - -func PtraceIO(req int, pid int, offs uintptr, out []byte, countin int) (count int, err error) { - ioDesc := PtraceIoDesc{ - Op: int32(req), - Offs: offs, - Addr: uintptr(unsafe.Pointer(&out[0])), // TODO(#58351): this is not safe. - Len: uint32(countin), - } - err = ptrace(PT_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) - return int(ioDesc.Len), err -} diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd_arm64.go b/vendor/golang.org/x/sys/unix/syscall_freebsd_arm64.go index 5537ee4..d151a0d 100644 --- a/vendor/golang.org/x/sys/unix/syscall_freebsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd_arm64.go @@ -42,6 +42,10 @@ func (cmsg *Cmsghdr) SetLen(length int) { cmsg.Len = uint32(length) } +func (d *PtraceIoDesc) SetLen(length int) { + d.Len = uint64(length) +} + func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { var writtenOut uint64 = 0 _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) @@ -55,14 +59,3 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e } func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) - -func PtraceIO(req int, pid int, offs uintptr, out []byte, countin int) (count int, err error) { - ioDesc := PtraceIoDesc{ - Op: int32(req), - Offs: offs, - Addr: uintptr(unsafe.Pointer(&out[0])), // TODO(#58351): this is not safe. - Len: uint64(countin), - } - err = ptrace(PT_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) - return int(ioDesc.Len), err -} diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd_riscv64.go b/vendor/golang.org/x/sys/unix/syscall_freebsd_riscv64.go index 164abd5..d5cd64b 100644 --- a/vendor/golang.org/x/sys/unix/syscall_freebsd_riscv64.go +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd_riscv64.go @@ -42,6 +42,10 @@ func (cmsg *Cmsghdr) SetLen(length int) { cmsg.Len = uint32(length) } +func (d *PtraceIoDesc) SetLen(length int) { + d.Len = uint64(length) +} + func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { var writtenOut uint64 = 0 _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) @@ -55,14 +59,3 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e } func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) - -func PtraceIO(req int, pid int, offs uintptr, out []byte, countin int) (count int, err error) { - ioDesc := PtraceIoDesc{ - Op: int32(req), - Offs: offs, - Addr: uintptr(unsafe.Pointer(&out[0])), // TODO(#58351): this is not safe. - Len: uint64(countin), - } - err = ptrace(PT_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) - return int(ioDesc.Len), err -} diff --git a/vendor/golang.org/x/sys/unix/syscall_hurd.go b/vendor/golang.org/x/sys/unix/syscall_hurd.go index 4ffb648..381fd46 100644 --- a/vendor/golang.org/x/sys/unix/syscall_hurd.go +++ b/vendor/golang.org/x/sys/unix/syscall_hurd.go @@ -20,3 +20,11 @@ func ioctl(fd int, req uint, arg uintptr) (err error) { } return } + +func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { + r0, er := C.ioctl(C.int(fd), C.ulong(req), C.uintptr_t(uintptr(arg))) + if r0 == -1 && er != nil { + err = er + } + return +} diff --git a/vendor/golang.org/x/sys/unix/syscall_linux.go b/vendor/golang.org/x/sys/unix/syscall_linux.go index 5443ddd..9735331 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux.go @@ -1015,8 +1015,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { for n < len(pp.Path) && pp.Path[n] != 0 { n++ } - bytes := (*[len(pp.Path)]byte)(unsafe.Pointer(&pp.Path[0]))[0:n] - sa.Name = string(bytes) + sa.Name = string(unsafe.Slice((*byte)(unsafe.Pointer(&pp.Path[0])), n)) return sa, nil case AF_INET: @@ -1365,6 +1364,10 @@ func SetsockoptTCPRepairOpt(fd, level, opt int, o []TCPRepairOpt) (err error) { return setsockopt(fd, level, opt, unsafe.Pointer(&o[0]), uintptr(SizeofTCPRepairOpt*len(o))) } +func SetsockoptTCPMD5Sig(fd, level, opt int, s *TCPMD5Sig) error { + return setsockopt(fd, level, opt, unsafe.Pointer(s), unsafe.Sizeof(*s)) +} + // Keyctl Commands (http://man7.org/linux/man-pages/man2/keyctl.2.html) // KeyctlInt calls keyctl commands in which each argument is an int. @@ -1579,6 +1582,7 @@ func BindToDevice(fd int, device string) (err error) { } //sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error) +//sys ptracePtr(request int, pid int, addr uintptr, data unsafe.Pointer) (err error) = SYS_PTRACE func ptracePeek(req int, pid int, addr uintptr, out []byte) (count int, err error) { // The peek requests are machine-size oriented, so we wrap it @@ -1596,7 +1600,7 @@ func ptracePeek(req int, pid int, addr uintptr, out []byte) (count int, err erro // boundary. n := 0 if addr%SizeofPtr != 0 { - err = ptrace(req, pid, addr-addr%SizeofPtr, uintptr(unsafe.Pointer(&buf[0]))) + err = ptracePtr(req, pid, addr-addr%SizeofPtr, unsafe.Pointer(&buf[0])) if err != nil { return 0, err } @@ -1608,7 +1612,7 @@ func ptracePeek(req int, pid int, addr uintptr, out []byte) (count int, err erro for len(out) > 0 { // We use an internal buffer to guarantee alignment. // It's not documented if this is necessary, but we're paranoid. - err = ptrace(req, pid, addr+uintptr(n), uintptr(unsafe.Pointer(&buf[0]))) + err = ptracePtr(req, pid, addr+uintptr(n), unsafe.Pointer(&buf[0])) if err != nil { return n, err } @@ -1640,7 +1644,7 @@ func ptracePoke(pokeReq int, peekReq int, pid int, addr uintptr, data []byte) (c n := 0 if addr%SizeofPtr != 0 { var buf [SizeofPtr]byte - err = ptrace(peekReq, pid, addr-addr%SizeofPtr, uintptr(unsafe.Pointer(&buf[0]))) + err = ptracePtr(peekReq, pid, addr-addr%SizeofPtr, unsafe.Pointer(&buf[0])) if err != nil { return 0, err } @@ -1667,7 +1671,7 @@ func ptracePoke(pokeReq int, peekReq int, pid int, addr uintptr, data []byte) (c // Trailing edge. if len(data) > 0 { var buf [SizeofPtr]byte - err = ptrace(peekReq, pid, addr+uintptr(n), uintptr(unsafe.Pointer(&buf[0]))) + err = ptracePtr(peekReq, pid, addr+uintptr(n), unsafe.Pointer(&buf[0])) if err != nil { return n, err } @@ -1696,11 +1700,11 @@ func PtracePokeUser(pid int, addr uintptr, data []byte) (count int, err error) { } func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error) { - return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) + return ptracePtr(PTRACE_GETREGS, pid, 0, unsafe.Pointer(regsout)) } func PtraceSetRegs(pid int, regs *PtraceRegs) (err error) { - return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) + return ptracePtr(PTRACE_SETREGS, pid, 0, unsafe.Pointer(regs)) } func PtraceSetOptions(pid int, options int) (err error) { @@ -1709,7 +1713,7 @@ func PtraceSetOptions(pid int, options int) (err error) { func PtraceGetEventMsg(pid int) (msg uint, err error) { var data _C_long - err = ptrace(PTRACE_GETEVENTMSG, pid, 0, uintptr(unsafe.Pointer(&data))) + err = ptracePtr(PTRACE_GETEVENTMSG, pid, 0, unsafe.Pointer(&data)) msg = uint(data) return } @@ -2154,6 +2158,14 @@ func isGroupMember(gid int) bool { return false } +func isCapDacOverrideSet() bool { + hdr := CapUserHeader{Version: LINUX_CAPABILITY_VERSION_3} + data := [2]CapUserData{} + err := Capget(&hdr, &data[0]) + + return err == nil && data[0].Effective&(1< 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go index 77479d4..1129065 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go @@ -388,6 +388,16 @@ func ioctl(fd int, req uint, arg uintptr) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { + _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { var _p0 unsafe.Pointer if len(mib) > 0 { @@ -414,6 +424,16 @@ func ptrace(request int, pid int, addr uintptr, data int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ptracePtr(request int, pid int, addr unsafe.Pointer, data int) (err error) { + _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Access(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go index 2e966d4..55f5abf 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go @@ -388,6 +388,16 @@ func ioctl(fd int, req uint, arg uintptr) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { + _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { var _p0 unsafe.Pointer if len(mib) > 0 { @@ -414,6 +424,16 @@ func ptrace(request int, pid int, addr uintptr, data int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ptracePtr(request int, pid int, addr unsafe.Pointer, data int) (err error) { + _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Access(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go index d65a7c0..d39651c 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go @@ -388,6 +388,16 @@ func ioctl(fd int, req uint, arg uintptr) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { + _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { var _p0 unsafe.Pointer if len(mib) > 0 { @@ -414,6 +424,16 @@ func ptrace(request int, pid int, addr uintptr, data int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ptracePtr(request int, pid int, addr unsafe.Pointer, data int) (err error) { + _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Access(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm64.go index 6f0b97c..ddb7408 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm64.go @@ -388,6 +388,16 @@ func ioctl(fd int, req uint, arg uintptr) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { + _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { var _p0 unsafe.Pointer if len(mib) > 0 { @@ -414,6 +424,16 @@ func ptrace(request int, pid int, addr uintptr, data int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ptracePtr(request int, pid int, addr unsafe.Pointer, data int) (err error) { + _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Access(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_riscv64.go b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_riscv64.go index e1c23b5..09a53a6 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_riscv64.go @@ -388,6 +388,16 @@ func ioctl(fd int, req uint, arg uintptr) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { + _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { var _p0 unsafe.Pointer if len(mib) > 0 { @@ -414,6 +424,16 @@ func ptrace(request int, pid int, addr uintptr, data int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ptracePtr(request int, pid int, addr unsafe.Pointer, data int) (err error) { + _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Access(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux.go b/vendor/golang.org/x/sys/unix/zsyscall_linux.go index 36ea3a5..430cb24 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux.go @@ -379,6 +379,16 @@ func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ptracePtr(request int, pid int, addr uintptr, data unsafe.Pointer) (err error) { + _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func reboot(magic1 uint, magic2 uint, cmd int, arg string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(arg) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go index 79f7389..8e1d9c8 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go @@ -405,6 +405,16 @@ func ioctl(fd int, req uint, arg uintptr) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { + _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { var _p0 unsafe.Pointer if len(mib) > 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go index fb161f3..21c6950 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go @@ -405,6 +405,16 @@ func ioctl(fd int, req uint, arg uintptr) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { + _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { var _p0 unsafe.Pointer if len(mib) > 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go index 4c8ac99..298168f 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go @@ -405,6 +405,16 @@ func ioctl(fd int, req uint, arg uintptr) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { + _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { var _p0 unsafe.Pointer if len(mib) > 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm64.go index 76dd8ec..68b8bd4 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm64.go @@ -405,6 +405,16 @@ func ioctl(fd int, req uint, arg uintptr) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { + _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { var _p0 unsafe.Pointer if len(mib) > 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go index caeb807..0b0f910 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go @@ -527,6 +527,14 @@ func ioctl(fd int, req uint, arg uintptr) (err error) { return } +func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { + _, _, e1 := syscall_syscall(libc_ioctl_trampoline_addr, uintptr(fd), uintptr(req), uintptr(arg)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + var libc_ioctl_trampoline_addr uintptr //go:cgo_import_dynamic libc_ioctl ioctl "libc.so" diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go index a05e5f4..48ff5de 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go @@ -527,6 +527,14 @@ func ioctl(fd int, req uint, arg uintptr) (err error) { return } +func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { + _, _, e1 := syscall_syscall(libc_ioctl_trampoline_addr, uintptr(fd), uintptr(req), uintptr(arg)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + var libc_ioctl_trampoline_addr uintptr //go:cgo_import_dynamic libc_ioctl ioctl "libc.so" diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go index b2da8e5..2452a64 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go @@ -527,6 +527,14 @@ func ioctl(fd int, req uint, arg uintptr) (err error) { return } +func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { + _, _, e1 := syscall_syscall(libc_ioctl_trampoline_addr, uintptr(fd), uintptr(req), uintptr(arg)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + var libc_ioctl_trampoline_addr uintptr //go:cgo_import_dynamic libc_ioctl ioctl "libc.so" diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go index 048b265..5e35600 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go @@ -527,6 +527,14 @@ func ioctl(fd int, req uint, arg uintptr) (err error) { return } +func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { + _, _, e1 := syscall_syscall(libc_ioctl_trampoline_addr, uintptr(fd), uintptr(req), uintptr(arg)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + var libc_ioctl_trampoline_addr uintptr //go:cgo_import_dynamic libc_ioctl ioctl "libc.so" diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go index 6f33e37..b04cef1 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go @@ -527,6 +527,14 @@ func ioctl(fd int, req uint, arg uintptr) (err error) { return } +func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { + _, _, e1 := syscall_syscall(libc_ioctl_trampoline_addr, uintptr(fd), uintptr(req), uintptr(arg)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + var libc_ioctl_trampoline_addr uintptr //go:cgo_import_dynamic libc_ioctl ioctl "libc.so" diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go index 330cf7f..47a07ee 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go @@ -527,6 +527,14 @@ func ioctl(fd int, req uint, arg uintptr) (err error) { return } +func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { + _, _, e1 := syscall_syscall(libc_ioctl_trampoline_addr, uintptr(fd), uintptr(req), uintptr(arg)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + var libc_ioctl_trampoline_addr uintptr //go:cgo_import_dynamic libc_ioctl ioctl "libc.so" diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go index 5f24de0..573378f 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go @@ -527,6 +527,14 @@ func ioctl(fd int, req uint, arg uintptr) (err error) { return } +func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { + _, _, e1 := syscall_syscall(libc_ioctl_trampoline_addr, uintptr(fd), uintptr(req), uintptr(arg)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + var libc_ioctl_trampoline_addr uintptr //go:cgo_import_dynamic libc_ioctl ioctl "libc.so" diff --git a/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go index 78d4a42..4873a1e 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go @@ -657,6 +657,17 @@ func ioctlRet(fd int, req uint, arg uintptr) (ret int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ioctlPtrRet(fd int, req uint, arg unsafe.Pointer) (ret int, err error) { + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procioctl)), 3, uintptr(fd), uintptr(req), uintptr(arg), 0, 0, 0) + ret = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procpoll)), 3, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout), 0, 0, 0) n = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_zos_s390x.go b/vendor/golang.org/x/sys/unix/zsyscall_zos_s390x.go index f207945..07bfe2e 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_zos_s390x.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_zos_s390x.go @@ -267,6 +267,16 @@ func ioctl(fd int, req uint, arg uintptr) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { + _, _, e1 := syscall_syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Access(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go index d9c78cd..29dc483 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go @@ -362,7 +362,7 @@ type FpExtendedPrecision struct{} type PtraceIoDesc struct { Op int32 Offs uintptr - Addr uintptr + Addr *byte Len uint32 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go index 26991b1..0a89b28 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go @@ -367,7 +367,7 @@ type FpExtendedPrecision struct{} type PtraceIoDesc struct { Op int32 Offs uintptr - Addr uintptr + Addr *byte Len uint64 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go index f8324e7..c8666bb 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go @@ -350,7 +350,7 @@ type FpExtendedPrecision struct { type PtraceIoDesc struct { Op int32 Offs uintptr - Addr uintptr + Addr *byte Len uint32 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go index 4220411..88fb48a 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go @@ -347,7 +347,7 @@ type FpExtendedPrecision struct{} type PtraceIoDesc struct { Op int32 Offs uintptr - Addr uintptr + Addr *byte Len uint64 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_riscv64.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_riscv64.go index 0660fd4..698dc97 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_riscv64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_riscv64.go @@ -348,7 +348,7 @@ type FpExtendedPrecision struct{} type PtraceIoDesc struct { Op int32 Offs uintptr - Addr uintptr + Addr *byte Len uint64 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux.go b/vendor/golang.org/x/sys/unix/ztypes_linux.go index 7d9fc8f..ca84727 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux.go @@ -456,36 +456,60 @@ type Ucred struct { } type TCPInfo struct { - State uint8 - Ca_state uint8 - Retransmits uint8 - Probes uint8 - Backoff uint8 - Options uint8 - Rto uint32 - Ato uint32 - Snd_mss uint32 - Rcv_mss uint32 - Unacked uint32 - Sacked uint32 - Lost uint32 - Retrans uint32 - Fackets uint32 - Last_data_sent uint32 - Last_ack_sent uint32 - Last_data_recv uint32 - Last_ack_recv uint32 - Pmtu uint32 - Rcv_ssthresh uint32 - Rtt uint32 - Rttvar uint32 - Snd_ssthresh uint32 - Snd_cwnd uint32 - Advmss uint32 - Reordering uint32 - Rcv_rtt uint32 - Rcv_space uint32 - Total_retrans uint32 + State uint8 + Ca_state uint8 + Retransmits uint8 + Probes uint8 + Backoff uint8 + Options uint8 + Rto uint32 + Ato uint32 + Snd_mss uint32 + Rcv_mss uint32 + Unacked uint32 + Sacked uint32 + Lost uint32 + Retrans uint32 + Fackets uint32 + Last_data_sent uint32 + Last_ack_sent uint32 + Last_data_recv uint32 + Last_ack_recv uint32 + Pmtu uint32 + Rcv_ssthresh uint32 + Rtt uint32 + Rttvar uint32 + Snd_ssthresh uint32 + Snd_cwnd uint32 + Advmss uint32 + Reordering uint32 + Rcv_rtt uint32 + Rcv_space uint32 + Total_retrans uint32 + Pacing_rate uint64 + Max_pacing_rate uint64 + Bytes_acked uint64 + Bytes_received uint64 + Segs_out uint32 + Segs_in uint32 + Notsent_bytes uint32 + Min_rtt uint32 + Data_segs_in uint32 + Data_segs_out uint32 + Delivery_rate uint64 + Busy_time uint64 + Rwnd_limited uint64 + Sndbuf_limited uint64 + Delivered uint32 + Delivered_ce uint32 + Bytes_sent uint64 + Bytes_retrans uint64 + Dsack_dups uint32 + Reord_seen uint32 + Rcv_ooopack uint32 + Snd_wnd uint32 + Rcv_wnd uint32 + Rehash uint32 } type CanFilter struct { @@ -528,7 +552,7 @@ const ( SizeofIPv6MTUInfo = 0x20 SizeofICMPv6Filter = 0x20 SizeofUcred = 0xc - SizeofTCPInfo = 0x68 + SizeofTCPInfo = 0xf0 SizeofCanFilter = 0x8 SizeofTCPRepairOpt = 0x8 ) @@ -1043,6 +1067,7 @@ const ( PerfBitCommExec = CBitFieldMaskBit24 PerfBitUseClockID = CBitFieldMaskBit25 PerfBitContextSwitch = CBitFieldMaskBit26 + PerfBitWriteBackward = CBitFieldMaskBit27 ) const ( @@ -1239,7 +1264,7 @@ type TCPMD5Sig struct { Flags uint8 Prefixlen uint8 Keylen uint16 - _ uint32 + Ifindex int32 Key [80]uint8 } @@ -1939,7 +1964,11 @@ const ( NFT_MSG_GETOBJ = 0x13 NFT_MSG_DELOBJ = 0x14 NFT_MSG_GETOBJ_RESET = 0x15 - NFT_MSG_MAX = 0x19 + NFT_MSG_NEWFLOWTABLE = 0x16 + NFT_MSG_GETFLOWTABLE = 0x17 + NFT_MSG_DELFLOWTABLE = 0x18 + NFT_MSG_GETRULE_RESET = 0x19 + NFT_MSG_MAX = 0x1a NFTA_LIST_UNSPEC = 0x0 NFTA_LIST_ELEM = 0x1 NFTA_HOOK_UNSPEC = 0x0 @@ -2443,9 +2472,11 @@ const ( SOF_TIMESTAMPING_OPT_STATS = 0x1000 SOF_TIMESTAMPING_OPT_PKTINFO = 0x2000 SOF_TIMESTAMPING_OPT_TX_SWHW = 0x4000 + SOF_TIMESTAMPING_BIND_PHC = 0x8000 + SOF_TIMESTAMPING_OPT_ID_TCP = 0x10000 - SOF_TIMESTAMPING_LAST = 0x8000 - SOF_TIMESTAMPING_MASK = 0xffff + SOF_TIMESTAMPING_LAST = 0x10000 + SOF_TIMESTAMPING_MASK = 0x1ffff SCM_TSTAMP_SND = 0x0 SCM_TSTAMP_SCHED = 0x1 @@ -3265,7 +3296,7 @@ const ( DEVLINK_ATTR_LINECARD_SUPPORTED_TYPES = 0xae DEVLINK_ATTR_NESTED_DEVLINK = 0xaf DEVLINK_ATTR_SELFTESTS = 0xb0 - DEVLINK_ATTR_MAX = 0xb0 + DEVLINK_ATTR_MAX = 0xb3 DEVLINK_DPIPE_FIELD_MAPPING_TYPE_NONE = 0x0 DEVLINK_DPIPE_FIELD_MAPPING_TYPE_IFINDEX = 0x1 DEVLINK_DPIPE_MATCH_TYPE_FIELD_EXACT = 0x0 @@ -3281,7 +3312,8 @@ const ( DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR = 0x1 DEVLINK_PORT_FN_ATTR_STATE = 0x2 DEVLINK_PORT_FN_ATTR_OPSTATE = 0x3 - DEVLINK_PORT_FUNCTION_ATTR_MAX = 0x3 + DEVLINK_PORT_FN_ATTR_CAPS = 0x4 + DEVLINK_PORT_FUNCTION_ATTR_MAX = 0x4 ) type FsverityDigest struct { @@ -3572,7 +3604,8 @@ const ( ETHTOOL_MSG_MODULE_SET = 0x23 ETHTOOL_MSG_PSE_GET = 0x24 ETHTOOL_MSG_PSE_SET = 0x25 - ETHTOOL_MSG_USER_MAX = 0x25 + ETHTOOL_MSG_RSS_GET = 0x26 + ETHTOOL_MSG_USER_MAX = 0x26 ETHTOOL_MSG_KERNEL_NONE = 0x0 ETHTOOL_MSG_STRSET_GET_REPLY = 0x1 ETHTOOL_MSG_LINKINFO_GET_REPLY = 0x2 @@ -3611,7 +3644,8 @@ const ( ETHTOOL_MSG_MODULE_GET_REPLY = 0x23 ETHTOOL_MSG_MODULE_NTF = 0x24 ETHTOOL_MSG_PSE_GET_REPLY = 0x25 - ETHTOOL_MSG_KERNEL_MAX = 0x25 + ETHTOOL_MSG_RSS_GET_REPLY = 0x26 + ETHTOOL_MSG_KERNEL_MAX = 0x26 ETHTOOL_A_HEADER_UNSPEC = 0x0 ETHTOOL_A_HEADER_DEV_INDEX = 0x1 ETHTOOL_A_HEADER_DEV_NAME = 0x2 @@ -3679,7 +3713,8 @@ const ( ETHTOOL_A_LINKSTATE_SQI_MAX = 0x4 ETHTOOL_A_LINKSTATE_EXT_STATE = 0x5 ETHTOOL_A_LINKSTATE_EXT_SUBSTATE = 0x6 - ETHTOOL_A_LINKSTATE_MAX = 0x6 + ETHTOOL_A_LINKSTATE_EXT_DOWN_CNT = 0x7 + ETHTOOL_A_LINKSTATE_MAX = 0x7 ETHTOOL_A_DEBUG_UNSPEC = 0x0 ETHTOOL_A_DEBUG_HEADER = 0x1 ETHTOOL_A_DEBUG_MSGMASK = 0x2 @@ -4409,7 +4444,7 @@ const ( NL80211_ATTR_MAC_HINT = 0xc8 NL80211_ATTR_MAC_MASK = 0xd7 NL80211_ATTR_MAX_AP_ASSOC_STA = 0xca - NL80211_ATTR_MAX = 0x140 + NL80211_ATTR_MAX = 0x141 NL80211_ATTR_MAX_CRIT_PROT_DURATION = 0xb4 NL80211_ATTR_MAX_CSA_COUNTERS = 0xce NL80211_ATTR_MAX_MATCH_SETS = 0x85 @@ -4552,6 +4587,7 @@ const ( NL80211_ATTR_SUPPORT_MESH_AUTH = 0x73 NL80211_ATTR_SURVEY_INFO = 0x54 NL80211_ATTR_SURVEY_RADIO_STATS = 0xda + NL80211_ATTR_TD_BITMAP = 0x141 NL80211_ATTR_TDLS_ACTION = 0x88 NL80211_ATTR_TDLS_DIALOG_TOKEN = 0x89 NL80211_ATTR_TDLS_EXTERNAL_SETUP = 0x8c @@ -5752,3 +5788,25 @@ const ( AUDIT_NLGRP_NONE = 0x0 AUDIT_NLGRP_READLOG = 0x1 ) + +const ( + TUN_F_CSUM = 0x1 + TUN_F_TSO4 = 0x2 + TUN_F_TSO6 = 0x4 + TUN_F_TSO_ECN = 0x8 + TUN_F_UFO = 0x10 +) + +const ( + VIRTIO_NET_HDR_F_NEEDS_CSUM = 0x1 + VIRTIO_NET_HDR_F_DATA_VALID = 0x2 + VIRTIO_NET_HDR_F_RSC_INFO = 0x4 +) + +const ( + VIRTIO_NET_HDR_GSO_NONE = 0x0 + VIRTIO_NET_HDR_GSO_TCPV4 = 0x1 + VIRTIO_NET_HDR_GSO_UDP = 0x3 + VIRTIO_NET_HDR_GSO_TCPV6 = 0x4 + VIRTIO_NET_HDR_GSO_ECN = 0x80 +) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_386.go b/vendor/golang.org/x/sys/unix/ztypes_linux_386.go index 89c516a..4ecc149 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_386.go @@ -414,7 +414,7 @@ const ( type SockaddrStorage struct { Family uint16 - _ [122]int8 + Data [122]byte _ uint32 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go index 62b4fb2..34fddff 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go @@ -427,7 +427,7 @@ const ( type SockaddrStorage struct { Family uint16 - _ [118]int8 + Data [118]byte _ uint64 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go b/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go index e86b358..3b14a60 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go @@ -405,7 +405,7 @@ const ( type SockaddrStorage struct { Family uint16 - _ [122]uint8 + Data [122]byte _ uint32 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go index 6c6be4c..0517651 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go @@ -406,7 +406,7 @@ const ( type SockaddrStorage struct { Family uint16 - _ [118]int8 + Data [118]byte _ uint64 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_loong64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_loong64.go index 4982ea3..3b0c518 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_loong64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_loong64.go @@ -407,7 +407,7 @@ const ( type SockaddrStorage struct { Family uint16 - _ [118]int8 + Data [118]byte _ uint64 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go index 173141a..fccdf4d 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go @@ -410,7 +410,7 @@ const ( type SockaddrStorage struct { Family uint16 - _ [122]int8 + Data [122]byte _ uint32 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go index 93ae4c5..500de8f 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go @@ -409,7 +409,7 @@ const ( type SockaddrStorage struct { Family uint16 - _ [118]int8 + Data [118]byte _ uint64 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go index 4e4e510..d0434cd 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go @@ -409,7 +409,7 @@ const ( type SockaddrStorage struct { Family uint16 - _ [118]int8 + Data [118]byte _ uint64 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go index 3f5ba01..84206ba 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go @@ -410,7 +410,7 @@ const ( type SockaddrStorage struct { Family uint16 - _ [122]int8 + Data [122]byte _ uint32 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc.go b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc.go index 71dfe7c..ab078cf 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc.go @@ -417,7 +417,7 @@ const ( type SockaddrStorage struct { Family uint16 - _ [122]uint8 + Data [122]byte _ uint32 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go index 3a2b7f0..42eb2c4 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go @@ -416,7 +416,7 @@ const ( type SockaddrStorage struct { Family uint16 - _ [118]uint8 + Data [118]byte _ uint64 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go index a52d627..31304a4 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go @@ -416,7 +416,7 @@ const ( type SockaddrStorage struct { Family uint16 - _ [118]uint8 + Data [118]byte _ uint64 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go index dfc007d..c311f96 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go @@ -434,7 +434,7 @@ const ( type SockaddrStorage struct { Family uint16 - _ [118]uint8 + Data [118]byte _ uint64 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go b/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go index b53cb91..bba3cef 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go @@ -429,7 +429,7 @@ const ( type SockaddrStorage struct { Family uint16 - _ [118]int8 + Data [118]byte _ uint64 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go index fe0aa35..ad8a013 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go @@ -411,7 +411,7 @@ const ( type SockaddrStorage struct { Family uint16 - _ [118]int8 + Data [118]byte _ uint64 } diff --git a/vendor/golang.org/x/text/unicode/norm/forminfo.go b/vendor/golang.org/x/text/unicode/norm/forminfo.go index d69ccb4..487335d 100644 --- a/vendor/golang.org/x/text/unicode/norm/forminfo.go +++ b/vendor/golang.org/x/text/unicode/norm/forminfo.go @@ -13,7 +13,7 @@ import "encoding/binary" // a rune to a uint16. The values take two forms. For v >= 0x8000: // bits // 15: 1 (inverse of NFD_QC bit of qcInfo) -// 13..7: qcInfo (see below). isYesD is always true (no decompostion). +// 13..7: qcInfo (see below). isYesD is always true (no decomposition). // 6..0: ccc (compressed CCC value). // For v < 0x8000, the respective rune has a decomposition and v is an index // into a byte array of UTF-8 decomposition sequences and additional info and diff --git a/vendor/modules.txt b/vendor/modules.txt index 07235e1..65b3d0f 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -9,6 +9,8 @@ github.com/goccy/go-json/internal/encoder/vm_color_indent github.com/goccy/go-json/internal/encoder/vm_indent github.com/goccy/go-json/internal/errors github.com/goccy/go-json/internal/runtime +# github.com/golang-jwt/jwt v3.2.2+incompatible +## explicit # github.com/golang/snappy v0.0.4 ## explicit github.com/golang/snappy @@ -17,7 +19,7 @@ github.com/golang/snappy # github.com/json-iterator/go v1.1.12 ## explicit; go 1.12 github.com/json-iterator/go -# github.com/labstack/echo/v4 v4.10.0 +# github.com/labstack/echo/v4 v4.10.2 ## explicit; go 1.17 github.com/labstack/echo/v4 # github.com/labstack/gommon v0.4.0 @@ -65,26 +67,29 @@ github.com/valyala/bytebufferpool # github.com/valyala/fasttemplate v1.2.2 ## explicit; go 1.12 github.com/valyala/fasttemplate -# golang.org/x/crypto v0.6.0 +# golang.org/x/crypto v0.7.0 ## explicit; go 1.17 golang.org/x/crypto/acme golang.org/x/crypto/acme/autocert -# golang.org/x/net v0.7.0 +# golang.org/x/net v0.8.0 ## explicit; go 1.17 golang.org/x/net/http/httpguts golang.org/x/net/http2 golang.org/x/net/http2/h2c golang.org/x/net/http2/hpack golang.org/x/net/idna -# golang.org/x/sys v0.5.0 +golang.org/x/net/websocket +# golang.org/x/sys v0.6.0 ## explicit; go 1.17 golang.org/x/sys/unix -# golang.org/x/text v0.7.0 +# golang.org/x/text v0.8.0 ## explicit; go 1.17 golang.org/x/text/secure/bidirule golang.org/x/text/transform golang.org/x/text/unicode/bidi golang.org/x/text/unicode/norm +# golang.org/x/time v0.3.0 +## explicit # gopkg.in/ini.v1 v1.67.0 ## explicit gopkg.in/ini.v1 From 98f07aaff882c09be4ad792aff2408aa5c1f51ce Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Sun, 5 Mar 2023 22:32:40 +0100 Subject: [PATCH 02/23] updated dependencies --- go.mod | 4 +--- go.sum | 25 +------------------------ vendor/modules.txt | 4 ---- 3 files changed, 2 insertions(+), 31 deletions(-) diff --git a/go.mod b/go.mod index f0b3d7c..9f8fd1a 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module git.paulbsd.com/paulbsd/ipbl -go 1.19 +go 1.20 require ( github.com/labstack/echo/v4 v4.10.2 @@ -13,7 +13,6 @@ require ( require ( github.com/goccy/go-json v0.10.0 // indirect - github.com/golang-jwt/jwt v3.2.2+incompatible // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/json-iterator/go v1.1.12 // indirect @@ -30,6 +29,5 @@ require ( golang.org/x/crypto v0.7.0 // indirect golang.org/x/sys v0.6.0 // indirect golang.org/x/text v0.8.0 // indirect - golang.org/x/time v0.3.0 // indirect xorm.io/builder v0.3.12 // indirect ) diff --git a/go.sum b/go.sum index c869924..8211151 100644 --- a/go.sum +++ b/go.sum @@ -84,8 +84,6 @@ github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFG github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= -github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= -github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -217,8 +215,6 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/labstack/echo/v4 v4.10.0 h1:5CiyngihEO4HXsz3vVsJn7f8xAlWwRr3aY6Ih280ZKA= -github.com/labstack/echo/v4 v4.10.0/go.mod h1:S/T/5fy/GigaXnHTkh0ZGe4LpkkQysvRjFMSUTkDRNQ= github.com/labstack/echo/v4 v4.10.2 h1:n1jAhnq/elIFTHr1EYpiYtyKgx4RW9ccVgkqByZaN2M= github.com/labstack/echo/v4 v4.10.2/go.mod h1:OEyqf2//K1DFdE57vw2DRgWY0M7s65IVQO2FzvI4J5k= github.com/labstack/gommon v0.4.0 h1:y7cvthEAEbU0yHOf4axH8ZG2NH8knB9iNSoTO8dyIk8= @@ -414,10 +410,6 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE= -golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= -golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= -golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -429,7 +421,6 @@ golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s= golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -450,10 +441,6 @@ golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw= -golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= -golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -501,10 +488,6 @@ golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18= -golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= @@ -514,16 +497,10 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k= -golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= -golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -542,7 +519,7 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU= +golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/vendor/modules.txt b/vendor/modules.txt index 65b3d0f..fe51e9e 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -9,8 +9,6 @@ github.com/goccy/go-json/internal/encoder/vm_color_indent github.com/goccy/go-json/internal/encoder/vm_indent github.com/goccy/go-json/internal/errors github.com/goccy/go-json/internal/runtime -# github.com/golang-jwt/jwt v3.2.2+incompatible -## explicit # github.com/golang/snappy v0.0.4 ## explicit github.com/golang/snappy @@ -88,8 +86,6 @@ golang.org/x/text/secure/bidirule golang.org/x/text/transform golang.org/x/text/unicode/bidi golang.org/x/text/unicode/norm -# golang.org/x/time v0.3.0 -## explicit # gopkg.in/ini.v1 v1.67.0 ## explicit gopkg.in/ini.v1 From bb76849f3330a17e34d893bd34d0c6f21d736869 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Sun, 5 Mar 2023 22:37:17 +0100 Subject: [PATCH 03/23] remove zmq from project --- .gitignore | 1 + cmd/ipbl/ipbl.go | 3 +- go.mod | 1 - go.sum | 2 - src/config/main.go | 8 +- src/models/models.go | 1 - src/zmqrouter/main.go | 110 --- src/zmqrouter/pubsub.go | 14 - src/zmqrouter/reqrep.go | 14 - vendor/gopkg.in/zeromq/goczmq.v4/.gitignore | 23 - vendor/gopkg.in/zeromq/goczmq.v4/.travis.yml | 17 - vendor/gopkg.in/zeromq/goczmq.v4/AUTHORS | 15 - .../gopkg.in/zeromq/goczmq.v4/CONTRIBUTING.md | 22 - vendor/gopkg.in/zeromq/goczmq.v4/LICENSE | 362 --------- vendor/gopkg.in/zeromq/goczmq.v4/Makefile | 18 - vendor/gopkg.in/zeromq/goczmq.v4/README.md | 261 ------ vendor/gopkg.in/zeromq/goczmq.v4/auth.go | 140 ---- vendor/gopkg.in/zeromq/goczmq.v4/beacon.go | 162 ---- vendor/gopkg.in/zeromq/goczmq.v4/cert.go | 158 ---- vendor/gopkg.in/zeromq/goczmq.v4/certstore.go | 60 -- vendor/gopkg.in/zeromq/goczmq.v4/channeler.go | 309 ------- vendor/gopkg.in/zeromq/goczmq.v4/goczmq.go | 201 ----- vendor/gopkg.in/zeromq/goczmq.v4/license.xml | 22 - vendor/gopkg.in/zeromq/goczmq.v4/poller.go | 106 --- vendor/gopkg.in/zeromq/goczmq.v4/proxy.go | 171 ---- .../gopkg.in/zeromq/goczmq.v4/readwriter.go | 120 --- vendor/gopkg.in/zeromq/goczmq.v4/sock.go | 435 ---------- .../gopkg.in/zeromq/goczmq.v4/sock_draft.go | 30 - .../gopkg.in/zeromq/goczmq.v4/sock_option.go | 765 ------------------ .../gopkg.in/zeromq/goczmq.v4/sock_option.gsl | 84 -- .../zeromq/goczmq.v4/sock_option_test.gsl | 83 -- vendor/gopkg.in/zeromq/goczmq.v4/sockopts.gsl | 32 - vendor/gopkg.in/zeromq/goczmq.v4/sockopts.xml | 233 ------ vendor/modules.txt | 3 - 34 files changed, 6 insertions(+), 3980 deletions(-) delete mode 100644 src/zmqrouter/main.go delete mode 100644 src/zmqrouter/pubsub.go delete mode 100644 src/zmqrouter/reqrep.go delete mode 100644 vendor/gopkg.in/zeromq/goczmq.v4/.gitignore delete mode 100644 vendor/gopkg.in/zeromq/goczmq.v4/.travis.yml delete mode 100644 vendor/gopkg.in/zeromq/goczmq.v4/AUTHORS delete mode 100644 vendor/gopkg.in/zeromq/goczmq.v4/CONTRIBUTING.md delete mode 100644 vendor/gopkg.in/zeromq/goczmq.v4/LICENSE delete mode 100644 vendor/gopkg.in/zeromq/goczmq.v4/Makefile delete mode 100644 vendor/gopkg.in/zeromq/goczmq.v4/README.md delete mode 100644 vendor/gopkg.in/zeromq/goczmq.v4/auth.go delete mode 100644 vendor/gopkg.in/zeromq/goczmq.v4/beacon.go delete mode 100644 vendor/gopkg.in/zeromq/goczmq.v4/cert.go delete mode 100644 vendor/gopkg.in/zeromq/goczmq.v4/certstore.go delete mode 100644 vendor/gopkg.in/zeromq/goczmq.v4/channeler.go delete mode 100644 vendor/gopkg.in/zeromq/goczmq.v4/goczmq.go delete mode 100644 vendor/gopkg.in/zeromq/goczmq.v4/license.xml delete mode 100644 vendor/gopkg.in/zeromq/goczmq.v4/poller.go delete mode 100644 vendor/gopkg.in/zeromq/goczmq.v4/proxy.go delete mode 100644 vendor/gopkg.in/zeromq/goczmq.v4/readwriter.go delete mode 100644 vendor/gopkg.in/zeromq/goczmq.v4/sock.go delete mode 100644 vendor/gopkg.in/zeromq/goczmq.v4/sock_draft.go delete mode 100644 vendor/gopkg.in/zeromq/goczmq.v4/sock_option.go delete mode 100644 vendor/gopkg.in/zeromq/goczmq.v4/sock_option.gsl delete mode 100644 vendor/gopkg.in/zeromq/goczmq.v4/sock_option_test.gsl delete mode 100644 vendor/gopkg.in/zeromq/goczmq.v4/sockopts.gsl delete mode 100644 vendor/gopkg.in/zeromq/goczmq.v4/sockopts.xml diff --git a/.gitignore b/.gitignore index f0551fd..86e16f7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ *.ini *.swp /test +/old version.go \ No newline at end of file diff --git a/cmd/ipbl/ipbl.go b/cmd/ipbl/ipbl.go index 4747fbf..5d32e21 100644 --- a/cmd/ipbl/ipbl.go +++ b/cmd/ipbl/ipbl.go @@ -10,7 +10,6 @@ import ( "git.paulbsd.com/paulbsd/ipbl/src/database" "git.paulbsd.com/paulbsd/ipbl/src/models" "git.paulbsd.com/paulbsd/ipbl/src/routers" - "git.paulbsd.com/paulbsd/ipbl/src/zmqrouter" "git.paulbsd.com/paulbsd/ipbl/utils" _ "github.com/lib/pq" ) @@ -36,7 +35,7 @@ func main() { if !cfg.Switchs.NoScanIP { go models.ScanIP(&cfg) } - go zmqrouter.Init(&cfg) + //go zmqrouter.Init(&cfg) go func() { err = routers.RunServer(&ctx, &cfg) }() if err != nil { log.Fatalln(err) diff --git a/go.mod b/go.mod index 9f8fd1a..91097e9 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,6 @@ require ( github.com/lib/pq v1.10.7 golang.org/x/net v0.8.0 gopkg.in/ini.v1 v1.67.0 - gopkg.in/zeromq/goczmq.v4 v4.1.0 xorm.io/xorm v1.3.2 ) diff --git a/go.sum b/go.sum index 8211151..31beb0b 100644 --- a/go.sum +++ b/go.sum @@ -572,8 +572,6 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/zeromq/goczmq.v4 v4.1.0 h1:CE+FE81mGVs2aSlnbfLuS1oAwdcVywyMM2AC1g33imI= -gopkg.in/zeromq/goczmq.v4 v4.1.0/go.mod h1:h4IlfePEYMpFdywGr5gAwKhBBj+hiBl/nF4VoSE4k+0= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/src/config/main.go b/src/config/main.go index 658c90e..9f8ff28 100644 --- a/src/config/main.go +++ b/src/config/main.go @@ -48,7 +48,7 @@ func (cfg *Config) GetConfig() error { cfg.DbParams.DbPassword = ipblsection.Key("password").MustString("password") cfg.DbParams.DbDatabase = ipblsection.Key("database").MustString("database") - cfg.Options.ZMQChannel = "ipbl" + cfg.Options.SocketChannel = "ipbl" cfg.Options.HideBanner = ipblsection.Key("hidebanner").MustBool(false) return nil @@ -63,9 +63,9 @@ type Config struct { DbDatabase string } Options struct { - Version string - HideBanner bool - ZMQChannel string + Version string + HideBanner bool + SocketChannel string } Switchs struct { Port int diff --git a/src/models/models.go b/src/models/models.go index e39a3f3..4a7f6e5 100644 --- a/src/models/models.go +++ b/src/models/models.go @@ -23,7 +23,6 @@ func init() { new(Cfg), new(CfgSet), new(CfgTrustlist), - new(CfgZMQ), new(CfgWS), new(City), new(Country), diff --git a/src/zmqrouter/main.go b/src/zmqrouter/main.go deleted file mode 100644 index e884728..0000000 --- a/src/zmqrouter/main.go +++ /dev/null @@ -1,110 +0,0 @@ -package zmqrouter - -import ( - "encoding/json" - "fmt" - "log" - "time" - - "git.paulbsd.com/paulbsd/ipbl/src/config" - "git.paulbsd.com/paulbsd/ipbl/src/models" - "gopkg.in/zeromq/goczmq.v4" -) - -func Init(cfg *config.Config) (err error) { - for { - log.Println("Initiating ZMQ sockets") - - reqsock, err := InitRep() - if err != nil { - break - } - - pubsock, err := InitPub() - if err != nil { - break - } - - err = Handle(cfg, reqsock, pubsock, cfg.Options.ZMQChannel) - if err != nil { - reqsock.Destroy() - pubsock.Destroy() - time.Sleep(1 * time.Second) - break - } - } - return -} - -func Handle(cfg *config.Config, reqsock *goczmq.Sock, pubsock *goczmq.Sock, channel string) (err error) { - log.Println("Start handling zmq sockets") - - var lastip string - for { - var msg = "err" - var req, err = reqsock.RecvMessage() - - if err != nil { - log.Println("unable to receive message from req socket", err) - continue - } - - var topub [][]byte - for _, val := range req { - - var apievent = models.APIEvent{} - var event = models.Event{} - - err = json.Unmarshal(val, &apievent) - if err != nil { - log.Println("unable to parse ip address", err) - time.Sleep(time.Second) - continue - } - if apievent.IPData.IP != "" && apievent.IPData.IP == lastip { - continue - } - - if apievent.MsgType == "add" { - session := cfg.Db.NewSession() - event.APIParse(session, apievent) - session.Close() - - err := event.Insert(cfg) - if err != nil { - log.Println(err) - } - log.Printf("zmq: Inserted event") - } - - if apievent.MsgType == "file" { - apievent.MsgType = "zmq" - } - - val, err = json.Marshal(apievent) - if err != nil { - fmt.Println(err) - } - - tmpval := fmt.Sprintf("%s %s", channel, string(val)) - ipjson := []byte(tmpval) - topub = append(topub, ipjson) - lastip = apievent.IPData.IP - } - - err = pubsock.SendMessage(topub) - if err != nil { - log.Println("error sending message to pub socket") - continue - } - - msg = "ok" - var resp [][]byte = [][]byte{[]byte(msg)} - - err = reqsock.SendMessage(resp) - if err != nil { - log.Println("error replying message to req socket") - continue - } - } -} diff --git a/src/zmqrouter/pubsub.go b/src/zmqrouter/pubsub.go deleted file mode 100644 index bd50025..0000000 --- a/src/zmqrouter/pubsub.go +++ /dev/null @@ -1,14 +0,0 @@ -package zmqrouter - -import ( - "fmt" - - "gopkg.in/zeromq/goczmq.v4" -) - -const pubsubport int = 9999 - -func InitPub() (sock *goczmq.Sock, err error) { - sock, err = goczmq.NewPub(fmt.Sprintf("tcp://*:%d", pubsubport)) - return -} diff --git a/src/zmqrouter/reqrep.go b/src/zmqrouter/reqrep.go deleted file mode 100644 index e1ad473..0000000 --- a/src/zmqrouter/reqrep.go +++ /dev/null @@ -1,14 +0,0 @@ -package zmqrouter - -import ( - "fmt" - - "gopkg.in/zeromq/goczmq.v4" -) - -const repreqport int = 9998 - -func InitRep() (sock *goczmq.Sock, err error) { - sock, err = goczmq.NewRep(fmt.Sprintf("tcp://*:%d", repreqport)) - return -} diff --git a/vendor/gopkg.in/zeromq/goczmq.v4/.gitignore b/vendor/gopkg.in/zeromq/goczmq.v4/.gitignore deleted file mode 100644 index 8365624..0000000 --- a/vendor/gopkg.in/zeromq/goczmq.v4/.gitignore +++ /dev/null @@ -1,23 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe -*.test diff --git a/vendor/gopkg.in/zeromq/goczmq.v4/.travis.yml b/vendor/gopkg.in/zeromq/goczmq.v4/.travis.yml deleted file mode 100644 index 11b52b2..0000000 --- a/vendor/gopkg.in/zeromq/goczmq.v4/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: go -warnings_are_errors: false - -addons: - apt: - sources: - - sourceline: 'deb http://download.opensuse.org/repositories/network:/messaging:/zeromq:/git-draft/xUbuntu_12.04/ ./' - key_url: 'http://download.opensuse.org/repositories/network:/messaging:/zeromq:/git-draft/xUbuntu_12.04/Release.key' - packages: - - libsodium-dev - - libczmq-dev - -go: - - 1.7.1 -script: - - go get -t -v ./... - - go test -v . diff --git a/vendor/gopkg.in/zeromq/goczmq.v4/AUTHORS b/vendor/gopkg.in/zeromq/goczmq.v4/AUTHORS deleted file mode 100644 index c7d24e9..0000000 --- a/vendor/gopkg.in/zeromq/goczmq.v4/AUTHORS +++ /dev/null @@ -1,15 +0,0 @@ -Contributors (no particular order) -================================== - -Brian Knox -Luna Duclos -Indradhanush Gupta -Armen Baghumian -Ben Aldrich -Jordan Sissel -Nick Bargnesi -Cyrille Verrier -Ben Aldrich -Matthew Campbell -James Reuss -Pieter Hintjens diff --git a/vendor/gopkg.in/zeromq/goczmq.v4/CONTRIBUTING.md b/vendor/gopkg.in/zeromq/goczmq.v4/CONTRIBUTING.md deleted file mode 100644 index e36ed56..0000000 --- a/vendor/gopkg.in/zeromq/goczmq.v4/CONTRIBUTING.md +++ /dev/null @@ -1,22 +0,0 @@ -# Contributing to GoCZMQ - -The contributors are listed in AUTHORS (add yourself). This project uses the MPL v2 license, see LICENSE. - -# Our Process -Before you send a pull request, please familiarize yourself with the [C4.1 Collective Code Construction Contract](http://rfc.zeromq.org/spec:22) process. A quick summary (but please, do read the process document): -* A Pull Request should be described in the form of a problem statement. -* The code included with the pull request should be a proposed solution to that problem. -* The submitted code should adhere to our style guidelines (described below). -* The submitted code should include tests. -* The submitted code should not break any existing tests. - -"A Problem" should be one single clear problem. Large complex problems should be broken down into a series of smaller problems when ever possible. - -**Please be aware** that GoCZMQ is **not versioned**. We merge to master. We deploy from master. Master is epxected to be working, at all times. We strive to do our very best to never break public API in this library. Changes can be additive, but they can not break the existing API. If a case arises where we need to, we will be loud about it on the ZeroMQ mailing list and try to build consensus among current maintainers that it's necessary. We will be very chagrined about it, and you can poke fun at us a bit. - -# Style Guide -* Your code must be formatted with [Gofmt](https://blog.golang.org/go-fmt-your-code) -* Your code should pass [golint](https://github.com/golang/lint). If for some reason it cannot, please provide an explanation. -* Your code should pass [go vet](https://golang.org/cmd/vet/) - - diff --git a/vendor/gopkg.in/zeromq/goczmq.v4/LICENSE b/vendor/gopkg.in/zeromq/goczmq.v4/LICENSE deleted file mode 100644 index be2cc4d..0000000 --- a/vendor/gopkg.in/zeromq/goczmq.v4/LICENSE +++ /dev/null @@ -1,362 +0,0 @@ -Mozilla Public License, version 2.0 - -1. Definitions - -1.1. "Contributor" - - means each individual or legal entity that creates, contributes to the - creation of, or owns Covered Software. - -1.2. "Contributor Version" - - means the combination of the Contributions of others (if any) used by a - Contributor and that particular Contributor's Contribution. - -1.3. "Contribution" - - means Covered Software of a particular Contributor. - -1.4. "Covered Software" - - means Source Code Form to which the initial Contributor has attached the - notice in Exhibit A, the Executable Form of such Source Code Form, and - Modifications of such Source Code Form, in each case including portions - thereof. - -1.5. "Incompatible With Secondary Licenses" - means - - a. that the initial Contributor has attached the notice described in - Exhibit B to the Covered Software; or - - b. that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the terms of - a Secondary License. - -1.6. "Executable Form" - - means any form of the work other than Source Code Form. - -1.7. "Larger Work" - - means a work that combines Covered Software with other material, in a - separate file or files, that is not Covered Software. - -1.8. "License" - - means this document. - -1.9. "Licensable" - - means having the right to grant, to the maximum extent possible, whether - at the time of the initial grant or subsequently, any and all of the - rights conveyed by this License. - -1.10. "Modifications" - - means any of the following: - - a. any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered Software; or - - b. any new file in Source Code Form that contains any Covered Software. - -1.11. "Patent Claims" of a Contributor - - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the License, - by the making, using, selling, offering for sale, having made, import, - or transfer of either its Contributions or its Contributor Version. - -1.12. "Secondary License" - - means either the GNU General Public License, Version 2.0, the GNU Lesser - General Public License, Version 2.1, the GNU Affero General Public - License, Version 3.0, or any later versions of those licenses. - -1.13. "Source Code Form" - - means the form of the work preferred for making modifications. - -1.14. "You" (or "Your") - - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that controls, is - controlled by, or is under common control with You. For purposes of this - definition, "control" means (a) the power, direct or indirect, to cause - the direction or management of such entity, whether by contract or - otherwise, or (b) ownership of more than fifty percent (50%) of the - outstanding shares or beneficial ownership of such entity. - - -2. License Grants and Conditions - -2.1. Grants - - Each Contributor hereby grants You a world-wide, royalty-free, - non-exclusive license: - - a. under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and - - b. under Patent Claims of such Contributor to make, use, sell, offer for - sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. - -2.2. Effective Date - - The licenses granted in Section 2.1 with respect to any Contribution - become effective for each Contribution on the date the Contributor first - distributes such Contribution. - -2.3. Limitations on Grant Scope - - The licenses granted in this Section 2 are the only rights granted under - this License. No additional rights or licenses will be implied from the - distribution or licensing of Covered Software under this License. - Notwithstanding Section 2.1(b) above, no patent license is granted by a - Contributor: - - a. for any code that a Contributor has removed from Covered Software; or - - b. for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - - c. under Patent Claims infringed by Covered Software in the absence of - its Contributions. - - This License does not grant any rights in the trademarks, service marks, - or logos of any Contributor (except as may be necessary to comply with - the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - - No Contributor makes additional grants as a result of Your choice to - distribute the Covered Software under a subsequent version of this - License (see Section 10.2) or under the terms of a Secondary License (if - permitted under the terms of Section 3.3). - -2.5. Representation - - Each Contributor represents that the Contributor believes its - Contributions are its original creation(s) or it has sufficient rights to - grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - - This License is not intended to limit any rights You have under - applicable copyright doctrines of fair use, fair dealing, or other - equivalents. - -2.7. Conditions - - Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in - Section 2.1. - - -3. Responsibilities - -3.1. Distribution of Source Form - - All distribution of Covered Software in Source Code Form, including any - Modifications that You create or to which You contribute, must be under - the terms of this License. You must inform recipients that the Source - Code Form of the Covered Software is governed by the terms of this - License, and how they can obtain a copy of this License. You may not - attempt to alter or restrict the recipients' rights in the Source Code - Form. - -3.2. Distribution of Executable Form - - If You distribute Covered Software in Executable Form then: - - a. such Covered Software must also be made available in Source Code Form, - as described in Section 3.1, and You must inform recipients of the - Executable Form how they can obtain a copy of such Source Code Form by - reasonable means in a timely manner, at a charge no more than the cost - of distribution to the recipient; and - - b. You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter the - recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - - You may create and distribute a Larger Work under terms of Your choice, - provided that You also comply with the requirements of this License for - the Covered Software. If the Larger Work is a combination of Covered - Software with a work governed by one or more Secondary Licenses, and the - Covered Software is not Incompatible With Secondary Licenses, this - License permits You to additionally distribute such Covered Software - under the terms of such Secondary License(s), so that the recipient of - the Larger Work may, at their option, further distribute the Covered - Software under the terms of either this License or such Secondary - License(s). - -3.4. Notices - - You may not remove or alter the substance of any license notices - (including copyright notices, patent notices, disclaimers of warranty, or - limitations of liability) contained within the Source Code Form of the - Covered Software, except that You may alter any license notices to the - extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - - You may choose to offer, and to charge a fee for, warranty, support, - indemnity or liability obligations to one or more recipients of Covered - Software. However, You may do so only on Your own behalf, and not on - behalf of any Contributor. You must make it absolutely clear that any - such warranty, support, indemnity, or liability obligation is offered by - You alone, and You hereby agree to indemnify every Contributor for any - liability incurred by such Contributor as a result of warranty, support, - indemnity or liability terms You offer. You may include additional - disclaimers of warranty and limitations of liability specific to any - jurisdiction. - -4. Inability to Comply Due to Statute or Regulation - - If it is impossible for You to comply with any of the terms of this License - with respect to some or all of the Covered Software due to statute, - judicial order, or regulation then You must: (a) comply with the terms of - this License to the maximum extent possible; and (b) describe the - limitations and the code they affect. Such description must be placed in a - text file included with all distributions of the Covered Software under - this License. Except to the extent prohibited by statute or regulation, - such description must be sufficiently detailed for a recipient of ordinary - skill to be able to understand it. - -5. Termination - -5.1. The rights granted under this License will terminate automatically if You - fail to comply with any of its terms. However, if You become compliant, - then the rights granted under this License from a particular Contributor - are reinstated (a) provisionally, unless and until such Contributor - explicitly and finally terminates Your grants, and (b) on an ongoing - basis, if such Contributor fails to notify You of the non-compliance by - some reasonable means prior to 60 days after You have come back into - compliance. Moreover, Your grants from a particular Contributor are - reinstated on an ongoing basis if such Contributor notifies You of the - non-compliance by some reasonable means, this is the first time You have - received notice of non-compliance with this License from such - Contributor, and You become compliant prior to 30 days after Your receipt - of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent - infringement claim (excluding declaratory judgment actions, - counter-claims, and cross-claims) alleging that a Contributor Version - directly or indirectly infringes any patent, then the rights granted to - You by any and all Contributors for the Covered Software under Section - 2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user - license agreements (excluding distributors and resellers) which have been - validly granted by You or Your distributors under this License prior to - termination shall survive termination. - -6. Disclaimer of Warranty - - Covered Software is provided under this License on an "as is" basis, - without warranty of any kind, either expressed, implied, or statutory, - including, without limitation, warranties that the Covered Software is free - of defects, merchantable, fit for a particular purpose or non-infringing. - The entire risk as to the quality and performance of the Covered Software - is with You. Should any Covered Software prove defective in any respect, - You (not any Contributor) assume the cost of any necessary servicing, - repair, or correction. This disclaimer of warranty constitutes an essential - part of this License. No use of any Covered Software is authorized under - this License except under this disclaimer. - -7. Limitation of Liability - - Under no circumstances and under no legal theory, whether tort (including - negligence), contract, or otherwise, shall any Contributor, or anyone who - distributes Covered Software as permitted above, be liable to You for any - direct, indirect, special, incidental, or consequential damages of any - character including, without limitation, damages for lost profits, loss of - goodwill, work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses, even if such party shall have been - informed of the possibility of such damages. This limitation of liability - shall not apply to liability for death or personal injury resulting from - such party's negligence to the extent applicable law prohibits such - limitation. Some jurisdictions do not allow the exclusion or limitation of - incidental or consequential damages, so this exclusion and limitation may - not apply to You. - -8. Litigation - - Any litigation relating to this License may be brought only in the courts - of a jurisdiction where the defendant maintains its principal place of - business and such litigation shall be governed by laws of that - jurisdiction, without reference to its conflict-of-law provisions. Nothing - in this Section shall prevent a party's ability to bring cross-claims or - counter-claims. - -9. Miscellaneous - - This License represents the complete agreement concerning the subject - matter hereof. If any provision of this License is held to be - unenforceable, such provision shall be reformed only to the extent - necessary to make it enforceable. Any law or regulation which provides that - the language of a contract shall be construed against the drafter shall not - be used to construe this License against a Contributor. - - -10. Versions of the License - -10.1. New Versions - - Mozilla Foundation is the license steward. Except as provided in Section - 10.3, no one other than the license steward has the right to modify or - publish new versions of this License. Each version will be given a - distinguishing version number. - -10.2. Effect of New Versions - - You may distribute the Covered Software under the terms of the version - of the License under which You originally received the Covered Software, - or under the terms of any subsequent version published by the license - steward. - -10.3. Modified Versions - - If you create software not governed by this License, and you want to - create a new license for such software, you may create and use a - modified version of this License if you rename the license and remove - any references to the name of the license steward (except to note that - such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary - Licenses If You choose to distribute Source Code Form that is - Incompatible With Secondary Licenses under the terms of this version of - the License, the notice described in Exhibit B of this License must be - attached. - -Exhibit A - Source Code Form License Notice - - This Source Code Form is subject to the - terms of the Mozilla Public License, v. - 2.0. If a copy of the MPL was not - distributed with this file, You can - obtain one at - http://mozilla.org/MPL/2.0/. - -If it is not possible or desirable to put the notice in a particular file, -then You may include the notice in a location (such as a LICENSE file in a -relevant directory) where a recipient would be likely to look for such a -notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice - - This Source Code Form is "Incompatible - With Secondary Licenses", as defined by - the Mozilla Public License, v. 2.0. diff --git a/vendor/gopkg.in/zeromq/goczmq.v4/Makefile b/vendor/gopkg.in/zeromq/goczmq.v4/Makefile deleted file mode 100644 index 0416f14..0000000 --- a/vendor/gopkg.in/zeromq/goczmq.v4/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -build: format clean test - go build ./... - -test: get - go test -v . - -bench: get - go test -v -bench . ./... - -get: - go get -t -v ./... - -format: - find . -name \*.go -type f -exec gofmt -w {} \; - -clean: - -.PHONY: clean build diff --git a/vendor/gopkg.in/zeromq/goczmq.v4/README.md b/vendor/gopkg.in/zeromq/goczmq.v4/README.md deleted file mode 100644 index 4f89745..0000000 --- a/vendor/gopkg.in/zeromq/goczmq.v4/README.md +++ /dev/null @@ -1,261 +0,0 @@ -# goczmq [![Build Status](https://travis-ci.org/zeromq/goczmq.svg?branch=master)](https://travis-ci.org/zeromq/goczmq) [![Doc Status](https://godoc.org/github.com/zeromq/goczmq?status.png)](https://godoc.org/github.com/zeromq/goczmq) - -## Introduction -A golang interface to the [CZMQ v4.2](http://czmq.zeromq.org) API. - -## Install -### Dependencies -* [libsodium](https://github.com/jedisct1/libsodium) -* [libzmq](https://github.com/zeromq/libzmq) -* [czmq](https://github.com/zeromq/czmq) - -### For CZMQ master -``` -go get github.com/zeromq/goczmq -``` -#### A Note on Build Tags -The CZMQ library includes experimental classes that are not built by default, but can be built -by passing `--enable-drafts` to configure. Support for these draft classes are being added -to goczmq. To build these features against a CZMQ that has been compiled with `--enable-drafts`, -use `go build -tags draft`. - -### For CMZQ = 4.0 -``` -go get gopkg.in/zeromq/goczmq.v4 -``` -### For CZMQ Before 4.0 -``` -go get gopkg.in/zeromq/goczmq.v1 -``` -## Usage -### Direct CZMQ Sock API -#### Example -```go -package main - -import ( - "log" - - "github.com/zeromq/goczmq" -) - -func main() { - // Create a router socket and bind it to port 5555. - router, err := goczmq.NewRouter("tcp://*:5555") - if err != nil { - log.Fatal(err) - } - defer router.Destroy() - - log.Println("router created and bound") - - // Create a dealer socket and connect it to the router. - dealer, err := goczmq.NewDealer("tcp://127.0.0.1:5555") - if err != nil { - log.Fatal(err) - } - defer dealer.Destroy() - - log.Println("dealer created and connected") - - // Send a 'Hello' message from the dealer to the router. - // Here we send it as a frame ([]byte), with a FlagNone - // flag to indicate there are no more frames following. - err = dealer.SendFrame([]byte("Hello"), goczmq.FlagNone) - if err != nil { - log.Fatal(err) - } - - log.Println("dealer sent 'Hello'") - - // Receve the message. Here we call RecvMessage, which - // will return the message as a slice of frames ([][]byte). - // Since this is a router socket that support async - // request / reply, the first frame of the message will - // be the routing frame. - request, err := router.RecvMessage() - if err != nil { - log.Fatal(err) - } - - log.Printf("router received '%s' from '%v'", request[1], request[0]) - - // Send a reply. First we send the routing frame, which - // lets the dealer know which client to send the message. - // The FlagMore flag tells the router there will be more - // frames in this message. - err = router.SendFrame(request[0], goczmq.FlagMore) - if err != nil { - log.Fatal(err) - } - - log.Printf("router sent 'World'") - - // Next send the reply. The FlagNone flag tells the router - // that this is the last frame of the message. - err = router.SendFrame([]byte("World"), goczmq.FlagNone) - if err != nil { - log.Fatal(err) - } - - // Receive the reply. - reply, err := dealer.RecvMessage() - if err != nil { - log.Fatal(err) - } - - log.Printf("dealer received '%s'", string(reply[0])) -} -``` -#### Output -``` -2015/05/26 21:52:52 router created and bound -2015/05/26 21:52:52 dealer created and connected -2015/05/26 21:52:52 dealer sent 'Hello' -2015/05/26 21:52:52 router received 'Hello' from '[0 103 84 189 175]' -2015/05/26 21:52:52 router sent 'World' -2015/05/26 21:52:52 dealer received 'World' -``` -### io.ReadWriter support -#### Example -```go -package main - -import ( - "log" - - "github.com/zeromq/goczmq" -) - -func main() { - // Create a router socket and bind it to port 5555. - router, err := goczmq.NewRouter("tcp://*:5555") - if err != nil { - log.Fatal(err) - } - defer router.Destroy() - - log.Println("router created and bound") - - // Create a dealer socket and connect it to the router. - dealer, err := goczmq.NewDealer("tcp://127.0.0.1:5555") - if err != nil { - log.Fatal(err) - } - defer dealer.Destroy() - - log.Println("dealer created and connected") - - // Send a 'Hello' message from the dealer to the router, - // using the io.Write interface - n, err := dealer.Write([]byte("Hello")) - if err != nil { - log.Fatal(err) - } - - log.Printf("dealer sent %d byte message 'Hello'\n", n) - - // Make a byte slice and pass it to the router - // Read interface. When using the ReadWriter - // interface with a router socket, the router - // caches the routing frames internally in a - // FIFO and uses them transparently when - // sending replies. - buf := make([]byte, 16386) - - n, err = router.Read(buf) - if err != nil { - log.Fatal(err) - } - - log.Printf("router received '%s'\n", buf[:n]) - - // Send a reply. - n, err = router.Write([]byte("World")) - if err != nil { - log.Fatal(err) - } - - log.Printf("router sent %d byte message 'World'\n", n) - - // Receive the reply, reusing the previous buffer. - n, err = dealer.Read(buf) - if err != nil { - log.Fatal(err) - } - - log.Printf("dealer received '%s'", string(buf[:n])) -} -``` -#### Output -``` -2015/05/26 21:54:10 router created and bound -2015/05/26 21:54:10 dealer created and connected -2015/05/26 21:54:10 dealer sent 5 byte message 'Hello' -2015/05/26 21:54:10 router received 'Hello' -2015/05/26 21:54:10 router sent 5 byte message 'World' -2015/05/26 21:54:10 dealer received 'World' -``` -### Thread safe channel interface -#### Example -```go -package main - -import ( - "log" - - "github.com/zeromq/goczmq" -) - -func main() { - // Create a router channeler and bind it to port 5555. - // A channeler provides a thread safe channel interface - // to a *Sock - router := goczmq.NewRouterChanneler("tcp://*:5555") - defer router.Destroy() - - log.Println("router created and bound") - - // Create a dealer channeler and connect it to the router. - dealer := goczmq.NewDealerChanneler("tcp://127.0.0.1:5555") - defer dealer.Destroy() - - log.Println("dealer created and connected") - - // Send a 'Hello' message from the dealer to the router. - dealer.SendChan <- [][]byte{[]byte("Hello")} - log.Println("dealer sent 'Hello'") - - // Receve the message as a [][]byte. Since this is - // a router, the first frame of the message wil - // be the routing frame. - request := <-router.RecvChan - log.Printf("router received '%s' from '%v'", request[1], request[0]) - - // Send a reply. First we send the routing frame, which - // lets the dealer know which client to send the message. - router.SendChan <- [][]byte{request[0], []byte("World")} - log.Printf("router sent 'World'") - - // Receive the reply. - reply := <-dealer.RecvChan - log.Printf("dealer received '%s'", string(reply[0])) -} -``` -#### Output -``` -2015/05/26 21:56:43 router created and bound -2015/05/26 21:56:43 dealer created and connected -2015/05/26 21:56:43 dealer sent 'Hello' -2015/05/26 21:56:43 received 'Hello' from '[0 12 109 153 35]' -2015/05/26 21:56:43 router sent 'World' -2015/05/26 21:56:43 dealer received 'World' -``` -## GoDoc -[godoc](https://godoc.org/github.com/zeromq/goczmq) - -## See Also -* [Peter Kleiweg's](https://github.com/pebbe) [zmq4](https://github.com/pebbe/zmq4) bindings - -## License -This project uses the MPL v2 license, see LICENSE diff --git a/vendor/gopkg.in/zeromq/goczmq.v4/auth.go b/vendor/gopkg.in/zeromq/goczmq.v4/auth.go deleted file mode 100644 index 764b82f..0000000 --- a/vendor/gopkg.in/zeromq/goczmq.v4/auth.go +++ /dev/null @@ -1,140 +0,0 @@ -package goczmq - -/* -#include "czmq.h" - -zactor_t *Auth_new () { - zactor_t *auth = zactor_new(zauth, NULL); return auth; -} -*/ -import "C" - -import ( - "unsafe" -) - -// Auth wraps the CZMQ zauth actor. It handles authentication -// for all incoming connections. It allows whitelisting and -// blackisting peers based on IP address and support -// PLAIN and CURVE authentication policies. -type Auth struct { - zactorT *C.struct__zactor_t -} - -// NewAuth creates a new Auth actor. -func NewAuth() *Auth { - z := &Auth{} - z.zactorT = C.Auth_new() - return z -} - -// Verbose sets the auth actor to log information to stdout. -func (a *Auth) Verbose() error { - cmd := C.CString("VERBOSE") - defer C.free(unsafe.Pointer(cmd)) - - rc := C.zstr_send(unsafe.Pointer(a.zactorT), cmd) - if rc == -1 { - return ErrActorCmd - } - C.zsock_wait(unsafe.Pointer(a.zactorT)) - - return nil -} - -// Deny adds an address to a socket's deny list -func (a *Auth) Deny(address string) error { - cmd := C.CString("DENY") - defer C.free(unsafe.Pointer(cmd)) - - cAddress := C.CString(address) - defer C.free(unsafe.Pointer(cAddress)) - - rc := C.zstr_sendm(unsafe.Pointer(a.zactorT), cmd) - if rc == -1 { - return ErrActorCmd - } - - rc = C.zstr_send(unsafe.Pointer(a.zactorT), cAddress) - if rc == -1 { - return ErrActorCmd - } - - C.zsock_wait(unsafe.Pointer(a.zactorT)) - - return nil -} - -// Allow removes a previous Deny -func (a *Auth) Allow(address string) error { - cmd := C.CString("ALLOW") - defer C.free(unsafe.Pointer(cmd)) - - cAddress := C.CString(address) - defer C.free(unsafe.Pointer(cAddress)) - - rc := C.zstr_sendm(unsafe.Pointer(a.zactorT), cmd) - if rc == -1 { - return ErrActorCmd - } - - rc = C.zstr_send(unsafe.Pointer(a.zactorT), cAddress) - if rc == -1 { - return ErrActorCmd - } - - C.zsock_wait(unsafe.Pointer(a.zactorT)) - - return nil -} - -// Curve sets auth method to curve -func (a *Auth) Curve(allowed string) error { - cmd := C.CString("CURVE") - defer C.free(unsafe.Pointer(cmd)) - - cAllowed := C.CString(allowed) - defer C.free(unsafe.Pointer(cAllowed)) - - rc := C.zstr_sendm(unsafe.Pointer(a.zactorT), cmd) - if rc == -1 { - return ErrActorCmd - } - - rc = C.zstr_send(unsafe.Pointer(a.zactorT), cAllowed) - if rc == -1 { - return ErrActorCmd - } - - C.zsock_wait(unsafe.Pointer(a.zactorT)) - - return nil -} - -// Plain sets auth method to plain -func (a *Auth) Plain(directory string) error { - cmd := C.CString("PLAIN") - defer C.free(unsafe.Pointer(cmd)) - - cDirectory := C.CString(directory) - defer C.free(unsafe.Pointer(cDirectory)) - - rc := C.zstr_sendm(unsafe.Pointer(a.zactorT), cmd) - if rc == -1 { - return ErrActorCmd - } - - rc = C.zstr_send(unsafe.Pointer(a.zactorT), cDirectory) - if rc == -1 { - return ErrActorCmd - } - - C.zsock_wait(unsafe.Pointer(a.zactorT)) - - return nil -} - -// Destroy destroys the auth actor. -func (a *Auth) Destroy() { - C.zactor_destroy(&a.zactorT) -} diff --git a/vendor/gopkg.in/zeromq/goczmq.v4/beacon.go b/vendor/gopkg.in/zeromq/goczmq.v4/beacon.go deleted file mode 100644 index 13df38f..0000000 --- a/vendor/gopkg.in/zeromq/goczmq.v4/beacon.go +++ /dev/null @@ -1,162 +0,0 @@ -package goczmq - -/* -#include "czmq.h" - -zactor_t *Beacon_new () { - zactor_t *beacon = zactor_new(zbeacon, NULL); return beacon; -} - -int Beacon_publish(void *actor, void *data, int size, int interval) { - return zsock_send(actor, "sbi", "PUBLISH", (byte*)data, size, interval); -} -*/ -import "C" - -import ( - "strconv" - "unsafe" -) - -// Beacon wraps the CZMQ beacon actor. It implements a -// peer-to-peer discovery service for local networks. Beacons -// can broadcast and receive UDPv4 service broadcasts. -type Beacon struct { - zactorT *C.struct__zactor_t -} - -// NewBeacon creates a new Beacon instance. -func NewBeacon() *Beacon { - z := &Beacon{} - z.zactorT = C.Beacon_new() - return z -} - -// Verbose sets the beacon to log information to stdout. -func (b *Beacon) Verbose() error { - cmd := C.CString("VERBOSE") - defer C.free(unsafe.Pointer(cmd)) - - rc := C.zstr_send(unsafe.Pointer(b.zactorT), cmd) - if rc == -1 { - return ErrActorCmd - } - - return nil -} - -// Configure accepts a port number and configures -// the beacon, returning an address -func (b *Beacon) Configure(port int) (string, error) { - cmd := C.CString("CONFIGURE") - defer C.free(unsafe.Pointer(cmd)) - - cPort := C.CString(strconv.Itoa(port)) - defer C.free(unsafe.Pointer(cPort)) - - rc := C.zstr_sendm(unsafe.Pointer(b.zactorT), cmd) - if rc == -1 { - return "", ErrActorCmd - } - - rc = C.zstr_send(unsafe.Pointer(b.zactorT), cPort) - if rc == -1 { - return "", ErrActorCmd - } - - cHostname := C.zstr_recv(unsafe.Pointer(b.zactorT)) - hostname := C.GoString(cHostname) - - return hostname, nil -} - -// Publish publishes an announcement string at an interval -func (b *Beacon) Publish(announcement string, interval int) error { - cmd := C.CString("PUBLISH") - defer C.free(unsafe.Pointer(cmd)) - - cAnnouncement := C.CString(announcement) - defer C.free(unsafe.Pointer(cAnnouncement)) - - cInterval := C.CString(strconv.Itoa(interval)) - defer C.free(unsafe.Pointer(cInterval)) - - rc := C.zstr_sendm(unsafe.Pointer(b.zactorT), cmd) - if rc == -1 { - return ErrActorCmd - } - - rc = C.zstr_sendm(unsafe.Pointer(b.zactorT), cAnnouncement) - if rc == -1 { - return ErrActorCmd - } - - rc = C.zstr_send(unsafe.Pointer(b.zactorT), cInterval) - if rc == -1 { - return ErrActorCmd - } - - return nil -} - -// PublishBytes publishes an announcement byte slice at an interval -func (b *Beacon) PublishBytes(announcement []byte, interval int) error { - rc := C.Beacon_publish( - unsafe.Pointer(b.zactorT), - unsafe.Pointer(&announcement[0]), - C.int(len(announcement)), - C.int(interval), - ) - if rc == -1 { - return ErrActorCmd - } - - return nil -} - -// Subscribe subscribes to beacons matching the filter -func (b *Beacon) Subscribe(filter string) error { - cmd := C.CString("SUBSCRIBE") - defer C.free(unsafe.Pointer(cmd)) - - cFilter := C.CString(filter) - defer C.free(unsafe.Pointer(cFilter)) - - rc := C.zstr_sendm(unsafe.Pointer(b.zactorT), cmd) - if rc == -1 { - return ErrActorCmd - } - - rc = C.zstr_send(unsafe.Pointer(b.zactorT), cFilter) - if rc == -1 { - return ErrActorCmd - } - - return nil -} - -// Recv waits for the specific timeout in milliseconds to receive a beacon -func (b *Beacon) Recv(timeout int) [][]byte { - C.zsock_set_rcvtimeo(unsafe.Pointer(b.zactorT), C.int(timeout)) - - cAddrFrame := C.zframe_recv(unsafe.Pointer(b.zactorT)) - defer C.zframe_destroy(&cAddrFrame) - if cAddrFrame == nil { - return nil - } - addr := C.GoBytes(unsafe.Pointer(C.zframe_data(cAddrFrame)), C.int(C.zframe_size(cAddrFrame))) - - cBeaconFrame := C.zframe_recv(unsafe.Pointer(b.zactorT)) - defer C.zframe_destroy(&cBeaconFrame) - if cBeaconFrame == nil { - return nil - } - beacon := C.GoBytes(unsafe.Pointer(C.zframe_data(cBeaconFrame)), C.int(C.zframe_size(cBeaconFrame))) - - return [][]byte{addr, beacon} -} - -// Destroy destroys the beacon. -func (b *Beacon) Destroy() { - C.zactor_destroy(&b.zactorT) -} diff --git a/vendor/gopkg.in/zeromq/goczmq.v4/cert.go b/vendor/gopkg.in/zeromq/goczmq.v4/cert.go deleted file mode 100644 index d1b8e84..0000000 --- a/vendor/gopkg.in/zeromq/goczmq.v4/cert.go +++ /dev/null @@ -1,158 +0,0 @@ -package goczmq - -/* -#include "czmq.h" - -void Set_meta(zcert_t *self, const char *key, const char *value) {zcert_set_meta(self, key, "%s", value);} -*/ -import "C" - -import ( - "fmt" - "os" - "unsafe" -) - -// Cert wraps the CZMQ zcert class. It provides tools for -// creating and working with ZMQ CURVE security certs. -// The certs can be used as a temporary object in memory -// or persisted to disk. Certs are made up of a public -// and secret keypair + metadata. -type Cert struct { - zcertT *C.struct__zcert_t -} - -// NewCert creates a new empty Cert instance -func NewCert() *Cert { - return &Cert{ - zcertT: C.zcert_new(), - } -} - -// NewCertFromKeys creates a new Cert from a public and private key -func NewCertFromKeys(public []byte, secret []byte) (*Cert, error) { - if len(public) != 32 { - return nil, fmt.Errorf("invalid public key") - } - - if len(secret) != 32 { - return nil, fmt.Errorf("invalid private key") - } - - return &Cert{ - zcertT: C.zcert_new_from( - (*C.byte)(unsafe.Pointer(&public[0])), - (*C.byte)(unsafe.Pointer(&secret[0]))), - }, nil -} - -// NewCertFromFile Load loads a Cert from files -func NewCertFromFile(filename string) (*Cert, error) { - _, err := os.Stat(filename) - if os.IsNotExist(err) { - return nil, ErrCertNotFound - } - - cFilename := C.CString(filename) - defer C.free(unsafe.Pointer(cFilename)) - - cert := C.zcert_load(cFilename) - return &Cert{ - zcertT: cert, - }, nil -} - -// SetMeta sets meta data for a Cert -func (c *Cert) SetMeta(key string, value string) { - cKey := C.CString(key) - defer C.free(unsafe.Pointer(cKey)) - - cValue := C.CString(value) - defer C.free(unsafe.Pointer(cValue)) - - C.Set_meta(c.zcertT, cKey, cValue) -} - -// Meta returns a meta data item from a Cert given a key -func (c *Cert) Meta(key string) string { - cKey := C.CString(key) - defer C.free(unsafe.Pointer(cKey)) - - val := C.zcert_meta(c.zcertT, cKey) - return C.GoString(val) -} - -// PublicText returns the public key as a string -func (c *Cert) PublicText() string { - val := C.zcert_public_txt(c.zcertT) - return C.GoString(val) -} - -// Apply sets the public and private keys for a socket -func (c *Cert) Apply(s *Sock) { - handle := C.zsock_resolve(unsafe.Pointer(s.zsockT)) - C.zsock_set_curve_secretkey_bin(handle, C.zcert_secret_key(c.zcertT)) - C.zsock_set_curve_publickey_bin(handle, C.zcert_public_key(c.zcertT)) -} - -// Dup duplicates a Cert -func (c *Cert) Dup() *Cert { - return &Cert{ - zcertT: C.zcert_dup(c.zcertT), - } -} - -// Equal checks two Certs for equality -func (c *Cert) Equal(compare *Cert) bool { - check := C.zcert_eq(c.zcertT, compare.zcertT) - if check == C.bool(true) { - return true - } - return false -} - -// Print prints a Cert to stdout -func (c *Cert) Print() { - C.zcert_print(c.zcertT) -} - -// SavePublic saves the public key to a file -func (c *Cert) SavePublic(filename string) error { - cFilename := C.CString(filename) - defer C.free(unsafe.Pointer(cFilename)) - - rc := C.zcert_save_public(c.zcertT, cFilename) - if rc == C.int(-1) { - return fmt.Errorf("SavePublic error") - } - return nil -} - -// SaveSecret saves the secret key to a file -func (c *Cert) SaveSecret(filename string) error { - cFilename := C.CString(filename) - defer C.free(unsafe.Pointer(cFilename)) - - rc := C.zcert_save_secret(c.zcertT, cFilename) - if rc == C.int(-1) { - return fmt.Errorf("SaveSecret error") - } - return nil -} - -// Save saves the public and secret key to filename and filename_secret -func (c *Cert) Save(filename string) error { - cFilename := C.CString(filename) - defer C.free(unsafe.Pointer(cFilename)) - - rc := C.zcert_save(c.zcertT, cFilename) - if rc == C.int(-1) { - return fmt.Errorf("SavePublic: error") - } - return nil -} - -// Destroy destroys Cert instance -func (c *Cert) Destroy() { - C.zcert_destroy(&c.zcertT) -} diff --git a/vendor/gopkg.in/zeromq/goczmq.v4/certstore.go b/vendor/gopkg.in/zeromq/goczmq.v4/certstore.go deleted file mode 100644 index 060a06c..0000000 --- a/vendor/gopkg.in/zeromq/goczmq.v4/certstore.go +++ /dev/null @@ -1,60 +0,0 @@ -package goczmq - -/* -#include "czmq.h" -*/ -import "C" -import - -// CertStore works with directories of CURVE security certificates. -// It lets you easily load stores from disk and check if a key -// is present or not. This could be done fairly easily in pure -// Go, but is included for the sake of compatibility. -"unsafe" - -type CertStore struct { - zcertstoreT *C.struct__zcertstore_t -} - -// NewCertStore creates a new certificate store from -// a disk directory, loading and indexing all certificates. -func NewCertStore(location string) *CertStore { - cLocation := C.CString(location) - defer C.free(unsafe.Pointer(cLocation)) - - return &CertStore{ - zcertstoreT: C.zcertstore_new(cLocation), - } -} - -// Insert inserts a certificate into the store in memory. -// Call Save directly on the cert if you wish to save it -// to disk. -func (c *CertStore) Insert(cert *Cert) { - C.zcertstore_insert(c.zcertstoreT, &cert.zcertT) -} - -// Lookup looks up a certificate in the store by public key and -// returns it. -func (c *CertStore) Lookup(key string) *Cert { - cKey := C.CString(key) - defer C.free(unsafe.Pointer(cKey)) - - ptr := C.zcertstore_lookup(c.zcertstoreT, cKey) - if ptr == nil { - return nil - } - return &Cert{ - zcertT: ptr, - } -} - -// Print prints a list of certificates in the store to stdout -func (c *CertStore) Print() { - C.zcertstore_print(c.zcertstoreT) -} - -// Destroy destroys Cert instance -func (c *CertStore) Destroy() { - C.zcertstore_destroy(&c.zcertstoreT) -} diff --git a/vendor/gopkg.in/zeromq/goczmq.v4/channeler.go b/vendor/gopkg.in/zeromq/goczmq.v4/channeler.go deleted file mode 100644 index 522eede..0000000 --- a/vendor/gopkg.in/zeromq/goczmq.v4/channeler.go +++ /dev/null @@ -1,309 +0,0 @@ -package goczmq - -/* -#include "czmq.h" -void Sock_init() {zsys_init();} -*/ -import "C" - -import ( - "fmt" - "math/rand" - "strings" -) - -// Channeler serializes all access to a socket through a send -// and receive channel. It starts two threads, on is used for receiving -// from the zeromq socket. The other is used to listen to the receive -// channel, and send everything back to the socket thrad for sending -// using an additional inproc socket. -type Channeler struct { - id int64 - sockType int - endpoints string - subscribe *string - commandAddr string - proxyAddr string - commandChan chan<- string - SendChan chan<- [][]byte - RecvChan <-chan [][]byte -} - -// Destroy sends a message to the Channeler to shut it down -// and clean it up. -func (c *Channeler) Destroy() { - c.commandChan <- "destroy" -} - -// Subscribe to a Topic -func (c *Channeler) Subscribe(topic string) { - c.commandChan <- fmt.Sprintf("subscribe %s", topic) -} - -// Unsubscribe from a Topic -func (c *Channeler) Unsubscribe(topic string) { - c.commandChan <- fmt.Sprintf("unsubscribe %s", topic) -} - -// actor is a routine that handles communication with -// the zeromq socket. -func (c *Channeler) actor(recvChan chan<- [][]byte) { - pipe, err := NewPair(fmt.Sprintf(">%s", c.commandAddr)) - if err != nil { - panic(err) - } - defer pipe.Destroy() - defer close(recvChan) - - pull, err := NewPull(c.proxyAddr) - if err != nil { - panic(err) - } - defer pull.Destroy() - - sock := NewSock(c.sockType) - defer sock.Destroy() - switch c.sockType { - case Pub, Rep, Pull, Router, XPub: - err = sock.Attach(c.endpoints, true) - if err != nil { - panic(err) - } - - case Req, Push, Dealer, Pair, Stream, XSub: - err = sock.Attach(c.endpoints, false) - if err != nil { - panic(err) - } - - case Sub: - if c.subscribe != nil { - subscriptions := strings.Split(*c.subscribe, ",") - for _, topic := range subscriptions { - sock.SetSubscribe(topic) - } - } - - err = sock.Attach(c.endpoints, false) - if err != nil { - panic(err) - } - - default: - panic(ErrInvalidSockType) - } - - poller, err := NewPoller(sock, pull, pipe) - if err != nil { - panic(err) - } - defer poller.Destroy() - - for { - s := poller.Wait(-1) - switch s { - case pipe: - cmd, err := pipe.RecvMessage() - if err != nil { - panic(err) - } - - switch string(cmd[0]) { - case "destroy": - disconnect := strings.Split(c.endpoints, ",") - for _, endpoint := range disconnect { - sock.Disconnect(endpoint) - } - pipe.SendMessage([][]byte{[]byte("ok")}) - goto ExitActor - case "subscribe": - topic := string(cmd[1]) - sock.SetSubscribe(topic) - pipe.SendMessage([][]byte{[]byte("ok")}) - case "unsubscribe": - topic := string(cmd[1]) - sock.SetUnsubscribe(topic) - pipe.SendMessage([][]byte{[]byte("ok")}) - } - - case sock: - msg, err := s.RecvMessage() - if err != nil { - panic(err) - } - recvChan <- msg - - case pull: - msg, err := pull.RecvMessage() - if err != nil { - panic(err) - } - - err = sock.SendMessage(msg) - if err != nil { - panic(err) - } - } - } -ExitActor: -} - -// channeler is a routine that handles the channel select loop -// and sends commands to the zeromq socket. -func (c *Channeler) channeler(commandChan <-chan string, sendChan <-chan [][]byte) { - push, err := NewPush(c.proxyAddr) - if err != nil { - panic(err) - } - defer push.Destroy() - - pipe, err := NewPair(fmt.Sprintf("@%s", c.commandAddr)) - if err != nil { - panic(err) - } - defer pipe.Destroy() - - for { - select { - case cmd := <-commandChan: - switch cmd { - case "destroy": - err = pipe.SendFrame([]byte("destroy"), FlagNone) - if err != nil { - panic(err) - } - _, err = pipe.RecvMessage() - if err != nil { - panic(err) - } - goto ExitChanneler - default: - parts := strings.Split(cmd, " ") - numParts := len(parts) - message := make([][]byte, numParts, numParts) - for i, p := range parts { - message[i] = []byte(p) - } - err := pipe.SendMessage(message) - if err != nil { - panic(err) - } - _, err = pipe.RecvMessage() - if err != nil { - panic(err) - } - } - - case msg := <-sendChan: - err := push.SendMessage(msg) - if err != nil { - panic(err) - } - } - } -ExitChanneler: -} - -// newChanneler accepts arguments from the socket type based -// constructors and creates a new Channeler instance -func newChanneler(sockType int, endpoints string, subscribe ...string) *Channeler { - commandChan := make(chan string) - sendChan := make(chan [][]byte) - recvChan := make(chan [][]byte) - - C.Sock_init() - c := &Channeler{ - id: rand.Int63(), - endpoints: endpoints, - sockType: sockType, - commandChan: commandChan, - SendChan: sendChan, - RecvChan: recvChan, - } - c.commandAddr = fmt.Sprintf("inproc://actorcontrol%d", c.id) - c.proxyAddr = fmt.Sprintf("inproc://proxy%d", c.id) - - if len(subscribe) > 0 { - topics := strings.Join(subscribe, ",") - c.subscribe = &topics - } - - go c.channeler(commandChan, sendChan) - go c.actor(recvChan) - - return c -} - -// NewPubChanneler creats a new Channeler wrapping -// a Pub socket. The socket will bind by default. -func NewPubChanneler(endpoints string) *Channeler { - return newChanneler(Pub, endpoints, "") -} - -// NewSubChanneler creates a new Channeler wrapping -// a Sub socket. Along with an endpoint list -// it accepts a comma delimited list of topics. -// The socket will connect by default. -func NewSubChanneler(endpoints string, subscribe ...string) *Channeler { - return newChanneler(Sub, endpoints, subscribe...) -} - -// NewRepChanneler creates a new Channeler wrapping -// a Rep socket. The socket will bind by default. -func NewRepChanneler(endpoints string) *Channeler { - return newChanneler(Rep, endpoints, "") -} - -// NewReqChanneler creates a new Channeler wrapping -// a Req socket. The socket will connect by default. -func NewReqChanneler(endpoints string) *Channeler { - return newChanneler(Req, endpoints, "") -} - -// NewPullChanneler creates a new Channeler wrapping -// a Pull socket. The socket will bind by default. -func NewPullChanneler(endpoints string) *Channeler { - return newChanneler(Pull, endpoints, "") -} - -// NewPushChanneler creates a new Channeler wrapping -// a Push socket. The socket will connect by default. -func NewPushChanneler(endpoints string) *Channeler { - return newChanneler(Push, endpoints, "") -} - -// NewRouterChanneler creates a new Channeler wrapping -// a Router socket. The socket will Bind by default. -func NewRouterChanneler(endpoints string) *Channeler { - return newChanneler(Router, endpoints, "") -} - -// NewDealerChanneler creates a new Channeler wrapping -// a Dealer socket. The socket will connect by default. -func NewDealerChanneler(endpoints string) *Channeler { - return newChanneler(Dealer, endpoints, "") -} - -// NewXPubChanneler creates a new Channeler wrapping -// an XPub socket. The socket will Bind by default. -func NewXPubChanneler(endpoints string) *Channeler { - return newChanneler(XPub, endpoints, "") -} - -// NewXSubChanneler creates a new Channeler wrapping -// a XSub socket. The socket will connect by default. -func NewXSubChanneler(endpoints string) *Channeler { - return newChanneler(XSub, endpoints, "") -} - -// NewPairChanneler creates a new Channeler wrapping -// a Pair socket. The socket will connect by default. -func NewPairChanneler(endpoints string) *Channeler { - return newChanneler(Pair, endpoints, "") -} - -// NewStreamChanneler creates a new Channeler wrapping -// a Pair socket. The socket will connect by default. -func NewStreamChanneler(endpoints string) *Channeler { - return newChanneler(Stream, endpoints, "") -} diff --git a/vendor/gopkg.in/zeromq/goczmq.v4/goczmq.go b/vendor/gopkg.in/zeromq/goczmq.v4/goczmq.go deleted file mode 100644 index 8bc738d..0000000 --- a/vendor/gopkg.in/zeromq/goczmq.v4/goczmq.go +++ /dev/null @@ -1,201 +0,0 @@ -// Package goczmq is a golang binding for CZMQ 3. CZMQ is a high level binding -// for ZeroMQ. Along with ZeroMQ socket support, CZMQ provides "actor" based -// services for authentication, service discovery, and creating proxies. -// GoCZMQ provides direct bindings to CZMQ along with higher level go -// abstractions such as channels and io.ReadWriter interface support. -// -// "Tell them I was a writer. -// A maker of software. -// A humanist. A father. -// And many things. -// But above all, a writer. -// Thank You. :) -// - Pieter Hintjens -package goczmq - -/* -#cgo !windows pkg-config: libczmq libzmq libsodium -#cgo windows LDFLAGS: -lws2_32 -liphlpapi -lrpcrt4 -lsodium -lzmq -lczmq -#cgo windows CFLAGS: -Wno-pedantic-ms-format -DLIBCZMQ_EXPORTS -DZMQ_DEFINED_STDINT -DLIBCZMQ_EXPORTS -DZMQ_BUILD_DRAFT_API - -#include "czmq.h" -#include -#include -*/ -import "C" - -import ( - "errors" -) - -const ( - // Req is a ZMQ_REQ socket type - Req = int(C.ZMQ_REQ) - - // Rep is a ZMQ_REP socket type - Rep = int(C.ZMQ_REP) - - // Dealer is a ZMQ_DEALER socket type - Dealer = int(C.ZMQ_DEALER) - - // Router is a ZMQ_ROUTER socket type - Router = int(C.ZMQ_ROUTER) - - // Pub is a ZMQ_PUB socket type - Pub = int(C.ZMQ_PUB) - - // Sub is a ZMQ_SUB socket type - Sub = int(C.ZMQ_SUB) - - // XPub is a ZMQ_XPUB socket type - XPub = int(C.ZMQ_XPUB) - - // XSub is a ZMQ_XSUB socket type - XSub = int(C.ZMQ_XSUB) - - // Push is a ZMQ_PUSH socket type - Push = int(C.ZMQ_PUSH) - - // Pull is a ZMQ_PULL socket type - Pull = int(C.ZMQ_PULL) - - // Pair is a ZMQ_PAIR socket type - Pair = int(C.ZMQ_PAIR) - - // Stream is a ZMQ_STREAM socket type - Stream = int(C.ZMQ_STREAM) - - // Pollin is the ZMQ_POLLIN constant - Pollin = int(C.ZMQ_POLLIN) - - // Pollout is the ZMQ_POLLOUT constant - Pollout = int(C.ZMQ_POLLOUT) - - // FlagMore is the ZFRAME_MORE flag - FlagMore = int(C.ZFRAME_MORE) - - // FlagReuse is the ZFRAME_REUSE flag - FlagReuse = int(C.ZFRAME_REUSE) - - //FlagDontWait is the ZFRAME_DONTWAIT flag - FlagDontWait = int(C.ZFRAME_DONTWAIT) - - //FlagNone means there are no flags - FlagNone = 0 - - // CurveAllowAny is a semantic convenience for allowing - // any Curve clients - CurveAllowAny = "*" - - //ZMQVersionMajor is the major version of the underlying ZeroMQ library - ZMQVersionMajor = int(C.ZMQ_VERSION_MAJOR) - - //ZMQVersionMinor is the minor version of the underlying ZeroMQ library - ZMQVersionMinor = int(C.ZMQ_VERSION_MINOR) - - //CZMQVersionMajor is the major version of the underlying CZMQ library - CZMQVersionMajor = int(C.CZMQ_VERSION_MAJOR) - - // CZMQVersionMinor is the minor version of the underlying CZMQ library - CZMQVersionMinor = int(C.CZMQ_VERSION_MINOR) -) - -var ( - // ErrActorCmd is returned when there is an error sending - // a command to an actor - ErrActorCmd = errors.New("error sending actor command") - - // ErrSockAttach is returned when an attach call to a socket fails - ErrSockAttach = errors.New("error attaching zsock") - - // ErrInvalidSockType is returned when a function is called - // against a socket type that is not applicable for that socket type - ErrInvalidSockType = errors.New("invalid socket type") - - // ErrSliceFull is returned if a []byte passed to Read was not - // large enough to hold the contents of a message - ErrSliceFull = errors.New("slice full") - - // ErrConnect is returned if Connect on a socket fails - ErrConnect = errors.New("connect error") - - // ErrDisconnect is returned if Disconnect on a socket fails - ErrDisconnect = errors.New("disconnect error") - - // ErrBind is returned if Bind on a socket fails - ErrBind = errors.New("bind error") - - // ErrUnbind is returned if Unbind on a socket fails - ErrUnbind = errors.New("unbind error") - - // ErrSendFrame is returned if SendFrame on a socket fails - ErrSendFrame = errors.New("send frame error") - - // ErrRecvFrame is returned if RecvFrame on a socket fails - ErrRecvFrame = errors.New("recv frame error") - - // ErrRecvFrameAfterDestroy is returned if RecvFrame is called - // on a socket after it has been destroyed. - ErrRecvFrameAfterDestroy = errors.New("RecvFrame() is invalid on socket after Detroy() has been called.") - - // ErrRecvMessage is returned if RecvMessage on a socket fails - ErrRecvMessage = errors.New("recv message error") - - // ErrWaitAfterDestroy is returned by a Poller if there is an error - // accessing the underlying socket pointer when Wait is called - ErrWaitAfterDestroy = errors.New("Wait() is invalid on Poller after Destroy() is called.") - - // ErrMultiPartUnsupported is returned when a function that does - // not support multi-part messages encounters a multi-part message - ErrMultiPartUnsupported = errors.New("function does not support multi part messages") - - // ErrTimeout is returned when a function that supports timeouts times out - ErrTimeout = errors.New("function timed out") - - // ErrCertNotFound is returned when NewCertFromFile tries to - // load a file that does not exist. - ErrCertNotFound = errors.New("file not found") -) - -// Shutdown shuts down the CZMQ zsys layer. -// The CZMQ zsys layer normally shuts down on process termination through the -// use of an atexit cleanup function. Calling this allows the zsys layer to be -// shutdown manually. -// -// This is beneficial when CZMQ will no longer be used but the process will not -// be terminating. Any potential resources allocated by the zsys layer can be -// freed as they will no longer be needed. -func Shutdown() { - C.zsys_shutdown() -} - -func getStringType(k int) string { - switch k { - case Req: - return "REQ" - case Rep: - return "REP" - case Dealer: - return "DEALER" - case Router: - return "ROUTER" - case Pub: - return "PUB" - case Sub: - return "SUB" - case XPub: - return "XPUB" - case XSub: - return "XSUB" - case Push: - return "PUSH" - case Pull: - return "PULL" - case Pair: - return "PAIR" - case Stream: - return "STREAM" - default: - return "" - } -} diff --git a/vendor/gopkg.in/zeromq/goczmq.v4/license.xml b/vendor/gopkg.in/zeromq/goczmq.v4/license.xml deleted file mode 100644 index 349e26b..0000000 --- a/vendor/gopkg.in/zeromq/goczmq.v4/license.xml +++ /dev/null @@ -1,22 +0,0 @@ - -Copyright (C) 2014 the Authors - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/vendor/gopkg.in/zeromq/goczmq.v4/poller.go b/vendor/gopkg.in/zeromq/goczmq.v4/poller.go deleted file mode 100644 index 983e1ff..0000000 --- a/vendor/gopkg.in/zeromq/goczmq.v4/poller.go +++ /dev/null @@ -1,106 +0,0 @@ -package goczmq - -/* -#include "czmq.h" - -zpoller_t *Poller_new(void *reader) { - zpoller_t *poller = zpoller_new(reader, NULL); - return poller; -} -*/ -import "C" - -import ( - "fmt" - "unsafe" -) - -// Poller provides a simple wrapper to ZeroMQ's zmq_poll API, -// for the common case of reading from a number of sockets. -// Sockets can be added and removed from the running poller. -type Poller struct { - zpollerT *C.struct__zpoller_t - socks []*Sock -} - -// NewPoller creates a new Poller instance. -// It accepts one or more readers to poll. -func NewPoller(readers ...*Sock) (*Poller, error) { - var p *Poller - if len(readers) == 0 { - p = &Poller{ - zpollerT: C.Poller_new(nil), - socks: make([]*Sock, 0), - } - } else { - p = &Poller{ - zpollerT: C.Poller_new(unsafe.Pointer(readers[0].zsockT)), - socks: make([]*Sock, 0), - } - - p.socks = append(p.socks, readers[0]) - if len(readers) == 1 { - return p, nil - } - - for _, reader := range readers[1:] { - err := p.Add(reader) - if err != nil { - return nil, err - } - } - } - return p, nil -} - -// Add adds a reader to be polled. -func (p *Poller) Add(reader *Sock) error { - rc := C.zpoller_add(p.zpollerT, unsafe.Pointer(reader.zsockT)) - if int(rc) == -1 { - return fmt.Errorf("error adding reader") - } - p.socks = append(p.socks, reader) - return nil -} - -// Remove removes a Sock from the poller -func (p *Poller) Remove(reader *Sock) { - numItems := len(p.socks) - for i := 0; i < numItems; i++ { - if p.socks[i] == reader { - if i == numItems-1 { - p.socks = p.socks[:i] - } else { - p.socks = append(p.socks[:i], p.socks[i+1:]...) - } - } - } -} - -// Wait waits for the timeout period in milliseconds for a Pollin -// event, and returns the first socket that returns one -func (p *Poller) Wait(millis int) *Sock { - if p.zpollerT == nil { - // Null pointer. Something is wrong or we've already had `Destroy` invoked on us. - panic(ErrWaitAfterDestroy) - } - s := C.zpoller_wait(p.zpollerT, C.int(millis)) - s = unsafe.Pointer(s) - if s == nil { - return nil - } - for _, sock := range p.socks { - if unsafe.Pointer(sock.zsockT) == s { - return sock - } - } - - panic(fmt.Sprintf( - "Could not match received pointer with %v with any socket (%v)", - s, p.socks)) -} - -// Destroy destroys the Poller -func (p *Poller) Destroy() { - C.zpoller_destroy(&p.zpollerT) -} diff --git a/vendor/gopkg.in/zeromq/goczmq.v4/proxy.go b/vendor/gopkg.in/zeromq/goczmq.v4/proxy.go deleted file mode 100644 index 073ec65..0000000 --- a/vendor/gopkg.in/zeromq/goczmq.v4/proxy.go +++ /dev/null @@ -1,171 +0,0 @@ -package goczmq - -/* -#include "czmq.h" - -zactor_t *Zproxy_new () { - zactor_t *proxy = zactor_new(zproxy, NULL); - return proxy; -} -*/ -import "C" - -import ( - "unsafe" -) - -// Proxy wraps the CZMQ zproxy actor. A proxy actor switches -// messages between a frontend and backend socket, and also -// provides an optional capture socket messages can be -// mirrored to. The proxy can be paused and resumed. -type Proxy struct { - zactorT *C.struct__zactor_t -} - -// NewProxy creates a new Proxy instance. -func NewProxy() *Proxy { - p := &Proxy{} - p.zactorT = C.Zproxy_new() - return p -} - -// SetFrontend accepts a socket type and endpoint, and sends a message -// to the zactor thread telling it to set up a socket bound to the endpoint. -func (p *Proxy) SetFrontend(sockType int, endpoint string) error { - typeString := getStringType(sockType) - - cmd := C.CString("FRONTEND") - defer C.free(unsafe.Pointer(cmd)) - - cTypeString := C.CString(typeString) - defer C.free(unsafe.Pointer(cTypeString)) - - cEndpoint := C.CString(endpoint) - defer C.free(unsafe.Pointer(cEndpoint)) - - rc := C.zstr_sendm(unsafe.Pointer(p.zactorT), cmd) - if rc == -1 { - return ErrActorCmd - } - - rc = C.zstr_sendm(unsafe.Pointer(p.zactorT), cTypeString) - if rc == -1 { - return ErrActorCmd - } - - rc = C.zstr_send(unsafe.Pointer(p.zactorT), cEndpoint) - if rc == -1 { - return ErrActorCmd - } - - rc = C.zsock_wait(unsafe.Pointer(p.zactorT)) - if rc == -1 { - return ErrActorCmd - } - - return nil -} - -// SetBackend accepts a socket type and endpoint, and sends a message -// to the zactor thread telling it to set up a socket bound to the endpoint. -func (p *Proxy) SetBackend(sockType int, endpoint string) error { - typeString := getStringType(sockType) - - cmd := C.CString("BACKEND") - defer C.free(unsafe.Pointer(cmd)) - - cTypeString := C.CString(typeString) - defer C.free(unsafe.Pointer(cTypeString)) - - cEndpoint := C.CString(endpoint) - defer C.free(unsafe.Pointer(cEndpoint)) - - rc := C.zstr_sendm(unsafe.Pointer(p.zactorT), cmd) - if rc == -1 { - return ErrActorCmd - } - - rc = C.zstr_sendm(unsafe.Pointer(p.zactorT), cTypeString) - if rc == -1 { - return ErrActorCmd - } - - rc = C.zstr_send(unsafe.Pointer(p.zactorT), cEndpoint) - if rc == -1 { - return ErrActorCmd - } - - rc = C.zsock_wait(unsafe.Pointer(p.zactorT)) - if rc == -1 { - return ErrActorCmd - } - - return nil -} - -// SetCapture accepts a socket endpoint and sets up a Push socket bound -// to that endpoint, that sends a copy of all messages passing through -// the proxy. -func (p *Proxy) SetCapture(endpoint string) error { - cmd := C.CString("CAPTURE") - defer C.free(unsafe.Pointer(cmd)) - - cEndpoint := C.CString(endpoint) - defer C.free(unsafe.Pointer(cEndpoint)) - - rc := C.zstr_sendm(unsafe.Pointer(p.zactorT), cmd) - if rc == -1 { - return ErrActorCmd - } - - rc = C.zstr_send(unsafe.Pointer(p.zactorT), cEndpoint) - if rc == -1 { - return ErrActorCmd - } - - return nil -} - -// Pause sends a message to the zproxy actor telling it to pause. -func (p *Proxy) Pause() error { - cmd := C.CString("PAUSE") - defer C.free(unsafe.Pointer(cmd)) - - rc := C.zstr_send(unsafe.Pointer(p.zactorT), cmd) - if rc == -1 { - return ErrActorCmd - } - - return nil -} - -// Resume sends a message to the zproxy actor telling it to resume. -func (p *Proxy) Resume() error { - cmd := C.CString("RESUME") - defer C.free(unsafe.Pointer(cmd)) - - rc := C.zstr_send(unsafe.Pointer(p.zactorT), cmd) - if rc == -1 { - return ErrActorCmd - } - - return nil -} - -// Verbose sets the proxy to log information to stdout. -func (p *Proxy) Verbose() error { - cmd := C.CString("VERBOSE") - defer C.free(unsafe.Pointer(cmd)) - - rc := C.zstr_send(unsafe.Pointer(p.zactorT), cmd) - if rc == -1 { - return ErrActorCmd - } - - return nil -} - -// Destroy destroys the proxy. -func (p *Proxy) Destroy() { - C.zactor_destroy(&p.zactorT) -} diff --git a/vendor/gopkg.in/zeromq/goczmq.v4/readwriter.go b/vendor/gopkg.in/zeromq/goczmq.v4/readwriter.go deleted file mode 100644 index 940b987..0000000 --- a/vendor/gopkg.in/zeromq/goczmq.v4/readwriter.go +++ /dev/null @@ -1,120 +0,0 @@ -package goczmq - -import ( - "C" - "io" -) - -// ReadWriter provides an io.ReadWriter compatible -// interface for goczmq.Sock -type ReadWriter struct { - sock *Sock - poller *Poller - clientIDs []string - frame []byte - currentIndex int - timeoutMillis int -} - -// NewReadWriter accepts a sock and returns a goczmq.ReadWriter. The -// io.ReadWriter should now be considered responsible for this -// Sock. -func NewReadWriter(sock *Sock) (*ReadWriter, error) { - rw := &ReadWriter{ - sock: sock, - timeoutMillis: -1, - } - - var err error - rw.poller, err = NewPoller(rw.sock) - return rw, err -} - -// SetTimeout sets the timeout on Read in millisecond. If no new -// data is received within the timeout period, Read will return -// an ErrTimeout -func (r *ReadWriter) SetTimeout(ms int) { - r.timeoutMillis = ms -} - -// Read satisifies io.Read -func (r *ReadWriter) Read(p []byte) (int, error) { - var totalRead int - var totalFrame int - - var flag int - var err error - - if r.currentIndex == 0 { - s := r.poller.Wait(r.timeoutMillis) - if s == nil { - return totalRead, ErrTimeout - } - - r.frame, flag, err = s.RecvFrame() - - if s.GetType() == Router && r.currentIndex == 0 { - r.clientIDs = append(r.clientIDs, string(r.frame)) - r.frame, flag, err = s.RecvFrame() - } - - if flag == FlagMore { - return totalRead, ErrMultiPartUnsupported - } - - if err != nil { - return totalRead, io.EOF - } - } - - totalRead += copy(p[:], r.frame[r.currentIndex:]) - totalFrame += len(r.frame) - - if totalFrame-r.currentIndex > len(p) { - r.currentIndex = totalRead - } else { - r.currentIndex = 0 - err = io.EOF - } - - return totalRead, err -} - -// Write satisfies io.Write -func (r *ReadWriter) Write(p []byte) (int, error) { - var total int - if r.sock.GetType() == Router { - err := r.sock.SendFrame(r.GetLastClientID(), FlagMore) - if err != nil { - return total, err - } - } - err := r.sock.SendFrame(p, 0) - if err != nil { - return total, err - } - - return len(p), nil - -} - -// GetLastClientID returns the id of the last client you received -// a message from if the underlying socket is a Router socket -func (r *ReadWriter) GetLastClientID() []byte { - id := []byte(r.clientIDs[0]) - r.clientIDs = r.clientIDs[1:] - return id -} - -// SetLastClientID lets you manually set the id of the client -// you last received a message from if the underlying socket -// is a Router socket -func (r *ReadWriter) SetLastClientID(id []byte) { - r.clientIDs = append(r.clientIDs, string(id)) -} - -// Destroy destroys both the ReadWriter and the underlying Sock -func (r *ReadWriter) Destroy() { - r.sock.Destroy() - r.poller.Destroy() -} diff --git a/vendor/gopkg.in/zeromq/goczmq.v4/sock.go b/vendor/gopkg.in/zeromq/goczmq.v4/sock.go deleted file mode 100644 index 42e3e70..0000000 --- a/vendor/gopkg.in/zeromq/goczmq.v4/sock.go +++ /dev/null @@ -1,435 +0,0 @@ -package goczmq - -/* -#include "czmq.h" -#include -#include - -int Sock_connect(zsock_t *self, const char *format) {return zsock_connect(self, format, NULL);} -int Sock_disconnect(zsock_t *self, const char *format) {return zsock_disconnect(self, format, NULL);} -int Sock_bind(zsock_t *self, const char *format) {return zsock_bind(self, format, NULL);} -int Sock_unbind(zsock_t *self, const char *format) {return zsock_unbind(self, format, NULL);} -int Sock_sendframe(zsock_t *sock, const void *data, size_t size, int flags) { - zframe_t *frame = zframe_new (data, size); - int rc = zframe_send (&frame, sock, flags); - return rc; -} -*/ -import "C" - -import ( - "os" - "runtime" - "strings" - "unsafe" -) - -// Sock wraps the CZMQ zsock class. -type Sock struct { - zsockT *C.struct__zsock_t - file string - line int - zType int - clientIDs []string -} - -func init() { - if err := os.Setenv("ZSYS_SIGHANDLER", "false"); err != nil { - panic(err) - } -} - -// GetLastClientID returns the id of the last client you received -// a message from if the underlying socket is a Router socket -// DEPRECATED: See goczmq.ReadWriter -func (s *Sock) GetLastClientID() []byte { - id := []byte(s.clientIDs[0]) - s.clientIDs = s.clientIDs[1:] - return id -} - -// SetLastClientID lets you manually set the id of the client -// you last received a message from if the underlying socket -// is a Router socket -// DEPRECATED: See goczmq.ReadWriter -func (s *Sock) SetLastClientID(id []byte) { - s.clientIDs = append(s.clientIDs, string(id)) -} - -// NewSock creates a new socket. The caller source and -// line number are passed so CZMQ can report socket leaks -// intelligently. -func NewSock(t int) *Sock { - var s *Sock - _, file, line, ok := runtime.Caller(1) - - if ok { - s = &Sock{ - file: file, - line: line, - zType: t, - clientIDs: make([]string, 0), - } - } else { - s = &Sock{ - file: "", - line: 0, - zType: t, - clientIDs: make([]string, 0), - } - } - - cFile := C.CString(s.file) - defer C.free(unsafe.Pointer(cFile)) - - s.zsockT = C.zsock_new_checked(C.int(s.zType), cFile, C.size_t(s.line)) - return s -} - -// Connect connects a socket to an endpoint -// returns an error if the connect failed. -func (s *Sock) Connect(endpoint string) error { - cEndpoint := C.CString(endpoint) - defer C.free(unsafe.Pointer(cEndpoint)) - - rc := C.Sock_connect(s.zsockT, cEndpoint) - if rc != C.int(0) { - return ErrConnect - } - return nil -} - -// Disconnect disconnects a socket from an endpoint. If returns -// an error if the endpoint was not found -func (s *Sock) Disconnect(endpoint string) error { - cEndpoint := C.CString(endpoint) - defer C.free(unsafe.Pointer(cEndpoint)) - - rc := C.Sock_disconnect(s.zsockT, cEndpoint) - if int(rc) == -1 { - return ErrDisconnect - } - return nil -} - -// Bind binds a socket to an endpoint. On success returns -// the port number used for tcp transports, or 0 for other -// transports. On failure returns a -1 for port, and an error. -func (s *Sock) Bind(endpoint string) (int, error) { - cEndpoint := C.CString(endpoint) - defer C.free(unsafe.Pointer(cEndpoint)) - - port := C.Sock_bind(s.zsockT, cEndpoint) - if port == C.int(-1) { - return -1, ErrBind - } - return int(port), nil -} - -// Unbind unbinds a socket from an endpoint. If returns -// an error if the endpoint was not found -func (s *Sock) Unbind(endpoint string) error { - cEndpoint := C.CString(endpoint) - defer C.free(unsafe.Pointer(cEndpoint)) - - rc := C.Sock_unbind(s.zsockT, cEndpoint) - if int(rc) == -1 { - return ErrUnbind - } - return nil -} - -// Attach attaches a socket to zero or more endpoints. If endpoints is not null, -// parses as list of ZeroMQ endpoints, separated by commas, and prefixed by -// '@' (to bind the socket) or '>' (to attach the socket). If the endpoint -// does not start with '@' or '>', the serverish argument determines whether -// it is used to bind (serverish = true) or connect (serverish = false) -func (s *Sock) Attach(endpoints string, serverish bool) error { - cEndpoints := C.CString(endpoints) - defer C.free(unsafe.Pointer(cEndpoints)) - - rc := C.zsock_attach(s.zsockT, cEndpoints, C._Bool(serverish)) - if rc == -1 { - return ErrSockAttach - } - return nil -} - -// NewPub creates a Pub socket and calls Attach. -// The socket will Bind by default. -func NewPub(endpoints string) (*Sock, error) { - s := NewSock(Pub) - return s, s.Attach(endpoints, true) -} - -// NewSub creates a Sub socket and calls Attach. -// 'subscribe' is a comma delimited list of topics to subscribe to. -// The socket will Connect by default. -func NewSub(endpoints string, subscribe string) (*Sock, error) { - s := NewSock(Sub) - subscriptions := strings.Split(subscribe, ",") - - for _, topic := range subscriptions { - s.SetSubscribe(topic) - } - - return s, s.Attach(endpoints, false) -} - -// NewRep creates a Rep socket and calls Attach. -// The socket will Bind by default. -func NewRep(endpoints string) (*Sock, error) { - s := NewSock(Rep) - return s, s.Attach(endpoints, true) -} - -// NewReq creates a Req socket and calls Attach. -// The socket will Connect by default. -func NewReq(endpoints string) (*Sock, error) { - s := NewSock(Req) - return s, s.Attach(endpoints, false) -} - -// NewPull creates a Pull socket and calls Attach. -// The socket will Bind by default. -func NewPull(endpoints string) (*Sock, error) { - s := NewSock(Pull) - return s, s.Attach(endpoints, true) -} - -// NewPush creates a Push socket and calls Attach. -// The socket will Connect by default. -func NewPush(endpoints string) (*Sock, error) { - s := NewSock(Push) - return s, s.Attach(endpoints, false) -} - -// NewRouter creates a Router socket and calls Attach. -// The socket will Bind by default. -func NewRouter(endpoints string) (*Sock, error) { - s := NewSock(Router) - return s, s.Attach(endpoints, true) -} - -// NewDealer creates a Dealer socket and calls Attach. -// The socket will Connect by default. -func NewDealer(endpoints string) (*Sock, error) { - s := NewSock(Dealer) - return s, s.Attach(endpoints, false) -} - -// NewXPub creates an XPub socket and calls Attach. -// The socket will Bind by default. -func NewXPub(endpoints string) (*Sock, error) { - s := NewSock(XPub) - return s, s.Attach(endpoints, true) -} - -// NewXSub creates an XSub socket and calls Attach. -// The socket will Connect by default. -func NewXSub(endpoints string) (*Sock, error) { - s := NewSock(XSub) - return s, s.Attach(endpoints, false) -} - -// NewPair creates a Pair socket and calls Attach. -// The socket will Connect by default. -func NewPair(endpoints string) (*Sock, error) { - s := NewSock(Pair) - return s, s.Attach(endpoints, false) -} - -// NewStream creates a Stream socket and calls Attach. -// The socket will Connect by default. -func NewStream(endpoints string) (*Sock, error) { - s := NewSock(Stream) - return s, s.Attach(endpoints, false) -} - -// Pollin returns true if there is a Pollin -// event on the socket -func (s *Sock) Pollin() bool { - return s.Events() == Pollin -} - -// Pollout returns true if there is a Pollout -// event on the socket -func (s *Sock) Pollout() bool { - return s.Events() == Pollout -} - -// SendFrame sends a byte array via the socket. For the flags -// value, use 0 for a single message, or SNDFlagMore if it is -// a multi-part message -func (s *Sock) SendFrame(data []byte, flags int) error { - var rc C.int - if len(data) == 0 { - rc = C.Sock_sendframe(s.zsockT, nil, C.size_t(0), C.int(flags)) - } else { - rc = C.Sock_sendframe(s.zsockT, unsafe.Pointer(&data[0]), C.size_t(len(data)), C.int(flags)) - } - if rc == C.int(-1) { - return ErrSendFrame - } - return nil -} - -// RecvFrame reads a frame from the socket and returns it -// as a byte array, along with a more flag and and error -// (if there is an error) -func (s *Sock) RecvFrame() ([]byte, int, error) { - if s.zsockT == nil { - return nil, -1, ErrRecvFrameAfterDestroy - } - - frame := C.zframe_recv(unsafe.Pointer(s.zsockT)) - if frame == nil { - return []byte{0}, 0, ErrRecvFrame - } - dataSize := C.zframe_size(frame) - dataPtr := C.zframe_data(frame) - b := C.GoBytes(unsafe.Pointer(dataPtr), C.int(dataSize)) - more := C.zframe_more(frame) - C.zframe_destroy(&frame) - return b, int(more), nil -} - -// RecvFrameNoWait receives a frame from the socket -// and returns it as a byte array if one is waiting. -// Returns an empty frame, a 0 more flag and an error -// if one is not immediately available -func (s *Sock) RecvFrameNoWait() ([]byte, int, error) { - if !s.Pollin() { - return []byte{0}, 0, ErrRecvFrame - } - - return s.RecvFrame() -} - -// SendMessage accepts an array of byte arrays and -// sends it as a multi-part message. -func (s *Sock) SendMessage(parts [][]byte) error { - var f int - numParts := len(parts) - for i, val := range parts { - if i == numParts-1 { - f = 0 - } else { - f = FlagMore - } - - err := s.SendFrame(val, f) - if err != nil { - return err - } - } - return nil -} - -// RecvMessage receives a full message from the socket -// and returns it as an array of byte arrays. -func (s *Sock) RecvMessage() ([][]byte, error) { - var msg [][]byte - - for { - frame, flag, err := s.RecvFrame() - if err != nil { - return msg, err - } - msg = append(msg, frame) - if flag != FlagMore { - break - } - } - return msg, nil -} - -// Read provides an io.Reader interface to a zeromq socket -// DEPRECATED: see goczmq.ReadWriter -func (s *Sock) Read(p []byte) (int, error) { - var totalRead int - var totalFrame int - - frame, flag, err := s.RecvFrame() - if err != nil { - return totalRead, err - } - - if s.GetType() == Router { - s.clientIDs = append(s.clientIDs, string(frame)) - } else { - totalRead += copy(p[:], frame[:]) - totalFrame += len(frame) - } - - for flag == FlagMore { - frame, flag, err = s.RecvFrame() - if err != nil { - return totalRead, err - } - totalRead += copy(p[totalRead:], frame[:]) - totalFrame += len(frame) - } - - if totalFrame > len(p) { - err = ErrSliceFull - } else { - err = nil - } - - return totalRead, err -} - -// Write provides an io.Writer interface to a zeromq socket -// DEPRECATED: See goczmq.ReadWriter -func (s *Sock) Write(p []byte) (int, error) { - var total int - if s.GetType() == Router { - err := s.SendFrame(s.GetLastClientID(), FlagMore) - if err != nil { - return total, err - } - } - err := s.SendFrame(p, 0) - if err != nil { - return total, err - } - - return len(p), nil -} - -// RecvMessageNoWait receives a full message from the socket -// and returns it as an array of byte arrays if one is waiting. -// Returns an empty message and an error if one is not immediately -// available -func (s *Sock) RecvMessageNoWait() ([][]byte, error) { - var msg [][]byte - if !s.Pollin() { - return msg, ErrRecvMessage - } - - for { - frame, flag, err := s.RecvFrame() - if err != nil { - return msg, err - } - msg = append(msg, frame) - if flag != FlagMore { - break - } - } - return msg, nil -} - -// GetType returns the socket's type -func (s *Sock) GetType() int { - return s.zType -} - -// Destroy destroys the underlying zsockT. -func (s *Sock) Destroy() { - cFile := C.CString(s.file) - defer C.free(unsafe.Pointer(cFile)) - - C.zsock_destroy_checked(&s.zsockT, cFile, C.size_t(s.line)) -} diff --git a/vendor/gopkg.in/zeromq/goczmq.v4/sock_draft.go b/vendor/gopkg.in/zeromq/goczmq.v4/sock_draft.go deleted file mode 100644 index ed552a3..0000000 --- a/vendor/gopkg.in/zeromq/goczmq.v4/sock_draft.go +++ /dev/null @@ -1,30 +0,0 @@ -// +build draft - -package goczmq - -/* -#include "czmq.h" -*/ -import "C" - -const ( - // Scatter is a ZMQ_SCATTER socket type - Scatter = int(C.ZMQ_SCATTER) - - // Gather is a ZMQ_GATHER socket type - Gather = int(C.ZMQ_GATHER) -) - -// NewGather creates a Gather socket and calls Attach. -// The socket will Bind by default. -func NewGather(endpoints string) (*Sock, error) { - s := NewSock(Gather) - return s, s.Attach(endpoints, true) -} - -// NewScatter creates a Scatter socket and calls Attach. -// The socket will Connect by default. -func NewScatter(endpoints string) (*Sock, error) { - s := NewSock(Scatter) - return s, s.Attach(endpoints, false) -} diff --git a/vendor/gopkg.in/zeromq/goczmq.v4/sock_option.go b/vendor/gopkg.in/zeromq/goczmq.v4/sock_option.go deleted file mode 100644 index 8a850d3..0000000 --- a/vendor/gopkg.in/zeromq/goczmq.v4/sock_option.go +++ /dev/null @@ -1,765 +0,0 @@ -//go:generate gsl sockopts.xml -package goczmq - -/* ========================================================================= - zsock_option - get/set 0MQ socket options - - **************************************************** - * GENERATED SOURCE CODE, DO NOT EDIT!! * - * TO CHANGE THIS, EDIT sockopts.gsl * - * AND RUN gsl -q sockopts.xml * - **************************************************** - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of goczmq, the high-level go binding for CZMQ: - http://github.com/zeromq/goczmq - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -/* -#include "czmq.h" -#include -#include -*/ -import "C" - -import ( - "unsafe" -) - -// SetHeartbeatIvl sets the heartbeat_ivl option for the socket -func (s *Sock) SetHeartbeatIvl(val int) { - C.zsock_set_heartbeat_ivl(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// HeartbeatIvl returns the current value of the socket's heartbeat_ivl option -func (s *Sock) HeartbeatIvl() int { - val := C.zsock_heartbeat_ivl(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetHeartbeatTtl sets the heartbeat_ttl option for the socket -func (s *Sock) SetHeartbeatTtl(val int) { - C.zsock_set_heartbeat_ttl(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// HeartbeatTtl returns the current value of the socket's heartbeat_ttl option -func (s *Sock) HeartbeatTtl() int { - val := C.zsock_heartbeat_ttl(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetHeartbeatTimeout sets the heartbeat_timeout option for the socket -func (s *Sock) SetHeartbeatTimeout(val int) { - C.zsock_set_heartbeat_timeout(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// HeartbeatTimeout returns the current value of the socket's heartbeat_timeout option -func (s *Sock) HeartbeatTimeout() int { - val := C.zsock_heartbeat_timeout(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetUseFd sets the use_fd option for the socket -func (s *Sock) SetUseFd(val int) { - C.zsock_set_use_fd(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// UseFd returns the current value of the socket's use_fd option -func (s *Sock) UseFd() int { - val := C.zsock_use_fd(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetXPubManual sets the xpub_manual option for the socket -func (s *Sock) SetXPubManual(val int) { - C.zsock_set_xpub_manual(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// SetXPubWelcomeMsg sets the xpub_welcome_msg option for the socket -func (s *Sock) SetXPubWelcomeMsg(val string) { - cVal := C.CString(val) - defer C.free(unsafe.Pointer(cVal)) - - C.zsock_set_xpub_welcome_msg(unsafe.Pointer(s.zsockT), cVal) -} - -// SetStreamNotify sets the stream_notify option for the socket -func (s *Sock) SetStreamNotify(val int) { - C.zsock_set_stream_notify(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// SetInvertMatching sets the invert_matching option for the socket -func (s *Sock) SetInvertMatching(val int) { - C.zsock_set_invert_matching(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// InvertMatching returns the current value of the socket's invert_matching option -func (s *Sock) InvertMatching() int { - val := C.zsock_invert_matching(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetXPubVerboser sets the xpub_verboser option for the socket -func (s *Sock) SetXPubVerboser(val int) { - C.zsock_set_xpub_verboser(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// SetConnectTimeout sets the connect_timeout option for the socket -func (s *Sock) SetConnectTimeout(val int) { - C.zsock_set_connect_timeout(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// ConnectTimeout returns the current value of the socket's connect_timeout option -func (s *Sock) ConnectTimeout() int { - val := C.zsock_connect_timeout(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetTcpMaxrt sets the tcp_maxrt option for the socket -func (s *Sock) SetTcpMaxrt(val int) { - C.zsock_set_tcp_maxrt(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// TcpMaxrt returns the current value of the socket's tcp_maxrt option -func (s *Sock) TcpMaxrt() int { - val := C.zsock_tcp_maxrt(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// ThreadSafe returns the current value of the socket's thread_safe option -func (s *Sock) ThreadSafe() int { - val := C.zsock_thread_safe(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetMulticastMaxtpdu sets the multicast_maxtpdu option for the socket -func (s *Sock) SetMulticastMaxtpdu(val int) { - C.zsock_set_multicast_maxtpdu(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// MulticastMaxtpdu returns the current value of the socket's multicast_maxtpdu option -func (s *Sock) MulticastMaxtpdu() int { - val := C.zsock_multicast_maxtpdu(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetVmciBufferSize sets the vmci_buffer_size option for the socket -func (s *Sock) SetVmciBufferSize(val int) { - C.zsock_set_vmci_buffer_size(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// VmciBufferSize returns the current value of the socket's vmci_buffer_size option -func (s *Sock) VmciBufferSize() int { - val := C.zsock_vmci_buffer_size(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetVmciBufferMinSize sets the vmci_buffer_min_size option for the socket -func (s *Sock) SetVmciBufferMinSize(val int) { - C.zsock_set_vmci_buffer_min_size(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// VmciBufferMinSize returns the current value of the socket's vmci_buffer_min_size option -func (s *Sock) VmciBufferMinSize() int { - val := C.zsock_vmci_buffer_min_size(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetVmciBufferMaxSize sets the vmci_buffer_max_size option for the socket -func (s *Sock) SetVmciBufferMaxSize(val int) { - C.zsock_set_vmci_buffer_max_size(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// VmciBufferMaxSize returns the current value of the socket's vmci_buffer_max_size option -func (s *Sock) VmciBufferMaxSize() int { - val := C.zsock_vmci_buffer_max_size(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetVmciConnectTimeout sets the vmci_connect_timeout option for the socket -func (s *Sock) SetVmciConnectTimeout(val int) { - C.zsock_set_vmci_connect_timeout(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// VmciConnectTimeout returns the current value of the socket's vmci_connect_timeout option -func (s *Sock) VmciConnectTimeout() int { - val := C.zsock_vmci_connect_timeout(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetTos sets the tos option for the socket -func (s *Sock) SetTos(val int) { - C.zsock_set_tos(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// Tos returns the current value of the socket's tos option -func (s *Sock) Tos() int { - val := C.zsock_tos(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetRouterHandover sets the router_handover option for the socket -func (s *Sock) SetRouterHandover(val int) { - C.zsock_set_router_handover(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// SetConnectRid sets the connect_rid option for the socket -func (s *Sock) SetConnectRid(val string) { - cVal := C.CString(val) - defer C.free(unsafe.Pointer(cVal)) - - C.zsock_set_connect_rid(unsafe.Pointer(s.zsockT), cVal) -} - -// SetHandshakeIvl sets the handshake_ivl option for the socket -func (s *Sock) SetHandshakeIvl(val int) { - C.zsock_set_handshake_ivl(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// HandshakeIvl returns the current value of the socket's handshake_ivl option -func (s *Sock) HandshakeIvl() int { - val := C.zsock_handshake_ivl(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetSocksProxy sets the socks_proxy option for the socket -func (s *Sock) SetSocksProxy(val string) { - cVal := C.CString(val) - defer C.free(unsafe.Pointer(cVal)) - - C.zsock_set_socks_proxy(unsafe.Pointer(s.zsockT), cVal) -} - -// SocksProxy returns the current value of the socket's socks_proxy option -func (s *Sock) SocksProxy() string { - val := C.zsock_socks_proxy(unsafe.Pointer(s.zsockT)) - return C.GoString(val) -} - -// SetXPubNodrop sets the xpub_nodrop option for the socket -func (s *Sock) SetXPubNodrop(val int) { - C.zsock_set_xpub_nodrop(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// SetRouterMandatory sets the router_mandatory option for the socket -func (s *Sock) SetRouterMandatory(val int) { - C.zsock_set_router_mandatory(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// SetProbeRouter sets the probe_router option for the socket -func (s *Sock) SetProbeRouter(val int) { - C.zsock_set_probe_router(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// SetReqRelaxed sets the req_relaxed option for the socket -func (s *Sock) SetReqRelaxed(val int) { - C.zsock_set_req_relaxed(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// SetReqCorrelate sets the req_correlate option for the socket -func (s *Sock) SetReqCorrelate(val int) { - C.zsock_set_req_correlate(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// SetConflate sets the conflate option for the socket -func (s *Sock) SetConflate(val int) { - C.zsock_set_conflate(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// SetZapDomain sets the zap_domain option for the socket -func (s *Sock) SetZapDomain(val string) { - cVal := C.CString(val) - defer C.free(unsafe.Pointer(cVal)) - - C.zsock_set_zap_domain(unsafe.Pointer(s.zsockT), cVal) -} - -// ZapDomain returns the current value of the socket's zap_domain option -func (s *Sock) ZapDomain() string { - val := C.zsock_zap_domain(unsafe.Pointer(s.zsockT)) - return C.GoString(val) -} - -// Mechanism returns the current value of the socket's mechanism option -func (s *Sock) Mechanism() int { - val := C.zsock_mechanism(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetPlainServer sets the plain_server option for the socket -func (s *Sock) SetPlainServer(val int) { - C.zsock_set_plain_server(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// PlainServer returns the current value of the socket's plain_server option -func (s *Sock) PlainServer() int { - val := C.zsock_plain_server(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetPlainUsername sets the plain_username option for the socket -func (s *Sock) SetPlainUsername(val string) { - cVal := C.CString(val) - defer C.free(unsafe.Pointer(cVal)) - - C.zsock_set_plain_username(unsafe.Pointer(s.zsockT), cVal) -} - -// PlainUsername returns the current value of the socket's plain_username option -func (s *Sock) PlainUsername() string { - val := C.zsock_plain_username(unsafe.Pointer(s.zsockT)) - return C.GoString(val) -} - -// SetPlainPassword sets the plain_password option for the socket -func (s *Sock) SetPlainPassword(val string) { - cVal := C.CString(val) - defer C.free(unsafe.Pointer(cVal)) - - C.zsock_set_plain_password(unsafe.Pointer(s.zsockT), cVal) -} - -// PlainPassword returns the current value of the socket's plain_password option -func (s *Sock) PlainPassword() string { - val := C.zsock_plain_password(unsafe.Pointer(s.zsockT)) - return C.GoString(val) -} - -// SetCurveServer sets the curve_server option for the socket -func (s *Sock) SetCurveServer(val int) { - C.zsock_set_curve_server(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// CurveServer returns the current value of the socket's curve_server option -func (s *Sock) CurveServer() int { - val := C.zsock_curve_server(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetCurvePublickey sets the curve_publickey option for the socket -func (s *Sock) SetCurvePublickey(val string) { - cVal := C.CString(val) - defer C.free(unsafe.Pointer(cVal)) - - C.zsock_set_curve_publickey(unsafe.Pointer(s.zsockT), cVal) -} - -// CurvePublickey returns the current value of the socket's curve_publickey option -func (s *Sock) CurvePublickey() string { - val := C.zsock_curve_publickey(unsafe.Pointer(s.zsockT)) - return C.GoString(val) -} - -// SetCurveSecretkey sets the curve_secretkey option for the socket -func (s *Sock) SetCurveSecretkey(val string) { - cVal := C.CString(val) - defer C.free(unsafe.Pointer(cVal)) - - C.zsock_set_curve_secretkey(unsafe.Pointer(s.zsockT), cVal) -} - -// CurveSecretkey returns the current value of the socket's curve_secretkey option -func (s *Sock) CurveSecretkey() string { - val := C.zsock_curve_secretkey(unsafe.Pointer(s.zsockT)) - return C.GoString(val) -} - -// SetCurveServerkey sets the curve_serverkey option for the socket -func (s *Sock) SetCurveServerkey(val string) { - cVal := C.CString(val) - defer C.free(unsafe.Pointer(cVal)) - - C.zsock_set_curve_serverkey(unsafe.Pointer(s.zsockT), cVal) -} - -// CurveServerkey returns the current value of the socket's curve_serverkey option -func (s *Sock) CurveServerkey() string { - val := C.zsock_curve_serverkey(unsafe.Pointer(s.zsockT)) - return C.GoString(val) -} - -// SetGssapiServer sets the gssapi_server option for the socket -func (s *Sock) SetGssapiServer(val int) { - C.zsock_set_gssapi_server(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// GssapiServer returns the current value of the socket's gssapi_server option -func (s *Sock) GssapiServer() int { - val := C.zsock_gssapi_server(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetGssapiPlaintext sets the gssapi_plaintext option for the socket -func (s *Sock) SetGssapiPlaintext(val int) { - C.zsock_set_gssapi_plaintext(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// GssapiPlaintext returns the current value of the socket's gssapi_plaintext option -func (s *Sock) GssapiPlaintext() int { - val := C.zsock_gssapi_plaintext(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetGssapiPrincipal sets the gssapi_principal option for the socket -func (s *Sock) SetGssapiPrincipal(val string) { - cVal := C.CString(val) - defer C.free(unsafe.Pointer(cVal)) - - C.zsock_set_gssapi_principal(unsafe.Pointer(s.zsockT), cVal) -} - -// GssapiPrincipal returns the current value of the socket's gssapi_principal option -func (s *Sock) GssapiPrincipal() string { - val := C.zsock_gssapi_principal(unsafe.Pointer(s.zsockT)) - return C.GoString(val) -} - -// SetGssapiServicePrincipal sets the gssapi_service_principal option for the socket -func (s *Sock) SetGssapiServicePrincipal(val string) { - cVal := C.CString(val) - defer C.free(unsafe.Pointer(cVal)) - - C.zsock_set_gssapi_service_principal(unsafe.Pointer(s.zsockT), cVal) -} - -// GssapiServicePrincipal returns the current value of the socket's gssapi_service_principal option -func (s *Sock) GssapiServicePrincipal() string { - val := C.zsock_gssapi_service_principal(unsafe.Pointer(s.zsockT)) - return C.GoString(val) -} - -// SetIpv6 sets the ipv6 option for the socket -func (s *Sock) SetIpv6(val int) { - C.zsock_set_ipv6(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// Ipv6 returns the current value of the socket's ipv6 option -func (s *Sock) Ipv6() int { - val := C.zsock_ipv6(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetImmediate sets the immediate option for the socket -func (s *Sock) SetImmediate(val int) { - C.zsock_set_immediate(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// Immediate returns the current value of the socket's immediate option -func (s *Sock) Immediate() int { - val := C.zsock_immediate(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetRouterRaw sets the router_raw option for the socket -func (s *Sock) SetRouterRaw(val int) { - C.zsock_set_router_raw(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// SetIpv4only sets the ipv4only option for the socket -func (s *Sock) SetIpv4only(val int) { - C.zsock_set_ipv4only(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// Ipv4only returns the current value of the socket's ipv4only option -func (s *Sock) Ipv4only() int { - val := C.zsock_ipv4only(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetDelayAttachOnConnect sets the delay_attach_on_connect option for the socket -func (s *Sock) SetDelayAttachOnConnect(val int) { - C.zsock_set_delay_attach_on_connect(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// Type returns the current value of the socket's type option -func (s *Sock) Type() int { - val := C.zsock_type(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetSndhwm sets the sndhwm option for the socket -func (s *Sock) SetSndhwm(val int) { - C.zsock_set_sndhwm(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// Sndhwm returns the current value of the socket's sndhwm option -func (s *Sock) Sndhwm() int { - val := C.zsock_sndhwm(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetRcvhwm sets the rcvhwm option for the socket -func (s *Sock) SetRcvhwm(val int) { - C.zsock_set_rcvhwm(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// Rcvhwm returns the current value of the socket's rcvhwm option -func (s *Sock) Rcvhwm() int { - val := C.zsock_rcvhwm(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetAffinity sets the affinity option for the socket -func (s *Sock) SetAffinity(val int) { - C.zsock_set_affinity(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// Affinity returns the current value of the socket's affinity option -func (s *Sock) Affinity() int { - val := C.zsock_affinity(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetSubscribe sets the subscribe option for the socket -func (s *Sock) SetSubscribe(val string) { - cVal := C.CString(val) - defer C.free(unsafe.Pointer(cVal)) - - C.zsock_set_subscribe(unsafe.Pointer(s.zsockT), cVal) -} - -// SetUnsubscribe sets the unsubscribe option for the socket -func (s *Sock) SetUnsubscribe(val string) { - cVal := C.CString(val) - defer C.free(unsafe.Pointer(cVal)) - - C.zsock_set_unsubscribe(unsafe.Pointer(s.zsockT), cVal) -} - -// SetIdentity sets the identity option for the socket -func (s *Sock) SetIdentity(val string) { - cVal := C.CString(val) - defer C.free(unsafe.Pointer(cVal)) - - C.zsock_set_identity(unsafe.Pointer(s.zsockT), cVal) -} - -// Identity returns the current value of the socket's identity option -func (s *Sock) Identity() string { - val := C.zsock_identity(unsafe.Pointer(s.zsockT)) - return C.GoString(val) -} - -// SetRate sets the rate option for the socket -func (s *Sock) SetRate(val int) { - C.zsock_set_rate(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// Rate returns the current value of the socket's rate option -func (s *Sock) Rate() int { - val := C.zsock_rate(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetRecoveryIvl sets the recovery_ivl option for the socket -func (s *Sock) SetRecoveryIvl(val int) { - C.zsock_set_recovery_ivl(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// RecoveryIvl returns the current value of the socket's recovery_ivl option -func (s *Sock) RecoveryIvl() int { - val := C.zsock_recovery_ivl(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetSndbuf sets the sndbuf option for the socket -func (s *Sock) SetSndbuf(val int) { - C.zsock_set_sndbuf(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// Sndbuf returns the current value of the socket's sndbuf option -func (s *Sock) Sndbuf() int { - val := C.zsock_sndbuf(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetRcvbuf sets the rcvbuf option for the socket -func (s *Sock) SetRcvbuf(val int) { - C.zsock_set_rcvbuf(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// Rcvbuf returns the current value of the socket's rcvbuf option -func (s *Sock) Rcvbuf() int { - val := C.zsock_rcvbuf(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetLinger sets the linger option for the socket -func (s *Sock) SetLinger(val int) { - C.zsock_set_linger(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// Linger returns the current value of the socket's linger option -func (s *Sock) Linger() int { - val := C.zsock_linger(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetReconnectIvl sets the reconnect_ivl option for the socket -func (s *Sock) SetReconnectIvl(val int) { - C.zsock_set_reconnect_ivl(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// ReconnectIvl returns the current value of the socket's reconnect_ivl option -func (s *Sock) ReconnectIvl() int { - val := C.zsock_reconnect_ivl(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetReconnectIvlMax sets the reconnect_ivl_max option for the socket -func (s *Sock) SetReconnectIvlMax(val int) { - C.zsock_set_reconnect_ivl_max(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// ReconnectIvlMax returns the current value of the socket's reconnect_ivl_max option -func (s *Sock) ReconnectIvlMax() int { - val := C.zsock_reconnect_ivl_max(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetBacklog sets the backlog option for the socket -func (s *Sock) SetBacklog(val int) { - C.zsock_set_backlog(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// Backlog returns the current value of the socket's backlog option -func (s *Sock) Backlog() int { - val := C.zsock_backlog(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetMaxmsgsize sets the maxmsgsize option for the socket -func (s *Sock) SetMaxmsgsize(val int) { - C.zsock_set_maxmsgsize(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// Maxmsgsize returns the current value of the socket's maxmsgsize option -func (s *Sock) Maxmsgsize() int { - val := C.zsock_maxmsgsize(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetMulticastHops sets the multicast_hops option for the socket -func (s *Sock) SetMulticastHops(val int) { - C.zsock_set_multicast_hops(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// MulticastHops returns the current value of the socket's multicast_hops option -func (s *Sock) MulticastHops() int { - val := C.zsock_multicast_hops(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetRcvtimeo sets the rcvtimeo option for the socket -func (s *Sock) SetRcvtimeo(val int) { - C.zsock_set_rcvtimeo(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// Rcvtimeo returns the current value of the socket's rcvtimeo option -func (s *Sock) Rcvtimeo() int { - val := C.zsock_rcvtimeo(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetSndtimeo sets the sndtimeo option for the socket -func (s *Sock) SetSndtimeo(val int) { - C.zsock_set_sndtimeo(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// Sndtimeo returns the current value of the socket's sndtimeo option -func (s *Sock) Sndtimeo() int { - val := C.zsock_sndtimeo(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetXPubVerbose sets the xpub_verbose option for the socket -func (s *Sock) SetXPubVerbose(val int) { - C.zsock_set_xpub_verbose(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// SetTcpKeepalive sets the tcp_keepalive option for the socket -func (s *Sock) SetTcpKeepalive(val int) { - C.zsock_set_tcp_keepalive(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// TcpKeepalive returns the current value of the socket's tcp_keepalive option -func (s *Sock) TcpKeepalive() int { - val := C.zsock_tcp_keepalive(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetTcpKeepaliveIdle sets the tcp_keepalive_idle option for the socket -func (s *Sock) SetTcpKeepaliveIdle(val int) { - C.zsock_set_tcp_keepalive_idle(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// TcpKeepaliveIdle returns the current value of the socket's tcp_keepalive_idle option -func (s *Sock) TcpKeepaliveIdle() int { - val := C.zsock_tcp_keepalive_idle(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetTcpKeepaliveCnt sets the tcp_keepalive_cnt option for the socket -func (s *Sock) SetTcpKeepaliveCnt(val int) { - C.zsock_set_tcp_keepalive_cnt(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// TcpKeepaliveCnt returns the current value of the socket's tcp_keepalive_cnt option -func (s *Sock) TcpKeepaliveCnt() int { - val := C.zsock_tcp_keepalive_cnt(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetTcpKeepaliveIntvl sets the tcp_keepalive_intvl option for the socket -func (s *Sock) SetTcpKeepaliveIntvl(val int) { - C.zsock_set_tcp_keepalive_intvl(unsafe.Pointer(s.zsockT), C.int(val)) -} - -// TcpKeepaliveIntvl returns the current value of the socket's tcp_keepalive_intvl option -func (s *Sock) TcpKeepaliveIntvl() int { - val := C.zsock_tcp_keepalive_intvl(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// SetTcpAcceptFilter sets the tcp_accept_filter option for the socket -func (s *Sock) SetTcpAcceptFilter(val string) { - cVal := C.CString(val) - defer C.free(unsafe.Pointer(cVal)) - - C.zsock_set_tcp_accept_filter(unsafe.Pointer(s.zsockT), cVal) -} - -// TcpAcceptFilter returns the current value of the socket's tcp_accept_filter option -func (s *Sock) TcpAcceptFilter() string { - val := C.zsock_tcp_accept_filter(unsafe.Pointer(s.zsockT)) - return C.GoString(val) -} - -// Rcvmore returns the current value of the socket's rcvmore option -func (s *Sock) Rcvmore() int { - val := C.zsock_rcvmore(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// Fd returns the current value of the socket's fd option -func (s *Sock) Fd() int { - val := C.zsock_fd(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// Events returns the current value of the socket's events option -func (s *Sock) Events() int { - val := C.zsock_events(unsafe.Pointer(s.zsockT)) - return int(val) -} - -// LastEndpoint returns the current value of the socket's last_endpoint option -func (s *Sock) LastEndpoint() string { - val := C.zsock_last_endpoint(unsafe.Pointer(s.zsockT)) - return C.GoString(val) -} diff --git a/vendor/gopkg.in/zeromq/goczmq.v4/sock_option.gsl b/vendor/gopkg.in/zeromq/goczmq.v4/sock_option.gsl deleted file mode 100644 index 137c252..0000000 --- a/vendor/gopkg.in/zeromq/goczmq.v4/sock_option.gsl +++ /dev/null @@ -1,84 +0,0 @@ -.# This is a code generator built using the iMatix GSL code generation -.# language. See https://github.com/imatix/gsl for details. This script -.# is licensed under MIT/X11. -.# -.output "./sock_option.go" -//go:generate gsl sockopts.xml -package goczmq - -/* ========================================================================= - zsock_option - get/set 0MQ socket options - - **************************************************** - * GENERATED SOURCE CODE, DO NOT EDIT!! * - * TO CHANGE THIS, EDIT sockopts.gsl * - * AND RUN gsl -q sockopts.xml * - **************************************************** - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of goczmq, the high-level go binding for CZMQ: - http://github.com/zeromq/goczmq - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -/* -#include "czmq.h" -#include -#include -*/ -import "C" - -import ( - "unsafe" -) - -.for version -.if major = "4" -.for option -.if mode = "rw" | mode = "w" -.if type = "uint64" | type = "int64" | type = "uint32" | type = "int" -// Set$(name:pascal) sets the $(name) option for the socket -func (s *Sock) Set$(name:pascal)(val $(gotype)) { - C.zsock_set_$(name)(unsafe.Pointer(s.zsockT), C.int(val)) -} - -.endif -.if type = "string" | type = "key" -// Set$(name:pascal) sets the $(name) option for the socket -func (s *Sock) Set$(name:pascal)(val $(gotype)) { - cVal := C.CString(val) - defer C.free(unsafe.Pointer(cVal)) - - C.zsock_set_$(name)(unsafe.Pointer(s.zsockT), cVal) -} - -.endif -.endif -.if mode = "rw" | mode = "r" -.if type = "uint64" | type = "int64" | type = "uint32" | type = "int" -// $(name:pascal) returns the current value of the socket's $(name) option -func (s *Sock) $(name:pascal)() $(gotype) { - val := C.zsock_$(name)(unsafe.Pointer(s.zsockT)) - return int(val) -} - -.endif -.if type = "string" | type = "key" -// $(name:pascal) returns the current value of the socket's $(name) option -func (s *Sock) $(name:pascal)() $(gotype) { - val := C.zsock_$(name)(unsafe.Pointer(s.zsockT)) - return C.GoString(val) -} - -.endif -.endif -.endfor -.endif -.for source -$(string.trim(.):) -.endfor -.endfor diff --git a/vendor/gopkg.in/zeromq/goczmq.v4/sock_option_test.gsl b/vendor/gopkg.in/zeromq/goczmq.v4/sock_option_test.gsl deleted file mode 100644 index 6ba4d88..0000000 --- a/vendor/gopkg.in/zeromq/goczmq.v4/sock_option_test.gsl +++ /dev/null @@ -1,83 +0,0 @@ -.# This is a code generator built using the iMatix GSL code generation -.# language. See https://github.com/imatix/gsl for details. This script -.# is licensed under MIT/X11. -.# -.output "./sock_option_test.go" -//go:generate gsl sockopts.xml -package goczmq -/* ========================================================================= - zsock_option - get/set 0MQ socket options - - **************************************************** - * GENERATED SOURCE CODE, DO NOT EDIT!! * - **************************************************** - - Copyright (c) the Contributors as noted in the AUTHORS file. - This file is part of goczmq, the high-level go binding for CZMQ: - http://github.com/zeromq/goczmq - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - ========================================================================= -*/ - -import ( - "testing" -) -.for version -.if major = "4" -.for option where defined(test) -.if mode = "rw" | mode = "w" -.if type = "uint64" | type = "int64" | type = "uint32" | type = "int" -func Test$(name:pascal)(t *testing.T) { - sock := NewSock($(test:neat)) - testval := $(test_value?'1':) - sock.Set$(name:pascal)(testval) -.if mode = "rw" - val := sock.$(name:pascal)() - if val != testval && val != 0 { - t.Errorf("$(name:pascal) returned %d, should be %d", val, testval) - } -.endif - sock.Destroy() -} - -.endif -.if type = "string" | type = "key" -func Test$(name:pascal)(t *testing.T) { - sock := NewSock($(test:neat)) - testval := "$(test_value?'test':)" - sock.Set$(name:pascal)(testval) -.if mode = "rw" - val := sock.$(name:pascal)() - if val != testval && val != "" { - t.Errorf("$(name:pascal) returned %s should be %s", val, testval) - } -.endif - sock.Destroy() -} - -.endif -.if mode = "r" -.if type = "uint64" | type = "int64" | type = "uint32" | type = "int" -func Test$(name:pascal)(t *testing.T) { - sock := NewSock($(test:neat)) - _ = sock.$(name:pascal)() - sock.Destroy() -} - -.endif -.if type = "string" | type = "key" -func Test$(name:pascal)(t *testing.T) { - sock := NewSock($(test:pascal)) - _ = sock.$(name:pascal)() - sock.Destroy() -} - -.endif -.endif -.endif -.endfor -.endif -.endfor diff --git a/vendor/gopkg.in/zeromq/goczmq.v4/sockopts.gsl b/vendor/gopkg.in/zeromq/goczmq.v4/sockopts.gsl deleted file mode 100644 index 4e54c88..0000000 --- a/vendor/gopkg.in/zeromq/goczmq.v4/sockopts.gsl +++ /dev/null @@ -1,32 +0,0 @@ -.# This is a code generator built using the iMatix GSL code generation -.# language. See https://github.com/imatix/gsl for details. This script -.# is licensed under MIT/X11. -.# -.template 0 -for version - # Expand any macros - for include - for options.macro where name = include.name - for . as child - copy child to version - endfor - endfor - endfor - # Preprocess options - for option - if type = "uint64" | type = "int64" | type = "uint32" | type = "int" - option.ctype = "int" - option.ctype_const = "int" - option.gotype = "int" - elsif type = "string" | type = "key" - option.ctype = "char *" # Enforce C strings - option.ctype_const = "const char *" - option.gotype = "string" - else - echo "E: unknown type: $(type)" - endif - endfor -endfor -.endtemplate -.include "sock_option.gsl" -.include "sock_option_test.gsl" diff --git a/vendor/gopkg.in/zeromq/goczmq.v4/sockopts.xml b/vendor/gopkg.in/zeromq/goczmq.v4/sockopts.xml deleted file mode 100644 index d505d2e..0000000 --- a/vendor/gopkg.in/zeromq/goczmq.v4/sockopts.xml +++ /dev/null @@ -1,233 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/vendor/modules.txt b/vendor/modules.txt index fe51e9e..5e95289 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -89,9 +89,6 @@ golang.org/x/text/unicode/norm # gopkg.in/ini.v1 v1.67.0 ## explicit gopkg.in/ini.v1 -# gopkg.in/zeromq/goczmq.v4 v4.1.0 -## explicit -gopkg.in/zeromq/goczmq.v4 # xorm.io/builder v0.3.12 ## explicit; go 1.11 xorm.io/builder From 697df686404751aa7e327567761b5791dcec0a33 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Sun, 5 Mar 2023 23:05:05 +0100 Subject: [PATCH 04/23] updated ws feature --- cmd/ipbl/ipbl.go | 2 ++ src/routers/funcs.go | 3 +-- src/ws/main.go | 52 ++++++++++++++++++++++++++++++++++++++++++++ src/ws/pubsub.go | 27 ----------------------- src/ws/reqrep.go | 31 -------------------------- 5 files changed, 55 insertions(+), 60 deletions(-) delete mode 100644 src/ws/pubsub.go delete mode 100644 src/ws/reqrep.go diff --git a/cmd/ipbl/ipbl.go b/cmd/ipbl/ipbl.go index 5d32e21..02fa911 100644 --- a/cmd/ipbl/ipbl.go +++ b/cmd/ipbl/ipbl.go @@ -10,6 +10,7 @@ import ( "git.paulbsd.com/paulbsd/ipbl/src/database" "git.paulbsd.com/paulbsd/ipbl/src/models" "git.paulbsd.com/paulbsd/ipbl/src/routers" + "git.paulbsd.com/paulbsd/ipbl/src/ws" "git.paulbsd.com/paulbsd/ipbl/utils" _ "github.com/lib/pq" ) @@ -36,6 +37,7 @@ func main() { go models.ScanIP(&cfg) } //go zmqrouter.Init(&cfg) + go ws.Init(&cfg) go func() { err = routers.RunServer(&ctx, &cfg) }() if err != nil { log.Fatalln(err) diff --git a/src/routers/funcs.go b/src/routers/funcs.go index 1d8e2b4..cabf1b9 100644 --- a/src/routers/funcs.go +++ b/src/routers/funcs.go @@ -155,6 +155,5 @@ func RegisterRoutes(e *echo.Echo, ctx *context.Context, cfg *config.Config) { return Result(c, err, disc) }) e.File("/test.html", "/home/paul/test.html") - e.GET("/wsps", ws.HandleWSPubSub) - e.GET("/wsrr", ws.HandleWSReqRep) + e.GET("/ws", ws.HandleWS) } diff --git a/src/ws/main.go b/src/ws/main.go index 9859295..12aea25 100644 --- a/src/ws/main.go +++ b/src/ws/main.go @@ -1 +1,53 @@ package ws + +import ( + "encoding/json" + "fmt" + "log" + + "git.paulbsd.com/paulbsd/ipbl/src/config" + "git.paulbsd.com/paulbsd/ipbl/src/models" + "github.com/labstack/echo/v4" + "golang.org/x/net/websocket" +) + +var LISTENERS map[string]*websocket.Conn +var CHAN int + +func Init(cfg *config.Config) { + LISTENERS = make(map[string]*websocket.Conn) +} + +func HandleWS(c echo.Context) error { + websocket.Handler(func(ws *websocket.Conn) { + defer ws.Close() + + fmt.Printf("rr: %v\n", ws) + + for { + // Read + var event models.APIEvent + var msg []byte + err := websocket.Message.Receive(ws, &msg) + if err != nil { + return + } + err = json.Unmarshal(msg, &event) + if err != nil { + log.Println(err) + } + if event.MsgType == "bootstrap" { + LISTENERS[event.Hostname] = ws + } + fmt.Println(LISTENERS) + + // Write + err = websocket.Message.Send(ws, "OK") + if err != nil { + return + } + + } + }).ServeHTTP(c.Response(), c.Request()) + return nil +} diff --git a/src/ws/pubsub.go b/src/ws/pubsub.go deleted file mode 100644 index fdacd55..0000000 --- a/src/ws/pubsub.go +++ /dev/null @@ -1,27 +0,0 @@ -package ws - -import ( - "github.com/labstack/echo/v4" - "golang.org/x/net/websocket" -) - -func HandleWSPubSub(c echo.Context) error { - websocket.Handler(func(ws *websocket.Conn) { - defer ws.Close() - for { - // Write - err := websocket.Message.Send(ws, "Hello, Client!") - if err != nil { - return - } - - // Read - msg := "" - err = websocket.Message.Receive(ws, &msg) - if err != nil { - return - } - } - }).ServeHTTP(c.Response(), c.Request()) - return nil -} diff --git a/src/ws/reqrep.go b/src/ws/reqrep.go deleted file mode 100644 index 89e0e27..0000000 --- a/src/ws/reqrep.go +++ /dev/null @@ -1,31 +0,0 @@ -package ws - -import ( - "fmt" - - "github.com/labstack/echo/v4" - "golang.org/x/net/websocket" -) - -func HandleWSReqRep(c echo.Context) error { - websocket.Handler(func(ws *websocket.Conn) { - defer ws.Close() - for { - // Read - msg := "" - err := websocket.Message.Receive(ws, &msg) - if err != nil { - return - } - fmt.Println(msg) - - // Write - err = websocket.Message.Send(ws, "OK") - if err != nil { - return - } - - } - }).ServeHTTP(c.Response(), c.Request()) - return nil -} From 0354fe3255c512b09c83ec53549df1c3969c2db2 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Sun, 12 Mar 2023 14:25:40 +0100 Subject: [PATCH 05/23] updated ws sockets --- src/routers/funcs.go | 5 ++++- src/ws/main.go | 49 ++++++++++++++++++++++++++++++++++++-------- 2 files changed, 44 insertions(+), 10 deletions(-) diff --git a/src/routers/funcs.go b/src/routers/funcs.go index cabf1b9..f3736ee 100644 --- a/src/routers/funcs.go +++ b/src/routers/funcs.go @@ -155,5 +155,8 @@ func RegisterRoutes(e *echo.Echo, ctx *context.Context, cfg *config.Config) { return Result(c, err, disc) }) e.File("/test.html", "/home/paul/test.html") - e.GET("/ws", ws.HandleWS) + e.GET("/ws", func(c echo.Context) (err error) { + ws.HandleWS(c, cfg) + return + }) } diff --git a/src/ws/main.go b/src/ws/main.go index 12aea25..ebbb8a6 100644 --- a/src/ws/main.go +++ b/src/ws/main.go @@ -18,32 +18,54 @@ func Init(cfg *config.Config) { LISTENERS = make(map[string]*websocket.Conn) } -func HandleWS(c echo.Context) error { +func HandleWS(c echo.Context, cfg *config.Config) error { websocket.Handler(func(ws *websocket.Conn) { defer ws.Close() - fmt.Printf("rr: %v\n", ws) - + var lastip string for { + var apievent = models.APIEvent{} + var event = models.Event{} + // Read - var event models.APIEvent var msg []byte err := websocket.Message.Receive(ws, &msg) if err != nil { + log.Println(err) return } - err = json.Unmarshal(msg, &event) + err = json.Unmarshal(msg, &apievent) if err != nil { log.Println(err) } - if event.MsgType == "bootstrap" { - LISTENERS[event.Hostname] = ws + + if apievent.IPData.IP != "" && apievent.IPData.IP == lastip { + continue + } + + switch apievent.MsgType { + case "bootstrap": + LISTENERS[apievent.Hostname] = ws + fmt.Println(LISTENERS) + case "add": + session := cfg.Db.NewSession() + event.APIParse(session, apievent) + session.Close() + + err := event.Insert(cfg) + if err != nil { + log.Println(err) + } + log.Printf("zmq: Inserted event") + case "file": + apievent.MsgType = "ws" } - fmt.Println(LISTENERS) // Write - err = websocket.Message.Send(ws, "OK") + err = websocket.Message.Send(ws, "OK_sendtest") if err != nil { + gcconn(ws) + fmt.Println(LISTENERS) return } @@ -51,3 +73,12 @@ func HandleWS(c echo.Context) error { }).ServeHTTP(c.Response(), c.Request()) return nil } + +func gcconn(conn *websocket.Conn) (err error) { + for i, v := range LISTENERS { + if v == conn { + delete(LISTENERS, i) + } + } + return err +} From f5ed3ee4554f0b65d9694023a2defbc86b3191b1 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Sun, 9 Apr 2023 01:41:52 +0200 Subject: [PATCH 06/23] updated ipbl websocket feat --- cmd/ipbl/ipbl.go | 4 +-- src/routers/funcs.go | 8 +++-- src/ws/init.go | 63 ++++++++++++++++++++++++++++++++ src/ws/pubsub.go | 51 ++++++++++++++++++++++++++ src/ws/{main.go => reqrep.go} | 67 +++++++++++++++++++++-------------- 5 files changed, 163 insertions(+), 30 deletions(-) create mode 100644 src/ws/init.go create mode 100644 src/ws/pubsub.go rename src/ws/{main.go => reqrep.go} (53%) diff --git a/cmd/ipbl/ipbl.go b/cmd/ipbl/ipbl.go index 02fa911..3301ae1 100644 --- a/cmd/ipbl/ipbl.go +++ b/cmd/ipbl/ipbl.go @@ -36,8 +36,8 @@ func main() { if !cfg.Switchs.NoScanIP { go models.ScanIP(&cfg) } - //go zmqrouter.Init(&cfg) - go ws.Init(&cfg) + + ws.Init(&cfg) go func() { err = routers.RunServer(&ctx, &cfg) }() if err != nil { log.Fatalln(err) diff --git a/src/routers/funcs.go b/src/routers/funcs.go index f3736ee..835b76e 100644 --- a/src/routers/funcs.go +++ b/src/routers/funcs.go @@ -155,8 +155,12 @@ func RegisterRoutes(e *echo.Echo, ctx *context.Context, cfg *config.Config) { return Result(c, err, disc) }) e.File("/test.html", "/home/paul/test.html") - e.GET("/ws", func(c echo.Context) (err error) { - ws.HandleWS(c, cfg) + e.GET("/wsps", func(c echo.Context) (err error) { + ws.HandleWSPS(c, cfg) + return + }) + e.GET("/wsrr", func(c echo.Context) (err error) { + ws.HandleWSRR(c, cfg) return }) } diff --git a/src/ws/init.go b/src/ws/init.go new file mode 100644 index 0000000..ea56441 --- /dev/null +++ b/src/ws/init.go @@ -0,0 +1,63 @@ +package ws + +import ( + "time" + + "git.paulbsd.com/paulbsd/ipbl/src/config" + "git.paulbsd.com/paulbsd/ipbl/src/models" + "golang.org/x/net/websocket" +) + +var WebSocketChannel = make(chan models.APIEvent, 100) +var WebSocketChannelDone = make(chan bool) + +var LISTENERS map[string]ConnectionInfo + +func Init(cfg *config.Config) { + LISTENERS = make(map[string]ConnectionInfo) +} + +func WelcomeAgents(ws *websocket.Conn, welcome WSWelcome, t string) { + connectinfo, ok := LISTENERS[welcome.Hostname] + + if !ok { + if t == "ps" { + connectinfo := ConnectionInfo{ + ConnectionPS: ws, + InitDate: time.Now(), + } + LISTENERS[welcome.Hostname] = connectinfo + } else if t == "rr" { + connectinfo := ConnectionInfo{ + ConnectionRR: ws, + InitDate: time.Now(), + } + LISTENERS[welcome.Hostname] = connectinfo + } + } else { + if t == "ps" { + connectinfo.ConnectionPS = ws + } else if t == "rr" { + connectinfo.ConnectionRR = ws + } + } +} + +type ConnectionInfo struct { + ConnectionPS *websocket.Conn + ConnectionRR *websocket.Conn + InitDate time.Time +} + +type WSWelcome struct { + Hostname string +} + +func gcConn(conn *websocket.Conn, t string) (err error) { + for index, value := range LISTENERS { + if value.ConnectionPS == conn { + delete(LISTENERS, index) + } + } + return err +} diff --git a/src/ws/pubsub.go b/src/ws/pubsub.go new file mode 100644 index 0000000..a65a5b5 --- /dev/null +++ b/src/ws/pubsub.go @@ -0,0 +1,51 @@ +package ws + +import ( + "encoding/json" + "log" + + "git.paulbsd.com/paulbsd/ipbl/src/config" + "github.com/labstack/echo/v4" + "golang.org/x/net/websocket" +) + +func HandleWSPS(c echo.Context, cfg *config.Config) (err error) { + websocket.Handler(func(ws *websocket.Conn) { + defer ws.Close() + + var welcome = WSWelcome{} + + var msg []byte + err := websocket.Message.Receive(ws, &msg) + if err != nil { + log.Println(err) + return + } + + err = json.Unmarshal(msg, &welcome) + if err != nil { + log.Println(err) + } else { + WelcomeAgents(ws, welcome, "ps") + } + + /*for { + var apievent, ok = <-WebSocketChannel + if ok { + log.Println(apievent, ok) + data, err := json.Marshal(apievent) + if err != nil { + log.Println(err) + } + err = websocket.Message.Send(ws, data) + if err != nil { + gcConn(ws, "ps") + log.Println(LISTENERS) + return + } + } + }*/ + + }).ServeHTTP(c.Response(), c.Request()) + return nil +} diff --git a/src/ws/main.go b/src/ws/reqrep.go similarity index 53% rename from src/ws/main.go rename to src/ws/reqrep.go index ebbb8a6..24cf8ea 100644 --- a/src/ws/main.go +++ b/src/ws/reqrep.go @@ -2,7 +2,6 @@ package ws import ( "encoding/json" - "fmt" "log" "git.paulbsd.com/paulbsd/ipbl/src/config" @@ -11,29 +10,38 @@ import ( "golang.org/x/net/websocket" ) -var LISTENERS map[string]*websocket.Conn -var CHAN int - -func Init(cfg *config.Config) { - LISTENERS = make(map[string]*websocket.Conn) -} - -func HandleWS(c echo.Context, cfg *config.Config) error { +func HandleWSRR(c echo.Context, cfg *config.Config) error { websocket.Handler(func(ws *websocket.Conn) { defer ws.Close() + var welcome = WSWelcome{} + + var msg []byte + err := websocket.Message.Receive(ws, &msg) + if err != nil { + log.Println(err) + return + } + + err = json.Unmarshal(msg, &welcome) + if err == nil { + WelcomeAgents(ws, welcome, "rr") + } + var lastip string for { var apievent = models.APIEvent{} var event = models.Event{} - // Read var msg []byte err := websocket.Message.Receive(ws, &msg) + log.Println(string(msg)) if err != nil { log.Println(err) return } + websocket.Message.Send(ws, "OK") + err = json.Unmarshal(msg, &apievent) if err != nil { log.Println(err) @@ -45,8 +53,14 @@ func HandleWS(c echo.Context, cfg *config.Config) error { switch apievent.MsgType { case "bootstrap": - LISTENERS[apievent.Hostname] = ws - fmt.Println(LISTENERS) + for _, value := range LISTENERS { + err = websocket.Message.Send(value.ConnectionPS, msg) + if err != nil { + log.Println(err) + } + } + + log.Println(LISTENERS) case "add": session := cfg.Db.NewSession() event.APIParse(session, apievent) @@ -56,16 +70,26 @@ func HandleWS(c echo.Context, cfg *config.Config) error { if err != nil { log.Println(err) } - log.Printf("zmq: Inserted event") + + for _, value := range LISTENERS { + err = websocket.Message.Send(value.ConnectionPS, msg) + if err != nil { + log.Println(err) + } + } + log.Printf("websocket: Inserted event") case "file": apievent.MsgType = "ws" + default: + log.Println("test") } - // Write - err = websocket.Message.Send(ws, "OK_sendtest") + WebSocketChannel <- apievent + + err = websocket.Message.Send(ws, "OK") if err != nil { - gcconn(ws) - fmt.Println(LISTENERS) + gcConn(ws, "rr") + log.Println(LISTENERS) return } @@ -73,12 +97,3 @@ func HandleWS(c echo.Context, cfg *config.Config) error { }).ServeHTTP(c.Response(), c.Request()) return nil } - -func gcconn(conn *websocket.Conn) (err error) { - for i, v := range LISTENERS { - if v == conn { - delete(LISTENERS, i) - } - } - return err -} From 14d72693dd9a5747eefed8f0d1d4f6fb06a3afa5 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Sun, 9 Apr 2023 15:05:31 +0200 Subject: [PATCH 07/23] more stable ipbl websocket feat --- src/ws/init.go | 8 ++++---- src/ws/pubsub.go | 13 +++++++++++-- src/ws/reqrep.go | 44 ++++++++++++++++++++++++++------------------ 3 files changed, 41 insertions(+), 24 deletions(-) diff --git a/src/ws/init.go b/src/ws/init.go index ea56441..6ffee2b 100644 --- a/src/ws/init.go +++ b/src/ws/init.go @@ -11,10 +11,10 @@ import ( var WebSocketChannel = make(chan models.APIEvent, 100) var WebSocketChannelDone = make(chan bool) -var LISTENERS map[string]ConnectionInfo +var LISTENERS map[string]*ConnectionInfo func Init(cfg *config.Config) { - LISTENERS = make(map[string]ConnectionInfo) + LISTENERS = make(map[string]*ConnectionInfo) } func WelcomeAgents(ws *websocket.Conn, welcome WSWelcome, t string) { @@ -26,13 +26,13 @@ func WelcomeAgents(ws *websocket.Conn, welcome WSWelcome, t string) { ConnectionPS: ws, InitDate: time.Now(), } - LISTENERS[welcome.Hostname] = connectinfo + LISTENERS[welcome.Hostname] = &connectinfo } else if t == "rr" { connectinfo := ConnectionInfo{ ConnectionRR: ws, InitDate: time.Now(), } - LISTENERS[welcome.Hostname] = connectinfo + LISTENERS[welcome.Hostname] = &connectinfo } } else { if t == "ps" { diff --git a/src/ws/pubsub.go b/src/ws/pubsub.go index a65a5b5..eeb3b97 100644 --- a/src/ws/pubsub.go +++ b/src/ws/pubsub.go @@ -3,6 +3,7 @@ package ws import ( "encoding/json" "log" + "time" "git.paulbsd.com/paulbsd/ipbl/src/config" "github.com/labstack/echo/v4" @@ -19,7 +20,6 @@ func HandleWSPS(c echo.Context, cfg *config.Config) (err error) { err := websocket.Message.Receive(ws, &msg) if err != nil { log.Println(err) - return } err = json.Unmarshal(msg, &welcome) @@ -29,6 +29,15 @@ func HandleWSPS(c echo.Context, cfg *config.Config) (err error) { WelcomeAgents(ws, welcome, "ps") } + err = websocket.Message.Receive(ws, "OK") + if err != nil { + log.Println(err) + } + + for { + time.Sleep(50 * time.Millisecond) + } + /*for { var apievent, ok = <-WebSocketChannel if ok { @@ -39,7 +48,7 @@ func HandleWSPS(c echo.Context, cfg *config.Config) (err error) { } err = websocket.Message.Send(ws, data) if err != nil { - gcConn(ws, "ps") + //gcConn(ws, "ps") log.Println(LISTENERS) return } diff --git a/src/ws/reqrep.go b/src/ws/reqrep.go index 24cf8ea..9815040 100644 --- a/src/ws/reqrep.go +++ b/src/ws/reqrep.go @@ -20,7 +20,6 @@ func HandleWSRR(c echo.Context, cfg *config.Config) error { err := websocket.Message.Receive(ws, &msg) if err != nil { log.Println(err) - return } err = json.Unmarshal(msg, &welcome) @@ -35,12 +34,10 @@ func HandleWSRR(c echo.Context, cfg *config.Config) error { var msg []byte err := websocket.Message.Receive(ws, &msg) - log.Println(string(msg)) if err != nil { log.Println(err) return } - websocket.Message.Send(ws, "OK") err = json.Unmarshal(msg, &apievent) if err != nil { @@ -53,14 +50,14 @@ func HandleWSRR(c echo.Context, cfg *config.Config) error { switch apievent.MsgType { case "bootstrap": - for _, value := range LISTENERS { - err = websocket.Message.Send(value.ConnectionPS, msg) - if err != nil { - log.Println(err) + for index, value := range LISTENERS { + if index != apievent.Hostname { + err = websocket.Message.Send(value.ConnectionPS, msg) + if err != nil { + log.Println(err) + } } } - - log.Println(LISTENERS) case "add": session := cfg.Db.NewSession() event.APIParse(session, apievent) @@ -77,22 +74,33 @@ func HandleWSRR(c echo.Context, cfg *config.Config) error { log.Println(err) } } - log.Printf("websocket: Inserted event") - case "file": - apievent.MsgType = "ws" + log.Printf("ws: Inserted event") + case "init": + for _, value := range LISTENERS { + err = websocket.Message.Send(value.ConnectionPS, msg) + if err != nil { + log.Println(err) + } + } default: - log.Println("test") } - WebSocketChannel <- apievent - err = websocket.Message.Send(ws, "OK") if err != nil { - gcConn(ws, "rr") - log.Println(LISTENERS) - return + log.Println(err) } + /* + WebSocketChannel <- apievent + + err = websocket.Message.Send(ws, "OK") + if err != nil { + //gcConn(ws, "rr") + log.Println(LISTENERS) + return + } + */ + } }).ServeHTTP(c.Response(), c.Request()) return nil From abc02caf929de4de56fe2f1dd13f974a6ac364fc Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Sun, 9 Apr 2023 17:38:19 +0200 Subject: [PATCH 08/23] updated ipbl websocket feat --- src/models/cfg.go | 17 ----------------- src/routers/funcs.go | 6 +----- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/src/models/cfg.go b/src/models/cfg.go index 3cf8fc5..24370fa 100644 --- a/src/models/cfg.go +++ b/src/models/cfg.go @@ -94,15 +94,6 @@ func InsertOrUpdateSets(cfg config.Config, folders []CfgSet) (res string, err er return } -func GetZMQ(cfg config.Config) (res []CfgZMQ, err error) { - var w = []CfgZMQ{} - - if err = cfg.Db.Find(&w); err == nil { - return w, err - } - return -} - func GetWS(cfg config.Config) (res []CfgWS, err error) { var w = []CfgWS{} @@ -149,14 +140,6 @@ type CfgTrustlist struct { IP string `xorm:"text notnull" json:"ip"` } -type CfgZMQ struct { - ID int `xorm:"pk autoincr" json:"-"` - Type string `xorm:"text notnull" json:"type"` - Hostname string `xorm:"text notnull" json:"hostname"` - Port int `json:"port"` - Subscription string `json:"subscription"` -} - type CfgWS struct { ID int `xorm:"pk autoincr" json:"-"` Type string `xorm:"text notnull" json:"type"` diff --git a/src/routers/funcs.go b/src/routers/funcs.go index 835b76e..5fcb2fd 100644 --- a/src/routers/funcs.go +++ b/src/routers/funcs.go @@ -86,7 +86,7 @@ func RegisterRoutes(e *echo.Echo, ctx *context.Context, cfg *config.Config) { ips = append(ips, *ip) } numinsert, numupdate, _ := models.InsertIPBulk(session, &ips) - msg = fmt.Sprintf("zmq: Inserted %d IP, Updated %d IP", numinsert, numupdate) + msg = fmt.Sprintf("Inserted %d IP, Updated %d IP", numinsert, numupdate) log.Println(msg) return Result(c, err, msg) }) @@ -142,10 +142,6 @@ func RegisterRoutes(e *echo.Echo, ctx *context.Context, cfg *config.Config) { sets, err := models.GetSets(*cfg) return Result(c, err, sets) }) - e.GET("/config/zmq", func(c echo.Context) (err error) { - folders, err := models.GetZMQ(*cfg) - return Result(c, err, folders) - }) e.GET("/config/ws", func(c echo.Context) (err error) { folders, err := models.GetWS(*cfg) return Result(c, err, folders) From 447f7569221fa15f35fe44ba3a3181c09c6c0e62 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Mon, 10 Apr 2023 11:57:25 +0200 Subject: [PATCH 09/23] updated ipbl websocket feat --- src/routers/funcs.go | 2 -- src/ws/init.go | 18 +++++++++--------- src/ws/reqrep.go | 3 +++ 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/routers/funcs.go b/src/routers/funcs.go index 5fcb2fd..6524909 100644 --- a/src/routers/funcs.go +++ b/src/routers/funcs.go @@ -3,7 +3,6 @@ package routers import ( "context" "fmt" - "log" "net/http" "strconv" @@ -87,7 +86,6 @@ func RegisterRoutes(e *echo.Echo, ctx *context.Context, cfg *config.Config) { } numinsert, numupdate, _ := models.InsertIPBulk(session, &ips) msg = fmt.Sprintf("Inserted %d IP, Updated %d IP", numinsert, numupdate) - log.Println(msg) return Result(c, err, msg) }) e.POST("/event", func(c echo.Context) (err error) { diff --git a/src/ws/init.go b/src/ws/init.go index 6ffee2b..d58fb77 100644 --- a/src/ws/init.go +++ b/src/ws/init.go @@ -43,6 +43,15 @@ func WelcomeAgents(ws *websocket.Conn, welcome WSWelcome, t string) { } } +func gcConn(conn *websocket.Conn) (err error) { + for index, value := range LISTENERS { + if value.ConnectionPS == conn || value.ConnectionRR == conn { + delete(LISTENERS, index) + } + } + return err +} + type ConnectionInfo struct { ConnectionPS *websocket.Conn ConnectionRR *websocket.Conn @@ -52,12 +61,3 @@ type ConnectionInfo struct { type WSWelcome struct { Hostname string } - -func gcConn(conn *websocket.Conn, t string) (err error) { - for index, value := range LISTENERS { - if value.ConnectionPS == conn { - delete(LISTENERS, index) - } - } - return err -} diff --git a/src/ws/reqrep.go b/src/ws/reqrep.go index 9815040..bca8628 100644 --- a/src/ws/reqrep.go +++ b/src/ws/reqrep.go @@ -80,11 +80,14 @@ func HandleWSRR(c echo.Context, cfg *config.Config) error { err = websocket.Message.Send(value.ConnectionPS, msg) if err != nil { log.Println(err) + } } default: } + gcConn(ws) + err = websocket.Message.Send(ws, "OK") if err != nil { log.Println(err) From 8b617a8f9feb0d2a7c31f307f91232533ae17440 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Mon, 10 Apr 2023 12:04:40 +0200 Subject: [PATCH 10/23] fix: gcConn --- src/ws/reqrep.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ws/reqrep.go b/src/ws/reqrep.go index bca8628..f6f10b6 100644 --- a/src/ws/reqrep.go +++ b/src/ws/reqrep.go @@ -55,6 +55,7 @@ func HandleWSRR(c echo.Context, cfg *config.Config) error { err = websocket.Message.Send(value.ConnectionPS, msg) if err != nil { log.Println(err) + gcConn(ws) } } } @@ -72,6 +73,7 @@ func HandleWSRR(c echo.Context, cfg *config.Config) error { err = websocket.Message.Send(value.ConnectionPS, msg) if err != nil { log.Println(err) + gcConn(ws) } } log.Printf("ws: Inserted event") @@ -80,14 +82,12 @@ func HandleWSRR(c echo.Context, cfg *config.Config) error { err = websocket.Message.Send(value.ConnectionPS, msg) if err != nil { log.Println(err) - + gcConn(ws) } } default: } - gcConn(ws) - err = websocket.Message.Send(ws, "OK") if err != nil { log.Println(err) From 77919b208f49f92d4a1b2e43eb18fef051a70c75 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Mon, 10 Apr 2023 15:28:36 +0200 Subject: [PATCH 11/23] fix: gcConnOnError --- src/ws/init.go | 5 +++-- src/ws/reqrep.go | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ws/init.go b/src/ws/init.go index d58fb77..c71865a 100644 --- a/src/ws/init.go +++ b/src/ws/init.go @@ -43,9 +43,10 @@ func WelcomeAgents(ws *websocket.Conn, welcome WSWelcome, t string) { } } -func gcConn(conn *websocket.Conn) (err error) { +func gcConnOnError(ws *websocket.Conn) (err error) { for index, value := range LISTENERS { - if value.ConnectionPS == conn || value.ConnectionRR == conn { + if value.ConnectionPS == ws || value.ConnectionRR == ws { + ws.Close() delete(LISTENERS, index) } } diff --git a/src/ws/reqrep.go b/src/ws/reqrep.go index f6f10b6..0e4d300 100644 --- a/src/ws/reqrep.go +++ b/src/ws/reqrep.go @@ -50,12 +50,13 @@ func HandleWSRR(c echo.Context, cfg *config.Config) error { switch apievent.MsgType { case "bootstrap": + log.Printf("bootstrap: %s\n", apievent.Hostname) for index, value := range LISTENERS { if index != apievent.Hostname { err = websocket.Message.Send(value.ConnectionPS, msg) if err != nil { log.Println(err) - gcConn(ws) + gcConnOnError(ws) } } } @@ -73,7 +74,7 @@ func HandleWSRR(c echo.Context, cfg *config.Config) error { err = websocket.Message.Send(value.ConnectionPS, msg) if err != nil { log.Println(err) - gcConn(ws) + gcConnOnError(ws) } } log.Printf("ws: Inserted event") @@ -82,7 +83,7 @@ func HandleWSRR(c echo.Context, cfg *config.Config) error { err = websocket.Message.Send(value.ConnectionPS, msg) if err != nil { log.Println(err) - gcConn(ws) + gcConnOnError(ws) } } default: From 1802abe55329afc7c4d6eb1b2c60c8bda5d49816 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Mon, 10 Apr 2023 16:53:53 +0200 Subject: [PATCH 12/23] fix: gcConnOnError --- src/ws/init.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ws/init.go b/src/ws/init.go index c71865a..2202a40 100644 --- a/src/ws/init.go +++ b/src/ws/init.go @@ -46,7 +46,8 @@ func WelcomeAgents(ws *websocket.Conn, welcome WSWelcome, t string) { func gcConnOnError(ws *websocket.Conn) (err error) { for index, value := range LISTENERS { if value.ConnectionPS == ws || value.ConnectionRR == ws { - ws.Close() + value.ConnectionPS.Close() + value.ConnectionRR.Close() delete(LISTENERS, index) } } From b99badcb877a76c085df26f158425254f8cc16cc Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Mon, 10 Apr 2023 16:59:48 +0200 Subject: [PATCH 13/23] fix: tmp remove gcConnOnError --- src/ws/reqrep.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ws/reqrep.go b/src/ws/reqrep.go index 0e4d300..7a9b05c 100644 --- a/src/ws/reqrep.go +++ b/src/ws/reqrep.go @@ -56,7 +56,7 @@ func HandleWSRR(c echo.Context, cfg *config.Config) error { err = websocket.Message.Send(value.ConnectionPS, msg) if err != nil { log.Println(err) - gcConnOnError(ws) + //gcConnOnError(ws) } } } @@ -74,7 +74,7 @@ func HandleWSRR(c echo.Context, cfg *config.Config) error { err = websocket.Message.Send(value.ConnectionPS, msg) if err != nil { log.Println(err) - gcConnOnError(ws) + //gcConnOnError(ws) } } log.Printf("ws: Inserted event") @@ -83,7 +83,7 @@ func HandleWSRR(c echo.Context, cfg *config.Config) error { err = websocket.Message.Send(value.ConnectionPS, msg) if err != nil { log.Println(err) - gcConnOnError(ws) + //gcConnOnError(ws) } } default: From 5da8a5c9522edb45a340fc7a0955c7ae3b4ff727 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Mon, 10 Apr 2023 17:09:57 +0200 Subject: [PATCH 14/23] fix: re-added gcConnOnError, addcheck on send --- src/ws/reqrep.go | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/ws/reqrep.go b/src/ws/reqrep.go index 7a9b05c..5906aad 100644 --- a/src/ws/reqrep.go +++ b/src/ws/reqrep.go @@ -52,11 +52,11 @@ func HandleWSRR(c echo.Context, cfg *config.Config) error { case "bootstrap": log.Printf("bootstrap: %s\n", apievent.Hostname) for index, value := range LISTENERS { - if index != apievent.Hostname { + if index != apievent.Hostname && value.ConnectionPS != nil { err = websocket.Message.Send(value.ConnectionPS, msg) if err != nil { log.Println(err) - //gcConnOnError(ws) + gcConnOnError(ws) } } } @@ -71,19 +71,23 @@ func HandleWSRR(c echo.Context, cfg *config.Config) error { } for _, value := range LISTENERS { - err = websocket.Message.Send(value.ConnectionPS, msg) - if err != nil { - log.Println(err) - //gcConnOnError(ws) + if value.ConnectionPS != nil { + err = websocket.Message.Send(value.ConnectionPS, msg) + if err != nil { + log.Println(err) + gcConnOnError(ws) + } } } log.Printf("ws: Inserted event") case "init": for _, value := range LISTENERS { - err = websocket.Message.Send(value.ConnectionPS, msg) - if err != nil { - log.Println(err) - //gcConnOnError(ws) + if value.ConnectionPS != nil { + err = websocket.Message.Send(value.ConnectionPS, msg) + if err != nil { + log.Println(err) + gcConnOnError(ws) + } } } default: From 2ed127c23894a7389e9901f4df2805926d6faa92 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Mon, 10 Apr 2023 18:08:34 +0200 Subject: [PATCH 15/23] updated dependencies --- go.mod | 12 +-- go.sum | 23 ++--- vendor/github.com/goccy/go-json/CHANGELOG.md | 32 +++++++ .../goccy/go-json/internal/decoder/array.go | 4 +- .../goccy/go-json/internal/decoder/map.go | 2 +- .../goccy/go-json/internal/decoder/struct.go | 54 ++++++++---- .../goccy/go-json/internal/encoder/code.go | 20 +++-- .../go-json/internal/encoder/compiler.go | 9 +- .../goccy/go-json/internal/encoder/opcode.go | 83 +++++++++++++++++++ .../goccy/go-json/internal/encoder/option.go | 1 + .../go-json/internal/encoder/vm/debug_vm.go | 6 ++ .../internal/encoder/vm_color_indent/util.go | 7 +- .../internal/encoder/vm_indent/util.go | 7 +- vendor/github.com/goccy/go-json/option.go | 7 ++ vendor/golang.org/x/net/http2/pipe.go | 6 +- vendor/golang.org/x/net/http2/server.go | 7 +- vendor/golang.org/x/net/http2/transport.go | 11 +-- vendor/golang.org/x/sys/unix/ioctl_signed.go | 70 ++++++++++++++++ .../sys/unix/{ioctl.go => ioctl_unsigned.go} | 4 +- vendor/golang.org/x/sys/unix/ioctl_zos.go | 12 +-- vendor/golang.org/x/sys/unix/mkerrors.sh | 2 + vendor/golang.org/x/sys/unix/syscall_aix.go | 4 +- .../golang.org/x/sys/unix/syscall_aix_ppc.go | 1 - .../x/sys/unix/syscall_aix_ppc64.go | 1 - .../golang.org/x/sys/unix/syscall_darwin.go | 3 +- .../x/sys/unix/syscall_dragonfly.go | 1 - .../golang.org/x/sys/unix/syscall_freebsd.go | 1 - vendor/golang.org/x/sys/unix/syscall_linux.go | 10 ++- .../x/sys/unix/syscall_linux_386.go | 27 ------ .../x/sys/unix/syscall_linux_amd64.go | 1 - .../x/sys/unix/syscall_linux_arm.go | 27 ------ .../x/sys/unix/syscall_linux_arm64.go | 10 --- .../x/sys/unix/syscall_linux_loong64.go | 5 -- .../x/sys/unix/syscall_linux_mips64x.go | 1 - .../x/sys/unix/syscall_linux_mipsx.go | 27 ------ .../x/sys/unix/syscall_linux_ppc.go | 27 ------ .../x/sys/unix/syscall_linux_ppc64x.go | 1 - .../x/sys/unix/syscall_linux_riscv64.go | 1 - .../x/sys/unix/syscall_linux_s390x.go | 1 - .../x/sys/unix/syscall_linux_sparc64.go | 1 - .../golang.org/x/sys/unix/syscall_netbsd.go | 2 - .../golang.org/x/sys/unix/syscall_openbsd.go | 1 - .../golang.org/x/sys/unix/syscall_solaris.go | 21 +++-- vendor/golang.org/x/sys/unix/syscall_unix.go | 7 ++ .../x/sys/unix/syscall_zos_s390x.go | 4 +- .../x/sys/unix/zerrors_darwin_amd64.go | 19 +++++ .../x/sys/unix/zerrors_darwin_arm64.go | 19 +++++ .../golang.org/x/sys/unix/zsyscall_aix_ppc.go | 15 +--- .../x/sys/unix/zsyscall_aix_ppc64.go | 18 +--- .../x/sys/unix/zsyscall_aix_ppc64_gc.go | 10 --- .../x/sys/unix/zsyscall_aix_ppc64_gccgo.go | 10 +-- .../x/sys/unix/zsyscall_darwin_amd64.go | 39 +++++---- .../x/sys/unix/zsyscall_darwin_amd64.s | 11 ++- .../x/sys/unix/zsyscall_darwin_arm64.go | 39 +++++---- .../x/sys/unix/zsyscall_darwin_arm64.s | 11 ++- .../x/sys/unix/zsyscall_dragonfly_amd64.go | 10 --- .../x/sys/unix/zsyscall_freebsd_386.go | 10 --- .../x/sys/unix/zsyscall_freebsd_amd64.go | 10 --- .../x/sys/unix/zsyscall_freebsd_arm.go | 10 --- .../x/sys/unix/zsyscall_freebsd_arm64.go | 10 --- .../x/sys/unix/zsyscall_freebsd_riscv64.go | 10 --- .../golang.org/x/sys/unix/zsyscall_linux.go | 10 --- .../x/sys/unix/zsyscall_linux_386.go | 10 --- .../x/sys/unix/zsyscall_linux_amd64.go | 10 --- .../x/sys/unix/zsyscall_linux_arm.go | 10 --- .../x/sys/unix/zsyscall_linux_arm64.go | 10 --- .../x/sys/unix/zsyscall_linux_mips.go | 10 --- .../x/sys/unix/zsyscall_linux_mips64.go | 10 --- .../x/sys/unix/zsyscall_linux_mips64le.go | 10 --- .../x/sys/unix/zsyscall_linux_mipsle.go | 10 --- .../x/sys/unix/zsyscall_linux_ppc.go | 10 --- .../x/sys/unix/zsyscall_linux_ppc64.go | 10 --- .../x/sys/unix/zsyscall_linux_ppc64le.go | 10 --- .../x/sys/unix/zsyscall_linux_riscv64.go | 10 --- .../x/sys/unix/zsyscall_linux_s390x.go | 10 --- .../x/sys/unix/zsyscall_linux_sparc64.go | 10 --- .../x/sys/unix/zsyscall_netbsd_386.go | 10 --- .../x/sys/unix/zsyscall_netbsd_amd64.go | 10 --- .../x/sys/unix/zsyscall_netbsd_arm.go | 10 --- .../x/sys/unix/zsyscall_netbsd_arm64.go | 10 --- .../x/sys/unix/zsyscall_openbsd_386.go | 14 ---- .../x/sys/unix/zsyscall_openbsd_386.s | 5 -- .../x/sys/unix/zsyscall_openbsd_amd64.go | 14 ---- .../x/sys/unix/zsyscall_openbsd_amd64.s | 5 -- .../x/sys/unix/zsyscall_openbsd_arm.go | 14 ---- .../x/sys/unix/zsyscall_openbsd_arm.s | 5 -- .../x/sys/unix/zsyscall_openbsd_arm64.go | 14 ---- .../x/sys/unix/zsyscall_openbsd_arm64.s | 5 -- .../x/sys/unix/zsyscall_openbsd_mips64.go | 14 ---- .../x/sys/unix/zsyscall_openbsd_mips64.s | 5 -- .../x/sys/unix/zsyscall_openbsd_ppc64.go | 14 ---- .../x/sys/unix/zsyscall_openbsd_ppc64.s | 6 -- .../x/sys/unix/zsyscall_openbsd_riscv64.go | 14 ---- .../x/sys/unix/zsyscall_openbsd_riscv64.s | 5 -- .../x/sys/unix/zsyscall_solaris_amd64.go | 17 +--- .../x/sys/unix/zsyscall_zos_s390x.go | 4 +- .../x/sys/unix/ztypes_darwin_amd64.go | 11 +++ .../x/sys/unix/ztypes_darwin_arm64.go | 11 +++ vendor/modules.txt | 12 +-- 99 files changed, 478 insertions(+), 716 deletions(-) create mode 100644 vendor/golang.org/x/sys/unix/ioctl_signed.go rename vendor/golang.org/x/sys/unix/{ioctl.go => ioctl_unsigned.go} (92%) diff --git a/go.mod b/go.mod index 91097e9..4c76fa3 100644 --- a/go.mod +++ b/go.mod @@ -5,19 +5,19 @@ go 1.20 require ( github.com/labstack/echo/v4 v4.10.2 github.com/lib/pq v1.10.7 - golang.org/x/net v0.8.0 + golang.org/x/net v0.9.0 gopkg.in/ini.v1 v1.67.0 xorm.io/xorm v1.3.2 ) require ( - github.com/goccy/go-json v0.10.0 // indirect + github.com/goccy/go-json v0.10.2 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/labstack/gommon v0.4.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.17 // indirect + github.com/mattn/go-isatty v0.0.18 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/onsi/ginkgo v1.16.5 // indirect @@ -25,8 +25,8 @@ require ( github.com/syndtr/goleveldb v1.0.0 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasttemplate v1.2.2 // indirect - golang.org/x/crypto v0.7.0 // indirect - golang.org/x/sys v0.6.0 // indirect - golang.org/x/text v0.8.0 // indirect + golang.org/x/crypto v0.8.0 // indirect + golang.org/x/sys v0.7.0 // indirect + golang.org/x/text v0.9.0 // indirect xorm.io/builder v0.3.12 // indirect ) diff --git a/go.sum b/go.sum index 31beb0b..194fbdd 100644 --- a/go.sum +++ b/go.sum @@ -76,8 +76,8 @@ github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LB github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/goccy/go-json v0.8.1/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= -github.com/goccy/go-json v0.10.0 h1:mXKd9Qw4NuzShiRlOXKews24ufknHO7gx30lsDyokKA= -github.com/goccy/go-json v0.10.0/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= +github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= @@ -245,8 +245,8 @@ github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2y 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 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= -github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98= +github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-sqlite3 v1.14.9 h1:10HX2Td0ocZpYEjhilsuo6WWtUqttj2Kb0KtD86/KYA= github.com/mattn/go-sqlite3 v1.14.9/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= @@ -410,8 +410,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= +golang.org/x/crypto v0.8.0 h1:pd9TJtTueMTVQXzk8E2XESSMQDj/U7OUu0PqJqPXQjQ= +golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= @@ -441,8 +441,8 @@ golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM= +golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -488,8 +488,9 @@ golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= +golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -497,8 +498,8 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/vendor/github.com/goccy/go-json/CHANGELOG.md b/vendor/github.com/goccy/go-json/CHANGELOG.md index d63009f..d09bb89 100644 --- a/vendor/github.com/goccy/go-json/CHANGELOG.md +++ b/vendor/github.com/goccy/go-json/CHANGELOG.md @@ -1,3 +1,35 @@ +# v0.10.2 - 2023/03/20 + +### New features + +* Support DebugDOT option for debugging encoder ( #440 ) + +### Fix bugs + +* Fix combination of embedding structure and omitempty option ( #442 ) + +# v0.10.1 - 2023/03/13 + +### Fix bugs + +* Fix checkptr error for array decoder ( #415 ) +* Fix added buffer size check when decoding key ( #430 ) +* Fix handling of anonymous fields other than struct ( #431 ) +* Fix to not optimize when lower conversion can't handle byte-by-byte ( #432 ) +* Fix a problem that MarshalIndent does not work when UnorderedMap is specified ( #435 ) +* Fix mapDecoder.DecodeStream() for empty objects containing whitespace ( #425 ) +* Fix an issue that could not set the correct NextField for fields in the embedded structure ( #438 ) + +# v0.10.0 - 2022/11/29 + +### New features + +* Support JSON Path ( #250 ) + +### Fix bugs + +* Fix marshaler for map's key ( #409 ) + # v0.9.11 - 2022/08/18 ### Fix bugs diff --git a/vendor/github.com/goccy/go-json/internal/decoder/array.go b/vendor/github.com/goccy/go-json/internal/decoder/array.go index 8ef91cf..4b23ed4 100644 --- a/vendor/github.com/goccy/go-json/internal/decoder/array.go +++ b/vendor/github.com/goccy/go-json/internal/decoder/array.go @@ -19,7 +19,9 @@ type arrayDecoder struct { } func newArrayDecoder(dec Decoder, elemType *runtime.Type, alen int, structName, fieldName string) *arrayDecoder { - zeroValue := *(*unsafe.Pointer)(unsafe_New(elemType)) + // workaround to avoid checkptr errors. cannot use `*(*unsafe.Pointer)(unsafe_New(elemType))` directly. + zeroValuePtr := unsafe_New(elemType) + zeroValue := **(**unsafe.Pointer)(unsafe.Pointer(&zeroValuePtr)) return &arrayDecoder{ valueDecoder: dec, elemType: elemType, diff --git a/vendor/github.com/goccy/go-json/internal/decoder/map.go b/vendor/github.com/goccy/go-json/internal/decoder/map.go index 7a6eea3..07a9cae 100644 --- a/vendor/github.com/goccy/go-json/internal/decoder/map.go +++ b/vendor/github.com/goccy/go-json/internal/decoder/map.go @@ -88,7 +88,7 @@ func (d *mapDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) erro mapValue = makemap(d.mapType, 0) } s.cursor++ - if s.equalChar('}') { + if s.skipWhiteSpace() == '}' { *(*unsafe.Pointer)(p) = mapValue s.cursor++ return nil diff --git a/vendor/github.com/goccy/go-json/internal/decoder/struct.go b/vendor/github.com/goccy/go-json/internal/decoder/struct.go index 6d32654..313da15 100644 --- a/vendor/github.com/goccy/go-json/internal/decoder/struct.go +++ b/vendor/github.com/goccy/go-json/internal/decoder/struct.go @@ -51,6 +51,14 @@ func init() { } } +func toASCIILower(s string) string { + b := []byte(s) + for i := range b { + b[i] = largeToSmallTable[b[i]] + } + return string(b) +} + func newStructDecoder(structName, fieldName string, fieldMap map[string]*structFieldSet) *structDecoder { return &structDecoder{ fieldMap: fieldMap, @@ -91,6 +99,10 @@ func (d *structDecoder) tryOptimize() { for k, v := range d.fieldMap { key := strings.ToLower(k) if key != k { + if key != toASCIILower(k) { + d.isTriedOptimize = true + return + } // already exists same key (e.g. Hello and HELLO has same lower case key if _, exists := conflicted[key]; exists { d.isTriedOptimize = true @@ -158,49 +170,53 @@ func (d *structDecoder) tryOptimize() { } // decode from '\uXXXX' -func decodeKeyCharByUnicodeRune(buf []byte, cursor int64) ([]byte, int64) { +func decodeKeyCharByUnicodeRune(buf []byte, cursor int64) ([]byte, int64, error) { const defaultOffset = 4 const surrogateOffset = 6 + if cursor+defaultOffset >= int64(len(buf)) { + return nil, 0, errors.ErrUnexpectedEndOfJSON("escaped string", cursor) + } + r := unicodeToRune(buf[cursor : cursor+defaultOffset]) if utf16.IsSurrogate(r) { cursor += defaultOffset if cursor+surrogateOffset >= int64(len(buf)) || buf[cursor] != '\\' || buf[cursor+1] != 'u' { - return []byte(string(unicode.ReplacementChar)), cursor + defaultOffset - 1 + return []byte(string(unicode.ReplacementChar)), cursor + defaultOffset - 1, nil } cursor += 2 r2 := unicodeToRune(buf[cursor : cursor+defaultOffset]) if r := utf16.DecodeRune(r, r2); r != unicode.ReplacementChar { - return []byte(string(r)), cursor + defaultOffset - 1 + return []byte(string(r)), cursor + defaultOffset - 1, nil } } - return []byte(string(r)), cursor + defaultOffset - 1 + return []byte(string(r)), cursor + defaultOffset - 1, nil } -func decodeKeyCharByEscapedChar(buf []byte, cursor int64) ([]byte, int64) { +func decodeKeyCharByEscapedChar(buf []byte, cursor int64) ([]byte, int64, error) { c := buf[cursor] cursor++ switch c { case '"': - return []byte{'"'}, cursor + return []byte{'"'}, cursor, nil case '\\': - return []byte{'\\'}, cursor + return []byte{'\\'}, cursor, nil case '/': - return []byte{'/'}, cursor + return []byte{'/'}, cursor, nil case 'b': - return []byte{'\b'}, cursor + return []byte{'\b'}, cursor, nil case 'f': - return []byte{'\f'}, cursor + return []byte{'\f'}, cursor, nil case 'n': - return []byte{'\n'}, cursor + return []byte{'\n'}, cursor, nil case 'r': - return []byte{'\r'}, cursor + return []byte{'\r'}, cursor, nil case 't': - return []byte{'\t'}, cursor + return []byte{'\t'}, cursor, nil case 'u': return decodeKeyCharByUnicodeRune(buf, cursor) } - return nil, cursor + return nil, cursor, nil } func decodeKeyByBitmapUint8(d *structDecoder, buf []byte, cursor int64) (int64, *structFieldSet, error) { @@ -242,7 +258,10 @@ func decodeKeyByBitmapUint8(d *structDecoder, buf []byte, cursor int64) (int64, return 0, nil, errors.ErrUnexpectedEndOfJSON("string", cursor) case '\\': cursor++ - chars, nextCursor := decodeKeyCharByEscapedChar(buf, cursor) + chars, nextCursor, err := decodeKeyCharByEscapedChar(buf, cursor) + if err != nil { + return 0, nil, err + } for _, c := range chars { curBit &= bitmap[keyIdx][largeToSmallTable[c]] if curBit == 0 { @@ -305,7 +324,10 @@ func decodeKeyByBitmapUint16(d *structDecoder, buf []byte, cursor int64) (int64, return 0, nil, errors.ErrUnexpectedEndOfJSON("string", cursor) case '\\': cursor++ - chars, nextCursor := decodeKeyCharByEscapedChar(buf, cursor) + chars, nextCursor, err := decodeKeyCharByEscapedChar(buf, cursor) + if err != nil { + return 0, nil, err + } for _, c := range chars { curBit &= bitmap[keyIdx][largeToSmallTable[c]] if curBit == 0 { diff --git a/vendor/github.com/goccy/go-json/internal/encoder/code.go b/vendor/github.com/goccy/go-json/internal/encoder/code.go index 8d62a9c..5b08fae 100644 --- a/vendor/github.com/goccy/go-json/internal/encoder/code.go +++ b/vendor/github.com/goccy/go-json/internal/encoder/code.go @@ -397,7 +397,10 @@ func (c *StructCode) lastFieldCode(field *StructFieldCode, firstField *Opcode) * func (c *StructCode) lastAnonymousFieldCode(firstField *Opcode) *Opcode { // firstField is special StructHead operation for anonymous structure. // So, StructHead's next operation is truly struct head operation. - lastField := firstField.Next + for firstField.Op == OpStructHead || firstField.Op == OpStructField { + firstField = firstField.Next + } + lastField := firstField for lastField.NextField != nil { lastField = lastField.NextField } @@ -437,11 +440,6 @@ func (c *StructCode) ToOpcode(ctx *compileContext) Opcodes { } if isEndField { endField := fieldCodes.Last() - if isEmbeddedStruct(field) { - firstField.End = endField - lastField := c.lastAnonymousFieldCode(firstField) - lastField.NextField = endField - } if len(codes) > 0 { codes.First().End = endField } else { @@ -698,7 +696,15 @@ func (c *StructFieldCode) addStructEndCode(ctx *compileContext, codes Opcodes) O Indent: ctx.indent, } codes.Last().Next = end - codes.First().NextField = end + code := codes.First() + for code.Op == OpStructField || code.Op == OpStructHead { + code = code.Next + } + for code.NextField != nil { + code = code.NextField + } + code.NextField = end + codes = codes.Add(end) ctx.incOpcodeIndex() return codes diff --git a/vendor/github.com/goccy/go-json/internal/encoder/compiler.go b/vendor/github.com/goccy/go-json/internal/encoder/compiler.go index 3b3ff3f..3ae39ba 100644 --- a/vendor/github.com/goccy/go-json/internal/encoder/compiler.go +++ b/vendor/github.com/goccy/go-json/internal/encoder/compiler.go @@ -617,6 +617,13 @@ func (c *Compiler) structCode(typ *runtime.Type, isPtr bool) (*StructCode, error return code, nil } +func toElemType(t *runtime.Type) *runtime.Type { + for t.Kind() == reflect.Ptr { + t = t.Elem() + } + return t +} + func (c *Compiler) structFieldCode(structCode *StructCode, tag *runtime.StructTag, isPtr, isOnlyOneFirstField bool) (*StructFieldCode, error) { field := tag.Field fieldType := runtime.Type2RType(field.Type) @@ -626,7 +633,7 @@ func (c *Compiler) structFieldCode(structCode *StructCode, tag *runtime.StructTa key: tag.Key, tag: tag, offset: field.Offset, - isAnonymous: field.Anonymous && !tag.IsTaggedKey, + isAnonymous: field.Anonymous && !tag.IsTaggedKey && toElemType(fieldType).Kind() == reflect.Struct, isTaggedKey: tag.IsTaggedKey, isNilableType: c.isNilableType(fieldType), isNilCheck: true, diff --git a/vendor/github.com/goccy/go-json/internal/encoder/opcode.go b/vendor/github.com/goccy/go-json/internal/encoder/opcode.go index 05fc3ce..df22f55 100644 --- a/vendor/github.com/goccy/go-json/internal/encoder/opcode.go +++ b/vendor/github.com/goccy/go-json/internal/encoder/opcode.go @@ -1,7 +1,9 @@ package encoder import ( + "bytes" "fmt" + "sort" "strings" "unsafe" @@ -555,6 +557,87 @@ func (c *Opcode) Dump() string { return strings.Join(codes, "\n") } +func (c *Opcode) DumpDOT() string { + type edge struct { + from, to *Opcode + label string + weight int + } + var edges []edge + + b := &bytes.Buffer{} + fmt.Fprintf(b, "digraph \"%p\" {\n", c.Type) + fmt.Fprintln(b, "mclimit=1.5;\nrankdir=TD;\nordering=out;\nnode[shape=box];") + for code := c; !code.IsEnd(); { + label := code.Op.String() + fmt.Fprintf(b, "\"%p\" [label=%q];\n", code, label) + if p := code.Next; p != nil { + edges = append(edges, edge{ + from: code, + to: p, + label: "Next", + weight: 10, + }) + } + if p := code.NextField; p != nil { + edges = append(edges, edge{ + from: code, + to: p, + label: "NextField", + weight: 2, + }) + } + if p := code.End; p != nil { + edges = append(edges, edge{ + from: code, + to: p, + label: "End", + weight: 1, + }) + } + if p := code.Jmp; p != nil { + edges = append(edges, edge{ + from: code, + to: p.Code, + label: "Jmp", + weight: 1, + }) + } + + switch code.Op.CodeType() { + case CodeSliceHead: + code = code.Next + case CodeMapHead: + code = code.Next + case CodeArrayElem, CodeSliceElem: + code = code.End + case CodeMapKey: + code = code.End + case CodeMapValue: + code = code.Next + case CodeMapEnd: + code = code.Next + case CodeStructField: + code = code.Next + case CodeStructEnd: + code = code.Next + default: + code = code.Next + } + if code.IsEnd() { + fmt.Fprintf(b, "\"%p\" [label=%q];\n", code, code.Op.String()) + } + } + sort.Slice(edges, func(i, j int) bool { + return edges[i].to.DisplayIdx < edges[j].to.DisplayIdx + }) + for _, e := range edges { + fmt.Fprintf(b, "\"%p\" -> \"%p\" [label=%q][weight=%d];\n", e.from, e.to, e.label, e.weight) + } + fmt.Fprint(b, "}") + return b.String() +} + func newSliceHeaderCode(ctx *compileContext, typ *runtime.Type) *Opcode { idx := opcodeOffset(ctx.ptrIndex) ctx.incPtrIndex() diff --git a/vendor/github.com/goccy/go-json/internal/encoder/option.go b/vendor/github.com/goccy/go-json/internal/encoder/option.go index 82d5ce3..12c58e4 100644 --- a/vendor/github.com/goccy/go-json/internal/encoder/option.go +++ b/vendor/github.com/goccy/go-json/internal/encoder/option.go @@ -23,6 +23,7 @@ type Option struct { ColorScheme *ColorScheme Context context.Context DebugOut io.Writer + DebugDOTOut io.WriteCloser } type EncodeFormat struct { diff --git a/vendor/github.com/goccy/go-json/internal/encoder/vm/debug_vm.go b/vendor/github.com/goccy/go-json/internal/encoder/vm/debug_vm.go index fbbc0de..82b6dd4 100644 --- a/vendor/github.com/goccy/go-json/internal/encoder/vm/debug_vm.go +++ b/vendor/github.com/goccy/go-json/internal/encoder/vm/debug_vm.go @@ -2,6 +2,7 @@ package vm import ( "fmt" + "io" "github.com/goccy/go-json/internal/encoder" ) @@ -14,6 +15,11 @@ func DebugRun(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) } else { code = codeSet.NoescapeKeyCode } + if wc := ctx.Option.DebugDOTOut; wc != nil { + _, _ = io.WriteString(wc, code.DumpDOT()) + wc.Close() + ctx.Option.DebugDOTOut = nil + } if err := recover(); err != nil { w := ctx.Option.DebugOut diff --git a/vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/util.go b/vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/util.go index 60e4a8e..2395abe 100644 --- a/vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/util.go +++ b/vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/util.go @@ -189,7 +189,7 @@ func appendNullComma(ctx *encoder.RuntimeContext, b []byte) []byte { } func appendColon(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, ':', ' ') + return append(b[:len(b)-2], ':', ' ') } func appendMapKeyValue(ctx *encoder.RuntimeContext, code *encoder.Opcode, b, key, value []byte) []byte { @@ -229,8 +229,9 @@ func appendEmptyObject(_ *encoder.RuntimeContext, b []byte) []byte { func appendObjectEnd(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { last := len(b) - 1 - b[last] = '\n' - b = appendIndent(ctx, b, code.Indent-1) + // replace comma to newline + b[last-1] = '\n' + b = appendIndent(ctx, b[:last], code.Indent) return append(b, '}', ',', '\n') } diff --git a/vendor/github.com/goccy/go-json/internal/encoder/vm_indent/util.go b/vendor/github.com/goccy/go-json/internal/encoder/vm_indent/util.go index fca8f18..6cb745e 100644 --- a/vendor/github.com/goccy/go-json/internal/encoder/vm_indent/util.go +++ b/vendor/github.com/goccy/go-json/internal/encoder/vm_indent/util.go @@ -133,7 +133,7 @@ func appendNullComma(_ *encoder.RuntimeContext, b []byte) []byte { } func appendColon(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, ':', ' ') + return append(b[:len(b)-2], ':', ' ') } func appendMapKeyValue(ctx *encoder.RuntimeContext, code *encoder.Opcode, b, key, value []byte) []byte { @@ -173,8 +173,9 @@ func appendEmptyObject(_ *encoder.RuntimeContext, b []byte) []byte { func appendObjectEnd(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { last := len(b) - 1 - b[last] = '\n' - b = appendIndent(ctx, b, code.Indent-1) + // replace comma to newline + b[last-1] = '\n' + b = appendIndent(ctx, b[:last], code.Indent) return append(b, '}', ',', '\n') } diff --git a/vendor/github.com/goccy/go-json/option.go b/vendor/github.com/goccy/go-json/option.go index af400a4..378031a 100644 --- a/vendor/github.com/goccy/go-json/option.go +++ b/vendor/github.com/goccy/go-json/option.go @@ -48,6 +48,13 @@ func DebugWith(w io.Writer) EncodeOptionFunc { } } +// DebugDOT sets the destination to write opcodes graph. +func DebugDOT(w io.WriteCloser) EncodeOptionFunc { + return func(opt *EncodeOption) { + opt.DebugDOTOut = w + } +} + // Colorize add an identifier for coloring to the string of the encoded result. func Colorize(scheme *ColorScheme) EncodeOptionFunc { return func(opt *EncodeOption) { diff --git a/vendor/golang.org/x/net/http2/pipe.go b/vendor/golang.org/x/net/http2/pipe.go index c15b8a7..684d984 100644 --- a/vendor/golang.org/x/net/http2/pipe.go +++ b/vendor/golang.org/x/net/http2/pipe.go @@ -88,13 +88,9 @@ func (p *pipe) Write(d []byte) (n int, err error) { p.c.L = &p.mu } defer p.c.Signal() - if p.err != nil { + if p.err != nil || p.breakErr != nil { return 0, errClosedPipeWrite } - if p.breakErr != nil { - p.unread += len(d) - return len(d), nil // discard when there is no reader - } return p.b.Write(d) } diff --git a/vendor/golang.org/x/net/http2/server.go b/vendor/golang.org/x/net/http2/server.go index 8cb14f3..cd057f3 100644 --- a/vendor/golang.org/x/net/http2/server.go +++ b/vendor/golang.org/x/net/http2/server.go @@ -1822,15 +1822,18 @@ func (sc *serverConn) processData(f *DataFrame) error { } if len(data) > 0 { + st.bodyBytes += int64(len(data)) wrote, err := st.body.Write(data) if err != nil { + // The handler has closed the request body. + // Return the connection-level flow control for the discarded data, + // but not the stream-level flow control. sc.sendWindowUpdate(nil, int(f.Length)-wrote) - return sc.countError("body_write_err", streamError(id, ErrCodeStreamClosed)) + return nil } if wrote != len(data) { panic("internal error: bad Writer") } - st.bodyBytes += int64(len(data)) } // Return any padded flow control now, since we won't diff --git a/vendor/golang.org/x/net/http2/transport.go b/vendor/golang.org/x/net/http2/transport.go index 05ba23d..f965579 100644 --- a/vendor/golang.org/x/net/http2/transport.go +++ b/vendor/golang.org/x/net/http2/transport.go @@ -560,10 +560,11 @@ func (t *Transport) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Res traceGotConn(req, cc, reused) res, err := cc.RoundTrip(req) if err != nil && retry <= 6 { + roundTripErr := err if req, err = shouldRetryRequest(req, err); err == nil { // After the first retry, do exponential backoff with 10% jitter. if retry == 0 { - t.vlogf("RoundTrip retrying after failure: %v", err) + t.vlogf("RoundTrip retrying after failure: %v", roundTripErr) continue } backoff := float64(uint(1) << (uint(retry) - 1)) @@ -572,7 +573,7 @@ func (t *Transport) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Res timer := backoffNewTimer(d) select { case <-timer.C: - t.vlogf("RoundTrip retrying after failure: %v", err) + t.vlogf("RoundTrip retrying after failure: %v", roundTripErr) continue case <-req.Context().Done(): timer.Stop() @@ -2555,6 +2556,9 @@ func (b transportResponseBody) Close() error { cs := b.cs cc := cs.cc + cs.bufPipe.BreakWithError(errClosedResponseBody) + cs.abortStream(errClosedResponseBody) + unread := cs.bufPipe.Len() if unread > 0 { cc.mu.Lock() @@ -2573,9 +2577,6 @@ func (b transportResponseBody) Close() error { cc.wmu.Unlock() } - cs.bufPipe.BreakWithError(errClosedResponseBody) - cs.abortStream(errClosedResponseBody) - select { case <-cs.donec: case <-cs.ctx.Done(): diff --git a/vendor/golang.org/x/sys/unix/ioctl_signed.go b/vendor/golang.org/x/sys/unix/ioctl_signed.go new file mode 100644 index 0000000..7def958 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ioctl_signed.go @@ -0,0 +1,70 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build aix || solaris +// +build aix solaris + +package unix + +import ( + "unsafe" +) + +// ioctl itself should not be exposed directly, but additional get/set +// functions for specific types are permissible. + +// IoctlSetInt performs an ioctl operation which sets an integer value +// on fd, using the specified request number. +func IoctlSetInt(fd int, req int, value int) error { + return ioctl(fd, req, uintptr(value)) +} + +// IoctlSetPointerInt performs an ioctl operation which sets an +// integer value on fd, using the specified request number. The ioctl +// argument is called with a pointer to the integer value, rather than +// passing the integer value directly. +func IoctlSetPointerInt(fd int, req int, value int) error { + v := int32(value) + return ioctlPtr(fd, req, unsafe.Pointer(&v)) +} + +// IoctlSetWinsize performs an ioctl on fd with a *Winsize argument. +// +// To change fd's window size, the req argument should be TIOCSWINSZ. +func IoctlSetWinsize(fd int, req int, value *Winsize) error { + // TODO: if we get the chance, remove the req parameter and + // hardcode TIOCSWINSZ. + return ioctlPtr(fd, req, unsafe.Pointer(value)) +} + +// IoctlSetTermios performs an ioctl on fd with a *Termios. +// +// The req value will usually be TCSETA or TIOCSETA. +func IoctlSetTermios(fd int, req int, value *Termios) error { + // TODO: if we get the chance, remove the req parameter. + return ioctlPtr(fd, req, unsafe.Pointer(value)) +} + +// IoctlGetInt performs an ioctl operation which gets an integer value +// from fd, using the specified request number. +// +// A few ioctl requests use the return value as an output parameter; +// for those, IoctlRetInt should be used instead of this function. +func IoctlGetInt(fd int, req int) (int, error) { + var value int + err := ioctlPtr(fd, req, unsafe.Pointer(&value)) + return value, err +} + +func IoctlGetWinsize(fd int, req int) (*Winsize, error) { + var value Winsize + err := ioctlPtr(fd, req, unsafe.Pointer(&value)) + return &value, err +} + +func IoctlGetTermios(fd int, req int) (*Termios, error) { + var value Termios + err := ioctlPtr(fd, req, unsafe.Pointer(&value)) + return &value, err +} diff --git a/vendor/golang.org/x/sys/unix/ioctl.go b/vendor/golang.org/x/sys/unix/ioctl_unsigned.go similarity index 92% rename from vendor/golang.org/x/sys/unix/ioctl.go rename to vendor/golang.org/x/sys/unix/ioctl_unsigned.go index 7ce8dd4..649913d 100644 --- a/vendor/golang.org/x/sys/unix/ioctl.go +++ b/vendor/golang.org/x/sys/unix/ioctl_unsigned.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build aix || darwin || dragonfly || freebsd || hurd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd hurd linux netbsd openbsd solaris +//go:build darwin || dragonfly || freebsd || hurd || linux || netbsd || openbsd +// +build darwin dragonfly freebsd hurd linux netbsd openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/ioctl_zos.go b/vendor/golang.org/x/sys/unix/ioctl_zos.go index 6532f09..cdc21bf 100644 --- a/vendor/golang.org/x/sys/unix/ioctl_zos.go +++ b/vendor/golang.org/x/sys/unix/ioctl_zos.go @@ -17,14 +17,14 @@ import ( // IoctlSetInt performs an ioctl operation which sets an integer value // on fd, using the specified request number. -func IoctlSetInt(fd int, req uint, value int) error { +func IoctlSetInt(fd int, req int, value int) error { return ioctl(fd, req, uintptr(value)) } // IoctlSetWinsize performs an ioctl on fd with a *Winsize argument. // // To change fd's window size, the req argument should be TIOCSWINSZ. -func IoctlSetWinsize(fd int, req uint, value *Winsize) error { +func IoctlSetWinsize(fd int, req int, value *Winsize) error { // TODO: if we get the chance, remove the req parameter and // hardcode TIOCSWINSZ. return ioctlPtr(fd, req, unsafe.Pointer(value)) @@ -33,7 +33,7 @@ func IoctlSetWinsize(fd int, req uint, value *Winsize) error { // IoctlSetTermios performs an ioctl on fd with a *Termios. // // The req value is expected to be TCSETS, TCSETSW, or TCSETSF -func IoctlSetTermios(fd int, req uint, value *Termios) error { +func IoctlSetTermios(fd int, req int, value *Termios) error { if (req != TCSETS) && (req != TCSETSW) && (req != TCSETSF) { return ENOSYS } @@ -47,13 +47,13 @@ func IoctlSetTermios(fd int, req uint, value *Termios) error { // // A few ioctl requests use the return value as an output parameter; // for those, IoctlRetInt should be used instead of this function. -func IoctlGetInt(fd int, req uint) (int, error) { +func IoctlGetInt(fd int, req int) (int, error) { var value int err := ioctlPtr(fd, req, unsafe.Pointer(&value)) return value, err } -func IoctlGetWinsize(fd int, req uint) (*Winsize, error) { +func IoctlGetWinsize(fd int, req int) (*Winsize, error) { var value Winsize err := ioctlPtr(fd, req, unsafe.Pointer(&value)) return &value, err @@ -62,7 +62,7 @@ func IoctlGetWinsize(fd int, req uint) (*Winsize, error) { // IoctlGetTermios performs an ioctl on fd with a *Termios. // // The req value is expected to be TCGETS -func IoctlGetTermios(fd int, req uint) (*Termios, error) { +func IoctlGetTermios(fd int, req int) (*Termios, error) { var value Termios if req != TCGETS { return &value, ENOSYS diff --git a/vendor/golang.org/x/sys/unix/mkerrors.sh b/vendor/golang.org/x/sys/unix/mkerrors.sh index 7456d9d..2045d3d 100644 --- a/vendor/golang.org/x/sys/unix/mkerrors.sh +++ b/vendor/golang.org/x/sys/unix/mkerrors.sh @@ -66,6 +66,7 @@ includes_Darwin=' #include #include #include +#include #include #include #include @@ -521,6 +522,7 @@ ccflags="$@" $2 ~ /^NFC_(GENL|PROTO|COMM|RF|SE|DIRECTION|LLCP|SOCKPROTO)_/ || $2 ~ /^NFC_.*_(MAX)?SIZE$/ || $2 ~ /^RAW_PAYLOAD_/ || + $2 ~ /^[US]F_/ || $2 ~ /^TP_STATUS_/ || $2 ~ /^FALLOC_/ || $2 ~ /^ICMPV?6?_(FILTER|SEC)/ || diff --git a/vendor/golang.org/x/sys/unix/syscall_aix.go b/vendor/golang.org/x/sys/unix/syscall_aix.go index d9f5544..c406ae0 100644 --- a/vendor/golang.org/x/sys/unix/syscall_aix.go +++ b/vendor/golang.org/x/sys/unix/syscall_aix.go @@ -408,8 +408,8 @@ func (w WaitStatus) CoreDump() bool { return w&0x80 == 0x80 } func (w WaitStatus) TrapCause() int { return -1 } -//sys ioctl(fd int, req uint, arg uintptr) (err error) -//sys ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) = ioctl +//sys ioctl(fd int, req int, arg uintptr) (err error) +//sys ioctlPtr(fd int, req int, arg unsafe.Pointer) (err error) = ioctl // fcntl must never be called with cmd=F_DUP2FD because it doesn't work on AIX // There is no way to create a custom fcntl and to keep //sys fcntl easily, diff --git a/vendor/golang.org/x/sys/unix/syscall_aix_ppc.go b/vendor/golang.org/x/sys/unix/syscall_aix_ppc.go index e92a0be..f2871fa 100644 --- a/vendor/golang.org/x/sys/unix/syscall_aix_ppc.go +++ b/vendor/golang.org/x/sys/unix/syscall_aix_ppc.go @@ -8,7 +8,6 @@ package unix //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) = getrlimit64 -//sysnb Setrlimit(resource int, rlim *Rlimit) (err error) = setrlimit64 //sys Seek(fd int, offset int64, whence int) (off int64, err error) = lseek64 //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_aix_ppc64.go b/vendor/golang.org/x/sys/unix/syscall_aix_ppc64.go index 16eed17..75718ec 100644 --- a/vendor/golang.org/x/sys/unix/syscall_aix_ppc64.go +++ b/vendor/golang.org/x/sys/unix/syscall_aix_ppc64.go @@ -8,7 +8,6 @@ package unix //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) -//sysnb Setrlimit(resource int, rlim *Rlimit) (err error) //sys Seek(fd int, offset int64, whence int) (off int64, err error) = lseek //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) = mmap64 diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin.go b/vendor/golang.org/x/sys/unix/syscall_darwin.go index 7064d6e..2069215 100644 --- a/vendor/golang.org/x/sys/unix/syscall_darwin.go +++ b/vendor/golang.org/x/sys/unix/syscall_darwin.go @@ -613,6 +613,7 @@ func SysctlKinfoProcSlice(name string, args ...int) ([]KinfoProc, error) { //sys Rmdir(path string) (err error) //sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) +//sys Setattrlist(path string, attrlist *Attrlist, attrBuf []byte, options int) (err error) //sys Setegid(egid int) (err error) //sysnb Seteuid(euid int) (err error) //sysnb Setgid(gid int) (err error) @@ -622,7 +623,6 @@ func SysctlKinfoProcSlice(name string, args ...int) ([]KinfoProc, error) { //sys Setprivexec(flag int) (err error) //sysnb Setregid(rgid int, egid int) (err error) //sysnb Setreuid(ruid int, euid int) (err error) -//sysnb Setrlimit(which int, lim *Rlimit) (err error) //sysnb Setsid() (pid int, err error) //sysnb Settimeofday(tp *Timeval) (err error) //sysnb Setuid(uid int) (err error) @@ -676,7 +676,6 @@ func SysctlKinfoProcSlice(name string, args ...int) ([]KinfoProc, error) { // Kqueue_from_portset_np // Kqueue_portset // Getattrlist -// Setattrlist // Getdirentriesattr // Searchfs // Delete diff --git a/vendor/golang.org/x/sys/unix/syscall_dragonfly.go b/vendor/golang.org/x/sys/unix/syscall_dragonfly.go index 221efc2..d4ce988 100644 --- a/vendor/golang.org/x/sys/unix/syscall_dragonfly.go +++ b/vendor/golang.org/x/sys/unix/syscall_dragonfly.go @@ -326,7 +326,6 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e //sysnb Setreuid(ruid int, euid int) (err error) //sysnb Setresgid(rgid int, egid int, sgid int) (err error) //sysnb Setresuid(ruid int, euid int, suid int) (err error) -//sysnb Setrlimit(which int, lim *Rlimit) (err error) //sysnb Setsid() (pid int, err error) //sysnb Settimeofday(tp *Timeval) (err error) //sysnb Setuid(uid int) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd.go b/vendor/golang.org/x/sys/unix/syscall_freebsd.go index 5bdde03..afb1010 100644 --- a/vendor/golang.org/x/sys/unix/syscall_freebsd.go +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd.go @@ -433,7 +433,6 @@ func Dup3(oldfd, newfd, flags int) error { //sysnb Setreuid(ruid int, euid int) (err error) //sysnb Setresgid(rgid int, egid int, sgid int) (err error) //sysnb Setresuid(ruid int, euid int, suid int) (err error) -//sysnb Setrlimit(which int, lim *Rlimit) (err error) //sysnb Setsid() (pid int, err error) //sysnb Settimeofday(tp *Timeval) (err error) //sysnb Setuid(uid int) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux.go b/vendor/golang.org/x/sys/unix/syscall_linux.go index 9735331..fbaeb5f 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux.go @@ -1873,7 +1873,6 @@ func Getpgrp() (pid int) { //sys OpenTree(dfd int, fileName string, flags uint) (r int, err error) //sys PerfEventOpen(attr *PerfEventAttr, pid int, cpu int, groupFd int, flags int) (fd int, err error) //sys PivotRoot(newroot string, putold string) (err error) = SYS_PIVOT_ROOT -//sysnb Prlimit(pid int, resource int, newlimit *Rlimit, old *Rlimit) (err error) = SYS_PRLIMIT64 //sys Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) //sys Pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *Sigset_t) (n int, err error) = SYS_PSELECT6 //sys read(fd int, p []byte) (n int, err error) @@ -1887,6 +1886,15 @@ func Getpgrp() (pid int) { //sysnb Settimeofday(tv *Timeval) (err error) //sys Setns(fd int, nstype int) (err error) +//go:linkname syscall_prlimit syscall.prlimit +func syscall_prlimit(pid, resource int, newlimit, old *syscall.Rlimit) error + +func Prlimit(pid, resource int, newlimit, old *Rlimit) error { + // Just call the syscall version, because as of Go 1.21 + // it will affect starting a new process. + return syscall_prlimit(pid, resource, (*syscall.Rlimit)(newlimit), (*syscall.Rlimit)(old)) +} + // PrctlRetInt performs a prctl operation specified by option and further // optional arguments arg2 through arg5 depending on option. It returns a // non-negative integer that is returned by the prctl syscall. diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_386.go b/vendor/golang.org/x/sys/unix/syscall_linux_386.go index ff5b589..c7d9945 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_386.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_386.go @@ -97,33 +97,6 @@ func Getrlimit(resource int, rlim *Rlimit) (err error) { return } -//sysnb setrlimit(resource int, rlim *rlimit32) (err error) = SYS_SETRLIMIT - -func Setrlimit(resource int, rlim *Rlimit) (err error) { - err = Prlimit(0, resource, rlim, nil) - if err != ENOSYS { - return err - } - - rl := rlimit32{} - if rlim.Cur == rlimInf64 { - rl.Cur = rlimInf32 - } else if rlim.Cur < uint64(rlimInf32) { - rl.Cur = uint32(rlim.Cur) - } else { - return EINVAL - } - if rlim.Max == rlimInf64 { - rl.Max = rlimInf32 - } else if rlim.Max < uint64(rlimInf32) { - rl.Max = uint32(rlim.Max) - } else { - return EINVAL - } - - return setrlimit(resource, &rl) -} - func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { newoffset, errno := seek(fd, offset, whence) if errno != 0 { diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go b/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go index 9b27035..5b21fcf 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go @@ -46,7 +46,6 @@ func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) //sys setfsgid(gid int) (prev int, err error) //sys setfsuid(uid int) (prev int, err error) -//sysnb Setrlimit(resource int, rlim *Rlimit) (err error) //sys Shutdown(fd int, how int) (err error) //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_arm.go b/vendor/golang.org/x/sys/unix/syscall_linux_arm.go index 856ad1d..da29864 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_arm.go @@ -171,33 +171,6 @@ func Getrlimit(resource int, rlim *Rlimit) (err error) { return } -//sysnb setrlimit(resource int, rlim *rlimit32) (err error) = SYS_SETRLIMIT - -func Setrlimit(resource int, rlim *Rlimit) (err error) { - err = Prlimit(0, resource, rlim, nil) - if err != ENOSYS { - return err - } - - rl := rlimit32{} - if rlim.Cur == rlimInf64 { - rl.Cur = rlimInf32 - } else if rlim.Cur < uint64(rlimInf32) { - rl.Cur = uint32(rlim.Cur) - } else { - return EINVAL - } - if rlim.Max == rlimInf64 { - rl.Max = rlimInf32 - } else if rlim.Max < uint64(rlimInf32) { - rl.Max = uint32(rlim.Max) - } else { - return EINVAL - } - - return setrlimit(resource, &rl) -} - func (r *PtraceRegs) PC() uint64 { return uint64(r.Uregs[15]) } func (r *PtraceRegs) SetPC(pc uint64) { r.Uregs[15] = uint32(pc) } diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go b/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go index 6422704..a81f574 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go @@ -39,7 +39,6 @@ func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) //sys setfsgid(gid int) (prev int, err error) //sys setfsuid(uid int) (prev int, err error) -//sysnb setrlimit(resource int, rlim *Rlimit) (err error) //sys Shutdown(fd int, how int) (err error) //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) @@ -143,15 +142,6 @@ func Getrlimit(resource int, rlim *Rlimit) error { return getrlimit(resource, rlim) } -// Setrlimit prefers the prlimit64 system call. See issue 38604. -func Setrlimit(resource int, rlim *Rlimit) error { - err := Prlimit(0, resource, rlim, nil) - if err != ENOSYS { - return err - } - return setrlimit(resource, rlim) -} - func (r *PtraceRegs) PC() uint64 { return r.Pc } func (r *PtraceRegs) SetPC(pc uint64) { r.Pc = pc } diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_loong64.go b/vendor/golang.org/x/sys/unix/syscall_linux_loong64.go index 59dab51..69d2d7c 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_loong64.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_loong64.go @@ -126,11 +126,6 @@ func Getrlimit(resource int, rlim *Rlimit) (err error) { return } -func Setrlimit(resource int, rlim *Rlimit) (err error) { - err = Prlimit(0, resource, rlim, nil) - return -} - func futimesat(dirfd int, path string, tv *[2]Timeval) (err error) { if tv == nil { return utimensat(dirfd, path, nil, 0) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go b/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go index bfef09a..76d5640 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go @@ -37,7 +37,6 @@ func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) //sys setfsgid(gid int) (prev int, err error) //sys setfsuid(uid int) (prev int, err error) -//sysnb Setrlimit(resource int, rlim *Rlimit) (err error) //sys Shutdown(fd int, how int) (err error) //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) //sys Statfs(path string, buf *Statfs_t) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go b/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go index ab30250..aae7f0f 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go @@ -151,33 +151,6 @@ func Getrlimit(resource int, rlim *Rlimit) (err error) { return } -//sysnb setrlimit(resource int, rlim *rlimit32) (err error) = SYS_SETRLIMIT - -func Setrlimit(resource int, rlim *Rlimit) (err error) { - err = Prlimit(0, resource, rlim, nil) - if err != ENOSYS { - return err - } - - rl := rlimit32{} - if rlim.Cur == rlimInf64 { - rl.Cur = rlimInf32 - } else if rlim.Cur < uint64(rlimInf32) { - rl.Cur = uint32(rlim.Cur) - } else { - return EINVAL - } - if rlim.Max == rlimInf64 { - rl.Max = rlimInf32 - } else if rlim.Max < uint64(rlimInf32) { - rl.Max = uint32(rlim.Max) - } else { - return EINVAL - } - - return setrlimit(resource, &rl) -} - func (r *PtraceRegs) PC() uint64 { return r.Epc } func (r *PtraceRegs) SetPC(pc uint64) { r.Epc = pc } diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_ppc.go b/vendor/golang.org/x/sys/unix/syscall_linux_ppc.go index eac1cf1..66eff19 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_ppc.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_ppc.go @@ -159,33 +159,6 @@ func Getrlimit(resource int, rlim *Rlimit) (err error) { return } -//sysnb setrlimit(resource int, rlim *rlimit32) (err error) = SYS_SETRLIMIT - -func Setrlimit(resource int, rlim *Rlimit) (err error) { - err = Prlimit(0, resource, rlim, nil) - if err != ENOSYS { - return err - } - - rl := rlimit32{} - if rlim.Cur == rlimInf64 { - rl.Cur = rlimInf32 - } else if rlim.Cur < uint64(rlimInf32) { - rl.Cur = uint32(rlim.Cur) - } else { - return EINVAL - } - if rlim.Max == rlimInf64 { - rl.Max = rlimInf32 - } else if rlim.Max < uint64(rlimInf32) { - rl.Max = uint32(rlim.Max) - } else { - return EINVAL - } - - return setrlimit(resource, &rl) -} - func (r *PtraceRegs) PC() uint32 { return r.Nip } func (r *PtraceRegs) SetPC(pc uint32) { r.Nip = pc } diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go b/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go index 4df5661..806aa25 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go @@ -34,7 +34,6 @@ package unix //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) //sys setfsgid(gid int) (prev int, err error) //sys setfsuid(uid int) (prev int, err error) -//sysnb Setrlimit(resource int, rlim *Rlimit) (err error) //sys Shutdown(fd int, how int) (err error) //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) //sys Stat(path string, stat *Stat_t) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go b/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go index 5f4243d..35851ef 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go @@ -38,7 +38,6 @@ func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) //sys setfsgid(gid int) (prev int, err error) //sys setfsuid(uid int) (prev int, err error) -//sysnb Setrlimit(resource int, rlim *Rlimit) (err error) //sys Shutdown(fd int, how int) (err error) //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go b/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go index d0a7d40..2f89e8f 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go @@ -34,7 +34,6 @@ import ( //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) //sys setfsgid(gid int) (prev int, err error) //sys setfsuid(uid int) (prev int, err error) -//sysnb Setrlimit(resource int, rlim *Rlimit) (err error) //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) //sys Stat(path string, stat *Stat_t) (err error) //sys Statfs(path string, buf *Statfs_t) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_sparc64.go b/vendor/golang.org/x/sys/unix/syscall_linux_sparc64.go index f5c793b..7ca064a 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_sparc64.go @@ -31,7 +31,6 @@ package unix //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) //sys setfsgid(gid int) (prev int, err error) //sys setfsuid(uid int) (prev int, err error) -//sysnb Setrlimit(resource int, rlim *Rlimit) (err error) //sys Shutdown(fd int, how int) (err error) //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) //sys Stat(path string, stat *Stat_t) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_netbsd.go b/vendor/golang.org/x/sys/unix/syscall_netbsd.go index e66865d..018d7d4 100644 --- a/vendor/golang.org/x/sys/unix/syscall_netbsd.go +++ b/vendor/golang.org/x/sys/unix/syscall_netbsd.go @@ -340,7 +340,6 @@ func Statvfs(path string, buf *Statvfs_t) (err error) { //sys Setpriority(which int, who int, prio int) (err error) //sysnb Setregid(rgid int, egid int) (err error) //sysnb Setreuid(ruid int, euid int) (err error) -//sysnb Setrlimit(which int, lim *Rlimit) (err error) //sysnb Setsid() (pid int, err error) //sysnb Settimeofday(tp *Timeval) (err error) //sysnb Setuid(uid int) (err error) @@ -501,7 +500,6 @@ func Statvfs(path string, buf *Statvfs_t) (err error) { // compat_43_osendmsg // compat_43_osethostid // compat_43_osethostname -// compat_43_osetrlimit // compat_43_osigblock // compat_43_osigsetmask // compat_43_osigstack diff --git a/vendor/golang.org/x/sys/unix/syscall_openbsd.go b/vendor/golang.org/x/sys/unix/syscall_openbsd.go index 5e9de23..f9c7a96 100644 --- a/vendor/golang.org/x/sys/unix/syscall_openbsd.go +++ b/vendor/golang.org/x/sys/unix/syscall_openbsd.go @@ -294,7 +294,6 @@ func Uname(uname *Utsname) error { //sysnb Setreuid(ruid int, euid int) (err error) //sysnb Setresgid(rgid int, egid int, sgid int) (err error) //sysnb Setresuid(ruid int, euid int, suid int) (err error) -//sysnb Setrlimit(which int, lim *Rlimit) (err error) //sysnb Setrtable(rtable int) (err error) //sysnb Setsid() (pid int, err error) //sysnb Settimeofday(tp *Timeval) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_solaris.go b/vendor/golang.org/x/sys/unix/syscall_solaris.go index d3444b6..b600a28 100644 --- a/vendor/golang.org/x/sys/unix/syscall_solaris.go +++ b/vendor/golang.org/x/sys/unix/syscall_solaris.go @@ -545,24 +545,24 @@ func Minor(dev uint64) uint32 { * Expose the ioctl function */ -//sys ioctlRet(fd int, req uint, arg uintptr) (ret int, err error) = libc.ioctl -//sys ioctlPtrRet(fd int, req uint, arg unsafe.Pointer) (ret int, err error) = libc.ioctl +//sys ioctlRet(fd int, req int, arg uintptr) (ret int, err error) = libc.ioctl +//sys ioctlPtrRet(fd int, req int, arg unsafe.Pointer) (ret int, err error) = libc.ioctl -func ioctl(fd int, req uint, arg uintptr) (err error) { +func ioctl(fd int, req int, arg uintptr) (err error) { _, err = ioctlRet(fd, req, arg) return err } -func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { +func ioctlPtr(fd int, req int, arg unsafe.Pointer) (err error) { _, err = ioctlPtrRet(fd, req, arg) return err } -func IoctlSetTermio(fd int, req uint, value *Termio) error { +func IoctlSetTermio(fd int, req int, value *Termio) error { return ioctlPtr(fd, req, unsafe.Pointer(value)) } -func IoctlGetTermio(fd int, req uint) (*Termio, error) { +func IoctlGetTermio(fd int, req int) (*Termio, error) { var value Termio err := ioctlPtr(fd, req, unsafe.Pointer(&value)) return &value, err @@ -665,7 +665,6 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e //sys Setpriority(which int, who int, prio int) (err error) //sysnb Setregid(rgid int, egid int) (err error) //sysnb Setreuid(ruid int, euid int) (err error) -//sysnb Setrlimit(which int, lim *Rlimit) (err error) //sysnb Setsid() (pid int, err error) //sysnb Setuid(uid int) (err error) //sys Shutdown(s int, how int) (err error) = libsocket.shutdown @@ -1080,11 +1079,11 @@ func Getmsg(fd int, cl []byte, data []byte) (retCl []byte, retData []byte, flags return retCl, retData, flags, nil } -func IoctlSetIntRetInt(fd int, req uint, arg int) (int, error) { +func IoctlSetIntRetInt(fd int, req int, arg int) (int, error) { return ioctlRet(fd, req, uintptr(arg)) } -func IoctlSetString(fd int, req uint, val string) error { +func IoctlSetString(fd int, req int, val string) error { bs := make([]byte, len(val)+1) copy(bs[:len(bs)-1], val) err := ioctlPtr(fd, req, unsafe.Pointer(&bs[0])) @@ -1120,7 +1119,7 @@ func (l *Lifreq) GetLifruUint() uint { return *(*uint)(unsafe.Pointer(&l.Lifru[0])) } -func IoctlLifreq(fd int, req uint, l *Lifreq) error { +func IoctlLifreq(fd int, req int, l *Lifreq) error { return ioctlPtr(fd, req, unsafe.Pointer(l)) } @@ -1131,6 +1130,6 @@ func (s *Strioctl) SetInt(i int) { s.Dp = (*int8)(unsafe.Pointer(&i)) } -func IoctlSetStrioctlRetInt(fd int, req uint, s *Strioctl) (int, error) { +func IoctlSetStrioctlRetInt(fd int, req int, s *Strioctl) (int, error) { return ioctlPtrRet(fd, req, unsafe.Pointer(s)) } diff --git a/vendor/golang.org/x/sys/unix/syscall_unix.go b/vendor/golang.org/x/sys/unix/syscall_unix.go index 00f0aa3..8e48c29 100644 --- a/vendor/golang.org/x/sys/unix/syscall_unix.go +++ b/vendor/golang.org/x/sys/unix/syscall_unix.go @@ -587,3 +587,10 @@ func emptyIovecs(iov []Iovec) bool { } return true } + +// Setrlimit sets a resource limit. +func Setrlimit(resource int, rlim *Rlimit) error { + // Just call the syscall version, because as of Go 1.21 + // it will affect starting a new process. + return syscall.Setrlimit(resource, (*syscall.Rlimit)(rlim)) +} diff --git a/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go b/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go index b295497..d3d49ec 100644 --- a/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go +++ b/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go @@ -212,8 +212,8 @@ func (cmsg *Cmsghdr) SetLen(length int) { //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) = SYS___SENDMSG_A //sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) = SYS_MMAP //sys munmap(addr uintptr, length uintptr) (err error) = SYS_MUNMAP -//sys ioctl(fd int, req uint, arg uintptr) (err error) = SYS_IOCTL -//sys ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) = SYS_IOCTL +//sys ioctl(fd int, req int, arg uintptr) (err error) = SYS_IOCTL +//sys ioctlPtr(fd int, req int, arg unsafe.Pointer) (err error) = SYS_IOCTL //sys Access(path string, mode uint32) (err error) = SYS___ACCESS_A //sys Chdir(path string) (err error) = SYS___CHDIR_A diff --git a/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go index 476a1c7..1430076 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go @@ -1270,6 +1270,16 @@ const ( SEEK_END = 0x2 SEEK_HOLE = 0x3 SEEK_SET = 0x0 + SF_APPEND = 0x40000 + SF_ARCHIVED = 0x10000 + SF_DATALESS = 0x40000000 + SF_FIRMLINK = 0x800000 + SF_IMMUTABLE = 0x20000 + SF_NOUNLINK = 0x100000 + SF_RESTRICTED = 0x80000 + SF_SETTABLE = 0x3fff0000 + SF_SUPPORTED = 0x9f0000 + SF_SYNTHETIC = 0xc0000000 SHUT_RD = 0x0 SHUT_RDWR = 0x2 SHUT_WR = 0x1 @@ -1543,6 +1553,15 @@ const ( TIOCTIMESTAMP = 0x40107459 TIOCUCNTL = 0x80047466 TOSTOP = 0x400000 + UF_APPEND = 0x4 + UF_COMPRESSED = 0x20 + UF_DATAVAULT = 0x80 + UF_HIDDEN = 0x8000 + UF_IMMUTABLE = 0x2 + UF_NODUMP = 0x1 + UF_OPAQUE = 0x8 + UF_SETTABLE = 0xffff + UF_TRACKED = 0x40 VDISCARD = 0xf VDSUSP = 0xb VEOF = 0x0 diff --git a/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go index e36f517..ab044a7 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go @@ -1270,6 +1270,16 @@ const ( SEEK_END = 0x2 SEEK_HOLE = 0x3 SEEK_SET = 0x0 + SF_APPEND = 0x40000 + SF_ARCHIVED = 0x10000 + SF_DATALESS = 0x40000000 + SF_FIRMLINK = 0x800000 + SF_IMMUTABLE = 0x20000 + SF_NOUNLINK = 0x100000 + SF_RESTRICTED = 0x80000 + SF_SETTABLE = 0x3fff0000 + SF_SUPPORTED = 0x9f0000 + SF_SYNTHETIC = 0xc0000000 SHUT_RD = 0x0 SHUT_RDWR = 0x2 SHUT_WR = 0x1 @@ -1543,6 +1553,15 @@ const ( TIOCTIMESTAMP = 0x40107459 TIOCUCNTL = 0x80047466 TOSTOP = 0x400000 + UF_APPEND = 0x4 + UF_COMPRESSED = 0x20 + UF_DATAVAULT = 0x80 + UF_HIDDEN = 0x8000 + UF_IMMUTABLE = 0x2 + UF_NODUMP = 0x1 + UF_OPAQUE = 0x8 + UF_SETTABLE = 0xffff + UF_TRACKED = 0x40 VDISCARD = 0xf VDSUSP = 0xb VEOF = 0x0 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go index ef9dcd1..9a25721 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go @@ -124,7 +124,6 @@ int utime(uintptr_t, uintptr_t); unsigned long long getsystemcfg(int); int umount(uintptr_t); int getrlimit64(int, uintptr_t); -int setrlimit64(int, uintptr_t); long long lseek64(int, long long, int); uintptr_t mmap(uintptr_t, uintptr_t, int, int, int, long long); @@ -213,7 +212,7 @@ func wait4(pid Pid_t, status *_C_int, options int, rusage *Rusage) (wpid Pid_t, // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func ioctl(fd int, req uint, arg uintptr) (err error) { +func ioctl(fd int, req int, arg uintptr) (err error) { r0, er := C.ioctl(C.int(fd), C.int(req), C.uintptr_t(arg)) if r0 == -1 && er != nil { err = er @@ -223,7 +222,7 @@ func ioctl(fd int, req uint, arg uintptr) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { +func ioctlPtr(fd int, req int, arg unsafe.Pointer) (err error) { r0, er := C.ioctl(C.int(fd), C.int(req), C.uintptr_t(uintptr(arg))) if r0 == -1 && er != nil { err = er @@ -1464,16 +1463,6 @@ func Getrlimit(resource int, rlim *Rlimit) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setrlimit(resource int, rlim *Rlimit) (err error) { - r0, er := C.setrlimit64(C.int(resource), C.uintptr_t(uintptr(unsafe.Pointer(rlim)))) - if r0 == -1 && er != nil { - err = er - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Seek(fd int, offset int64, whence int) (off int64, err error) { r0, er := C.lseek64(C.int(fd), C.longlong(offset), C.int(whence)) off = int64(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go index f86a945..6de80c2 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go @@ -93,8 +93,8 @@ func wait4(pid Pid_t, status *_C_int, options int, rusage *Rusage) (wpid Pid_t, // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func ioctl(fd int, req uint, arg uintptr) (err error) { - _, e1 := callioctl(fd, int(req), arg) +func ioctl(fd int, req int, arg uintptr) (err error) { + _, e1 := callioctl(fd, req, arg) if e1 != 0 { err = errnoErr(e1) } @@ -103,8 +103,8 @@ func ioctl(fd int, req uint, arg uintptr) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { - _, e1 := callioctl_ptr(fd, int(req), arg) +func ioctlPtr(fd int, req int, arg unsafe.Pointer) (err error) { + _, e1 := callioctl_ptr(fd, req, arg) if e1 != 0 { err = errnoErr(e1) } @@ -1422,16 +1422,6 @@ func Getrlimit(resource int, rlim *Rlimit) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setrlimit(resource int, rlim *Rlimit) (err error) { - _, e1 := callsetrlimit(resource, uintptr(unsafe.Pointer(rlim))) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Seek(fd int, offset int64, whence int) (off int64, err error) { r0, e1 := calllseek(fd, offset, whence) off = int64(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gc.go b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gc.go index d32a84c..c4d50ae 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gc.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gc.go @@ -124,7 +124,6 @@ import ( //go:cgo_import_dynamic libc_getsystemcfg getsystemcfg "libc.a/shr_64.o" //go:cgo_import_dynamic libc_umount umount "libc.a/shr_64.o" //go:cgo_import_dynamic libc_getrlimit getrlimit "libc.a/shr_64.o" -//go:cgo_import_dynamic libc_setrlimit setrlimit "libc.a/shr_64.o" //go:cgo_import_dynamic libc_lseek lseek "libc.a/shr_64.o" //go:cgo_import_dynamic libc_mmap64 mmap64 "libc.a/shr_64.o" @@ -242,7 +241,6 @@ import ( //go:linkname libc_getsystemcfg libc_getsystemcfg //go:linkname libc_umount libc_umount //go:linkname libc_getrlimit libc_getrlimit -//go:linkname libc_setrlimit libc_setrlimit //go:linkname libc_lseek libc_lseek //go:linkname libc_mmap64 libc_mmap64 @@ -363,7 +361,6 @@ var ( libc_getsystemcfg, libc_umount, libc_getrlimit, - libc_setrlimit, libc_lseek, libc_mmap64 syscallFunc ) @@ -1179,13 +1176,6 @@ func callgetrlimit(resource int, rlim uintptr) (r1 uintptr, e1 Errno) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func callsetrlimit(resource int, rlim uintptr) (r1 uintptr, e1 Errno) { - r1, _, e1 = rawSyscall6(uintptr(unsafe.Pointer(&libc_setrlimit)), 2, uintptr(resource), rlim, 0, 0, 0, 0) - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func calllseek(fd int, offset int64, whence int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_lseek)), 3, uintptr(fd), uintptr(offset), uintptr(whence), 0, 0, 0) return diff --git a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gccgo.go b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gccgo.go index d7d8baf..6903d3b 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gccgo.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gccgo.go @@ -123,7 +123,6 @@ int utime(uintptr_t, uintptr_t); unsigned long long getsystemcfg(int); int umount(uintptr_t); int getrlimit(int, uintptr_t); -int setrlimit(int, uintptr_t); long long lseek(int, long long, int); uintptr_t mmap64(uintptr_t, uintptr_t, int, int, int, long long); @@ -131,6 +130,7 @@ uintptr_t mmap64(uintptr_t, uintptr_t, int, int, int, long long); import "C" import ( "syscall" + "unsafe" ) // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -1055,14 +1055,6 @@ func callgetrlimit(resource int, rlim uintptr) (r1 uintptr, e1 Errno) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func callsetrlimit(resource int, rlim uintptr) (r1 uintptr, e1 Errno) { - r1 = uintptr(C.setrlimit(C.int(resource), C.uintptr_t(rlim))) - e1 = syscall.GetErrno() - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func calllseek(fd int, offset int64, whence int) (r1 uintptr, e1 Errno) { r1 = uintptr(C.lseek(C.int(fd), C.longlong(offset), C.int(whence))) e1 = syscall.GetErrno() diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go index a29ffdd..4037ccf 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go @@ -1992,6 +1992,31 @@ var libc_select_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Setattrlist(path string, attrlist *Attrlist, attrBuf []byte, options int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(attrBuf) > 0 { + _p1 = unsafe.Pointer(&attrBuf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + _, _, e1 := syscall_syscall6(libc_setattrlist_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(attrlist)), uintptr(_p1), uintptr(len(attrBuf)), uintptr(options), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_setattrlist_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_setattrlist setattrlist "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Setegid(egid int) (err error) { _, _, e1 := syscall_syscall(libc_setegid_trampoline_addr, uintptr(egid), 0, 0) if e1 != 0 { @@ -2123,20 +2148,6 @@ var libc_setreuid_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setrlimit(which int, lim *Rlimit) (err error) { - _, _, e1 := syscall_rawSyscall(libc_setrlimit_trampoline_addr, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -var libc_setrlimit_trampoline_addr uintptr - -//go:cgo_import_dynamic libc_setrlimit setrlimit "/usr/lib/libSystem.B.dylib" - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setsid() (pid int, err error) { r0, _, e1 := syscall_rawSyscall(libc_setsid_trampoline_addr, 0, 0, 0) pid = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s index 95fe4c0..4baaed0 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s @@ -705,6 +705,11 @@ TEXT libc_select_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_select_trampoline_addr(SB), RODATA, $8 DATA ·libc_select_trampoline_addr(SB)/8, $libc_select_trampoline<>(SB) +TEXT libc_setattrlist_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_setattrlist(SB) +GLOBL ·libc_setattrlist_trampoline_addr(SB), RODATA, $8 +DATA ·libc_setattrlist_trampoline_addr(SB)/8, $libc_setattrlist_trampoline<>(SB) + TEXT libc_setegid_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_setegid(SB) @@ -759,12 +764,6 @@ TEXT libc_setreuid_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_setreuid_trampoline_addr(SB), RODATA, $8 DATA ·libc_setreuid_trampoline_addr(SB)/8, $libc_setreuid_trampoline<>(SB) -TEXT libc_setrlimit_trampoline<>(SB),NOSPLIT,$0-0 - JMP libc_setrlimit(SB) - -GLOBL ·libc_setrlimit_trampoline_addr(SB), RODATA, $8 -DATA ·libc_setrlimit_trampoline_addr(SB)/8, $libc_setrlimit_trampoline<>(SB) - TEXT libc_setsid_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_setsid(SB) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go index 2fd4590..51d6f3f 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go @@ -1992,6 +1992,31 @@ var libc_select_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Setattrlist(path string, attrlist *Attrlist, attrBuf []byte, options int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(attrBuf) > 0 { + _p1 = unsafe.Pointer(&attrBuf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + _, _, e1 := syscall_syscall6(libc_setattrlist_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(attrlist)), uintptr(_p1), uintptr(len(attrBuf)), uintptr(options), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_setattrlist_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_setattrlist setattrlist "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Setegid(egid int) (err error) { _, _, e1 := syscall_syscall(libc_setegid_trampoline_addr, uintptr(egid), 0, 0) if e1 != 0 { @@ -2123,20 +2148,6 @@ var libc_setreuid_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setrlimit(which int, lim *Rlimit) (err error) { - _, _, e1 := syscall_rawSyscall(libc_setrlimit_trampoline_addr, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -var libc_setrlimit_trampoline_addr uintptr - -//go:cgo_import_dynamic libc_setrlimit setrlimit "/usr/lib/libSystem.B.dylib" - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setsid() (pid int, err error) { r0, _, e1 := syscall_rawSyscall(libc_setsid_trampoline_addr, 0, 0, 0) pid = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s index efa5b4c..c3b82c0 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s @@ -705,6 +705,11 @@ TEXT libc_select_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_select_trampoline_addr(SB), RODATA, $8 DATA ·libc_select_trampoline_addr(SB)/8, $libc_select_trampoline<>(SB) +TEXT libc_setattrlist_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_setattrlist(SB) +GLOBL ·libc_setattrlist_trampoline_addr(SB), RODATA, $8 +DATA ·libc_setattrlist_trampoline_addr(SB)/8, $libc_setattrlist_trampoline<>(SB) + TEXT libc_setegid_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_setegid(SB) @@ -759,12 +764,6 @@ TEXT libc_setreuid_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_setreuid_trampoline_addr(SB), RODATA, $8 DATA ·libc_setreuid_trampoline_addr(SB)/8, $libc_setreuid_trampoline<>(SB) -TEXT libc_setrlimit_trampoline<>(SB),NOSPLIT,$0-0 - JMP libc_setrlimit(SB) - -GLOBL ·libc_setrlimit_trampoline_addr(SB), RODATA, $8 -DATA ·libc_setrlimit_trampoline_addr(SB)/8, $libc_setrlimit_trampoline<>(SB) - TEXT libc_setsid_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_setsid(SB) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go index 3b85134..0eabac7 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go @@ -1410,16 +1410,6 @@ func Setresuid(ruid int, euid int, suid int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setrlimit(which int, lim *Rlimit) (err error) { - _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setsid() (pid int, err error) { r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) pid = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go index 1129065..ee313eb 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go @@ -1645,16 +1645,6 @@ func Setresuid(ruid int, euid int, suid int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setrlimit(which int, lim *Rlimit) (err error) { - _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setsid() (pid int, err error) { r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) pid = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go index 55f5abf..4c986e4 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go @@ -1645,16 +1645,6 @@ func Setresuid(ruid int, euid int, suid int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setrlimit(which int, lim *Rlimit) (err error) { - _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setsid() (pid int, err error) { r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) pid = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go index d39651c..5552169 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go @@ -1645,16 +1645,6 @@ func Setresuid(ruid int, euid int, suid int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setrlimit(which int, lim *Rlimit) (err error) { - _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setsid() (pid int, err error) { r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) pid = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm64.go index ddb7408..67a226f 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm64.go @@ -1645,16 +1645,6 @@ func Setresuid(ruid int, euid int, suid int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setrlimit(which int, lim *Rlimit) (err error) { - _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setsid() (pid int, err error) { r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) pid = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_riscv64.go b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_riscv64.go index 09a53a6..f0b9dda 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_riscv64.go @@ -1645,16 +1645,6 @@ func Setresuid(ruid int, euid int, suid int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setrlimit(which int, lim *Rlimit) (err error) { - _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setsid() (pid int, err error) { r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) pid = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux.go b/vendor/golang.org/x/sys/unix/zsyscall_linux.go index 430cb24..da63d9d 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux.go @@ -1346,16 +1346,6 @@ func PivotRoot(newroot string, putold string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Prlimit(pid int, resource int, newlimit *Rlimit, old *Rlimit) (err error) { - _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(newlimit)), uintptr(unsafe.Pointer(old)), 0, 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) { _, _, e1 := Syscall6(SYS_PRCTL, uintptr(option), uintptr(arg2), uintptr(arg3), uintptr(arg4), uintptr(arg5), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go index c81b0ad..07b549c 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go @@ -411,16 +411,6 @@ func getrlimit(resource int, rlim *rlimit32) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func setrlimit(resource int, rlim *rlimit32) (err error) { - _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func futimesat(dirfd int, path string, times *[2]Timeval) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go index 2206bce..5f481bf 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go @@ -334,16 +334,6 @@ func setfsuid(uid int) (prev int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setrlimit(resource int, rlim *Rlimit) (err error) { - _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Shutdown(fd int, how int) (err error) { _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go index edf6b39..824cd52 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go @@ -578,16 +578,6 @@ func getrlimit(resource int, rlim *rlimit32) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func setrlimit(resource int, rlim *rlimit32) (err error) { - _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func armSyncFileRange(fd int, flags int, off int64, n int64) (err error) { _, _, e1 := Syscall6(SYS_ARM_SYNC_FILE_RANGE, uintptr(fd), uintptr(flags), uintptr(off), uintptr(off>>32), uintptr(n), uintptr(n>>32)) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go index 190609f..e77aecf 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go @@ -289,16 +289,6 @@ func setfsuid(uid int) (prev int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func setrlimit(resource int, rlim *Rlimit) (err error) { - _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Shutdown(fd int, how int) (err error) { _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go index 5f984cb..961a3af 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go @@ -644,16 +644,6 @@ func getrlimit(resource int, rlim *rlimit32) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func setrlimit(resource int, rlim *rlimit32) (err error) { - _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Alarm(seconds uint) (remaining uint, err error) { r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0) remaining = uint(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go index 46fc380..ed05005 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go @@ -278,16 +278,6 @@ func setfsuid(uid int) (prev int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setrlimit(resource int, rlim *Rlimit) (err error) { - _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Shutdown(fd int, how int) (err error) { _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go index cbd0d4d..d365b71 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go @@ -278,16 +278,6 @@ func setfsuid(uid int) (prev int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setrlimit(resource int, rlim *Rlimit) (err error) { - _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Shutdown(fd int, how int) (err error) { _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go index 0c13d15..c3f1b8b 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go @@ -644,16 +644,6 @@ func getrlimit(resource int, rlim *rlimit32) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func setrlimit(resource int, rlim *rlimit32) (err error) { - _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Alarm(seconds uint) (remaining uint, err error) { r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0) remaining = uint(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc.go index e01432a..a6574cf 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc.go @@ -624,16 +624,6 @@ func getrlimit(resource int, rlim *rlimit32) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func setrlimit(resource int, rlim *rlimit32) (err error) { - _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func syncFileRange2(fd int, flags int, off int64, n int64) (err error) { _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE2, uintptr(fd), uintptr(flags), uintptr(off>>32), uintptr(off), uintptr(n>>32), uintptr(n)) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go index 13c7ee7..f409902 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go @@ -349,16 +349,6 @@ func setfsuid(uid int) (prev int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setrlimit(resource int, rlim *Rlimit) (err error) { - _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Shutdown(fd int, how int) (err error) { _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go index 02d0c0f..9dfcc29 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go @@ -349,16 +349,6 @@ func setfsuid(uid int) (prev int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setrlimit(resource int, rlim *Rlimit) (err error) { - _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Shutdown(fd int, how int) (err error) { _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go index 9fee3b1..0b29239 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go @@ -269,16 +269,6 @@ func setfsuid(uid int) (prev int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setrlimit(resource int, rlim *Rlimit) (err error) { - _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Shutdown(fd int, how int) (err error) { _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go index 647bbfe..6cde322 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go @@ -319,16 +319,6 @@ func setfsuid(uid int) (prev int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setrlimit(resource int, rlim *Rlimit) (err error) { - _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) { r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)) n = int64(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go index ada057f..5253d65 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go @@ -329,16 +329,6 @@ func setfsuid(uid int) (prev int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setrlimit(resource int, rlim *Rlimit) (err error) { - _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Shutdown(fd int, how int) (err error) { _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go index 8e1d9c8..cdb2af5 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go @@ -1607,16 +1607,6 @@ func Setreuid(ruid int, euid int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setrlimit(which int, lim *Rlimit) (err error) { - _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setsid() (pid int, err error) { r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) pid = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go index 21c6950..9d25f76 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go @@ -1607,16 +1607,6 @@ func Setreuid(ruid int, euid int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setrlimit(which int, lim *Rlimit) (err error) { - _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setsid() (pid int, err error) { r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) pid = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go index 298168f..d3f8035 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go @@ -1607,16 +1607,6 @@ func Setreuid(ruid int, euid int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setrlimit(which int, lim *Rlimit) (err error) { - _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setsid() (pid int, err error) { r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) pid = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm64.go index 68b8bd4..887188a 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm64.go @@ -1607,16 +1607,6 @@ func Setreuid(ruid int, euid int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setrlimit(which int, lim *Rlimit) (err error) { - _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setsid() (pid int, err error) { r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) pid = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go index 0b0f910..6699a78 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go @@ -1894,20 +1894,6 @@ var libc_setresuid_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setrlimit(which int, lim *Rlimit) (err error) { - _, _, e1 := syscall_rawSyscall(libc_setrlimit_trampoline_addr, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -var libc_setrlimit_trampoline_addr uintptr - -//go:cgo_import_dynamic libc_setrlimit setrlimit "libc.so" - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setrtable(rtable int) (err error) { _, _, e1 := syscall_rawSyscall(libc_setrtable_trampoline_addr, uintptr(rtable), 0, 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s index 0874442..04f0de3 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s @@ -573,11 +573,6 @@ TEXT libc_setresuid_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_setresuid_trampoline_addr(SB), RODATA, $4 DATA ·libc_setresuid_trampoline_addr(SB)/4, $libc_setresuid_trampoline<>(SB) -TEXT libc_setrlimit_trampoline<>(SB),NOSPLIT,$0-0 - JMP libc_setrlimit(SB) -GLOBL ·libc_setrlimit_trampoline_addr(SB), RODATA, $4 -DATA ·libc_setrlimit_trampoline_addr(SB)/4, $libc_setrlimit_trampoline<>(SB) - TEXT libc_setrtable_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_setrtable(SB) GLOBL ·libc_setrtable_trampoline_addr(SB), RODATA, $4 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go index 48ff5de..1e775fe 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go @@ -1894,20 +1894,6 @@ var libc_setresuid_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setrlimit(which int, lim *Rlimit) (err error) { - _, _, e1 := syscall_rawSyscall(libc_setrlimit_trampoline_addr, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -var libc_setrlimit_trampoline_addr uintptr - -//go:cgo_import_dynamic libc_setrlimit setrlimit "libc.so" - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setrtable(rtable int) (err error) { _, _, e1 := syscall_rawSyscall(libc_setrtable_trampoline_addr, uintptr(rtable), 0, 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s index 5782cd1..27b6f4d 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s @@ -573,11 +573,6 @@ TEXT libc_setresuid_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_setresuid_trampoline_addr(SB), RODATA, $8 DATA ·libc_setresuid_trampoline_addr(SB)/8, $libc_setresuid_trampoline<>(SB) -TEXT libc_setrlimit_trampoline<>(SB),NOSPLIT,$0-0 - JMP libc_setrlimit(SB) -GLOBL ·libc_setrlimit_trampoline_addr(SB), RODATA, $8 -DATA ·libc_setrlimit_trampoline_addr(SB)/8, $libc_setrlimit_trampoline<>(SB) - TEXT libc_setrtable_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_setrtable(SB) GLOBL ·libc_setrtable_trampoline_addr(SB), RODATA, $8 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go index 2452a64..7f64278 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go @@ -1894,20 +1894,6 @@ var libc_setresuid_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setrlimit(which int, lim *Rlimit) (err error) { - _, _, e1 := syscall_rawSyscall(libc_setrlimit_trampoline_addr, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -var libc_setrlimit_trampoline_addr uintptr - -//go:cgo_import_dynamic libc_setrlimit setrlimit "libc.so" - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setrtable(rtable int) (err error) { _, _, e1 := syscall_rawSyscall(libc_setrtable_trampoline_addr, uintptr(rtable), 0, 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s index cf31042..b797045 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s @@ -573,11 +573,6 @@ TEXT libc_setresuid_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_setresuid_trampoline_addr(SB), RODATA, $4 DATA ·libc_setresuid_trampoline_addr(SB)/4, $libc_setresuid_trampoline<>(SB) -TEXT libc_setrlimit_trampoline<>(SB),NOSPLIT,$0-0 - JMP libc_setrlimit(SB) -GLOBL ·libc_setrlimit_trampoline_addr(SB), RODATA, $4 -DATA ·libc_setrlimit_trampoline_addr(SB)/4, $libc_setrlimit_trampoline<>(SB) - TEXT libc_setrtable_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_setrtable(SB) GLOBL ·libc_setrtable_trampoline_addr(SB), RODATA, $4 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go index 5e35600..756ef7b 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go @@ -1894,20 +1894,6 @@ var libc_setresuid_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setrlimit(which int, lim *Rlimit) (err error) { - _, _, e1 := syscall_rawSyscall(libc_setrlimit_trampoline_addr, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -var libc_setrlimit_trampoline_addr uintptr - -//go:cgo_import_dynamic libc_setrlimit setrlimit "libc.so" - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setrtable(rtable int) (err error) { _, _, e1 := syscall_rawSyscall(libc_setrtable_trampoline_addr, uintptr(rtable), 0, 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s index 484bb42..a871266 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s @@ -573,11 +573,6 @@ TEXT libc_setresuid_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_setresuid_trampoline_addr(SB), RODATA, $8 DATA ·libc_setresuid_trampoline_addr(SB)/8, $libc_setresuid_trampoline<>(SB) -TEXT libc_setrlimit_trampoline<>(SB),NOSPLIT,$0-0 - JMP libc_setrlimit(SB) -GLOBL ·libc_setrlimit_trampoline_addr(SB), RODATA, $8 -DATA ·libc_setrlimit_trampoline_addr(SB)/8, $libc_setrlimit_trampoline<>(SB) - TEXT libc_setrtable_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_setrtable(SB) GLOBL ·libc_setrtable_trampoline_addr(SB), RODATA, $8 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go index b04cef1..7bc2e24 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go @@ -1894,20 +1894,6 @@ var libc_setresuid_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setrlimit(which int, lim *Rlimit) (err error) { - _, _, e1 := syscall_rawSyscall(libc_setrlimit_trampoline_addr, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -var libc_setrlimit_trampoline_addr uintptr - -//go:cgo_import_dynamic libc_setrlimit setrlimit "libc.so" - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setrtable(rtable int) (err error) { _, _, e1 := syscall_rawSyscall(libc_setrtable_trampoline_addr, uintptr(rtable), 0, 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s index 55af272..05d4bff 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s @@ -573,11 +573,6 @@ TEXT libc_setresuid_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_setresuid_trampoline_addr(SB), RODATA, $8 DATA ·libc_setresuid_trampoline_addr(SB)/8, $libc_setresuid_trampoline<>(SB) -TEXT libc_setrlimit_trampoline<>(SB),NOSPLIT,$0-0 - JMP libc_setrlimit(SB) -GLOBL ·libc_setrlimit_trampoline_addr(SB), RODATA, $8 -DATA ·libc_setrlimit_trampoline_addr(SB)/8, $libc_setrlimit_trampoline<>(SB) - TEXT libc_setrtable_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_setrtable(SB) GLOBL ·libc_setrtable_trampoline_addr(SB), RODATA, $8 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go index 47a07ee..739be62 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go @@ -1894,20 +1894,6 @@ var libc_setresuid_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setrlimit(which int, lim *Rlimit) (err error) { - _, _, e1 := syscall_rawSyscall(libc_setrlimit_trampoline_addr, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -var libc_setrlimit_trampoline_addr uintptr - -//go:cgo_import_dynamic libc_setrlimit setrlimit "libc.so" - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setrtable(rtable int) (err error) { _, _, e1 := syscall_rawSyscall(libc_setrtable_trampoline_addr, uintptr(rtable), 0, 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s index 4028255..74a25f8 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s @@ -687,12 +687,6 @@ TEXT libc_setresuid_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_setresuid_trampoline_addr(SB), RODATA, $8 DATA ·libc_setresuid_trampoline_addr(SB)/8, $libc_setresuid_trampoline<>(SB) -TEXT libc_setrlimit_trampoline<>(SB),NOSPLIT,$0-0 - CALL libc_setrlimit(SB) - RET -GLOBL ·libc_setrlimit_trampoline_addr(SB), RODATA, $8 -DATA ·libc_setrlimit_trampoline_addr(SB)/8, $libc_setrlimit_trampoline<>(SB) - TEXT libc_setrtable_trampoline<>(SB),NOSPLIT,$0-0 CALL libc_setrtable(SB) RET diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go index 573378f..7d95a19 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go @@ -1894,20 +1894,6 @@ var libc_setresuid_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setrlimit(which int, lim *Rlimit) (err error) { - _, _, e1 := syscall_rawSyscall(libc_setrlimit_trampoline_addr, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -var libc_setrlimit_trampoline_addr uintptr - -//go:cgo_import_dynamic libc_setrlimit setrlimit "libc.so" - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setrtable(rtable int) (err error) { _, _, e1 := syscall_rawSyscall(libc_setrtable_trampoline_addr, uintptr(rtable), 0, 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s index e1fbd4d..990be24 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s @@ -573,11 +573,6 @@ TEXT libc_setresuid_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_setresuid_trampoline_addr(SB), RODATA, $8 DATA ·libc_setresuid_trampoline_addr(SB)/8, $libc_setresuid_trampoline<>(SB) -TEXT libc_setrlimit_trampoline<>(SB),NOSPLIT,$0-0 - JMP libc_setrlimit(SB) -GLOBL ·libc_setrlimit_trampoline_addr(SB), RODATA, $8 -DATA ·libc_setrlimit_trampoline_addr(SB)/8, $libc_setrlimit_trampoline<>(SB) - TEXT libc_setrtable_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_setrtable(SB) GLOBL ·libc_setrtable_trampoline_addr(SB), RODATA, $8 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go index 4873a1e..609d1c5 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go @@ -110,7 +110,6 @@ import ( //go:cgo_import_dynamic libc_setpriority setpriority "libc.so" //go:cgo_import_dynamic libc_setregid setregid "libc.so" //go:cgo_import_dynamic libc_setreuid setreuid "libc.so" -//go:cgo_import_dynamic libc_setrlimit setrlimit "libc.so" //go:cgo_import_dynamic libc_setsid setsid "libc.so" //go:cgo_import_dynamic libc_setuid setuid "libc.so" //go:cgo_import_dynamic libc_shutdown shutdown "libsocket.so" @@ -250,7 +249,6 @@ import ( //go:linkname procSetpriority libc_setpriority //go:linkname procSetregid libc_setregid //go:linkname procSetreuid libc_setreuid -//go:linkname procSetrlimit libc_setrlimit //go:linkname procSetsid libc_setsid //go:linkname procSetuid libc_setuid //go:linkname procshutdown libc_shutdown @@ -391,7 +389,6 @@ var ( procSetpriority, procSetregid, procSetreuid, - procSetrlimit, procSetsid, procSetuid, procshutdown, @@ -646,7 +643,7 @@ func __minor(version int, dev uint64) (val uint) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func ioctlRet(fd int, req uint, arg uintptr) (ret int, err error) { +func ioctlRet(fd int, req int, arg uintptr) (ret int, err error) { r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procioctl)), 3, uintptr(fd), uintptr(req), uintptr(arg), 0, 0, 0) ret = int(r0) if e1 != 0 { @@ -657,7 +654,7 @@ func ioctlRet(fd int, req uint, arg uintptr) (ret int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func ioctlPtrRet(fd int, req uint, arg unsafe.Pointer) (ret int, err error) { +func ioctlPtrRet(fd int, req int, arg unsafe.Pointer) (ret int, err error) { r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procioctl)), 3, uintptr(fd), uintptr(req), uintptr(arg), 0, 0, 0) ret = int(r0) if e1 != 0 { @@ -1650,16 +1647,6 @@ func Setreuid(ruid int, euid int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setrlimit(which int, lim *Rlimit) (err error) { - _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetrlimit)), 2, uintptr(which), uintptr(unsafe.Pointer(lim)), 0, 0, 0, 0) - if e1 != 0 { - err = e1 - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setsid() (pid int, err error) { r0, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetsid)), 0, 0, 0, 0, 0, 0, 0) pid = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_zos_s390x.go b/vendor/golang.org/x/sys/unix/zsyscall_zos_s390x.go index 07bfe2e..c316817 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_zos_s390x.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_zos_s390x.go @@ -257,7 +257,7 @@ func munmap(addr uintptr, length uintptr) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func ioctl(fd int, req uint, arg uintptr) (err error) { +func ioctl(fd int, req int, arg uintptr) (err error) { _, _, e1 := syscall_syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) if e1 != 0 { err = errnoErr(e1) @@ -267,7 +267,7 @@ func ioctl(fd int, req uint, arg uintptr) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { +func ioctlPtr(fd int, req int, arg unsafe.Pointer) (err error) { _, _, e1 := syscall_syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) if e1 != 0 { err = errnoErr(e1) diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go index e2a64f0..690cefc 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go @@ -151,6 +151,16 @@ type Dirent struct { _ [3]byte } +type Attrlist struct { + Bitmapcount uint16 + Reserved uint16 + Commonattr uint32 + Volattr uint32 + Dirattr uint32 + Fileattr uint32 + Forkattr uint32 +} + const ( PathMax = 0x400 ) @@ -610,6 +620,7 @@ const ( AT_REMOVEDIR = 0x80 AT_SYMLINK_FOLLOW = 0x40 AT_SYMLINK_NOFOLLOW = 0x20 + AT_EACCESS = 0x10 ) type PollFd struct { diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go index 34aa775..5bffc10 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go @@ -151,6 +151,16 @@ type Dirent struct { _ [3]byte } +type Attrlist struct { + Bitmapcount uint16 + Reserved uint16 + Commonattr uint32 + Volattr uint32 + Dirattr uint32 + Fileattr uint32 + Forkattr uint32 +} + const ( PathMax = 0x400 ) @@ -610,6 +620,7 @@ const ( AT_REMOVEDIR = 0x80 AT_SYMLINK_FOLLOW = 0x40 AT_SYMLINK_NOFOLLOW = 0x20 + AT_EACCESS = 0x10 ) type PollFd struct { diff --git a/vendor/modules.txt b/vendor/modules.txt index 5e95289..1e8893d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,4 +1,4 @@ -# github.com/goccy/go-json v0.10.0 +# github.com/goccy/go-json v0.10.2 ## explicit; go 1.12 github.com/goccy/go-json github.com/goccy/go-json/internal/decoder @@ -32,7 +32,7 @@ github.com/lib/pq/scram # github.com/mattn/go-colorable v0.1.13 ## explicit; go 1.15 github.com/mattn/go-colorable -# github.com/mattn/go-isatty v0.0.17 +# github.com/mattn/go-isatty v0.0.18 ## explicit; go 1.15 github.com/mattn/go-isatty # github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd @@ -65,11 +65,11 @@ github.com/valyala/bytebufferpool # github.com/valyala/fasttemplate v1.2.2 ## explicit; go 1.12 github.com/valyala/fasttemplate -# golang.org/x/crypto v0.7.0 +# golang.org/x/crypto v0.8.0 ## explicit; go 1.17 golang.org/x/crypto/acme golang.org/x/crypto/acme/autocert -# golang.org/x/net v0.8.0 +# golang.org/x/net v0.9.0 ## explicit; go 1.17 golang.org/x/net/http/httpguts golang.org/x/net/http2 @@ -77,10 +77,10 @@ golang.org/x/net/http2/h2c golang.org/x/net/http2/hpack golang.org/x/net/idna golang.org/x/net/websocket -# golang.org/x/sys v0.6.0 +# golang.org/x/sys v0.7.0 ## explicit; go 1.17 golang.org/x/sys/unix -# golang.org/x/text v0.8.0 +# golang.org/x/text v0.9.0 ## explicit; go 1.17 golang.org/x/text/secure/bidirule golang.org/x/text/transform From 6b569681fe357fa0597e596ca5c9914f67ff41b8 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Fri, 28 Apr 2023 17:51:43 +0200 Subject: [PATCH 16/23] updated dependencies --- go.mod | 2 +- go.sum | 2 + vendor/github.com/lib/pq/conn.go | 136 +++++++++++++++++-------- vendor/github.com/lib/pq/conn_go115.go | 8 ++ vendor/github.com/lib/pq/copy.go | 35 ++++--- vendor/modules.txt | 2 +- 6 files changed, 125 insertions(+), 60 deletions(-) create mode 100644 vendor/github.com/lib/pq/conn_go115.go diff --git a/go.mod b/go.mod index 4c76fa3..7fd7da5 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/labstack/echo/v4 v4.10.2 - github.com/lib/pq v1.10.7 + github.com/lib/pq v1.10.9 golang.org/x/net v0.9.0 gopkg.in/ini.v1 v1.67.0 xorm.io/xorm v1.3.2 diff --git a/go.sum b/go.sum index 194fbdd..f7396e4 100644 --- a/go.sum +++ b/go.sum @@ -226,6 +226,8 @@ github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw= github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= +github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= diff --git a/vendor/github.com/lib/pq/conn.go b/vendor/github.com/lib/pq/conn.go index e70b386..da4ff9d 100644 --- a/vendor/github.com/lib/pq/conn.go +++ b/vendor/github.com/lib/pq/conn.go @@ -2,6 +2,7 @@ package pq import ( "bufio" + "bytes" "context" "crypto/md5" "crypto/sha256" @@ -112,7 +113,9 @@ type defaultDialer struct { func (d defaultDialer) Dial(network, address string) (net.Conn, error) { return d.d.Dial(network, address) } -func (d defaultDialer) DialTimeout(network, address string, timeout time.Duration) (net.Conn, error) { +func (d defaultDialer) DialTimeout( + network, address string, timeout time.Duration, +) (net.Conn, error) { ctx, cancel := context.WithTimeout(context.Background(), timeout) defer cancel() return d.DialContext(ctx, network, address) @@ -260,47 +263,56 @@ func (cn *conn) handlePgpass(o values) { } defer file.Close() scanner := bufio.NewScanner(io.Reader(file)) + // From: https://github.com/tg/pgpass/blob/master/reader.go + for scanner.Scan() { + if scanText(scanner.Text(), o) { + break + } + } +} + +// GetFields is a helper function for scanText. +func getFields(s string) []string { + fs := make([]string, 0, 5) + f := make([]rune, 0, len(s)) + + var esc bool + for _, c := range s { + switch { + case esc: + f = append(f, c) + esc = false + case c == '\\': + esc = true + case c == ':': + fs = append(fs, string(f)) + f = f[:0] + default: + f = append(f, c) + } + } + return append(fs, string(f)) +} + +// ScanText assists HandlePgpass in it's objective. +func scanText(line string, o values) bool { hostname := o["host"] ntw, _ := network(o) port := o["port"] db := o["dbname"] username := o["user"] - // From: https://github.com/tg/pgpass/blob/master/reader.go - getFields := func(s string) []string { - fs := make([]string, 0, 5) - f := make([]rune, 0, len(s)) - - var esc bool - for _, c := range s { - switch { - case esc: - f = append(f, c) - esc = false - case c == '\\': - esc = true - case c == ':': - fs = append(fs, string(f)) - f = f[:0] - default: - f = append(f, c) - } - } - return append(fs, string(f)) + if len(line) == 0 || line[0] == '#' { + return false } - for scanner.Scan() { - line := scanner.Text() - if len(line) == 0 || line[0] == '#' { - continue - } - split := getFields(line) - if len(split) != 5 { - continue - } - if (split[0] == "*" || split[0] == hostname || (split[0] == "localhost" && (hostname == "" || ntw == "unix"))) && (split[1] == "*" || split[1] == port) && (split[2] == "*" || split[2] == db) && (split[3] == "*" || split[3] == username) { - o["password"] = split[4] - return - } + split := getFields(line) + if len(split) != 5 { + return false } + if (split[0] == "*" || split[0] == hostname || (split[0] == "localhost" && (hostname == "" || ntw == "unix"))) && (split[1] == "*" || split[1] == port) && (split[2] == "*" || split[2] == db) && (split[3] == "*" || split[3] == username) { + o["password"] = split[4] + return true + } + return false } func (cn *conn) writeBuf(b byte) *writeBuf { @@ -765,7 +777,9 @@ func (noRows) RowsAffected() (int64, error) { // Decides which column formats to use for a prepared statement. The input is // an array of type oids, one element per result column. -func decideColumnFormats(colTyps []fieldDesc, forceText bool) (colFmts []format, colFmtData []byte) { +func decideColumnFormats( + colTyps []fieldDesc, forceText bool, +) (colFmts []format, colFmtData []byte) { if len(colTyps) == 0 { return nil, colFmtDataAllText } @@ -1631,10 +1645,10 @@ func (rs *rows) NextResultSet() error { // QuoteIdentifier quotes an "identifier" (e.g. a table or a column name) to be // used as part of an SQL statement. For example: // -// tblname := "my_table" -// data := "my_data" -// quoted := pq.QuoteIdentifier(tblname) -// err := db.Exec(fmt.Sprintf("INSERT INTO %s VALUES ($1)", quoted), data) +// tblname := "my_table" +// data := "my_data" +// quoted := pq.QuoteIdentifier(tblname) +// err := db.Exec(fmt.Sprintf("INSERT INTO %s VALUES ($1)", quoted), data) // // Any double quotes in name will be escaped. The quoted identifier will be // case sensitive when used in a query. If the input string contains a zero @@ -1647,12 +1661,24 @@ func QuoteIdentifier(name string) string { return `"` + strings.Replace(name, `"`, `""`, -1) + `"` } +// BufferQuoteIdentifier satisfies the same purpose as QuoteIdentifier, but backed by a +// byte buffer. +func BufferQuoteIdentifier(name string, buffer *bytes.Buffer) { + end := strings.IndexRune(name, 0) + if end > -1 { + name = name[:end] + } + buffer.WriteRune('"') + buffer.WriteString(strings.Replace(name, `"`, `""`, -1)) + buffer.WriteRune('"') +} + // QuoteLiteral quotes a 'literal' (e.g. a parameter, often used to pass literal // to DDL and other statements that do not accept parameters) to be used as part // of an SQL statement. For example: // -// exp_date := pq.QuoteLiteral("2023-01-05 15:00:00Z") -// err := db.Exec(fmt.Sprintf("CREATE ROLE my_user VALID UNTIL %s", exp_date)) +// exp_date := pq.QuoteLiteral("2023-01-05 15:00:00Z") +// err := db.Exec(fmt.Sprintf("CREATE ROLE my_user VALID UNTIL %s", exp_date)) // // Any single quotes in name will be escaped. Any backslashes (i.e. "\") will be // replaced by two backslashes (i.e. "\\") and the C-style escape identifier @@ -1808,7 +1834,11 @@ func (cn *conn) readParseResponse() { } } -func (cn *conn) readStatementDescribeResponse() (paramTyps []oid.Oid, colNames []string, colTyps []fieldDesc) { +func (cn *conn) readStatementDescribeResponse() ( + paramTyps []oid.Oid, + colNames []string, + colTyps []fieldDesc, +) { for { t, r := cn.recv1() switch t { @@ -1896,7 +1926,9 @@ func (cn *conn) postExecuteWorkaround() { } // Only for Exec(), since we ignore the returned data -func (cn *conn) readExecuteResponse(protocolState string) (res driver.Result, commandTag string, err error) { +func (cn *conn) readExecuteResponse( + protocolState string, +) (res driver.Result, commandTag string, err error) { for { t, r := cn.recv1() switch t { @@ -2062,3 +2094,19 @@ func alnumLowerASCII(ch rune) rune { } return -1 // discard } + +// The database/sql/driver package says: +// All Conn implementations should implement the following interfaces: Pinger, SessionResetter, and Validator. +var _ driver.Pinger = &conn{} +var _ driver.SessionResetter = &conn{} + +func (cn *conn) ResetSession(ctx context.Context) error { + // Ensure bad connections are reported: From database/sql/driver: + // If a connection is never returned to the connection pool but immediately reused, then + // ResetSession is called prior to reuse but IsValid is not called. + return cn.err.get() +} + +func (cn *conn) IsValid() bool { + return cn.err.get() == nil +} diff --git a/vendor/github.com/lib/pq/conn_go115.go b/vendor/github.com/lib/pq/conn_go115.go new file mode 100644 index 0000000..f4ef030 --- /dev/null +++ b/vendor/github.com/lib/pq/conn_go115.go @@ -0,0 +1,8 @@ +//go:build go1.15 +// +build go1.15 + +package pq + +import "database/sql/driver" + +var _ driver.Validator = &conn{} diff --git a/vendor/github.com/lib/pq/copy.go b/vendor/github.com/lib/pq/copy.go index 2f5c1ec..a8f16b2 100644 --- a/vendor/github.com/lib/pq/copy.go +++ b/vendor/github.com/lib/pq/copy.go @@ -1,6 +1,7 @@ package pq import ( + "bytes" "context" "database/sql/driver" "encoding/binary" @@ -20,29 +21,35 @@ var ( // CopyIn creates a COPY FROM statement which can be prepared with // Tx.Prepare(). The target table should be visible in search_path. func CopyIn(table string, columns ...string) string { - stmt := "COPY " + QuoteIdentifier(table) + " (" + buffer := bytes.NewBufferString("COPY ") + BufferQuoteIdentifier(table, buffer) + buffer.WriteString(" (") + makeStmt(buffer, columns...) + return buffer.String() +} + +// MakeStmt makes the stmt string for CopyIn and CopyInSchema. +func makeStmt(buffer *bytes.Buffer, columns ...string) { + //s := bytes.NewBufferString() for i, col := range columns { if i != 0 { - stmt += ", " + buffer.WriteString(", ") } - stmt += QuoteIdentifier(col) + BufferQuoteIdentifier(col, buffer) } - stmt += ") FROM STDIN" - return stmt + buffer.WriteString(") FROM STDIN") } // CopyInSchema creates a COPY FROM statement which can be prepared with // Tx.Prepare(). func CopyInSchema(schema, table string, columns ...string) string { - stmt := "COPY " + QuoteIdentifier(schema) + "." + QuoteIdentifier(table) + " (" - for i, col := range columns { - if i != 0 { - stmt += ", " - } - stmt += QuoteIdentifier(col) - } - stmt += ") FROM STDIN" - return stmt + buffer := bytes.NewBufferString("COPY ") + BufferQuoteIdentifier(schema, buffer) + buffer.WriteRune('.') + BufferQuoteIdentifier(table, buffer) + buffer.WriteString(" (") + makeStmt(buffer, columns...) + return buffer.String() } type copyin struct { diff --git a/vendor/modules.txt b/vendor/modules.txt index 1e8893d..eb83759 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -24,7 +24,7 @@ github.com/labstack/echo/v4 ## explicit; go 1.12 github.com/labstack/gommon/color github.com/labstack/gommon/log -# github.com/lib/pq v1.10.7 +# github.com/lib/pq v1.10.9 ## explicit; go 1.13 github.com/lib/pq github.com/lib/pq/oid From efc26fb27a5a27e59e543464d91d9ffa3dbd2355 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Fri, 28 Apr 2023 18:18:35 +0200 Subject: [PATCH 17/23] updated README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 58bf0cf..e5597f7 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ db_table="ipbl" ## License ```text -Copyright (c) 2020, 2021, 2022 PaulBSD +Copyright (c) 2021, 2022, 2023 PaulBSD All rights reserved. Redistribution and use in source and binary forms, with or without From a735f5402460d982f1bf982978ff6a6ffcf90deb Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Sat, 29 Apr 2023 11:14:35 +0200 Subject: [PATCH 18/23] updated WelcomeAgents func --- src/ws/init.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ws/init.go b/src/ws/init.go index 2202a40..25fb6ae 100644 --- a/src/ws/init.go +++ b/src/ws/init.go @@ -21,13 +21,14 @@ func WelcomeAgents(ws *websocket.Conn, welcome WSWelcome, t string) { connectinfo, ok := LISTENERS[welcome.Hostname] if !ok { - if t == "ps" { + switch t { + case "ps": connectinfo := ConnectionInfo{ ConnectionPS: ws, InitDate: time.Now(), } LISTENERS[welcome.Hostname] = &connectinfo - } else if t == "rr" { + case "rr": connectinfo := ConnectionInfo{ ConnectionRR: ws, InitDate: time.Now(), @@ -35,9 +36,10 @@ func WelcomeAgents(ws *websocket.Conn, welcome WSWelcome, t string) { LISTENERS[welcome.Hostname] = &connectinfo } } else { - if t == "ps" { + switch t { + case "ps": connectinfo.ConnectionPS = ws - } else if t == "rr" { + case "rr": connectinfo.ConnectionRR = ws } } From 2f60ee84e1db71415cb8b482828c2dd999494d11 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Mon, 1 May 2023 08:19:58 +0200 Subject: [PATCH 19/23] added timeout on ip scan when error --- src/models/ip.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/ip.go b/src/models/ip.go index 32e4d32..de8692d 100644 --- a/src/models/ip.go +++ b/src/models/ip.go @@ -163,7 +163,6 @@ func ScanIP(cfg *config.Config) (err error) { close(orphanchan) <-done wg.Wait() - } else { time.Sleep(30 * time.Second) } @@ -185,6 +184,7 @@ func ScanOrphan(wg *sync.WaitGroup, orphans chan IP, done chan bool, thr int, cf query, err := QueryInfo(&queryclient, orphan.IP) if err != nil { log.Println(err) + time.Sleep(10 * time.Minute) continue } From e5658ff99ff20cd9c4713cc8ed186becbe9ed10e Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Thu, 11 May 2023 07:36:48 +0200 Subject: [PATCH 20/23] updated dependencies --- go.mod | 6 ++-- go.sum | 6 ++++ vendor/golang.org/x/net/http2/transport.go | 30 +++++++++++++++---- vendor/golang.org/x/sys/unix/mkerrors.sh | 3 +- vendor/golang.org/x/sys/unix/zerrors_linux.go | 14 +++++++++ vendor/modules.txt | 6 ++-- 6 files changed, 52 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index 7fd7da5..c046b28 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.20 require ( github.com/labstack/echo/v4 v4.10.2 github.com/lib/pq v1.10.9 - golang.org/x/net v0.9.0 + golang.org/x/net v0.10.0 gopkg.in/ini.v1 v1.67.0 xorm.io/xorm v1.3.2 ) @@ -25,8 +25,8 @@ require ( github.com/syndtr/goleveldb v1.0.0 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasttemplate v1.2.2 // indirect - golang.org/x/crypto v0.8.0 // indirect - golang.org/x/sys v0.7.0 // indirect + golang.org/x/crypto v0.9.0 // indirect + golang.org/x/sys v0.8.0 // indirect golang.org/x/text v0.9.0 // indirect xorm.io/builder v0.3.12 // indirect ) diff --git a/go.sum b/go.sum index f7396e4..6f25325 100644 --- a/go.sum +++ b/go.sum @@ -414,6 +414,8 @@ golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.8.0 h1:pd9TJtTueMTVQXzk8E2XESSMQDj/U7OUu0PqJqPXQjQ= golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE= +golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g= +golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= @@ -445,6 +447,8 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM= golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= +golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -493,6 +497,8 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/vendor/golang.org/x/net/http2/transport.go b/vendor/golang.org/x/net/http2/transport.go index f965579..ac90a26 100644 --- a/vendor/golang.org/x/net/http2/transport.go +++ b/vendor/golang.org/x/net/http2/transport.go @@ -1266,6 +1266,27 @@ func (cc *ClientConn) RoundTrip(req *http.Request) (*http.Response, error) { return res, nil } + cancelRequest := func(cs *clientStream, err error) error { + cs.cc.mu.Lock() + defer cs.cc.mu.Unlock() + cs.abortStreamLocked(err) + if cs.ID != 0 { + // This request may have failed because of a problem with the connection, + // or for some unrelated reason. (For example, the user might have canceled + // the request without waiting for a response.) Mark the connection as + // not reusable, since trying to reuse a dead connection is worse than + // unnecessarily creating a new one. + // + // If cs.ID is 0, then the request was never allocated a stream ID and + // whatever went wrong was unrelated to the connection. We might have + // timed out waiting for a stream slot when StrictMaxConcurrentStreams + // is set, for example, in which case retrying on a different connection + // will not help. + cs.cc.doNotReuse = true + } + return err + } + for { select { case <-cs.respHeaderRecv: @@ -1280,15 +1301,12 @@ func (cc *ClientConn) RoundTrip(req *http.Request) (*http.Response, error) { return handleResponseHeaders() default: waitDone() - return nil, cs.abortErr + return nil, cancelRequest(cs, cs.abortErr) } case <-ctx.Done(): - err := ctx.Err() - cs.abortStream(err) - return nil, err + return nil, cancelRequest(cs, ctx.Err()) case <-cs.reqCancel: - cs.abortStream(errRequestCanceled) - return nil, errRequestCanceled + return nil, cancelRequest(cs, errRequestCanceled) } } } diff --git a/vendor/golang.org/x/sys/unix/mkerrors.sh b/vendor/golang.org/x/sys/unix/mkerrors.sh index 2045d3d..be0423e 100644 --- a/vendor/golang.org/x/sys/unix/mkerrors.sh +++ b/vendor/golang.org/x/sys/unix/mkerrors.sh @@ -204,6 +204,7 @@ struct ltchars { #include #include #include +#include #include #include #include @@ -518,7 +519,7 @@ ccflags="$@" $2 ~ /^LOCK_(SH|EX|NB|UN)$/ || $2 ~ /^LO_(KEY|NAME)_SIZE$/ || $2 ~ /^LOOP_(CLR|CTL|GET|SET)_/ || - $2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|TCP|MCAST|EVFILT|NOTE|SHUT|PROT|MAP|MFD|T?PACKET|MSG|SCM|MCL|DT|MADV|PR|LOCAL|TCPOPT)_/ || + $2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|TCP|MCAST|EVFILT|NOTE|SHUT|PROT|MAP|MFD|T?PACKET|MSG|SCM|MCL|DT|MADV|PR|LOCAL|TCPOPT|UDP)_/ || $2 ~ /^NFC_(GENL|PROTO|COMM|RF|SE|DIRECTION|LLCP|SOCKPROTO)_/ || $2 ~ /^NFC_.*_(MAX)?SIZE$/ || $2 ~ /^RAW_PAYLOAD_/ || diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux.go b/vendor/golang.org/x/sys/unix/zerrors_linux.go index 398c37e..de936b6 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux.go @@ -2967,6 +2967,7 @@ const ( SOL_TCP = 0x6 SOL_TIPC = 0x10f SOL_TLS = 0x11a + SOL_UDP = 0x11 SOL_X25 = 0x106 SOL_XDP = 0x11b SOMAXCONN = 0x1000 @@ -3251,6 +3252,19 @@ const ( TRACEFS_MAGIC = 0x74726163 TS_COMM_LEN = 0x20 UDF_SUPER_MAGIC = 0x15013346 + UDP_CORK = 0x1 + UDP_ENCAP = 0x64 + UDP_ENCAP_ESPINUDP = 0x2 + UDP_ENCAP_ESPINUDP_NON_IKE = 0x1 + UDP_ENCAP_GTP0 = 0x4 + UDP_ENCAP_GTP1U = 0x5 + UDP_ENCAP_L2TPINUDP = 0x3 + UDP_GRO = 0x68 + UDP_NO_CHECK6_RX = 0x66 + UDP_NO_CHECK6_TX = 0x65 + UDP_SEGMENT = 0x67 + UDP_V4_FLOW = 0x2 + UDP_V6_FLOW = 0x6 UMOUNT_NOFOLLOW = 0x8 USBDEVICE_SUPER_MAGIC = 0x9fa2 UTIME_NOW = 0x3fffffff diff --git a/vendor/modules.txt b/vendor/modules.txt index eb83759..9eccee6 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -65,11 +65,11 @@ github.com/valyala/bytebufferpool # github.com/valyala/fasttemplate v1.2.2 ## explicit; go 1.12 github.com/valyala/fasttemplate -# golang.org/x/crypto v0.8.0 +# golang.org/x/crypto v0.9.0 ## explicit; go 1.17 golang.org/x/crypto/acme golang.org/x/crypto/acme/autocert -# golang.org/x/net v0.9.0 +# golang.org/x/net v0.10.0 ## explicit; go 1.17 golang.org/x/net/http/httpguts golang.org/x/net/http2 @@ -77,7 +77,7 @@ golang.org/x/net/http2/h2c golang.org/x/net/http2/hpack golang.org/x/net/idna golang.org/x/net/websocket -# golang.org/x/sys v0.7.0 +# golang.org/x/sys v0.8.0 ## explicit; go 1.17 golang.org/x/sys/unix # golang.org/x/text v0.9.0 From 670f8a6f9fabe1afb1a4aaf6bae8e82a7bea077c Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Sat, 27 May 2023 18:36:15 +0200 Subject: [PATCH 21/23] updated ipbl --- src/models/ip.go | 1 + src/ws/init.go | 33 ++++++++++++++++++--------------- src/ws/pubsub.go | 5 +++-- src/ws/reqrep.go | 13 +++++++------ 4 files changed, 29 insertions(+), 23 deletions(-) diff --git a/src/models/ip.go b/src/models/ip.go index de8692d..b22f148 100644 --- a/src/models/ip.go +++ b/src/models/ip.go @@ -236,6 +236,7 @@ func QueryInfo(client *http.Client, ip string) (query QueryIP, err error) { res, err := client.Do(req) if err != nil { log.Println(err) + return } data, err := io.ReadAll(res.Body) if err != nil { diff --git a/src/ws/init.go b/src/ws/init.go index 25fb6ae..11c1cb6 100644 --- a/src/ws/init.go +++ b/src/ws/init.go @@ -8,32 +8,32 @@ import ( "golang.org/x/net/websocket" ) -var WebSocketChannel = make(chan models.APIEvent, 100) -var WebSocketChannelDone = make(chan bool) +var webSocketChannel = make(chan models.APIEvent, 100) +var webSocketChannelDone = make(chan bool) -var LISTENERS map[string]*ConnectionInfo +var listeners map[string]*connectionInfo func Init(cfg *config.Config) { - LISTENERS = make(map[string]*ConnectionInfo) + listeners = make(map[string]*connectionInfo) } -func WelcomeAgents(ws *websocket.Conn, welcome WSWelcome, t string) { - connectinfo, ok := LISTENERS[welcome.Hostname] +func welcomeAgents(ws *websocket.Conn, welcome wsWelcome, t string) { + connectinfo, ok := listeners[welcome.Hostname] if !ok { switch t { case "ps": - connectinfo := ConnectionInfo{ + connectinfo := connectionInfo{ ConnectionPS: ws, InitDate: time.Now(), } - LISTENERS[welcome.Hostname] = &connectinfo + listeners[welcome.Hostname] = &connectinfo case "rr": - connectinfo := ConnectionInfo{ + connectinfo := connectionInfo{ ConnectionRR: ws, InitDate: time.Now(), } - LISTENERS[welcome.Hostname] = &connectinfo + listeners[welcome.Hostname] = &connectinfo } } else { switch t { @@ -46,22 +46,25 @@ func WelcomeAgents(ws *websocket.Conn, welcome WSWelcome, t string) { } func gcConnOnError(ws *websocket.Conn) (err error) { - for index, value := range LISTENERS { - if value.ConnectionPS == ws || value.ConnectionRR == ws { + for index, value := range listeners { + if value.ConnectionPS == ws { value.ConnectionPS.Close() + delete(listeners, index) + } else if value.ConnectionRR == ws { value.ConnectionRR.Close() - delete(LISTENERS, index) + delete(listeners, index) } } return err } -type ConnectionInfo struct { +type connectionInfo struct { ConnectionPS *websocket.Conn ConnectionRR *websocket.Conn InitDate time.Time } -type WSWelcome struct { +// WSWelcome +type wsWelcome struct { Hostname string } diff --git a/src/ws/pubsub.go b/src/ws/pubsub.go index eeb3b97..19d22b4 100644 --- a/src/ws/pubsub.go +++ b/src/ws/pubsub.go @@ -10,11 +10,12 @@ import ( "golang.org/x/net/websocket" ) +// HandleWSPS handle pub sub flows func HandleWSPS(c echo.Context, cfg *config.Config) (err error) { websocket.Handler(func(ws *websocket.Conn) { defer ws.Close() - var welcome = WSWelcome{} + var welcome = wsWelcome{} var msg []byte err := websocket.Message.Receive(ws, &msg) @@ -26,7 +27,7 @@ func HandleWSPS(c echo.Context, cfg *config.Config) (err error) { if err != nil { log.Println(err) } else { - WelcomeAgents(ws, welcome, "ps") + welcomeAgents(ws, welcome, "ps") } err = websocket.Message.Receive(ws, "OK") diff --git a/src/ws/reqrep.go b/src/ws/reqrep.go index 5906aad..240d6f7 100644 --- a/src/ws/reqrep.go +++ b/src/ws/reqrep.go @@ -10,11 +10,12 @@ import ( "golang.org/x/net/websocket" ) +// HandleWSRR handle req rep flows func HandleWSRR(c echo.Context, cfg *config.Config) error { websocket.Handler(func(ws *websocket.Conn) { defer ws.Close() - var welcome = WSWelcome{} + var welcome = wsWelcome{} var msg []byte err := websocket.Message.Receive(ws, &msg) @@ -24,7 +25,7 @@ func HandleWSRR(c echo.Context, cfg *config.Config) error { err = json.Unmarshal(msg, &welcome) if err == nil { - WelcomeAgents(ws, welcome, "rr") + welcomeAgents(ws, welcome, "rr") } var lastip string @@ -51,7 +52,7 @@ func HandleWSRR(c echo.Context, cfg *config.Config) error { switch apievent.MsgType { case "bootstrap": log.Printf("bootstrap: %s\n", apievent.Hostname) - for index, value := range LISTENERS { + for index, value := range listeners { if index != apievent.Hostname && value.ConnectionPS != nil { err = websocket.Message.Send(value.ConnectionPS, msg) if err != nil { @@ -70,7 +71,7 @@ func HandleWSRR(c echo.Context, cfg *config.Config) error { log.Println(err) } - for _, value := range LISTENERS { + for _, value := range listeners { if value.ConnectionPS != nil { err = websocket.Message.Send(value.ConnectionPS, msg) if err != nil { @@ -81,7 +82,7 @@ func HandleWSRR(c echo.Context, cfg *config.Config) error { } log.Printf("ws: Inserted event") case "init": - for _, value := range LISTENERS { + for _, value := range listeners { if value.ConnectionPS != nil { err = websocket.Message.Send(value.ConnectionPS, msg) if err != nil { @@ -104,7 +105,7 @@ func HandleWSRR(c echo.Context, cfg *config.Config) error { err = websocket.Message.Send(ws, "OK") if err != nil { //gcConn(ws, "rr") - log.Println(LISTENERS) + log.Println(listeners) return } */ From 62ed0e030c356d617811f17408c6cea1b8d9f7f2 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Mon, 5 Jun 2023 22:00:52 +0200 Subject: [PATCH 22/23] added error handling --- src/models/ip.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/models/ip.go b/src/models/ip.go index b22f148..7c2744c 100644 --- a/src/models/ip.go +++ b/src/models/ip.go @@ -206,7 +206,10 @@ func ScanOrphan(wg *sync.WaitGroup, orphans chan IP, done chan bool, thr int, cf log.Printf("%s -> \"%s\"\n", orphan.IP, query.Rdns) } - orphan.GetOrCreate(session) + _, err = orphan.GetOrCreate(session) + if err != nil { + continue + } err = session.Commit() if err != nil { From 16b150503f020f90631ec5a7a03e65744786f702 Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 9 Jun 2023 13:44:44 +0200 Subject: [PATCH 23/23] updated dependencies --- go.mod | 2 +- go.sum | 2 ++ vendor/modules.txt | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index c046b28..0dd1778 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/json-iterator/go v1.1.12 // indirect github.com/labstack/gommon v0.4.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.18 // indirect + github.com/mattn/go-isatty v0.0.19 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/onsi/ginkgo v1.16.5 // indirect diff --git a/go.sum b/go.sum index 6f25325..ba8ea98 100644 --- a/go.sum +++ b/go.sum @@ -249,6 +249,8 @@ github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27k github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98= github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +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.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-sqlite3 v1.14.9 h1:10HX2Td0ocZpYEjhilsuo6WWtUqttj2Kb0KtD86/KYA= github.com/mattn/go-sqlite3 v1.14.9/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= diff --git a/vendor/modules.txt b/vendor/modules.txt index 9eccee6..7ca4e26 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -32,7 +32,7 @@ github.com/lib/pq/scram # github.com/mattn/go-colorable v0.1.13 ## explicit; go 1.15 github.com/mattn/go-colorable -# github.com/mattn/go-isatty v0.0.18 +# github.com/mattn/go-isatty v0.0.19 ## explicit; go 1.15 github.com/mattn/go-isatty # github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd