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/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 diff --git a/cmd/ipbl/ipbl.go b/cmd/ipbl/ipbl.go index 4747fbf..3301ae1 100644 --- a/cmd/ipbl/ipbl.go +++ b/cmd/ipbl/ipbl.go @@ -10,7 +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/zmqrouter" + "git.paulbsd.com/paulbsd/ipbl/src/ws" "git.paulbsd.com/paulbsd/ipbl/utils" _ "github.com/lib/pq" ) @@ -36,7 +36,8 @@ func main() { if !cfg.Switchs.NoScanIP { go models.ScanIP(&cfg) } - go zmqrouter.Init(&cfg) + + ws.Init(&cfg) go func() { err = routers.RunServer(&ctx, &cfg) }() if err != nil { log.Fatalln(err) diff --git a/go.mod b/go.mod index 348e33a..4d4307f 100644 --- a/go.mod +++ b/go.mod @@ -1,12 +1,12 @@ module git.paulbsd.com/paulbsd/ipbl -go 1.19 +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.11.0 gopkg.in/ini.v1 v1.67.0 - gopkg.in/zeromq/goczmq.v4 v4.1.0 xorm.io/xorm v1.3.2 ) @@ -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 @@ -25,9 +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/net v0.8.0 // indirect - golang.org/x/sys v0.6.0 // indirect - golang.org/x/text v0.8.0 // indirect + golang.org/x/crypto v0.10.0 // indirect + golang.org/x/sys v0.9.0 // indirect + golang.org/x/text v0.10.0 // indirect xorm.io/builder v0.3.12 // indirect ) diff --git a/go.sum b/go.sum index 1bb4ce1..060dcfd 100644 --- a/go.sum +++ b/go.sum @@ -76,8 +76,6 @@ 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.1 h1:lEs5Ob+oOG/Ze199njvzHbhn6p9T+h64F5hRj69iTTo= -github.com/goccy/go-json v0.10.1/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= @@ -111,12 +109,10 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= @@ -206,7 +202,6 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= @@ -226,8 +221,8 @@ github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= 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= @@ -247,12 +242,9 @@ 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-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= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= @@ -279,7 +271,6 @@ github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxzi github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= -github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= @@ -287,12 +278,10 @@ github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:v github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.22.1 h1:pY8O4lBfsHKZHM/6nrxkhVPUznOlIu3quZcKP/M20KI= github.com/onsi/gomega v1.22.1/go.mod h1:x6n7VNe4hw0vkyYUM4mjIXx3JbLiPaBPNgB7PRQ1tuM= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= @@ -312,7 +301,6 @@ github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= @@ -332,7 +320,6 @@ github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= -github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk= github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= @@ -368,7 +355,6 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE= github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= @@ -414,8 +400,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.10.0 h1:LKqV2xt9+kDzSTfOhx4FrkEBcMrAgHSYgzywV9zcGmM= +golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I= 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= @@ -425,7 +411,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.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= @@ -445,8 +430,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.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU= +golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= 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= @@ -492,8 +477,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.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= +golang.org/x/sys v0.9.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= @@ -501,8 +487,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.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58= +golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= 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= @@ -523,7 +509,6 @@ 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.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= @@ -565,7 +550,6 @@ gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:a gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= @@ -575,14 +559,10 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 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= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -lukechampine.com/uint128 v1.1.1 h1:pnxCASz787iMf+02ssImqk6OLt+Z5QHMoZyUXR4z6JU= lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= modernc.org/cc/v3 v3.33.6/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g= modernc.org/cc/v3 v3.33.9/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g= @@ -597,7 +577,6 @@ modernc.org/cc/v3 v3.35.10/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g modernc.org/cc/v3 v3.35.15/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g= modernc.org/cc/v3 v3.35.16/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g= modernc.org/cc/v3 v3.35.17/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g= -modernc.org/cc/v3 v3.35.18 h1:rMZhRcWrba0y3nVmdiQ7kxAgOOSq2m2f2VzjHLgEs6U= modernc.org/cc/v3 v3.35.18/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g= modernc.org/ccgo/v3 v3.9.5/go.mod h1:umuo2EP2oDSBnD3ckjaVUXMrmeAw8C8OSICVa0iFf60= modernc.org/ccgo/v3 v3.10.0/go.mod h1:c0yBmkRFi7uW4J7fwx/JiijwOjeAeR2NoSaRVFPmjMw= @@ -633,7 +612,6 @@ modernc.org/ccgo/v3 v3.12.66/go.mod h1:jUuxlCFZTUZLMV08s7B1ekHX5+LIAurKTTaugUr/E modernc.org/ccgo/v3 v3.12.67/go.mod h1:Bll3KwKvGROizP2Xj17GEGOTrlvB1XcVaBrC90ORO84= modernc.org/ccgo/v3 v3.12.73/go.mod h1:hngkB+nUUqzOf3iqsM48Gf1FZhY599qzVg1iX+BT3cQ= modernc.org/ccgo/v3 v3.12.81/go.mod h1:p2A1duHoBBg1mFtYvnhAnQyI6vL0uw5PGYLSIgF6rYY= -modernc.org/ccgo/v3 v3.12.82 h1:wudcnJyjLj1aQQCXF3IM9Gz2X6UNjw+afIghzdtn0v8= modernc.org/ccgo/v3 v3.12.82/go.mod h1:ApbflUfa5BKadjHynCficldU1ghjen84tuM5jRynB7w= modernc.org/ccorpus v1.11.1/go.mod h1:2gEUTrWqdpH2pXsmTM1ZkjeSrUWDpjMu2T6m29L/ErQ= modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM= @@ -671,24 +649,17 @@ modernc.org/libc v1.11.71/go.mod h1:DUOmMYe+IvKi9n6Mycyx3DbjfzSKrdr/0Vgt3j7P5gw= modernc.org/libc v1.11.75/go.mod h1:dGRVugT6edz361wmD9gk6ax1AbDSe0x5vji0dGJiPT0= modernc.org/libc v1.11.82/go.mod h1:NF+Ek1BOl2jeC7lw3a7Jj5PWyHPwWD4aq3wVKxqV1fI= modernc.org/libc v1.11.86/go.mod h1:ePuYgoQLmvxdNT06RpGnaDKJmDNEkV7ZPKI2jnsvZoE= -modernc.org/libc v1.11.87 h1:PzIzOqtlzMDDcCzJ5cUP6h/Ku6Fa9iyflP2ccTY64aE= modernc.org/libc v1.11.87/go.mod h1:Qvd5iXTeLhI5PS0XSyqMY99282y+3euapQFxM7jYnpY= modernc.org/mathutil v1.1.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= modernc.org/mathutil v1.4.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= -modernc.org/mathutil v1.4.1 h1:ij3fYGe8zBF4Vu+g0oT7mB06r8sqGWKuJu1yXeR4by8= modernc.org/mathutil v1.4.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= modernc.org/memory v1.0.4/go.mod h1:nV2OApxradM3/OVbs2/0OsP6nPfakXpi50C7dcoHXlc= -modernc.org/memory v1.0.5 h1:XRch8trV7GgvTec2i7jc33YlUI0RKVDBvZ5eZ5m8y14= modernc.org/memory v1.0.5/go.mod h1:B7OYswTRnfGg+4tDH1t1OeUNnsy2viGTdME4tzd+IjM= -modernc.org/opt v0.1.1 h1:/0RX92k9vwVeDXj+Xn23DKp2VJubL7k8qNffND6qn3A= modernc.org/opt v0.1.1/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= -modernc.org/sqlite v1.14.2 h1:ohsW2+e+Qe2To1W6GNezzKGwjXwSax6R+CrhRxVaFbE= modernc.org/sqlite v1.14.2/go.mod h1:yqfn85u8wVOE6ub5UT8VI9JjhrwBUUCNyTACN0h6Sx8= -modernc.org/strutil v1.1.1 h1:xv+J1BXY3Opl2ALrBwyfEikFAj8pmqcpnfmuwUwcozs= modernc.org/strutil v1.1.1/go.mod h1:DE+MQQ/hjKBZS2zNInV5hhcipt5rLPWkmpbGeW5mmdw= modernc.org/tcl v1.8.13/go.mod h1:V+q/Ef0IJaNUSECieLU4o+8IScapxnMyFV6i/7uQlAY= -modernc.org/token v1.0.0 h1:a0jaWiNMDhDUtqOj09wvjWWAqd3q7WpBulmL9H2egsk= modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= modernc.org/z v1.2.19/go.mod h1:+ZpP0pc4zz97eukOzW3xagV/lS82IpPN9NGG5pNF9vY= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= 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/cfg.go b/src/models/cfg.go index f00253b..24370fa 100644 --- a/src/models/cfg.go +++ b/src/models/cfg.go @@ -94,8 +94,8 @@ func InsertOrUpdateSets(cfg config.Config, folders []CfgSet) (res string, err er return } -func GetZMQ(cfg config.Config) (res []CfgZMQ, err error) { - var w = []CfgZMQ{} +func GetWS(cfg config.Config) (res []CfgWS, err error) { + var w = []CfgWS{} if err = cfg.Db.Find(&w); err == nil { return w, err @@ -140,11 +140,10 @@ type CfgTrustlist struct { IP string `xorm:"text notnull" json:"ip"` } -type CfgZMQ struct { +type CfgWS 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"` + Endpoint string `xorm:"text notnull" json:"endpoint"` Subscription string `json:"subscription"` } diff --git a/src/models/ip.go b/src/models/ip.go index bb875eb..7c2744c 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 } @@ -202,9 +202,14 @@ 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) + _, err = orphan.GetOrCreate(session) + if err != nil { + continue + } err = session.Commit() if err != nil { @@ -225,40 +230,29 @@ 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) + return + } + 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..4a7f6e5 100644 --- a/src/models/models.go +++ b/src/models/models.go @@ -23,7 +23,7 @@ func init() { new(Cfg), 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..6524909 100644 --- a/src/routers/funcs.go +++ b/src/routers/funcs.go @@ -3,12 +3,12 @@ package routers import ( "context" "fmt" - "log" "net/http" "strconv" "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" ) @@ -85,8 +85,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) - log.Println(msg) + msg = fmt.Sprintf("Inserted %d IP, Updated %d IP", numinsert, numupdate) return Result(c, err, msg) }) e.POST("/event", func(c echo.Context) (err error) { @@ -141,12 +140,21 @@ 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) + 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", 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..11c1cb6 --- /dev/null +++ b/src/ws/init.go @@ -0,0 +1,70 @@ +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 { + switch t { + case "ps": + connectinfo := connectionInfo{ + ConnectionPS: ws, + InitDate: time.Now(), + } + listeners[welcome.Hostname] = &connectinfo + case "rr": + connectinfo := connectionInfo{ + ConnectionRR: ws, + InitDate: time.Now(), + } + listeners[welcome.Hostname] = &connectinfo + } + } else { + switch t { + case "ps": + connectinfo.ConnectionPS = ws + case "rr": + connectinfo.ConnectionRR = ws + } + } +} + +func gcConnOnError(ws *websocket.Conn) (err error) { + 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) + } + } + return err +} + +type connectionInfo struct { + ConnectionPS *websocket.Conn + ConnectionRR *websocket.Conn + InitDate time.Time +} + +// WSWelcome +type wsWelcome struct { + Hostname string +} diff --git a/src/ws/pubsub.go b/src/ws/pubsub.go new file mode 100644 index 0000000..19d22b4 --- /dev/null +++ b/src/ws/pubsub.go @@ -0,0 +1,61 @@ +package ws + +import ( + "encoding/json" + "log" + "time" + + "git.paulbsd.com/paulbsd/ipbl/src/config" + "github.com/labstack/echo/v4" + "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 msg []byte + err := websocket.Message.Receive(ws, &msg) + if err != nil { + log.Println(err) + } + + err = json.Unmarshal(msg, &welcome) + if err != nil { + log.Println(err) + } else { + 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 { + 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/reqrep.go b/src/ws/reqrep.go new file mode 100644 index 0000000..240d6f7 --- /dev/null +++ b/src/ws/reqrep.go @@ -0,0 +1,116 @@ +package ws + +import ( + "encoding/json" + "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" +) + +// 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 msg []byte + err := websocket.Message.Receive(ws, &msg) + if err != nil { + log.Println(err) + } + + err = json.Unmarshal(msg, &welcome) + if err == nil { + welcomeAgents(ws, welcome, "rr") + } + + var lastip string + for { + var apievent = models.APIEvent{} + var event = models.Event{} + + var msg []byte + err := websocket.Message.Receive(ws, &msg) + if err != nil { + log.Println(err) + return + } + + err = json.Unmarshal(msg, &apievent) + if err != nil { + log.Println(err) + } + + if apievent.IPData.IP != "" && apievent.IPData.IP == lastip { + continue + } + + switch apievent.MsgType { + case "bootstrap": + log.Printf("bootstrap: %s\n", apievent.Hostname) + for index, value := range listeners { + if index != apievent.Hostname && value.ConnectionPS != nil { + err = websocket.Message.Send(value.ConnectionPS, msg) + if err != nil { + log.Println(err) + gcConnOnError(ws) + } + } + } + case "add": + session := cfg.Db.NewSession() + event.APIParse(session, apievent) + session.Close() + + err := event.Insert(cfg) + if err != nil { + log.Println(err) + } + + for _, value := range listeners { + 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 { + if value.ConnectionPS != nil { + err = websocket.Message.Send(value.ConnectionPS, msg) + if err != nil { + log.Println(err) + gcConnOnError(ws) + } + } + } + default: + } + + err = websocket.Message.Send(ws, "OK") + if err != nil { + 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 +} diff --git a/src/zmqrouter/main.go b/src/zmqrouter/main.go deleted file mode 100644 index 77ba7c5..0000000 --- a/src/zmqrouter/main.go +++ /dev/null @@ -1,102 +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) { - log.Println("Initiating ZMQ sockets") - - reqsock, err := InitRep() - if err != nil { - return - } - - pubsock, err := InitPub() - if err != nil { - return - } - - Handle(cfg, reqsock, pubsock, cfg.Options.ZMQChannel) - 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/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/golang.org/x/net/http2/h2c/h2c.go b/vendor/golang.org/x/net/http2/h2c/h2c.go index a72bbed..2d6bf86 100644 --- a/vendor/golang.org/x/net/http2/h2c/h2c.go +++ b/vendor/golang.org/x/net/http2/h2c/h2c.go @@ -44,7 +44,7 @@ func init() { // HTTP/1, but unlikely to occur in practice and (2) Upgrading from HTTP/1 to // h2c - this works by using the HTTP/1 Upgrade header to request an upgrade to // h2c. When either of those situations occur we hijack the HTTP/1 connection, -// convert it to a HTTP/2 connection and pass the net.Conn to http2.ServeConn. +// convert it to an HTTP/2 connection and pass the net.Conn to http2.ServeConn. type h2cHandler struct { Handler http.Handler s *http2.Server 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..033b6e6 100644 --- a/vendor/golang.org/x/net/http2/server.go +++ b/vendor/golang.org/x/net/http2/server.go @@ -441,7 +441,7 @@ func (s *Server) ServeConn(c net.Conn, opts *ServeConnOpts) { if s.NewWriteScheduler != nil { sc.writeSched = s.NewWriteScheduler() } else { - sc.writeSched = NewPriorityWriteScheduler(nil) + sc.writeSched = newRoundRobinWriteScheduler() } // These start at the RFC-specified defaults. If there is a higher @@ -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 @@ -2426,7 +2429,7 @@ type requestBody struct { conn *serverConn closeOnce sync.Once // for use by Close only sawEOF bool // for use by Read only - pipe *pipe // non-nil if we have a HTTP entity message body + pipe *pipe // non-nil if we have an HTTP entity message body needsContinue bool // need to send a 100-continue } @@ -2566,7 +2569,8 @@ func (rws *responseWriterState) writeChunk(p []byte) (n int, err error) { clen = "" } } - if clen == "" && rws.handlerDone && bodyAllowedForStatus(rws.status) && (len(p) > 0 || !isHeadResp) { + _, hasContentLength := rws.snapHeader["Content-Length"] + if !hasContentLength && clen == "" && rws.handlerDone && bodyAllowedForStatus(rws.status) && (len(p) > 0 || !isHeadResp) { clen = strconv.Itoa(len(p)) } _, hasContentType := rws.snapHeader["Content-Type"] @@ -2771,7 +2775,7 @@ func (w *responseWriter) FlushError() error { err = rws.bw.Flush() } else { // The bufio.Writer won't call chunkWriter.Write - // (writeChunk with zero bytes, so we have to do it + // (writeChunk with zero bytes), so we have to do it // ourselves to force the HTTP response header and/or // final DATA frame (with END_STREAM) to be sent. _, err = chunkWriter{rws}.Write(nil) diff --git a/vendor/golang.org/x/net/http2/transport.go b/vendor/golang.org/x/net/http2/transport.go index 05ba23d..4f08ccb 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() @@ -1265,6 +1266,44 @@ func (cc *ClientConn) RoundTrip(req *http.Request) (*http.Response, error) { return res, nil } + cancelRequest := func(cs *clientStream, err error) error { + cs.cc.mu.Lock() + cs.abortStreamLocked(err) + bodyClosed := cs.reqBodyClosed + 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 + } + cs.cc.mu.Unlock() + // Wait for the request body to be closed. + // + // If nothing closed the body before now, abortStreamLocked + // will have started a goroutine to close it. + // + // Closing the body before returning avoids a race condition + // with net/http checking its readTrackingBody to see if the + // body was read from or closed. See golang/go#60041. + // + // The body is closed in a separate goroutine without the + // connection mutex held, but dropping the mutex before waiting + // will keep us from holding it indefinitely if the body + // close is slow for some reason. + if bodyClosed != nil { + <-bodyClosed + } + return err + } + for { select { case <-cs.respHeaderRecv: @@ -1279,15 +1318,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) } } } @@ -1880,7 +1916,7 @@ func (cc *ClientConn) encodeHeaders(req *http.Request, addGzipHeader bool, trail // 8.1.2.3 Request Pseudo-Header Fields // The :path pseudo-header field includes the path and query parts of the // target URI (the path-absolute production and optionally a '?' character - // followed by the query production (see Sections 3.3 and 3.4 of + // followed by the query production, see Sections 3.3 and 3.4 of // [RFC3986]). f(":authority", host) m := req.Method @@ -2555,6 +2591,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 +2612,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/net/http2/writesched.go b/vendor/golang.org/x/net/http2/writesched.go index c7cd001..cc893ad 100644 --- a/vendor/golang.org/x/net/http2/writesched.go +++ b/vendor/golang.org/x/net/http2/writesched.go @@ -184,7 +184,8 @@ func (wr *FrameWriteRequest) replyToWriter(err error) { // writeQueue is used by implementations of WriteScheduler. type writeQueue struct { - s []FrameWriteRequest + s []FrameWriteRequest + prev, next *writeQueue } func (q *writeQueue) empty() bool { return len(q.s) == 0 } diff --git a/vendor/golang.org/x/net/http2/writesched_roundrobin.go b/vendor/golang.org/x/net/http2/writesched_roundrobin.go new file mode 100644 index 0000000..54fe863 --- /dev/null +++ b/vendor/golang.org/x/net/http2/writesched_roundrobin.go @@ -0,0 +1,119 @@ +// Copyright 2023 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 http2 + +import ( + "fmt" + "math" +) + +type roundRobinWriteScheduler struct { + // control contains control frames (SETTINGS, PING, etc.). + control writeQueue + + // streams maps stream ID to a queue. + streams map[uint32]*writeQueue + + // stream queues are stored in a circular linked list. + // head is the next stream to write, or nil if there are no streams open. + head *writeQueue + + // pool of empty queues for reuse. + queuePool writeQueuePool +} + +// newRoundRobinWriteScheduler constructs a new write scheduler. +// The round robin scheduler priorizes control frames +// like SETTINGS and PING over DATA frames. +// When there are no control frames to send, it performs a round-robin +// selection from the ready streams. +func newRoundRobinWriteScheduler() WriteScheduler { + ws := &roundRobinWriteScheduler{ + streams: make(map[uint32]*writeQueue), + } + return ws +} + +func (ws *roundRobinWriteScheduler) OpenStream(streamID uint32, options OpenStreamOptions) { + if ws.streams[streamID] != nil { + panic(fmt.Errorf("stream %d already opened", streamID)) + } + q := ws.queuePool.get() + ws.streams[streamID] = q + if ws.head == nil { + ws.head = q + q.next = q + q.prev = q + } else { + // Queues are stored in a ring. + // Insert the new stream before ws.head, putting it at the end of the list. + q.prev = ws.head.prev + q.next = ws.head + q.prev.next = q + q.next.prev = q + } +} + +func (ws *roundRobinWriteScheduler) CloseStream(streamID uint32) { + q := ws.streams[streamID] + if q == nil { + return + } + if q.next == q { + // This was the only open stream. + ws.head = nil + } else { + q.prev.next = q.next + q.next.prev = q.prev + if ws.head == q { + ws.head = q.next + } + } + delete(ws.streams, streamID) + ws.queuePool.put(q) +} + +func (ws *roundRobinWriteScheduler) AdjustStream(streamID uint32, priority PriorityParam) {} + +func (ws *roundRobinWriteScheduler) Push(wr FrameWriteRequest) { + if wr.isControl() { + ws.control.push(wr) + return + } + q := ws.streams[wr.StreamID()] + if q == nil { + // This is a closed stream. + // wr should not be a HEADERS or DATA frame. + // We push the request onto the control queue. + if wr.DataSize() > 0 { + panic("add DATA on non-open stream") + } + ws.control.push(wr) + return + } + q.push(wr) +} + +func (ws *roundRobinWriteScheduler) Pop() (FrameWriteRequest, bool) { + // Control and RST_STREAM frames first. + if !ws.control.empty() { + return ws.control.shift(), true + } + if ws.head == nil { + return FrameWriteRequest{}, false + } + q := ws.head + for { + if wr, ok := q.consume(math.MaxInt32); ok { + ws.head = q.next + return wr, true + } + q = q.next + if q == ws.head { + break + } + } + return FrameWriteRequest{}, false +} 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_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/mkall.sh b/vendor/golang.org/x/sys/unix/mkall.sh index 8e3947c..e6f31d3 100644 --- a/vendor/golang.org/x/sys/unix/mkall.sh +++ b/vendor/golang.org/x/sys/unix/mkall.sh @@ -50,7 +50,7 @@ if [[ "$GOOS" = "linux" ]]; then # Use the Docker-based build system # Files generated through docker (use $cmd so you can Ctl-C the build or run) $cmd docker build --tag generate:$GOOS $GOOS - $cmd docker run --interactive --tty --volume $(cd -- "$(dirname -- "$0")/.." && /bin/pwd):/build generate:$GOOS + $cmd docker run --interactive --tty --volume $(cd -- "$(dirname -- "$0")/.." && pwd):/build generate:$GOOS exit fi diff --git a/vendor/golang.org/x/sys/unix/mkerrors.sh b/vendor/golang.org/x/sys/unix/mkerrors.sh index 7456d9d..3156462 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 @@ -203,6 +204,7 @@ struct ltchars { #include #include #include +#include #include #include #include @@ -517,10 +519,11 @@ 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_/ || + $2 ~ /^[US]F_/ || $2 ~ /^TP_STATUS_/ || $2 ~ /^FALLOC_/ || $2 ~ /^ICMPV?6?_(FILTER|SEC)/ || @@ -738,7 +741,8 @@ main(void) e = errors[i].num; if(i > 0 && errors[i-1].num == e) continue; - strcpy(buf, strerror(e)); + strncpy(buf, strerror(e), sizeof(buf) - 1); + buf[sizeof(buf) - 1] = '\0'; // lowercase first letter: Bad -> bad, but STREAM -> STREAM. if(A <= buf[0] && buf[0] <= Z && a <= buf[1] && buf[1] <= z) buf[0] += a - A; @@ -757,7 +761,8 @@ main(void) e = signals[i].num; if(i > 0 && signals[i-1].num == e) continue; - strcpy(buf, strsignal(e)); + strncpy(buf, strsignal(e), sizeof(buf) - 1); + buf[sizeof(buf) - 1] = '\0'; // lowercase first letter: Bad -> bad, but STREAM -> STREAM. if(A <= buf[0] && buf[0] <= Z && a <= buf[1] && buf[1] <= z) buf[0] += a - A; 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..6de486b 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux.go @@ -1699,12 +1699,23 @@ func PtracePokeUser(pid int, addr uintptr, data []byte) (count int, err error) { return ptracePoke(PTRACE_POKEUSR, PTRACE_PEEKUSR, pid, addr, data) } +// elfNT_PRSTATUS is a copy of the debug/elf.NT_PRSTATUS constant so +// x/sys/unix doesn't need to depend on debug/elf and thus +// compress/zlib, debug/dwarf, and other packages. +const elfNT_PRSTATUS = 1 + func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error) { - return ptracePtr(PTRACE_GETREGS, pid, 0, unsafe.Pointer(regsout)) + var iov Iovec + iov.Base = (*byte)(unsafe.Pointer(regsout)) + iov.SetLen(int(unsafe.Sizeof(*regsout))) + return ptracePtr(PTRACE_GETREGSET, pid, uintptr(elfNT_PRSTATUS), unsafe.Pointer(&iov)) } func PtraceSetRegs(pid int, regs *PtraceRegs) (err error) { - return ptracePtr(PTRACE_SETREGS, pid, 0, unsafe.Pointer(regs)) + var iov Iovec + iov.Base = (*byte)(unsafe.Pointer(regs)) + iov.SetLen(int(unsafe.Sizeof(*regs))) + return ptracePtr(PTRACE_SETREGSET, pid, uintptr(elfNT_PRSTATUS), unsafe.Pointer(&iov)) } func PtraceSetOptions(pid int, options int) (err error) { @@ -1873,7 +1884,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 +1897,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. @@ -2412,6 +2431,21 @@ func PthreadSigmask(how int, set, oldset *Sigset_t) error { return rtSigprocmask(how, set, oldset, _C__NSIG/8) } +//sysnb getresuid(ruid *_C_int, euid *_C_int, suid *_C_int) +//sysnb getresgid(rgid *_C_int, egid *_C_int, sgid *_C_int) + +func Getresuid() (ruid, euid, suid int) { + var r, e, s _C_int + getresuid(&r, &e, &s) + return int(r), int(e), int(s) +} + +func Getresgid() (rgid, egid, sgid int) { + var r, e, s _C_int + getresgid(&r, &e, &s) + return int(r), int(e), int(s) +} + /* * Unimplemented */ 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..c5f166a 100644 --- a/vendor/golang.org/x/sys/unix/syscall_openbsd.go +++ b/vendor/golang.org/x/sys/unix/syscall_openbsd.go @@ -151,6 +151,21 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { return } +//sysnb getresuid(ruid *_C_int, euid *_C_int, suid *_C_int) +//sysnb getresgid(rgid *_C_int, egid *_C_int, sgid *_C_int) + +func Getresuid() (ruid, euid, suid int) { + var r, e, s _C_int + getresuid(&r, &e, &s) + return int(r), int(e), int(s) +} + +func Getresgid() (rgid, egid, sgid int) { + var r, e, s _C_int + getresgid(&r, &e, &s) + return int(r), int(e), int(s) +} + //sys ioctl(fd int, req uint, arg uintptr) (err error) //sys ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) = SYS_IOCTL @@ -294,7 +309,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) @@ -339,8 +353,6 @@ func Uname(uname *Utsname) error { // getgid // getitimer // getlogin -// getresgid -// getresuid // getthrid // ktrace // lfs_bmapv 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/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/golang.org/x/sys/unix/zerrors_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go index f619252..4898420 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go @@ -329,6 +329,54 @@ const ( SCM_WIFI_STATUS = 0x25 SFD_CLOEXEC = 0x400000 SFD_NONBLOCK = 0x4000 + SF_FP = 0x38 + SF_I0 = 0x20 + SF_I1 = 0x24 + SF_I2 = 0x28 + SF_I3 = 0x2c + SF_I4 = 0x30 + SF_I5 = 0x34 + SF_L0 = 0x0 + SF_L1 = 0x4 + SF_L2 = 0x8 + SF_L3 = 0xc + SF_L4 = 0x10 + SF_L5 = 0x14 + SF_L6 = 0x18 + SF_L7 = 0x1c + SF_PC = 0x3c + SF_RETP = 0x40 + SF_V9_FP = 0x70 + SF_V9_I0 = 0x40 + SF_V9_I1 = 0x48 + SF_V9_I2 = 0x50 + SF_V9_I3 = 0x58 + SF_V9_I4 = 0x60 + SF_V9_I5 = 0x68 + SF_V9_L0 = 0x0 + SF_V9_L1 = 0x8 + SF_V9_L2 = 0x10 + SF_V9_L3 = 0x18 + SF_V9_L4 = 0x20 + SF_V9_L5 = 0x28 + SF_V9_L6 = 0x30 + SF_V9_L7 = 0x38 + SF_V9_PC = 0x78 + SF_V9_RETP = 0x80 + SF_V9_XARG0 = 0x88 + SF_V9_XARG1 = 0x90 + SF_V9_XARG2 = 0x98 + SF_V9_XARG3 = 0xa0 + SF_V9_XARG4 = 0xa8 + SF_V9_XARG5 = 0xb0 + SF_V9_XXARG = 0xb8 + SF_XARG0 = 0x44 + SF_XARG1 = 0x48 + SF_XARG2 = 0x4c + SF_XARG3 = 0x50 + SF_XARG4 = 0x54 + SF_XARG5 = 0x58 + SF_XXARG = 0x5c SIOCATMARK = 0x8905 SIOCGPGRP = 0x8904 SIOCGSTAMPNS_NEW = 0x40108907 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..722c29a 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 { @@ -2182,3 +2172,17 @@ func rtSigprocmask(how int, set *Sigset_t, oldset *Sigset_t, sigsetsize uintptr) } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getresuid(ruid *_C_int, euid *_C_int, suid *_C_int) { + RawSyscallNoError(SYS_GETRESUID, uintptr(unsafe.Pointer(ruid)), uintptr(unsafe.Pointer(euid)), uintptr(unsafe.Pointer(suid))) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getresgid(rgid *_C_int, egid *_C_int, sgid *_C_int) { + RawSyscallNoError(SYS_GETRESGID, uintptr(unsafe.Pointer(rgid)), uintptr(unsafe.Pointer(egid)), uintptr(unsafe.Pointer(sgid))) + return +} 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..9ab9abf 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go @@ -519,6 +519,28 @@ var libc_getcwd_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func getresuid(ruid *_C_int, euid *_C_int, suid *_C_int) { + syscall_rawSyscall(libc_getresuid_trampoline_addr, uintptr(unsafe.Pointer(ruid)), uintptr(unsafe.Pointer(euid)), uintptr(unsafe.Pointer(suid))) + return +} + +var libc_getresuid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getresuid getresuid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getresgid(rgid *_C_int, egid *_C_int, sgid *_C_int) { + syscall_rawSyscall(libc_getresgid_trampoline_addr, uintptr(unsafe.Pointer(rgid)), uintptr(unsafe.Pointer(egid)), uintptr(unsafe.Pointer(sgid))) + return +} + +var libc_getresgid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getresgid getresgid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func ioctl(fd int, req uint, arg uintptr) (err error) { _, _, e1 := syscall_syscall(libc_ioctl_trampoline_addr, uintptr(fd), uintptr(req), uintptr(arg)) if e1 != 0 { @@ -1894,20 +1916,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..3dcacd3 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s @@ -158,6 +158,16 @@ TEXT libc_getcwd_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_getcwd_trampoline_addr(SB), RODATA, $4 DATA ·libc_getcwd_trampoline_addr(SB)/4, $libc_getcwd_trampoline<>(SB) +TEXT libc_getresuid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getresuid(SB) +GLOBL ·libc_getresuid_trampoline_addr(SB), RODATA, $4 +DATA ·libc_getresuid_trampoline_addr(SB)/4, $libc_getresuid_trampoline<>(SB) + +TEXT libc_getresgid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getresgid(SB) +GLOBL ·libc_getresgid_trampoline_addr(SB), RODATA, $4 +DATA ·libc_getresgid_trampoline_addr(SB)/4, $libc_getresgid_trampoline<>(SB) + TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_ioctl(SB) GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $4 @@ -573,11 +583,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..915761e 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go @@ -519,15 +519,29 @@ var libc_getcwd_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func ioctl(fd int, req uint, arg uintptr) (err error) { - _, _, e1 := syscall_syscall(libc_ioctl_trampoline_addr, uintptr(fd), uintptr(req), uintptr(arg)) - if e1 != 0 { - err = errnoErr(e1) - } +func getresuid(ruid *_C_int, euid *_C_int, suid *_C_int) { + syscall_rawSyscall(libc_getresuid_trampoline_addr, uintptr(unsafe.Pointer(ruid)), uintptr(unsafe.Pointer(euid)), uintptr(unsafe.Pointer(suid))) return } -func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { +var libc_getresuid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getresuid getresuid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getresgid(rgid *_C_int, egid *_C_int, sgid *_C_int) { + syscall_rawSyscall(libc_getresgid_trampoline_addr, uintptr(unsafe.Pointer(rgid)), uintptr(unsafe.Pointer(egid)), uintptr(unsafe.Pointer(sgid))) + return +} + +var libc_getresgid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getresgid getresgid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ioctl(fd int, req uint, arg uintptr) (err error) { _, _, e1 := syscall_syscall(libc_ioctl_trampoline_addr, uintptr(fd), uintptr(req), uintptr(arg)) if e1 != 0 { err = errnoErr(e1) @@ -541,6 +555,16 @@ var libc_ioctl_trampoline_addr uintptr // 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(libc_ioctl_trampoline_addr, 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 { @@ -1894,20 +1918,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..2763620 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s @@ -158,6 +158,16 @@ TEXT libc_getcwd_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_getcwd_trampoline_addr(SB), RODATA, $8 DATA ·libc_getcwd_trampoline_addr(SB)/8, $libc_getcwd_trampoline<>(SB) +TEXT libc_getresuid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getresuid(SB) +GLOBL ·libc_getresuid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getresuid_trampoline_addr(SB)/8, $libc_getresuid_trampoline<>(SB) + +TEXT libc_getresgid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getresgid(SB) +GLOBL ·libc_getresgid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getresgid_trampoline_addr(SB)/8, $libc_getresgid_trampoline<>(SB) + TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_ioctl(SB) GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $8 @@ -573,11 +583,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..8e87fdf 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go @@ -519,6 +519,28 @@ var libc_getcwd_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func getresuid(ruid *_C_int, euid *_C_int, suid *_C_int) { + syscall_rawSyscall(libc_getresuid_trampoline_addr, uintptr(unsafe.Pointer(ruid)), uintptr(unsafe.Pointer(euid)), uintptr(unsafe.Pointer(suid))) + return +} + +var libc_getresuid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getresuid getresuid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getresgid(rgid *_C_int, egid *_C_int, sgid *_C_int) { + syscall_rawSyscall(libc_getresgid_trampoline_addr, uintptr(unsafe.Pointer(rgid)), uintptr(unsafe.Pointer(egid)), uintptr(unsafe.Pointer(sgid))) + return +} + +var libc_getresgid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getresgid getresgid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func ioctl(fd int, req uint, arg uintptr) (err error) { _, _, e1 := syscall_syscall(libc_ioctl_trampoline_addr, uintptr(fd), uintptr(req), uintptr(arg)) if e1 != 0 { @@ -1894,20 +1916,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..c922314 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s @@ -158,6 +158,16 @@ TEXT libc_getcwd_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_getcwd_trampoline_addr(SB), RODATA, $4 DATA ·libc_getcwd_trampoline_addr(SB)/4, $libc_getcwd_trampoline<>(SB) +TEXT libc_getresuid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getresuid(SB) +GLOBL ·libc_getresuid_trampoline_addr(SB), RODATA, $4 +DATA ·libc_getresuid_trampoline_addr(SB)/4, $libc_getresuid_trampoline<>(SB) + +TEXT libc_getresgid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getresgid(SB) +GLOBL ·libc_getresgid_trampoline_addr(SB), RODATA, $4 +DATA ·libc_getresgid_trampoline_addr(SB)/4, $libc_getresgid_trampoline<>(SB) + TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_ioctl(SB) GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $4 @@ -573,11 +583,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..12a7a21 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go @@ -519,6 +519,28 @@ var libc_getcwd_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func getresuid(ruid *_C_int, euid *_C_int, suid *_C_int) { + syscall_rawSyscall(libc_getresuid_trampoline_addr, uintptr(unsafe.Pointer(ruid)), uintptr(unsafe.Pointer(euid)), uintptr(unsafe.Pointer(suid))) + return +} + +var libc_getresuid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getresuid getresuid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getresgid(rgid *_C_int, egid *_C_int, sgid *_C_int) { + syscall_rawSyscall(libc_getresgid_trampoline_addr, uintptr(unsafe.Pointer(rgid)), uintptr(unsafe.Pointer(egid)), uintptr(unsafe.Pointer(sgid))) + return +} + +var libc_getresgid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getresgid getresgid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func ioctl(fd int, req uint, arg uintptr) (err error) { _, _, e1 := syscall_syscall(libc_ioctl_trampoline_addr, uintptr(fd), uintptr(req), uintptr(arg)) if e1 != 0 { @@ -1894,20 +1916,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..a6bc32c 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s @@ -158,6 +158,16 @@ TEXT libc_getcwd_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_getcwd_trampoline_addr(SB), RODATA, $8 DATA ·libc_getcwd_trampoline_addr(SB)/8, $libc_getcwd_trampoline<>(SB) +TEXT libc_getresuid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getresuid(SB) +GLOBL ·libc_getresuid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getresuid_trampoline_addr(SB)/8, $libc_getresuid_trampoline<>(SB) + +TEXT libc_getresgid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getresgid(SB) +GLOBL ·libc_getresgid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getresgid_trampoline_addr(SB)/8, $libc_getresgid_trampoline<>(SB) + TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_ioctl(SB) GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $8 @@ -573,11 +583,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..b19e8aa 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go @@ -519,6 +519,28 @@ var libc_getcwd_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func getresuid(ruid *_C_int, euid *_C_int, suid *_C_int) { + syscall_rawSyscall(libc_getresuid_trampoline_addr, uintptr(unsafe.Pointer(ruid)), uintptr(unsafe.Pointer(euid)), uintptr(unsafe.Pointer(suid))) + return +} + +var libc_getresuid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getresuid getresuid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getresgid(rgid *_C_int, egid *_C_int, sgid *_C_int) { + syscall_rawSyscall(libc_getresgid_trampoline_addr, uintptr(unsafe.Pointer(rgid)), uintptr(unsafe.Pointer(egid)), uintptr(unsafe.Pointer(sgid))) + return +} + +var libc_getresgid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getresgid getresgid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func ioctl(fd int, req uint, arg uintptr) (err error) { _, _, e1 := syscall_syscall(libc_ioctl_trampoline_addr, uintptr(fd), uintptr(req), uintptr(arg)) if e1 != 0 { @@ -1894,20 +1916,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..b4e7bce 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s @@ -158,6 +158,16 @@ TEXT libc_getcwd_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_getcwd_trampoline_addr(SB), RODATA, $8 DATA ·libc_getcwd_trampoline_addr(SB)/8, $libc_getcwd_trampoline<>(SB) +TEXT libc_getresuid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getresuid(SB) +GLOBL ·libc_getresuid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getresuid_trampoline_addr(SB)/8, $libc_getresuid_trampoline<>(SB) + +TEXT libc_getresgid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getresgid(SB) +GLOBL ·libc_getresgid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getresgid_trampoline_addr(SB)/8, $libc_getresgid_trampoline<>(SB) + TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_ioctl(SB) GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $8 @@ -573,11 +583,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..fb99594 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go @@ -519,6 +519,28 @@ var libc_getcwd_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func getresuid(ruid *_C_int, euid *_C_int, suid *_C_int) { + syscall_rawSyscall(libc_getresuid_trampoline_addr, uintptr(unsafe.Pointer(ruid)), uintptr(unsafe.Pointer(euid)), uintptr(unsafe.Pointer(suid))) + return +} + +var libc_getresuid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getresuid getresuid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getresgid(rgid *_C_int, egid *_C_int, sgid *_C_int) { + syscall_rawSyscall(libc_getresgid_trampoline_addr, uintptr(unsafe.Pointer(rgid)), uintptr(unsafe.Pointer(egid)), uintptr(unsafe.Pointer(sgid))) + return +} + +var libc_getresgid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getresgid getresgid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func ioctl(fd int, req uint, arg uintptr) (err error) { _, _, e1 := syscall_syscall(libc_ioctl_trampoline_addr, uintptr(fd), uintptr(req), uintptr(arg)) if e1 != 0 { @@ -1894,20 +1916,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..ca3f766 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s @@ -189,6 +189,18 @@ TEXT libc_getcwd_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_getcwd_trampoline_addr(SB), RODATA, $8 DATA ·libc_getcwd_trampoline_addr(SB)/8, $libc_getcwd_trampoline<>(SB) +TEXT libc_getresuid_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_getresuid(SB) + RET +GLOBL ·libc_getresuid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getresuid_trampoline_addr(SB)/8, $libc_getresuid_trampoline<>(SB) + +TEXT libc_getresgid_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_getresgid(SB) + RET +GLOBL ·libc_getresgid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getresgid_trampoline_addr(SB)/8, $libc_getresgid_trampoline<>(SB) + TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 CALL libc_ioctl(SB) RET @@ -687,12 +699,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..32cbbbc 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go @@ -519,6 +519,28 @@ var libc_getcwd_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func getresuid(ruid *_C_int, euid *_C_int, suid *_C_int) { + syscall_rawSyscall(libc_getresuid_trampoline_addr, uintptr(unsafe.Pointer(ruid)), uintptr(unsafe.Pointer(euid)), uintptr(unsafe.Pointer(suid))) + return +} + +var libc_getresuid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getresuid getresuid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getresgid(rgid *_C_int, egid *_C_int, sgid *_C_int) { + syscall_rawSyscall(libc_getresgid_trampoline_addr, uintptr(unsafe.Pointer(rgid)), uintptr(unsafe.Pointer(egid)), uintptr(unsafe.Pointer(sgid))) + return +} + +var libc_getresgid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getresgid getresgid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func ioctl(fd int, req uint, arg uintptr) (err error) { _, _, e1 := syscall_syscall(libc_ioctl_trampoline_addr, uintptr(fd), uintptr(req), uintptr(arg)) if e1 != 0 { @@ -1894,20 +1916,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..477a7d5 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s @@ -158,6 +158,16 @@ TEXT libc_getcwd_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_getcwd_trampoline_addr(SB), RODATA, $8 DATA ·libc_getcwd_trampoline_addr(SB)/8, $libc_getcwd_trampoline<>(SB) +TEXT libc_getresuid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getresuid(SB) +GLOBL ·libc_getresuid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getresuid_trampoline_addr(SB)/8, $libc_getresuid_trampoline<>(SB) + +TEXT libc_getresgid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getresgid(SB) +GLOBL ·libc_getresgid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getresgid_trampoline_addr(SB)/8, $libc_getresgid_trampoline<>(SB) + TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_ioctl(SB) GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $8 @@ -573,11 +583,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/golang.org/x/sys/unix/ztypes_linux.go b/vendor/golang.org/x/sys/unix/ztypes_linux.go index ca84727..00c3b8c 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux.go @@ -2555,6 +2555,11 @@ const ( BPF_REG_8 = 0x8 BPF_REG_9 = 0x9 BPF_REG_10 = 0xa + BPF_CGROUP_ITER_ORDER_UNSPEC = 0x0 + BPF_CGROUP_ITER_SELF_ONLY = 0x1 + BPF_CGROUP_ITER_DESCENDANTS_PRE = 0x2 + BPF_CGROUP_ITER_DESCENDANTS_POST = 0x3 + BPF_CGROUP_ITER_ANCESTORS_UP = 0x4 BPF_MAP_CREATE = 0x0 BPF_MAP_LOOKUP_ELEM = 0x1 BPF_MAP_UPDATE_ELEM = 0x2 @@ -2566,6 +2571,7 @@ const ( BPF_PROG_ATTACH = 0x8 BPF_PROG_DETACH = 0x9 BPF_PROG_TEST_RUN = 0xa + BPF_PROG_RUN = 0xa BPF_PROG_GET_NEXT_ID = 0xb BPF_MAP_GET_NEXT_ID = 0xc BPF_PROG_GET_FD_BY_ID = 0xd @@ -2610,6 +2616,7 @@ const ( BPF_MAP_TYPE_CPUMAP = 0x10 BPF_MAP_TYPE_XSKMAP = 0x11 BPF_MAP_TYPE_SOCKHASH = 0x12 + BPF_MAP_TYPE_CGROUP_STORAGE_DEPRECATED = 0x13 BPF_MAP_TYPE_CGROUP_STORAGE = 0x13 BPF_MAP_TYPE_REUSEPORT_SOCKARRAY = 0x14 BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE = 0x15 @@ -2620,6 +2627,10 @@ const ( BPF_MAP_TYPE_STRUCT_OPS = 0x1a BPF_MAP_TYPE_RINGBUF = 0x1b BPF_MAP_TYPE_INODE_STORAGE = 0x1c + BPF_MAP_TYPE_TASK_STORAGE = 0x1d + BPF_MAP_TYPE_BLOOM_FILTER = 0x1e + BPF_MAP_TYPE_USER_RINGBUF = 0x1f + BPF_MAP_TYPE_CGRP_STORAGE = 0x20 BPF_PROG_TYPE_UNSPEC = 0x0 BPF_PROG_TYPE_SOCKET_FILTER = 0x1 BPF_PROG_TYPE_KPROBE = 0x2 @@ -2651,6 +2662,7 @@ const ( BPF_PROG_TYPE_EXT = 0x1c BPF_PROG_TYPE_LSM = 0x1d BPF_PROG_TYPE_SK_LOOKUP = 0x1e + BPF_PROG_TYPE_SYSCALL = 0x1f BPF_CGROUP_INET_INGRESS = 0x0 BPF_CGROUP_INET_EGRESS = 0x1 BPF_CGROUP_INET_SOCK_CREATE = 0x2 @@ -2689,6 +2701,12 @@ const ( BPF_XDP_CPUMAP = 0x23 BPF_SK_LOOKUP = 0x24 BPF_XDP = 0x25 + BPF_SK_SKB_VERDICT = 0x26 + BPF_SK_REUSEPORT_SELECT = 0x27 + BPF_SK_REUSEPORT_SELECT_OR_MIGRATE = 0x28 + BPF_PERF_EVENT = 0x29 + BPF_TRACE_KPROBE_MULTI = 0x2a + BPF_LSM_CGROUP = 0x2b BPF_LINK_TYPE_UNSPEC = 0x0 BPF_LINK_TYPE_RAW_TRACEPOINT = 0x1 BPF_LINK_TYPE_TRACING = 0x2 @@ -2696,6 +2714,9 @@ const ( BPF_LINK_TYPE_ITER = 0x4 BPF_LINK_TYPE_NETNS = 0x5 BPF_LINK_TYPE_XDP = 0x6 + BPF_LINK_TYPE_PERF_EVENT = 0x7 + BPF_LINK_TYPE_KPROBE_MULTI = 0x8 + BPF_LINK_TYPE_STRUCT_OPS = 0x9 BPF_ANY = 0x0 BPF_NOEXIST = 0x1 BPF_EXIST = 0x2 @@ -2733,6 +2754,7 @@ const ( BPF_F_ZERO_CSUM_TX = 0x2 BPF_F_DONT_FRAGMENT = 0x4 BPF_F_SEQ_NUMBER = 0x8 + BPF_F_TUNINFO_FLAGS = 0x10 BPF_F_INDEX_MASK = 0xffffffff BPF_F_CURRENT_CPU = 0xffffffff BPF_F_CTXLEN_MASK = 0xfffff00000000 @@ -2747,6 +2769,7 @@ const ( BPF_F_ADJ_ROOM_ENCAP_L4_GRE = 0x8 BPF_F_ADJ_ROOM_ENCAP_L4_UDP = 0x10 BPF_F_ADJ_ROOM_NO_CSUM_RESET = 0x20 + BPF_F_ADJ_ROOM_ENCAP_L2_ETH = 0x40 BPF_ADJ_ROOM_ENCAP_L2_MASK = 0xff BPF_ADJ_ROOM_ENCAP_L2_SHIFT = 0x38 BPF_F_SYSCTL_BASE_NAME = 0x1 @@ -2771,10 +2794,16 @@ const ( BPF_LWT_ENCAP_SEG6 = 0x0 BPF_LWT_ENCAP_SEG6_INLINE = 0x1 BPF_LWT_ENCAP_IP = 0x2 + BPF_F_BPRM_SECUREEXEC = 0x1 + BPF_F_BROADCAST = 0x8 + BPF_F_EXCLUDE_INGRESS = 0x10 + BPF_SKB_TSTAMP_UNSPEC = 0x0 + BPF_SKB_TSTAMP_DELIVERY_MONO = 0x1 BPF_OK = 0x0 BPF_DROP = 0x2 BPF_REDIRECT = 0x7 BPF_LWT_REROUTE = 0x80 + BPF_FLOW_DISSECTOR_CONTINUE = 0x81 BPF_SOCK_OPS_RTO_CB_FLAG = 0x1 BPF_SOCK_OPS_RETRANS_CB_FLAG = 0x2 BPF_SOCK_OPS_STATE_CB_FLAG = 0x4 @@ -2838,6 +2867,10 @@ const ( BPF_FIB_LKUP_RET_UNSUPP_LWT = 0x6 BPF_FIB_LKUP_RET_NO_NEIGH = 0x7 BPF_FIB_LKUP_RET_FRAG_NEEDED = 0x8 + BPF_MTU_CHK_SEGS = 0x1 + BPF_MTU_CHK_RET_SUCCESS = 0x0 + BPF_MTU_CHK_RET_FRAG_NEEDED = 0x1 + BPF_MTU_CHK_RET_SEGS_TOOBIG = 0x2 BPF_FD_TYPE_RAW_TRACEPOINT = 0x0 BPF_FD_TYPE_TRACEPOINT = 0x1 BPF_FD_TYPE_KPROBE = 0x2 @@ -2847,6 +2880,19 @@ const ( BPF_FLOW_DISSECTOR_F_PARSE_1ST_FRAG = 0x1 BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL = 0x2 BPF_FLOW_DISSECTOR_F_STOP_AT_ENCAP = 0x4 + BPF_CORE_FIELD_BYTE_OFFSET = 0x0 + BPF_CORE_FIELD_BYTE_SIZE = 0x1 + BPF_CORE_FIELD_EXISTS = 0x2 + BPF_CORE_FIELD_SIGNED = 0x3 + BPF_CORE_FIELD_LSHIFT_U64 = 0x4 + BPF_CORE_FIELD_RSHIFT_U64 = 0x5 + BPF_CORE_TYPE_ID_LOCAL = 0x6 + BPF_CORE_TYPE_ID_TARGET = 0x7 + BPF_CORE_TYPE_EXISTS = 0x8 + BPF_CORE_TYPE_SIZE = 0x9 + BPF_CORE_ENUMVAL_EXISTS = 0xa + BPF_CORE_ENUMVAL_VALUE = 0xb + BPF_CORE_TYPE_MATCHES = 0xc ) const ( 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 efda164..22fac19 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 @@ -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 @@ -65,21 +65,22 @@ 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.10.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.11.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.6.0 +golang.org/x/net/websocket +# golang.org/x/sys v0.9.0 ## explicit; go 1.17 golang.org/x/sys/unix -# golang.org/x/text v0.8.0 +# golang.org/x/text v0.10.0 ## explicit; go 1.17 golang.org/x/text/secure/bidirule golang.org/x/text/transform @@ -88,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