mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-23 11:11:36 +00:00
Fix crash
This commit is contained in:
parent
7efd66932f
commit
e824c73e21
@ -113,7 +113,9 @@ func (l *links) isConnectedTo(info linkInfo) bool {
|
|||||||
func (l *links) call(u *url.URL, sintf string, errch chan<- error) (info linkInfo, err error) {
|
func (l *links) call(u *url.URL, sintf string, errch chan<- error) (info linkInfo, err error) {
|
||||||
info = linkInfoFor(u.Scheme, sintf, u.Host)
|
info = linkInfoFor(u.Scheme, sintf, u.Host)
|
||||||
if l.isConnectedTo(info) {
|
if l.isConnectedTo(info) {
|
||||||
close(errch) // already connected, no error
|
if errch != nil {
|
||||||
|
close(errch) // already connected, no error
|
||||||
|
}
|
||||||
return info, nil
|
return info, nil
|
||||||
}
|
}
|
||||||
options := linkOptions{
|
options := linkOptions{
|
||||||
@ -122,7 +124,9 @@ func (l *links) call(u *url.URL, sintf string, errch chan<- error) (info linkInf
|
|||||||
for _, pubkey := range u.Query()["key"] {
|
for _, pubkey := range u.Query()["key"] {
|
||||||
sigPub, err := hex.DecodeString(pubkey)
|
sigPub, err := hex.DecodeString(pubkey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
close(errch)
|
if errch != nil {
|
||||||
|
close(errch)
|
||||||
|
}
|
||||||
return info, fmt.Errorf("pinned key contains invalid hex characters")
|
return info, fmt.Errorf("pinned key contains invalid hex characters")
|
||||||
}
|
}
|
||||||
var sigPubKey keyArray
|
var sigPubKey keyArray
|
||||||
@ -132,7 +136,9 @@ func (l *links) call(u *url.URL, sintf string, errch chan<- error) (info linkInf
|
|||||||
if p := u.Query().Get("priority"); p != "" {
|
if p := u.Query().Get("priority"); p != "" {
|
||||||
pi, err := strconv.ParseUint(p, 10, 8)
|
pi, err := strconv.ParseUint(p, 10, 8)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
close(errch)
|
if errch != nil {
|
||||||
|
close(errch)
|
||||||
|
}
|
||||||
return info, fmt.Errorf("priority invalid: %w", err)
|
return info, fmt.Errorf("priority invalid: %w", err)
|
||||||
}
|
}
|
||||||
options.priority = uint8(pi)
|
options.priority = uint8(pi)
|
||||||
@ -208,7 +214,9 @@ func (l *links) call(u *url.URL, sintf string, errch chan<- error) (info linkInf
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
default:
|
default:
|
||||||
close(errch)
|
if errch != nil {
|
||||||
|
close(errch)
|
||||||
|
}
|
||||||
return info, errors.New("unknown call scheme: " + u.Scheme)
|
return info, errors.New("unknown call scheme: " + u.Scheme)
|
||||||
}
|
}
|
||||||
return info, nil
|
return info, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user