vendor: github.com/ishidawataru/sctp f2269e66cdee387bd321445d5d300893449805be
full diff: 6e2cb13661...f2269e66cd
- support SO_SNDBUF/SO_RCVBUF handling
- Support Go Modules
- license clarificaton
- ci: drop 1.6, 1.7, 1.8 support
- Add support for SocketConfig
- support goarch mips64le architecture.
- fix possible socket leak when bind fails
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
e4109b3b6b
commit
22b9e2a7e5
7 changed files with 169 additions and 2 deletions
|
@ -70,7 +70,7 @@ github.com/coreos/etcd 2c834459e1aab78a5d5219c7dfe4
|
|||
github.com/coreos/go-semver 8ab6407b697782a06568d4b7f1db25550ec2e4c6 # v0.2.0
|
||||
github.com/hashicorp/consul 9a9cc9341bb487651a0399e3fc5e1e8a42e62dd9 # v0.5.2
|
||||
github.com/miekg/dns 6c0c4e6581f8e173cc562c8b3363ab984e4ae071 # v1.1.27
|
||||
github.com/ishidawataru/sctp 6e2cb1366111dcf547c13531e3a263a067715847
|
||||
github.com/ishidawataru/sctp f2269e66cdee387bd321445d5d300893449805be
|
||||
go.etcd.io/bbolt 232d8fc87f50244f9c808f4745759e08a304c029 # v1.3.5
|
||||
github.com/json-iterator/go a1ca0830781e007c66b225121d2cdb3a649421f6 # v1.1.10
|
||||
github.com/modern-go/concurrent bacd9c7ef1dd9b15be4a9909b8ac7a4e313eec94 # 1.0.3
|
||||
|
|
3
vendor/github.com/ishidawataru/sctp/NOTICE
generated
vendored
Normal file
3
vendor/github.com/ishidawataru/sctp/NOTICE
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
This source code includes following third party code
|
||||
|
||||
- ipsock_linux.go : licensed by the Go authors, see GO_LICENSE file for the license which applies to the code
|
3
vendor/github.com/ishidawataru/sctp/go.mod
generated
vendored
Normal file
3
vendor/github.com/ishidawataru/sctp/go.mod
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
module github.com/ishidawataru/sctp
|
||||
|
||||
go 1.12
|
4
vendor/github.com/ishidawataru/sctp/ipsock_linux.go
generated
vendored
4
vendor/github.com/ishidawataru/sctp/ipsock_linux.go
generated
vendored
|
@ -1,3 +1,7 @@
|
|||
// 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 GO_LICENSE file.
|
||||
|
||||
package sctp
|
||||
|
||||
import (
|
||||
|
|
49
vendor/github.com/ishidawataru/sctp/sctp.go
generated
vendored
49
vendor/github.com/ishidawataru/sctp/sctp.go
generated
vendored
|
@ -1,3 +1,18 @@
|
|||
// Copyright 2019 Wataru Ishida. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
// implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package sctp
|
||||
|
||||
import (
|
||||
|
@ -678,3 +693,37 @@ func (c *SCTPSndRcvInfoWrappedConn) SetReadDeadline(t time.Time) error {
|
|||
func (c *SCTPSndRcvInfoWrappedConn) SetWriteDeadline(t time.Time) error {
|
||||
return c.conn.SetWriteDeadline(t)
|
||||
}
|
||||
|
||||
func (c *SCTPSndRcvInfoWrappedConn) SetWriteBuffer(bytes int) error {
|
||||
return c.conn.SetWriteBuffer(bytes)
|
||||
}
|
||||
|
||||
func (c *SCTPSndRcvInfoWrappedConn) GetWriteBuffer() (int, error) {
|
||||
return c.conn.GetWriteBuffer()
|
||||
}
|
||||
|
||||
func (c *SCTPSndRcvInfoWrappedConn) SetReadBuffer(bytes int) error {
|
||||
return c.conn.SetReadBuffer(bytes)
|
||||
}
|
||||
|
||||
func (c *SCTPSndRcvInfoWrappedConn) GetReadBuffer() (int, error) {
|
||||
return c.conn.GetReadBuffer()
|
||||
}
|
||||
|
||||
// SocketConfig contains options for the SCTP socket.
|
||||
type SocketConfig struct {
|
||||
// If Control is not nil it is called after the socket is created but before
|
||||
// it is bound or connected.
|
||||
Control func(network, address string, c syscall.RawConn) error
|
||||
|
||||
// InitMsg is the options to send in the initial SCTP message
|
||||
InitMsg InitMsg
|
||||
}
|
||||
|
||||
func (cfg *SocketConfig) Listen(net string, laddr *SCTPAddr) (*SCTPListener, error) {
|
||||
return listenSCTPExtConfig(net, laddr, cfg.InitMsg, cfg.Control)
|
||||
}
|
||||
|
||||
func (cfg *SocketConfig) Dial(net string, laddr, raddr *SCTPAddr) (*SCTPConn, error) {
|
||||
return dialSCTPExtConfig(net, laddr, raddr, cfg.InitMsg, cfg.Control)
|
||||
}
|
||||
|
|
71
vendor/github.com/ishidawataru/sctp/sctp_linux.go
generated
vendored
71
vendor/github.com/ishidawataru/sctp/sctp_linux.go
generated
vendored
|
@ -1,4 +1,18 @@
|
|||
// +build linux,!386
|
||||
// Copyright 2019 Wataru Ishida. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
// implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package sctp
|
||||
|
||||
|
@ -40,6 +54,23 @@ func getsockopt(fd int, optname, optval, optlen uintptr) (uintptr, uintptr, erro
|
|||
return r0, r1, nil
|
||||
}
|
||||
|
||||
type rawConn struct {
|
||||
sockfd int
|
||||
}
|
||||
|
||||
func (r rawConn) Control(f func(fd uintptr)) error {
|
||||
f(uintptr(r.sockfd))
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r rawConn) Read(f func(fd uintptr) (done bool)) error {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (r rawConn) Write(f func(fd uintptr) (done bool)) error {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (c *SCTPConn) SCTPWrite(b []byte, info *SndRcvInfo) (int, error) {
|
||||
var cbuf []byte
|
||||
if info != nil {
|
||||
|
@ -114,6 +145,22 @@ func (c *SCTPConn) Close() error {
|
|||
return syscall.EBADF
|
||||
}
|
||||
|
||||
func (c *SCTPConn) SetWriteBuffer(bytes int) error {
|
||||
return syscall.SetsockoptInt(c.fd(), syscall.SOL_SOCKET, syscall.SO_SNDBUF, bytes)
|
||||
}
|
||||
|
||||
func (c *SCTPConn) GetWriteBuffer() (int, error) {
|
||||
return syscall.GetsockoptInt(c.fd(), syscall.SOL_SOCKET, syscall.SO_SNDBUF)
|
||||
}
|
||||
|
||||
func (c *SCTPConn) SetReadBuffer(bytes int) error {
|
||||
return syscall.SetsockoptInt(c.fd(), syscall.SOL_SOCKET, syscall.SO_RCVBUF, bytes)
|
||||
}
|
||||
|
||||
func (c *SCTPConn) GetReadBuffer() (int, error) {
|
||||
return syscall.GetsockoptInt(c.fd(), syscall.SOL_SOCKET, syscall.SO_RCVBUF)
|
||||
}
|
||||
|
||||
// ListenSCTP - start listener on specified address/port
|
||||
func ListenSCTP(net string, laddr *SCTPAddr) (*SCTPListener, error) {
|
||||
return ListenSCTPExt(net, laddr, InitMsg{NumOstreams: SCTP_MAX_STREAM})
|
||||
|
@ -121,6 +168,11 @@ func ListenSCTP(net string, laddr *SCTPAddr) (*SCTPListener, error) {
|
|||
|
||||
// ListenSCTPExt - start listener on specified address/port with given SCTP options
|
||||
func ListenSCTPExt(network string, laddr *SCTPAddr, options InitMsg) (*SCTPListener, error) {
|
||||
return listenSCTPExtConfig(network, laddr, options, nil)
|
||||
}
|
||||
|
||||
// listenSCTPExtConfig - start listener on specified address/port with given SCTP options and socket configuration
|
||||
func listenSCTPExtConfig(network string, laddr *SCTPAddr, options InitMsg, control func(network, address string, c syscall.RawConn) error) (*SCTPListener, error) {
|
||||
af, ipv6only := favoriteAddrFamily(network, laddr, nil, "listen")
|
||||
sock, err := syscall.Socket(
|
||||
af,
|
||||
|
@ -140,6 +192,12 @@ func ListenSCTPExt(network string, laddr *SCTPAddr, options InitMsg) (*SCTPListe
|
|||
if err = setDefaultSockopts(sock, af, ipv6only); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if control != nil {
|
||||
rc := rawConn{sockfd: sock}
|
||||
if err = control(network, laddr.String(), rc); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
err = setInitOpts(sock, options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -154,7 +212,7 @@ func ListenSCTPExt(network string, laddr *SCTPAddr, options InitMsg) (*SCTPListe
|
|||
laddr.IPAddrs = append(laddr.IPAddrs, net.IPAddr{IP: net.IPv6zero})
|
||||
}
|
||||
}
|
||||
err := SCTPBind(sock, laddr, SCTP_BINDX_ADD_ADDR)
|
||||
err = SCTPBind(sock, laddr, SCTP_BINDX_ADD_ADDR)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -191,6 +249,11 @@ func DialSCTP(net string, laddr, raddr *SCTPAddr) (*SCTPConn, error) {
|
|||
|
||||
// DialSCTPExt - same as DialSCTP but with given SCTP options
|
||||
func DialSCTPExt(network string, laddr, raddr *SCTPAddr, options InitMsg) (*SCTPConn, error) {
|
||||
return dialSCTPExtConfig(network, laddr, raddr, options, nil)
|
||||
}
|
||||
|
||||
// dialSCTPExtConfig - same as DialSCTP but with given SCTP options and socket configuration
|
||||
func dialSCTPExtConfig(network string, laddr, raddr *SCTPAddr, options InitMsg, control func(network, address string, c syscall.RawConn) error) (*SCTPConn, error) {
|
||||
af, ipv6only := favoriteAddrFamily(network, laddr, raddr, "dial")
|
||||
sock, err := syscall.Socket(
|
||||
af,
|
||||
|
@ -210,6 +273,12 @@ func DialSCTPExt(network string, laddr, raddr *SCTPAddr, options InitMsg) (*SCTP
|
|||
if err = setDefaultSockopts(sock, af, ipv6only); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if control != nil {
|
||||
rc := rawConn{sockfd: sock}
|
||||
if err = control(network, laddr.String(), rc); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
err = setInitOpts(sock, options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
39
vendor/github.com/ishidawataru/sctp/sctp_unsupported.go
generated
vendored
39
vendor/github.com/ishidawataru/sctp/sctp_unsupported.go
generated
vendored
|
@ -1,4 +1,18 @@
|
|||
// +build !linux linux,386
|
||||
// Copyright 2019 Wataru Ishida. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
// implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package sctp
|
||||
|
||||
|
@ -6,6 +20,7 @@ import (
|
|||
"errors"
|
||||
"net"
|
||||
"runtime"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
var ErrUnsupported = errors.New("SCTP is unsupported on " + runtime.GOOS + "/" + runtime.GOARCH)
|
||||
|
@ -30,6 +45,22 @@ func (c *SCTPConn) Close() error {
|
|||
return ErrUnsupported
|
||||
}
|
||||
|
||||
func (c *SCTPConn) SetWriteBuffer(bytes int) error {
|
||||
return ErrUnsupported
|
||||
}
|
||||
|
||||
func (c *SCTPConn) GetWriteBuffer() (int, error) {
|
||||
return 0, ErrUnsupported
|
||||
}
|
||||
|
||||
func (c *SCTPConn) SetReadBuffer(bytes int) error {
|
||||
return ErrUnsupported
|
||||
}
|
||||
|
||||
func (c *SCTPConn) GetReadBuffer() (int, error) {
|
||||
return 0, ErrUnsupported
|
||||
}
|
||||
|
||||
func ListenSCTP(net string, laddr *SCTPAddr) (*SCTPListener, error) {
|
||||
return nil, ErrUnsupported
|
||||
}
|
||||
|
@ -38,6 +69,10 @@ func ListenSCTPExt(net string, laddr *SCTPAddr, options InitMsg) (*SCTPListener,
|
|||
return nil, ErrUnsupported
|
||||
}
|
||||
|
||||
func listenSCTPExtConfig(network string, laddr *SCTPAddr, options InitMsg, control func(network, address string, c syscall.RawConn) error) (*SCTPListener, error) {
|
||||
return nil, ErrUnsupported
|
||||
}
|
||||
|
||||
func (ln *SCTPListener) Accept() (net.Conn, error) {
|
||||
return nil, ErrUnsupported
|
||||
}
|
||||
|
@ -57,3 +92,7 @@ func DialSCTP(net string, laddr, raddr *SCTPAddr) (*SCTPConn, error) {
|
|||
func DialSCTPExt(network string, laddr, raddr *SCTPAddr, options InitMsg) (*SCTPConn, error) {
|
||||
return nil, ErrUnsupported
|
||||
}
|
||||
|
||||
func dialSCTPExtConfig(network string, laddr, raddr *SCTPAddr, options InitMsg, control func(network, address string, c syscall.RawConn) error) (*SCTPConn, error) {
|
||||
return nil, ErrUnsupported
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue