mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-06-16 14:15:07 +03:00
Use Go 1.21 in CI, update minimum version to Go 1.20, lint fixes, update quic-go
This commit is contained in:
parent
fe14981dda
commit
5b203ad8c5
13 changed files with 59 additions and 58 deletions
|
@ -2,7 +2,7 @@ package core
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"math/rand"
|
||||
"crypto/rand"
|
||||
"net/url"
|
||||
"os"
|
||||
"testing"
|
||||
|
@ -146,7 +146,7 @@ func TestCore_Start_Transfer(t *testing.T) {
|
|||
|
||||
// Send
|
||||
msg := make([]byte, msgLen)
|
||||
rand.Read(msg[40:])
|
||||
_, _ = rand.Read(msg[40:])
|
||||
msg[0] = 0x60
|
||||
copy(msg[8:24], nodeB.Address())
|
||||
copy(msg[24:40], nodeA.Address())
|
||||
|
@ -178,7 +178,7 @@ func BenchmarkCore_Start_Transfer(b *testing.B) {
|
|||
|
||||
// Send
|
||||
msg := make([]byte, msgLen)
|
||||
rand.Read(msg[40:])
|
||||
_, _ = rand.Read(msg[40:])
|
||||
msg[0] = 0x60
|
||||
copy(msg[8:24], nodeB.Address())
|
||||
copy(msg[24:40], nodeA.Address())
|
||||
|
|
|
@ -40,7 +40,7 @@ type links struct {
|
|||
}
|
||||
|
||||
type linkProtocol interface {
|
||||
dial(url *url.URL, info linkInfo, options linkOptions) (net.Conn, error)
|
||||
dial(ctx context.Context, url *url.URL, info linkInfo, options linkOptions) (net.Conn, error)
|
||||
listen(ctx context.Context, url *url.URL, sintf string) (net.Listener, error)
|
||||
}
|
||||
|
||||
|
@ -473,7 +473,7 @@ func (l *links) connect(u *url.URL, info linkInfo, options linkOptions) (net.Con
|
|||
default:
|
||||
return nil, ErrLinkUnrecognisedSchema
|
||||
}
|
||||
return dialer.dial(u, info, options)
|
||||
return dialer.dial(l.core.ctx, u, info, options)
|
||||
}
|
||||
|
||||
func (l *links) handler(linkType linkType, options linkOptions, conn net.Conn) error {
|
||||
|
|
|
@ -24,7 +24,7 @@ type linkQUICStream struct {
|
|||
}
|
||||
|
||||
type linkQUICListener struct {
|
||||
quic.EarlyListener
|
||||
*quic.EarlyListener
|
||||
ch <-chan *linkQUICStream
|
||||
}
|
||||
|
||||
|
@ -49,8 +49,8 @@ func (l *links) newLinkQUIC() *linkQUIC {
|
|||
return lt
|
||||
}
|
||||
|
||||
func (l *linkQUIC) dial(url *url.URL, info linkInfo, options linkOptions) (net.Conn, error) {
|
||||
qc, err := quic.DialAddrEarly(url.Host, l.tlsconfig, l.quicconfig)
|
||||
func (l *linkQUIC) dial(ctx context.Context, url *url.URL, info linkInfo, options linkOptions) (net.Conn, error) {
|
||||
qc, err := quic.DialAddrEarly(ctx, url.Host, l.tlsconfig, l.quicconfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ func (l *links) newLinkSOCKS() *linkSOCKS {
|
|||
return lt
|
||||
}
|
||||
|
||||
func (l *linkSOCKS) dial(url *url.URL, info linkInfo, options linkOptions) (net.Conn, error) {
|
||||
func (l *linkSOCKS) dial(_ context.Context, url *url.URL, info linkInfo, options linkOptions) (net.Conn, error) {
|
||||
var proxyAuth *proxy.Auth
|
||||
if url.User != nil && url.User.Username() != "" {
|
||||
proxyAuth = &proxy.Auth{
|
||||
|
|
|
@ -68,7 +68,7 @@ func (l *linkTCP) dialersFor(url *url.URL, info linkInfo) ([]*tcpDialer, error)
|
|||
return dialers, nil
|
||||
}
|
||||
|
||||
func (l *linkTCP) dial(url *url.URL, info linkInfo, options linkOptions) (net.Conn, error) {
|
||||
func (l *linkTCP) dial(ctx context.Context, url *url.URL, info linkInfo, options linkOptions) (net.Conn, error) {
|
||||
if l.core.isTLSOnly() {
|
||||
return nil, fmt.Errorf("TCP peer prohibited in TLS-only mode")
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ func (l *linkTCP) dial(url *url.URL, info linkInfo, options linkOptions) (net.Co
|
|||
}
|
||||
for _, d := range dialers {
|
||||
var conn net.Conn
|
||||
conn, err = d.dialer.DialContext(l.core.ctx, "tcp", d.addr.String())
|
||||
conn, err = d.dialer.DialContext(ctx, "tcp", d.addr.String())
|
||||
if err != nil {
|
||||
l.core.log.Warnf("Failed to connect to %s: %s", d.addr, err)
|
||||
continue
|
||||
|
|
|
@ -33,7 +33,7 @@ func (l *links) newLinkTLS(tcp *linkTCP) *linkTLS {
|
|||
return lt
|
||||
}
|
||||
|
||||
func (l *linkTLS) dial(url *url.URL, info linkInfo, options linkOptions) (net.Conn, error) {
|
||||
func (l *linkTLS) dial(ctx context.Context, url *url.URL, info linkInfo, options linkOptions) (net.Conn, error) {
|
||||
dialers, err := l.tcp.dialersFor(url, info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -49,7 +49,7 @@ func (l *linkTLS) dial(url *url.URL, info linkInfo, options linkOptions) (net.Co
|
|||
Config: tlsconfig,
|
||||
}
|
||||
var conn net.Conn
|
||||
conn, err = tlsdialer.DialContext(l.core.ctx, "tcp", d.addr.String())
|
||||
conn, err = tlsdialer.DialContext(ctx, "tcp", d.addr.String())
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -32,12 +32,12 @@ func (l *links) newLinkUNIX() *linkUNIX {
|
|||
return lt
|
||||
}
|
||||
|
||||
func (l *linkUNIX) dial(url *url.URL, info linkInfo, options linkOptions) (net.Conn, error) {
|
||||
func (l *linkUNIX) dial(ctx context.Context, url *url.URL, info linkInfo, options linkOptions) (net.Conn, error) {
|
||||
addr, err := net.ResolveUnixAddr("unix", url.Path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return l.dialer.DialContext(l.core.ctx, "unix", addr.String())
|
||||
return l.dialer.DialContext(ctx, "unix", addr.String())
|
||||
}
|
||||
|
||||
func (l *linkUNIX) listen(ctx context.Context, url *url.URL, _ string) (net.Listener, error) {
|
||||
|
|
|
@ -3,7 +3,7 @@ package core
|
|||
import (
|
||||
"bytes"
|
||||
"crypto/ed25519"
|
||||
"math/rand"
|
||||
"crypto/rand"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
@ -21,7 +21,7 @@ func TestVersionRoundtrip(t *testing.T) {
|
|||
// Generate a random public key for each time, since it is
|
||||
// a required field.
|
||||
test.publicKey = make(ed25519.PublicKey, ed25519.PublicKeySize)
|
||||
rand.Read(test.publicKey)
|
||||
_, _ = rand.Read(test.publicKey)
|
||||
|
||||
encoded := bytes.NewBuffer(test.encode())
|
||||
decoded := &version_metadata{}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue