Update datarhei/gosrt dependency

This commit is contained in:
Ingo Oppermann 2023-11-27 14:11:10 +01:00
parent ff698ff50c
commit 46a44e1a59
No known key found for this signature in database
GPG key ID: 2AB32426E9DD229E
402 changed files with 1067 additions and 2717 deletions

8
go.mod
View file

@ -7,7 +7,7 @@ require (
github.com/Masterminds/semver/v3 v3.2.1 github.com/Masterminds/semver/v3 v3.2.1
github.com/atrox/haikunatorgo/v2 v2.0.1 github.com/atrox/haikunatorgo/v2 v2.0.1
github.com/caddyserver/certmagic v0.19.2 github.com/caddyserver/certmagic v0.19.2
github.com/datarhei/gosrt v0.5.4 github.com/datarhei/gosrt v0.5.5
github.com/datarhei/joy4 v0.0.0-20230505074825-fde05957445a github.com/datarhei/joy4 v0.0.0-20230505074825-fde05957445a
github.com/go-playground/validator/v10 v10.15.3 github.com/go-playground/validator/v10 v10.15.3
github.com/gobwas/glob v0.2.3 github.com/gobwas/glob v0.2.3
@ -95,10 +95,10 @@ require (
github.com/yusufpapurcu/wmi v1.2.3 // indirect github.com/yusufpapurcu/wmi v1.2.3 // indirect
github.com/zeebo/blake3 v0.2.3 // indirect github.com/zeebo/blake3 v0.2.3 // indirect
go.uber.org/multierr v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.12.0 // indirect golang.org/x/crypto v0.15.0 // indirect
golang.org/x/net v0.14.0 // indirect golang.org/x/net v0.14.0 // indirect
golang.org/x/sys v0.12.0 // indirect golang.org/x/sys v0.14.0 // indirect
golang.org/x/text v0.13.0 // indirect golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.3.0 // indirect golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.12.0 // indirect golang.org/x/tools v0.12.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect google.golang.org/protobuf v1.31.0 // indirect

16
go.sum
View file

@ -24,8 +24,8 @@ github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/datarhei/gosrt v0.5.4 h1:dE3mmSB+n1GeviGM8xQAW3+UD3mKeFmd84iefDul5Vs= github.com/datarhei/gosrt v0.5.5 h1:4Xx4v7pn/rz6EaWhZRE37fROW+rry0y4yBHZBkq5d8g=
github.com/datarhei/gosrt v0.5.4/go.mod h1:MiUCwCG+LzFMzLM/kTA+3wiTtlnkVvGbW/F0XzyhtG8= github.com/datarhei/gosrt v0.5.5/go.mod h1:In1zba2/999S1d+ENIJ0h9s3alHO3FvCNrIpykxYbEE=
github.com/datarhei/joy4 v0.0.0-20230505074825-fde05957445a h1:Tf4DSHY1xruBglr+yYP5Wct7czM86GKMYgbXH8a7OFo= github.com/datarhei/joy4 v0.0.0-20230505074825-fde05957445a h1:Tf4DSHY1xruBglr+yYP5Wct7czM86GKMYgbXH8a7OFo=
github.com/datarhei/joy4 v0.0.0-20230505074825-fde05957445a/go.mod h1:Jcw/6jZDQQmPx8A7INEkXmuEF7E9jjBbSTfVSLwmiQw= github.com/datarhei/joy4 v0.0.0-20230505074825-fde05957445a/go.mod h1:Jcw/6jZDQQmPx8A7INEkXmuEF7E9jjBbSTfVSLwmiQw=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@ -245,8 +245,8 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c= go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c=
go.uber.org/zap v1.25.0/go.mod h1:JIAUzQIH94IC4fOJQm7gMmBJP5k7wQfdcnYdPoEXJYk= go.uber.org/zap v1.25.0/go.mod h1:JIAUzQIH94IC4fOJQm7gMmBJP5k7wQfdcnYdPoEXJYk=
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA=
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g=
golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
@ -265,10 +265,10 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss= golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss=

View file

@ -46,13 +46,13 @@ A Go version of 1.18+ is required.
## Installation ## Installation
``` ```shell
go get github.com/datarhei/gosrt go get github.com/datarhei/gosrt
``` ```
## Caller example ## Caller example
``` ```go
import "github.com/datarhei/gosrt" import "github.com/datarhei/gosrt"
conn, err := srt.Dial("srt", "golang.org:6000", srt.Config{ conn, err := srt.Dial("srt", "golang.org:6000", srt.Config{
@ -80,7 +80,7 @@ In the `contrib/client` directory you'll find a complete example of a SRT client
## Listener example ## Listener example
``` ```go
import "github.com/datarhei/gosrt" import "github.com/datarhei/gosrt"
ln, err := srt.Listen("srt", ":6000", srt.Config{...}) ln, err := srt.Listen("srt", ":6000", srt.Config{...})
@ -128,7 +128,7 @@ In the `contrib/client` directory you'll find an example implementation of a SRT
Build the client application with Build the client application with
``` ```shell
cd contrib/client && go build cd contrib/client && go build
``` ```
@ -187,31 +187,45 @@ known options (similar to [srt-live-transmit](https://github.com/Haivision/srt/b
Reading from a SRT sender and play with `ffplay`: Reading from a SRT sender and play with `ffplay`:
``` ```shell
./client -from "srt://127.0.0.1:6001/?mode=listener&streamid=..." -to - | ffplay -f mpegts -i - ./client -from "srt://127.0.0.1:6001/?mode=listener&streamid=..." -to - | ffplay -f mpegts -i -
``` ```
Reading from UDP and sending to a SRT server: Reading from UDP and sending to a SRT server:
``` ```shell
./client -from udp://:6000 -to "srt://127.0.0.1:6001/?mode=caller&streamid=..." ./client -from udp://:6000 -to "srt://127.0.0.1:6001/?mode=caller&streamid=..."
``` ```
Simulate point-to-point transfer on localhost. Open one console and start `ffmpeg` (you need at least version 4.3.2, built with SRT enabled) to send to an UDP address: Simulate point-to-point transfer on localhost. Open one console and start `ffmpeg` (you need at least version 4.3.2, built with SRT enabled) to send to an UDP address:
``` ```shell
ffmpeg -f lavfi -re -i testsrc2=rate=25:size=640x360 -codec:v libx264 -b:v 1024k -maxrate:v 1024k -bufsize:v 1024k -preset ultrafast -r 25 -g 50 -pix_fmt yuv420p -vsync 1 -flags2 local_header -f mpegts "udp://127.0.0.1:6000?pkt_size=1316" ffmpeg \
-f lavfi \
-re \
-i testsrc2=rate=25:size=640x360 \
-codec:v libx264 \
-b:v 1024k \
-maxrate:v 1024k \
-bufsize:v 1024k \
-preset ultrafast \
-r 25 \
-g 50 \
-pix_fmt yuv420p \
-flags2 local_header \
-f mpegts \
"udp://127.0.0.1:6000?pkt_size=1316"
``` ```
In another console read from the UDP and start a SRT listenr: In another console read from the UDP and start a SRT listenr:
``` ```shell
./client -from udp://:6000 -to "srt://127.0.0.1:6001/?mode=listener&streamid=foobar" ./client -from udp://:6000 -to "srt://127.0.0.1:6001/?mode=listener&streamid=foobar"
``` ```
In the third console connect to that stream and play the video with `ffplay`: In the third console connect to that stream and play the video with `ffplay`:
``` ```shell
./client -from "srt://127.0.0.1:6001/?mode=caller&streamid=foobar" -to - | ffplay -f mpegts -i - ./client -from "srt://127.0.0.1:6001/?mode=caller&streamid=foobar" -to - | ffplay -f mpegts -i -
``` ```
@ -222,7 +236,7 @@ a stream that can be read by many clients.
Build the client application with Build the client application with
``` ```shell
cd contrib/server && go build cd contrib/server && go build
``` ```
@ -264,27 +278,42 @@ If you implement your own server you are free to interpret the streamID as you w
Running a server listening on port 6001 with defaults: Running a server listening on port 6001 with defaults:
``` ```shell
./server -addr ":6001" ./server -addr ":6001"
``` ```
Now you can use the contributed client to publish a stream: Now you can use the contributed client to publish a stream:
``` ```shell
./client -from ... -to "srt://127.0.0.1:6001/?mode=caller&streamid=publish:/live/stream" ./client -from ... -to "srt://127.0.0.1:6001/?mode=caller&streamid=publish:/live/stream"
``` ```
or directly from `ffmpeg`: or directly from `ffmpeg`:
``` ```shell
ffmpeg -f lavfi -re -i testsrc2=rate=25:size=640x360 -codec:v libx264 -b:v 1024k -maxrate:v 1024k -bufsize:v 1024k -preset ultrafast -r 25 -g 50 -pix_fmt yuv420p -vsync 1 -flags2 local_header -f mpegts -transtype live "srt://127.0.0.1:6001?streamid=publish:/live/stream" ffmpeg \
-f lavfi \
-re \
-i testsrc2=rate=25:size=640x360 \
-codec:v libx264 \
-b:v 1024k \
-maxrate:v 1024k \
-bufsize:v 1024k \
-preset ultrafast \
-r 25 \
-g 50 \
-pix_fmt yuv420p \
-flags2 local_header \
-f mpegts \
-transtype live \
"srt://127.0.0.1:6001?streamid=publish:/live/stream"
``` ```
If the server is not on localhost, you might adjust the `peerlatency` in order to avoid packet loss: `-peerlatency 1000000`. If the server is not on localhost, you might adjust the `peerlatency` in order to avoid packet loss: `-peerlatency 1000000`.
Now you can play the stream: Now you can play the stream:
``` ```shell
ffplay -f mpegts -transtype live -i "srt://127.0.0.1:6001?streamid=/live/stream" ffplay -f mpegts -transtype live -i "srt://127.0.0.1:6001?streamid=/live/stream"
``` ```
@ -295,19 +324,34 @@ get more errors during playback, you might increase the receive buffer by adding
The stream can be encrypted with a passphrase. First start the server with a passphrase. If you are using `srt-live-transmit`, the passphrase has to be at least 10 characters long otherwise it will not be accepted. The stream can be encrypted with a passphrase. First start the server with a passphrase. If you are using `srt-live-transmit`, the passphrase has to be at least 10 characters long otherwise it will not be accepted.
``` ```shell
./server -addr :6001 -passphrase foobarfoobar ./server -addr :6001 -passphrase foobarfoobar
``` ```
Send an encrpyted stream to the server: Send an encrpyted stream to the server:
``` ```shell
ffmpeg -f lavfi -re -i testsrc2=rate=25:size=640x360 -codec:v libx264 -b:v 1024k -maxrate:v 1024k -bufsize:v 1024k -preset ultrafast -r 25 -g 50 -pix_fmt yuv420p -vsync 1 -flags2 local_header -f mpegts -transtype live "srt://127.0.0.1:6001?streamid=publish:/live/stream&passphrase=foobarfoobar" ffmpeg \
-f lavfi \
-re \
-i testsrc2=rate=25:size=640x360 \
-codec:v libx264 \
-b:v 1024k \
-maxrate:v 1024k \
-bufsize:v 1024k \
-preset ultrafast \
-r 25 \
-g 50 \
-pix_fmt yuv420p \
-flags2 local_header \
-f mpegts \
-transtype live \
"srt://127.0.0.1:6001?streamid=publish:/live/stream&passphrase=foobarfoobar"
``` ```
Receive an encrypted stream from the server: Receive an encrypted stream from the server:
``` ```shell
ffplay -f mpegts -transtype live -i "srt://127.0.0.1:6001?streamid=/live/stream&passphrase=foobarfoobar" ffplay -f mpegts -transtype live -i "srt://127.0.0.1:6001?streamid=/live/stream&passphrase=foobarfoobar"
``` ```
@ -320,7 +364,7 @@ This SRT module has a built-in logging facility for debugging purposes. Check th
In the contributed server you see an example of how logging is used. Here's the essence: In the contributed server you see an example of how logging is used. Here's the essence:
``` ```go
logger := srt.NewLogger([]string{"connection", "handshake"}) logger := srt.NewLogger([]string{"connection", "handshake"})
config := srt.DefaultConfig config := srt.DefaultConfig

View file

@ -44,14 +44,15 @@ type dialer struct {
start time.Time start time.Time
rcvQueue chan packet.Packet // for packets that come from the wire rcvQueue chan packet.Packet // for packets that come from the wire
sndQueue chan packet.Packet // for packets that go to the wire
sndMutex sync.Mutex
sndData bytes.Buffer // for packets that go to the wire
shutdown bool shutdown bool
shutdownLock sync.RWMutex shutdownLock sync.RWMutex
shutdownOnce sync.Once shutdownOnce sync.Once
stopReader context.CancelFunc stopReader context.CancelFunc
stopWriter context.CancelFunc
doneChan chan error doneChan chan error
} }
@ -112,7 +113,6 @@ func Dial(network, address string, config Config) (Conn, error) {
dl.connChan = make(chan connResponse) dl.connChan = make(chan connResponse)
dl.rcvQueue = make(chan packet.Packet, 2048) dl.rcvQueue = make(chan packet.Packet, 2048)
dl.sndQueue = make(chan packet.Packet, 2048)
dl.doneChan = make(chan error) dl.doneChan = make(chan error)
@ -175,10 +175,6 @@ func Dial(network, address string, config Config) (Conn, error) {
readerCtx, dl.stopReader = context.WithCancel(context.Background()) readerCtx, dl.stopReader = context.WithCancel(context.Background())
go dl.reader(readerCtx) go dl.reader(readerCtx)
var writerCtx context.Context
writerCtx, dl.stopWriter = context.WithCancel(context.Background())
go dl.writer(writerCtx)
// Send the initial handshake request // Send the initial handshake request
dl.sendInduction() dl.sendInduction()
@ -258,51 +254,29 @@ func (dl *dialer) reader(ctx context.Context) {
} }
} }
// send adds a packet to the send queue // Send a packet to the wire. This function must be synchronous in order to allow to safely call Packet.Decommission() afterward.
func (dl *dialer) send(p packet.Packet) { func (dl *dialer) send(p packet.Packet) {
// non-blocking dl.sndMutex.Lock()
select { defer dl.sndMutex.Unlock()
case dl.sndQueue <- p:
default: dl.sndData.Reset()
dl.log("dial", func() string { return "send queue is full" })
if err := p.Marshal(&dl.sndData); err != nil {
p.Decommission()
dl.log("packet:send:error", func() string { return "marshalling packet failed" })
return
} }
}
// writer reads packets from the send queue and writes them to the wire buffer := dl.sndData.Bytes()
func (dl *dialer) writer(ctx context.Context) {
defer func() {
dl.log("dial", func() string { return "left writer loop" })
}()
dl.log("dial", func() string { return "writer loop started" }) dl.log("packet:send:dump", func() string { return p.Dump() })
var data bytes.Buffer // Write the packet's contents to the wire
dl.pc.Write(buffer)
for { if p.Header().IsControlPacket {
select { // Control packets can be decommissioned because they will not be sent again (data packets might be retransferred)
case <-ctx.Done(): p.Decommission()
return
case p := <-dl.sndQueue:
data.Reset()
if err := p.Marshal(&data); err != nil {
p.Decommission()
dl.log("packet:send:error", func() string { return "marshalling packet failed" })
continue
}
buffer := data.Bytes()
dl.log("packet:send:dump", func() string { return p.Dump() })
// Write the packet's contents to the wire.
dl.pc.Write(buffer)
if p.Header().IsControlPacket {
// Control packets can be decommissioned because they will not be sent again
p.Decommission()
}
}
} }
} }
@ -657,7 +631,6 @@ func (dl *dialer) Close() error {
dl.connLock.RUnlock() dl.connLock.RUnlock()
dl.stopReader() dl.stopReader()
dl.stopWriter()
dl.log("dial", func() string { return "closing socket" }) dl.log("dial", func() string { return "closing socket" })
dl.pc.Close() dl.pc.Close()

View file

@ -148,7 +148,9 @@ type listener struct {
start time.Time start time.Time
rcvQueue chan packet.Packet rcvQueue chan packet.Packet
sndQueue chan packet.Packet
sndMutex sync.Mutex
sndData bytes.Buffer
syncookie *srtnet.SYNCookie syncookie *srtnet.SYNCookie
@ -157,7 +159,6 @@ type listener struct {
shutdownOnce sync.Once shutdownOnce sync.Once
stopReader context.CancelFunc stopReader context.CancelFunc
stopWriter context.CancelFunc
doneChan chan error doneChan chan error
} }
@ -208,7 +209,6 @@ func Listen(network, address string, config Config) (Listener, error) {
ln.backlog = make(chan connRequest, 128) ln.backlog = make(chan connRequest, 128)
ln.rcvQueue = make(chan packet.Packet, 2048) ln.rcvQueue = make(chan packet.Packet, 2048)
ln.sndQueue = make(chan packet.Packet, 2048)
ln.syncookie, err = srtnet.NewSYNCookie(ln.addr.String(), nil) ln.syncookie, err = srtnet.NewSYNCookie(ln.addr.String(), nil)
if err != nil { if err != nil {
@ -224,10 +224,6 @@ func Listen(network, address string, config Config) (Listener, error) {
readerCtx, ln.stopReader = context.WithCancel(context.Background()) readerCtx, ln.stopReader = context.WithCancel(context.Background())
go ln.reader(readerCtx) go ln.reader(readerCtx)
var writerCtx context.Context
writerCtx, ln.stopWriter = context.WithCancel(context.Background())
go ln.writer(writerCtx)
go func() { go func() {
buffer := make([]byte, config.MSS) // MTU size buffer := make([]byte, config.MSS) // MTU size
@ -436,7 +432,6 @@ func (ln *listener) Close() {
ln.lock.RUnlock() ln.lock.RUnlock()
ln.stopReader() ln.stopReader()
ln.stopWriter()
ln.log("listen", func() string { return "closing socket" }) ln.log("listen", func() string { return "closing socket" })
@ -489,49 +484,29 @@ func (ln *listener) reader(ctx context.Context) {
} }
} }
// Send a packet to the wire. This function must be synchronous in order to allow to safely call Packet.Decommission() afterward.
func (ln *listener) send(p packet.Packet) { func (ln *listener) send(p packet.Packet) {
// non-blocking ln.sndMutex.Lock()
select { defer ln.sndMutex.Unlock()
case ln.sndQueue <- p:
default: ln.sndData.Reset()
ln.log("listen", func() string { return "send queue is full" })
if err := p.Marshal(&ln.sndData); err != nil {
p.Decommission()
ln.log("packet:send:error", func() string { return "marshalling packet failed" })
return
} }
}
func (ln *listener) writer(ctx context.Context) { buffer := ln.sndData.Bytes()
defer func() {
ln.log("listen", func() string { return "left writer loop" })
}()
ln.log("listen", func() string { return "writer loop started" }) ln.log("packet:send:dump", func() string { return p.Dump() })
var data bytes.Buffer // Write the packet's contents to the wire
ln.pc.WriteTo(buffer, p.Header().Addr)
for { if p.Header().IsControlPacket {
select { // Control packets can be decommissioned because they will not be sent again (data packets might be retransferred)
case <-ctx.Done(): p.Decommission()
return
case p := <-ln.sndQueue:
data.Reset()
if err := p.Marshal(&data); err != nil {
p.Decommission()
ln.log("packet:send:error", func() string { return "marshalling packet failed" })
continue
}
buffer := data.Bytes()
ln.log("packet:send:dump", func() string { return p.Dump() })
// Write the packet's contents to the wire
ln.pc.WriteTo(buffer, p.Header().Addr)
if p.Header().IsControlPacket {
// Control packets can be decommissioned because they will not be sent again (data packets might be retransferred)
p.Decommission()
}
}
} }
} }

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build go1.12 //go:build go1.12
// +build go1.12
package acme package acme

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build amd64 && gc && !purego //go:build amd64 && gc && !purego
// +build amd64,gc,!purego
package argon2 package argon2

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build amd64 && gc && !purego //go:build amd64 && gc && !purego
// +build amd64,gc,!purego
#include "textflag.h" #include "textflag.h"

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !amd64 || purego || !gc //go:build !amd64 || purego || !gc
// +build !amd64 purego !gc
package argon2 package argon2

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build go1.7 && amd64 && gc && !purego //go:build go1.7 && amd64 && gc && !purego
// +build go1.7,amd64,gc,!purego
package blake2b package blake2b

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build go1.7 && amd64 && gc && !purego //go:build go1.7 && amd64 && gc && !purego
// +build go1.7,amd64,gc,!purego
#include "textflag.h" #include "textflag.h"

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !go1.7 && amd64 && gc && !purego //go:build !go1.7 && amd64 && gc && !purego
// +build !go1.7,amd64,gc,!purego
package blake2b package blake2b

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build amd64 && gc && !purego //go:build amd64 && gc && !purego
// +build amd64,gc,!purego
#include "textflag.h" #include "textflag.h"

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !amd64 || purego || !gc //go:build !amd64 || purego || !gc
// +build !amd64 purego !gc
package blake2b package blake2b

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build go1.9 //go:build go1.9
// +build go1.9
package blake2b package blake2b

View file

@ -95,6 +95,11 @@ func (b *Builder) AddUint32(v uint32) {
b.add(byte(v>>24), byte(v>>16), byte(v>>8), byte(v)) b.add(byte(v>>24), byte(v>>16), byte(v>>8), byte(v))
} }
// AddUint48 appends a big-endian, 48-bit value to the byte string.
func (b *Builder) AddUint48(v uint64) {
b.add(byte(v>>40), byte(v>>32), byte(v>>24), byte(v>>16), byte(v>>8), byte(v))
}
// AddUint64 appends a big-endian, 64-bit value to the byte string. // AddUint64 appends a big-endian, 64-bit value to the byte string.
func (b *Builder) AddUint64(v uint64) { func (b *Builder) AddUint64(v uint64) {
b.add(byte(v>>56), byte(v>>48), byte(v>>40), byte(v>>32), byte(v>>24), byte(v>>16), byte(v>>8), byte(v)) b.add(byte(v>>56), byte(v>>48), byte(v>>40), byte(v>>32), byte(v>>24), byte(v>>16), byte(v>>8), byte(v))

View file

@ -81,6 +81,17 @@ func (s *String) ReadUint32(out *uint32) bool {
return true return true
} }
// ReadUint48 decodes a big-endian, 48-bit value into out and advances over it.
// It reports whether the read was successful.
func (s *String) ReadUint48(out *uint64) bool {
v := s.read(6)
if v == nil {
return false
}
*out = uint64(v[0])<<40 | uint64(v[1])<<32 | uint64(v[2])<<24 | uint64(v[3])<<16 | uint64(v[4])<<8 | uint64(v[5])
return true
}
// ReadUint64 decodes a big-endian, 64-bit value into out and advances over it. // ReadUint64 decodes a big-endian, 64-bit value into out and advances over it.
// It reports whether the read was successful. // It reports whether the read was successful.
func (s *String) ReadUint64(out *uint64) bool { func (s *String) ReadUint64(out *uint64) bool {

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !gc || purego || !s390x //go:build !gc || purego || !s390x
// +build !gc purego !s390x
package sha3 package sha3

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !amd64 || purego || !gc //go:build !amd64 || purego || !gc
// +build !amd64 purego !gc
package sha3 package sha3

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build amd64 && !purego && gc //go:build amd64 && !purego && gc
// +build amd64,!purego,gc
package sha3 package sha3

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build amd64 && !purego && gc //go:build amd64 && !purego && gc
// +build amd64,!purego,gc
// This code was translated into a form compatible with 6a from the public // This code was translated into a form compatible with 6a from the public
// domain sources at https://github.com/gvanas/KeccakCodePackage // domain sources at https://github.com/gvanas/KeccakCodePackage

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build go1.4 //go:build go1.4
// +build go1.4
package sha3 package sha3

View file

@ -121,11 +121,11 @@ func (d *state) padAndPermute(dsbyte byte) {
copyOut(d, d.buf) copyOut(d, d.buf)
} }
// Write absorbs more data into the hash's state. It produces an error // Write absorbs more data into the hash's state. It panics if any
// if more data is written to the ShakeHash after writing // output has already been read.
func (d *state) Write(p []byte) (written int, err error) { func (d *state) Write(p []byte) (written int, err error) {
if d.state != spongeAbsorbing { if d.state != spongeAbsorbing {
panic("sha3: write to sponge after read") panic("sha3: Write after Read")
} }
if d.buf == nil { if d.buf == nil {
d.buf = d.storage.asBytes()[:0] d.buf = d.storage.asBytes()[:0]
@ -182,12 +182,16 @@ func (d *state) Read(out []byte) (n int, err error) {
} }
// Sum applies padding to the hash state and then squeezes out the desired // Sum applies padding to the hash state and then squeezes out the desired
// number of output bytes. // number of output bytes. It panics if any output has already been read.
func (d *state) Sum(in []byte) []byte { func (d *state) Sum(in []byte) []byte {
if d.state != spongeAbsorbing {
panic("sha3: Sum after Read")
}
// Make a copy of the original hash so that caller can keep writing // Make a copy of the original hash so that caller can keep writing
// and summing. // and summing.
dup := d.clone() dup := d.clone()
hash := make([]byte, dup.outputLen) hash := make([]byte, dup.outputLen, 64) // explicit cap to allow stack allocation
dup.Read(hash) dup.Read(hash)
return append(in, hash...) return append(in, hash...)
} }

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gc && !purego //go:build gc && !purego
// +build gc,!purego
package sha3 package sha3
@ -49,7 +48,7 @@ type asmState struct {
buf []byte // care must be taken to ensure cap(buf) is a multiple of rate buf []byte // care must be taken to ensure cap(buf) is a multiple of rate
rate int // equivalent to block size rate int // equivalent to block size
storage [3072]byte // underlying storage for buf storage [3072]byte // underlying storage for buf
outputLen int // output length if fixed, 0 if not outputLen int // output length for full security
function code // KIMD/KLMD function code function code // KIMD/KLMD function code
state spongeDirection // whether the sponge is absorbing or squeezing state spongeDirection // whether the sponge is absorbing or squeezing
} }
@ -72,8 +71,10 @@ func newAsmState(function code) *asmState {
s.outputLen = 64 s.outputLen = 64
case shake_128: case shake_128:
s.rate = 168 s.rate = 168
s.outputLen = 32
case shake_256: case shake_256:
s.rate = 136 s.rate = 136
s.outputLen = 64
default: default:
panic("sha3: unrecognized function code") panic("sha3: unrecognized function code")
} }
@ -108,7 +109,7 @@ func (s *asmState) resetBuf() {
// It never returns an error. // It never returns an error.
func (s *asmState) Write(b []byte) (int, error) { func (s *asmState) Write(b []byte) (int, error) {
if s.state != spongeAbsorbing { if s.state != spongeAbsorbing {
panic("sha3: write to sponge after read") panic("sha3: Write after Read")
} }
length := len(b) length := len(b)
for len(b) > 0 { for len(b) > 0 {
@ -192,8 +193,8 @@ func (s *asmState) Read(out []byte) (n int, err error) {
// Sum appends the current hash to b and returns the resulting slice. // Sum appends the current hash to b and returns the resulting slice.
// It does not change the underlying hash state. // It does not change the underlying hash state.
func (s *asmState) Sum(b []byte) []byte { func (s *asmState) Sum(b []byte) []byte {
if s.outputLen == 0 { if s.state != spongeAbsorbing {
panic("sha3: cannot call Sum on SHAKE functions") panic("sha3: Sum after Read")
} }
// Copy the state to preserve the original. // Copy the state to preserve the original.

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gc && !purego //go:build gc && !purego
// +build gc,!purego
#include "textflag.h" #include "textflag.h"

View file

@ -17,26 +17,25 @@ package sha3
import ( import (
"encoding/binary" "encoding/binary"
"hash"
"io" "io"
) )
// ShakeHash defines the interface to hash functions that // ShakeHash defines the interface to hash functions that support
// support arbitrary-length output. // arbitrary-length output. When used as a plain [hash.Hash], it
// produces minimum-length outputs that provide full-strength generic
// security.
type ShakeHash interface { type ShakeHash interface {
// Write absorbs more data into the hash's state. It panics if input is hash.Hash
// written to it after output has been read from it.
io.Writer
// Read reads more output from the hash; reading affects the hash's // Read reads more output from the hash; reading affects the hash's
// state. (ShakeHash.Read is thus very different from Hash.Sum) // state. (ShakeHash.Read is thus very different from Hash.Sum)
// It never returns an error. // It never returns an error, but subsequent calls to Write or Sum
// will panic.
io.Reader io.Reader
// Clone returns a copy of the ShakeHash in its current state. // Clone returns a copy of the ShakeHash in its current state.
Clone() ShakeHash Clone() ShakeHash
// Reset resets the ShakeHash to its initial state.
Reset()
} }
// cSHAKE specific context // cSHAKE specific context
@ -81,8 +80,8 @@ func leftEncode(value uint64) []byte {
return b[i-1:] return b[i-1:]
} }
func newCShake(N, S []byte, rate int, dsbyte byte) ShakeHash { func newCShake(N, S []byte, rate, outputLen int, dsbyte byte) ShakeHash {
c := cshakeState{state: &state{rate: rate, dsbyte: dsbyte}} c := cshakeState{state: &state{rate: rate, outputLen: outputLen, dsbyte: dsbyte}}
// leftEncode returns max 9 bytes // leftEncode returns max 9 bytes
c.initBlock = make([]byte, 0, 9*2+len(N)+len(S)) c.initBlock = make([]byte, 0, 9*2+len(N)+len(S))
@ -119,7 +118,7 @@ func NewShake128() ShakeHash {
if h := newShake128Asm(); h != nil { if h := newShake128Asm(); h != nil {
return h return h
} }
return &state{rate: rate128, dsbyte: dsbyteShake} return &state{rate: rate128, outputLen: 32, dsbyte: dsbyteShake}
} }
// NewShake256 creates a new SHAKE256 variable-output-length ShakeHash. // NewShake256 creates a new SHAKE256 variable-output-length ShakeHash.
@ -129,7 +128,7 @@ func NewShake256() ShakeHash {
if h := newShake256Asm(); h != nil { if h := newShake256Asm(); h != nil {
return h return h
} }
return &state{rate: rate256, dsbyte: dsbyteShake} return &state{rate: rate256, outputLen: 64, dsbyte: dsbyteShake}
} }
// NewCShake128 creates a new instance of cSHAKE128 variable-output-length ShakeHash, // NewCShake128 creates a new instance of cSHAKE128 variable-output-length ShakeHash,
@ -142,7 +141,7 @@ func NewCShake128(N, S []byte) ShakeHash {
if len(N) == 0 && len(S) == 0 { if len(N) == 0 && len(S) == 0 {
return NewShake128() return NewShake128()
} }
return newCShake(N, S, rate128, dsbyteCShake) return newCShake(N, S, rate128, 32, dsbyteCShake)
} }
// NewCShake256 creates a new instance of cSHAKE256 variable-output-length ShakeHash, // NewCShake256 creates a new instance of cSHAKE256 variable-output-length ShakeHash,
@ -155,7 +154,7 @@ func NewCShake256(N, S []byte) ShakeHash {
if len(N) == 0 && len(S) == 0 { if len(N) == 0 && len(S) == 0 {
return NewShake256() return NewShake256()
} }
return newCShake(N, S, rate256, dsbyteCShake) return newCShake(N, S, rate256, 64, dsbyteCShake)
} }
// ShakeSum128 writes an arbitrary-length digest of data into hash. // ShakeSum128 writes an arbitrary-length digest of data into hash.

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !gc || purego || !s390x //go:build !gc || purego || !s390x
// +build !gc purego !s390x
package sha3 package sha3

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build (!amd64 && !386 && !ppc64le) || purego //go:build (!amd64 && !386 && !ppc64le) || purego
// +build !amd64,!386,!ppc64le purego
package sha3 package sha3

View file

@ -3,8 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build (amd64 || 386 || ppc64le) && !purego //go:build (amd64 || 386 || ppc64le) && !purego
// +build amd64 386 ppc64le
// +build !purego
package sha3 package sha3

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gc //go:build gc
// +build gc
#include "textflag.h" #include "textflag.h"

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build aix //go:build aix
// +build aix
package cpu package cpu

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gc //go:build gc
// +build gc
#include "textflag.h" #include "textflag.h"

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gc //go:build gc
// +build gc
package cpu package cpu

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gc //go:build gc
// +build gc
package cpu package cpu

View file

@ -3,8 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build (386 || amd64 || amd64p32) && gc //go:build (386 || amd64 || amd64p32) && gc
// +build 386 amd64 amd64p32
// +build gc
package cpu package cpu

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gccgo //go:build gccgo
// +build gccgo
package cpu package cpu

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gccgo //go:build gccgo
// +build gccgo
package cpu package cpu

View file

@ -3,8 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build (386 || amd64 || amd64p32) && gccgo //go:build (386 || amd64 || amd64p32) && gccgo
// +build 386 amd64 amd64p32
// +build gccgo
#include <cpuid.h> #include <cpuid.h>
#include <stdint.h> #include <stdint.h>

View file

@ -3,8 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build (386 || amd64 || amd64p32) && gccgo //go:build (386 || amd64 || amd64p32) && gccgo
// +build 386 amd64 amd64p32
// +build gccgo
package cpu package cpu

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !386 && !amd64 && !amd64p32 && !arm64 //go:build !386 && !amd64 && !amd64p32 && !arm64
// +build !386,!amd64,!amd64p32,!arm64
package cpu package cpu

View file

@ -3,8 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build linux && (mips64 || mips64le) //go:build linux && (mips64 || mips64le)
// +build linux
// +build mips64 mips64le
package cpu package cpu

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build linux && !arm && !arm64 && !mips64 && !mips64le && !ppc64 && !ppc64le && !s390x //go:build linux && !arm && !arm64 && !mips64 && !mips64le && !ppc64 && !ppc64le && !s390x
// +build linux,!arm,!arm64,!mips64,!mips64le,!ppc64,!ppc64le,!s390x
package cpu package cpu

View file

@ -3,8 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build linux && (ppc64 || ppc64le) //go:build linux && (ppc64 || ppc64le)
// +build linux
// +build ppc64 ppc64le
package cpu package cpu

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build loong64 //go:build loong64
// +build loong64
package cpu package cpu

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build mips64 || mips64le //go:build mips64 || mips64le
// +build mips64 mips64le
package cpu package cpu

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build mips || mipsle //go:build mips || mipsle
// +build mips mipsle
package cpu package cpu

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !linux && arm //go:build !linux && arm
// +build !linux,arm
package cpu package cpu

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !linux && !netbsd && !openbsd && arm64 //go:build !linux && !netbsd && !openbsd && arm64
// +build !linux,!netbsd,!openbsd,arm64
package cpu package cpu

View file

@ -3,8 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !linux && (mips64 || mips64le) //go:build !linux && (mips64 || mips64le)
// +build !linux
// +build mips64 mips64le
package cpu package cpu

View file

@ -3,9 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !aix && !linux && (ppc64 || ppc64le) //go:build !aix && !linux && (ppc64 || ppc64le)
// +build !aix
// +build !linux
// +build ppc64 ppc64le
package cpu package cpu

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !linux && riscv64 //go:build !linux && riscv64
// +build !linux,riscv64
package cpu package cpu

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build ppc64 || ppc64le //go:build ppc64 || ppc64le
// +build ppc64 ppc64le
package cpu package cpu

View file

@ -3,10 +3,9 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build riscv64 //go:build riscv64
// +build riscv64
package cpu package cpu
const cacheLineSize = 32 const cacheLineSize = 64
func initOptions() {} func initOptions() {}

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gc //go:build gc
// +build gc
#include "textflag.h" #include "textflag.h"

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build wasm //go:build wasm
// +build wasm
package cpu package cpu

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build 386 || amd64 || amd64p32 //go:build 386 || amd64 || amd64p32
// +build 386 amd64 amd64p32
package cpu package cpu

View file

@ -3,8 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build (386 || amd64 || amd64p32) && gc //go:build (386 || amd64 || amd64p32) && gc
// +build 386 amd64 amd64p32
// +build gc
#include "textflag.h" #include "textflag.h"

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build armbe || arm64be || m68k || mips || mips64 || mips64p32 || ppc || ppc64 || s390 || s390x || shbe || sparc || sparc64 //go:build armbe || arm64be || m68k || mips || mips64 || mips64p32 || ppc || ppc64 || s390 || s390x || shbe || sparc || sparc64
// +build armbe arm64be m68k mips mips64 mips64p32 ppc ppc64 s390 s390x shbe sparc sparc64
package cpu package cpu

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build 386 || amd64 || amd64p32 || alpha || arm || arm64 || loong64 || mipsle || mips64le || mips64p32le || nios2 || ppc64le || riscv || riscv64 || sh || wasm //go:build 386 || amd64 || amd64p32 || alpha || arm || arm64 || loong64 || mipsle || mips64le || mips64p32le || nios2 || ppc64le || riscv || riscv64 || sh || wasm
// +build 386 amd64 amd64p32 alpha arm arm64 loong64 mipsle mips64le mips64p32le nios2 ppc64le riscv riscv64 sh wasm
package cpu package cpu

View file

@ -5,7 +5,7 @@
package cpu package cpu
import ( import (
"io/ioutil" "os"
) )
const ( const (
@ -39,7 +39,7 @@ func readHWCAP() error {
return nil return nil
} }
buf, err := ioutil.ReadFile(procAuxv) buf, err := os.ReadFile(procAuxv)
if err != nil { if err != nil {
// e.g. on android /proc/self/auxv is not accessible, so silently // e.g. on android /proc/self/auxv is not accessible, so silently
// ignore the error and leave Initialized = false. On some // ignore the error and leave Initialized = false. On some

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build linux && arm64 //go:build linux && arm64
// +build linux,arm64
package cpu package cpu

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build go1.21 //go:build go1.21
// +build go1.21
package cpu package cpu

View file

@ -9,7 +9,6 @@
// gccgo's libgo and thus must not used a CGo method. // gccgo's libgo and thus must not used a CGo method.
//go:build aix && gccgo //go:build aix && gccgo
// +build aix,gccgo
package cpu package cpu

View file

@ -7,7 +7,6 @@
// (See golang.org/issue/32102) // (See golang.org/issue/32102)
//go:build aix && ppc64 && gc //go:build aix && ppc64 && gc
// +build aix,ppc64,gc
package cpu package cpu

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !go1.19 //go:build !go1.19
// +build !go1.19
package execabs package execabs

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build go1.19 //go:build go1.19
// +build go1.19
package execabs package execabs

View file

@ -1,30 +0,0 @@
// Copyright 2020 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 unsafeheader contains header declarations for the Go runtime's
// slice and string implementations.
//
// This package allows x/sys to use types equivalent to
// reflect.SliceHeader and reflect.StringHeader without introducing
// a dependency on the (relatively heavy) "reflect" package.
package unsafeheader
import (
"unsafe"
)
// Slice is the runtime representation of a slice.
// It cannot be used safely or portably and its representation may change in a later release.
type Slice struct {
Data unsafe.Pointer
Len int
Cap int
}
// String is the runtime representation of a string.
// It cannot be used safely or portably and its representation may change in a later release.
type String struct {
Data unsafe.Pointer
Len int
}

View file

@ -3,8 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build (aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos) && go1.9 //go:build (aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos) && go1.9
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos
// +build go1.9
package unix package unix

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gc //go:build gc
// +build gc
#include "textflag.h" #include "textflag.h"

View file

@ -3,8 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build (freebsd || netbsd || openbsd) && gc //go:build (freebsd || netbsd || openbsd) && gc
// +build freebsd netbsd openbsd
// +build gc
#include "textflag.h" #include "textflag.h"

View file

@ -3,8 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build (darwin || dragonfly || freebsd || netbsd || openbsd) && gc //go:build (darwin || dragonfly || freebsd || netbsd || openbsd) && gc
// +build darwin dragonfly freebsd netbsd openbsd
// +build gc
#include "textflag.h" #include "textflag.h"

View file

@ -3,8 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build (freebsd || netbsd || openbsd) && gc //go:build (freebsd || netbsd || openbsd) && gc
// +build freebsd netbsd openbsd
// +build gc
#include "textflag.h" #include "textflag.h"

View file

@ -3,8 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build (darwin || freebsd || netbsd || openbsd) && gc //go:build (darwin || freebsd || netbsd || openbsd) && gc
// +build darwin freebsd netbsd openbsd
// +build gc
#include "textflag.h" #include "textflag.h"

View file

@ -3,8 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build (darwin || freebsd || netbsd || openbsd) && gc //go:build (darwin || freebsd || netbsd || openbsd) && gc
// +build darwin freebsd netbsd openbsd
// +build gc
#include "textflag.h" #include "textflag.h"

View file

@ -3,8 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build (darwin || freebsd || netbsd || openbsd) && gc //go:build (darwin || freebsd || netbsd || openbsd) && gc
// +build darwin freebsd netbsd openbsd
// +build gc
#include "textflag.h" #include "textflag.h"

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gc //go:build gc
// +build gc
#include "textflag.h" #include "textflag.h"

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gc //go:build gc
// +build gc
#include "textflag.h" #include "textflag.h"

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gc //go:build gc
// +build gc
#include "textflag.h" #include "textflag.h"

View file

@ -3,9 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build linux && arm64 && gc //go:build linux && arm64 && gc
// +build linux
// +build arm64
// +build gc
#include "textflag.h" #include "textflag.h"

View file

@ -3,9 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build linux && loong64 && gc //go:build linux && loong64 && gc
// +build linux
// +build loong64
// +build gc
#include "textflag.h" #include "textflag.h"

View file

@ -3,9 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build linux && (mips64 || mips64le) && gc //go:build linux && (mips64 || mips64le) && gc
// +build linux
// +build mips64 mips64le
// +build gc
#include "textflag.h" #include "textflag.h"

View file

@ -3,9 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build linux && (mips || mipsle) && gc //go:build linux && (mips || mipsle) && gc
// +build linux
// +build mips mipsle
// +build gc
#include "textflag.h" #include "textflag.h"

View file

@ -3,9 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build linux && (ppc64 || ppc64le) && gc //go:build linux && (ppc64 || ppc64le) && gc
// +build linux
// +build ppc64 ppc64le
// +build gc
#include "textflag.h" #include "textflag.h"

View file

@ -3,8 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build riscv64 && gc //go:build riscv64 && gc
// +build riscv64
// +build gc
#include "textflag.h" #include "textflag.h"

View file

@ -3,9 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build linux && s390x && gc //go:build linux && s390x && gc
// +build linux
// +build s390x
// +build gc
#include "textflag.h" #include "textflag.h"

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gc //go:build gc
// +build gc
#include "textflag.h" #include "textflag.h"

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gc //go:build gc
// +build gc
#include "textflag.h" #include "textflag.h"

View file

@ -3,9 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build zos && s390x && gc //go:build zos && s390x && gc
// +build zos
// +build s390x
// +build gc
#include "textflag.h" #include "textflag.h"

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build freebsd //go:build freebsd
// +build freebsd
package unix package unix

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos
package unix package unix

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build aix && ppc //go:build aix && ppc
// +build aix,ppc
// Functions to access/create device major and minor numbers matching the // Functions to access/create device major and minor numbers matching the
// encoding used by AIX. // encoding used by AIX.

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build aix && ppc64 //go:build aix && ppc64
// +build aix,ppc64
// Functions to access/create device major and minor numbers matching the // Functions to access/create device major and minor numbers matching the
// encoding used AIX. // encoding used AIX.

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build zos && s390x //go:build zos && s390x
// +build zos,s390x
// Functions to access/create device major and minor numbers matching the // Functions to access/create device major and minor numbers matching the
// encoding used by z/OS. // encoding used by z/OS.

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos
package unix package unix

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// //
//go:build armbe || arm64be || m68k || mips || mips64 || mips64p32 || ppc || ppc64 || s390 || s390x || shbe || sparc || sparc64 //go:build armbe || arm64be || m68k || mips || mips64 || mips64p32 || ppc || ppc64 || s390 || s390x || shbe || sparc || sparc64
// +build armbe arm64be m68k mips mips64 mips64p32 ppc ppc64 s390 s390x shbe sparc sparc64
package unix package unix

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// //
//go:build 386 || amd64 || amd64p32 || alpha || arm || arm64 || loong64 || mipsle || mips64le || mips64p32le || nios2 || ppc64le || riscv || riscv64 || sh //go:build 386 || amd64 || amd64p32 || alpha || arm || arm64 || loong64 || mipsle || mips64le || mips64p32le || nios2 || ppc64le || riscv || riscv64 || sh
// +build 386 amd64 amd64p32 alpha arm arm64 loong64 mipsle mips64le mips64p32le nios2 ppc64le riscv riscv64 sh
package unix package unix

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos
// Unix environment variables. // Unix environment variables.

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build zos && s390x //go:build zos && s390x
// +build zos,s390x
package unix package unix

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build dragonfly || freebsd || linux || netbsd || openbsd //go:build dragonfly || freebsd || linux || netbsd || openbsd
// +build dragonfly freebsd linux netbsd openbsd
package unix package unix

View file

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build (linux && 386) || (linux && arm) || (linux && mips) || (linux && mipsle) || (linux && ppc) //go:build (linux && 386) || (linux && arm) || (linux && mips) || (linux && mipsle) || (linux && ppc)
// +build linux,386 linux,arm linux,mips linux,mipsle linux,ppc
package unix package unix

Some files were not shown because too many files have changed in this diff Show more