mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2026-05-21 13:26:29 +03:00
Linter update & fixes
This commit is contained in:
@@ -314,26 +314,26 @@ func (a *AdminSocket) handleRequest(conn net.Conn) {
|
||||
req.Arguments = []byte("{}")
|
||||
if err := func() error {
|
||||
if err = decoder.Decode(&buf); err != nil {
|
||||
return fmt.Errorf("Failed to find request")
|
||||
return fmt.Errorf("failed to find request")
|
||||
}
|
||||
if err = json.Unmarshal(buf, &req); err != nil {
|
||||
return fmt.Errorf("Failed to unmarshal request")
|
||||
return fmt.Errorf("failed to unmarshal request")
|
||||
}
|
||||
resp.Request = req
|
||||
if req.Name == "" {
|
||||
return fmt.Errorf("No request specified")
|
||||
return fmt.Errorf("no request specified")
|
||||
}
|
||||
reqname := strings.ToLower(req.Name)
|
||||
handler, ok := a.handlers[reqname]
|
||||
if !ok {
|
||||
return fmt.Errorf("Unknown action '%s', try 'list' for help", reqname)
|
||||
return fmt.Errorf("unknown action '%s', try 'list' for help", reqname)
|
||||
}
|
||||
res, err := handler.handler(req.Arguments)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if resp.Response, err = json.Marshal(res); err != nil {
|
||||
return fmt.Errorf("Failed to marshal response: %w", err)
|
||||
return fmt.Errorf("failed to marshal response: %w", err)
|
||||
}
|
||||
resp.Status = "success"
|
||||
return nil
|
||||
|
||||
@@ -138,7 +138,7 @@ func (c *Core) GetPaths() []PathEntryInfo {
|
||||
|
||||
func (c *Core) GetSessions() []SessionInfo {
|
||||
var sessions []SessionInfo
|
||||
ss := c.PacketConn.Debug.GetSessions()
|
||||
ss := c.Debug.GetSessions()
|
||||
for _, s := range ss {
|
||||
var info SessionInfo
|
||||
info.Key = s.Key
|
||||
|
||||
@@ -27,14 +27,14 @@ type Core struct {
|
||||
// guarantee that it will be covered by the mutex
|
||||
phony.Inbox
|
||||
*iwe.PacketConn
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc
|
||||
secret ed25519.PrivateKey
|
||||
public ed25519.PublicKey
|
||||
links links
|
||||
proto protoHandler
|
||||
log Logger
|
||||
config struct {
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc
|
||||
secret ed25519.PrivateKey
|
||||
public ed25519.PublicKey
|
||||
links links
|
||||
proto protoHandler
|
||||
log Logger
|
||||
config struct {
|
||||
tls *tls.Config // immutable after startup
|
||||
//_peers map[Peer]*linkInfo // configurable after startup
|
||||
_listeners map[ListenAddress]struct{} // configurable after startup
|
||||
@@ -157,7 +157,7 @@ func (c *Core) Stop() {
|
||||
func (c *Core) _close() error {
|
||||
c.cancel()
|
||||
c.links.shutdown()
|
||||
err := c.PacketConn.Close()
|
||||
err := c.Close()
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ func (l *links) newLinkQUIC() *linkQUIC {
|
||||
|
||||
func (l *linkQUIC) dial(ctx context.Context, url *url.URL, info linkInfo, options linkOptions) (net.Conn, error) {
|
||||
tlsconfig := l.tlsconfig.Clone()
|
||||
return l.links.findSuitableIP(url, func(hostname string, ip net.IP, port int) (net.Conn, error) {
|
||||
return l.findSuitableIP(url, func(hostname string, ip net.IP, port int) (net.Conn, error) {
|
||||
tlsconfig.ServerName = hostname
|
||||
tlsconfig.MinVersion = tls.VersionTLS12
|
||||
tlsconfig.MaxVersion = tls.VersionTLS13
|
||||
|
||||
@@ -31,7 +31,7 @@ func (l *linkSOCKS) dial(_ context.Context, url *url.URL, info linkInfo, options
|
||||
proxyAuth.Password, _ = url.User.Password()
|
||||
}
|
||||
tlsconfig := l.tls.config.Clone()
|
||||
return l.links.findSuitableIP(url, func(hostname string, ip net.IP, port int) (net.Conn, error) {
|
||||
return l.findSuitableIP(url, func(hostname string, ip net.IP, port int) (net.Conn, error) {
|
||||
hostport := net.JoinHostPort(ip.String(), fmt.Sprintf("%d", port))
|
||||
dialer, err := l.tcp.dialerFor(&net.TCPAddr{
|
||||
IP: ip,
|
||||
|
||||
@@ -28,7 +28,7 @@ func (l *links) newLinkTCP() *linkTCP {
|
||||
}
|
||||
|
||||
func (l *linkTCP) dial(ctx context.Context, url *url.URL, info linkInfo, options linkOptions) (net.Conn, error) {
|
||||
return l.links.findSuitableIP(url, func(hostname string, ip net.IP, port int) (net.Conn, error) {
|
||||
return l.findSuitableIP(url, func(hostname string, ip net.IP, port int) (net.Conn, error) {
|
||||
addr := &net.TCPAddr{
|
||||
IP: ip,
|
||||
Port: port,
|
||||
|
||||
@@ -33,7 +33,7 @@ func (l *links) newLinkTLS(tcp *linkTCP) *linkTLS {
|
||||
|
||||
func (l *linkTLS) dial(ctx context.Context, url *url.URL, info linkInfo, options linkOptions) (net.Conn, error) {
|
||||
tlsconfig := l.config.Clone()
|
||||
return l.links.findSuitableIP(url, func(hostname string, ip net.IP, port int) (net.Conn, error) {
|
||||
return l.findSuitableIP(url, func(hostname string, ip net.IP, port int) (net.Conn, error) {
|
||||
tlsconfig.ServerName = hostname
|
||||
tlsconfig.MinVersion = tls.VersionTLS12
|
||||
tlsconfig.MaxVersion = tls.VersionTLS13
|
||||
|
||||
@@ -88,7 +88,7 @@ func (l *links) newLinkWS() *linkWS {
|
||||
}
|
||||
|
||||
func (l *linkWS) dial(ctx context.Context, url *url.URL, info linkInfo, options linkOptions) (net.Conn, error) {
|
||||
return l.links.findSuitableIP(url, func(hostname string, ip net.IP, port int) (net.Conn, error) {
|
||||
return l.findSuitableIP(url, func(hostname string, ip net.IP, port int) (net.Conn, error) {
|
||||
u := *url
|
||||
u.Host = net.JoinHostPort(ip.String(), fmt.Sprintf("%d", port))
|
||||
addr := &net.TCPAddr{
|
||||
|
||||
@@ -32,7 +32,7 @@ func (l *links) newLinkWSS() *linkWSS {
|
||||
|
||||
func (l *linkWSS) dial(ctx context.Context, url *url.URL, info linkInfo, options linkOptions) (net.Conn, error) {
|
||||
tlsconfig := l.tlsconfig.Clone()
|
||||
return l.links.findSuitableIP(url, func(hostname string, ip net.IP, port int) (net.Conn, error) {
|
||||
return l.findSuitableIP(url, func(hostname string, ip net.IP, port int) (net.Conn, error) {
|
||||
tlsconfig.ServerName = hostname
|
||||
tlsconfig.MinVersion = tls.VersionTLS12
|
||||
tlsconfig.MaxVersion = tls.VersionTLS13
|
||||
|
||||
@@ -143,13 +143,13 @@ func (m *nodeinfo) nodeInfoAdminHandler(in json.RawMessage) (interface{}, error)
|
||||
return nil, err
|
||||
}
|
||||
if req.Key == "" {
|
||||
return nil, fmt.Errorf("No remote public key supplied")
|
||||
return nil, fmt.Errorf("no remote public key supplied")
|
||||
}
|
||||
var key keyArray
|
||||
var kbs []byte
|
||||
var err error
|
||||
if kbs, err = hex.DecodeString(req.Key); err != nil {
|
||||
return nil, fmt.Errorf("Failed to decode public key: %w", err)
|
||||
return nil, fmt.Errorf("failed to decode public key: %w", err)
|
||||
}
|
||||
copy(key[:], kbs)
|
||||
ch := make(chan []byte, 1)
|
||||
@@ -160,7 +160,7 @@ func (m *nodeinfo) nodeInfoAdminHandler(in json.RawMessage) (interface{}, error)
|
||||
defer timer.Stop()
|
||||
select {
|
||||
case <-timer.C:
|
||||
return nil, errors.New("Timed out waiting for response")
|
||||
return nil, errors.New("timed out waiting for response")
|
||||
case info := <-ch:
|
||||
var msg json.RawMessage
|
||||
if err := msg.UnmarshalJSON(info); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user