mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 14:15:06 +03:00
Linter errors fixes
This commit is contained in:
parent
432b87e602
commit
ae954bad35
4 changed files with 33 additions and 22 deletions
|
@ -1,14 +1,12 @@
|
|||
package admin
|
||||
|
||||
import (
|
||||
|
||||
"fmt"
|
||||
|
||||
)
|
||||
|
||||
type AddPeersRequest struct {
|
||||
Uri string `json:"uri"`
|
||||
Intf string `json:"intf"`
|
||||
Uri string `json:"uri"`
|
||||
Intf string `json:"intf"`
|
||||
}
|
||||
|
||||
type AddPeersResponse struct {
|
||||
|
@ -17,12 +15,12 @@ type AddPeersResponse struct {
|
|||
|
||||
func (a *AdminSocket) addPeersHandler(req *AddPeersRequest, res *AddPeersResponse) error {
|
||||
// Set sane defaults
|
||||
err:=a.core.AddPeer(req.Uri, req.Intf)
|
||||
err := a.core.AddPeer(req.Uri, req.Intf)
|
||||
if err != nil {
|
||||
fmt.Println("adding peer error %s", err)
|
||||
fmt.Printf("adding peer error %s\n", err)
|
||||
return err
|
||||
} else {
|
||||
fmt.Println("added peer %s", req.Uri)
|
||||
fmt.Printf("added peer %s\n", req.Uri)
|
||||
res.List = append(res.List, req.Uri)
|
||||
}
|
||||
|
||||
|
|
|
@ -255,7 +255,7 @@ func (a *AdminSocket) StartHttpServer(nc *config.NodeConfig) {
|
|||
if err != nil {
|
||||
http.Error(w, err.Error(), 503)
|
||||
}
|
||||
fmt.Fprintf(w, string(b[:]))
|
||||
fmt.Fprint(w, string(b[:]))
|
||||
})
|
||||
http.HandleFunc("/api/getpeers", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
|
@ -269,7 +269,7 @@ func (a *AdminSocket) StartHttpServer(nc *config.NodeConfig) {
|
|||
if err != nil {
|
||||
http.Error(w, err.Error(), 503)
|
||||
}
|
||||
fmt.Fprintf(w, string(b[:]))
|
||||
fmt.Fprint(w, string(b[:]))
|
||||
})
|
||||
var docFs = ""
|
||||
pakReader, err := zip.OpenReader(nc.WwwRoot)
|
||||
|
|
|
@ -49,12 +49,14 @@ func (l *linkMPATH) dial(url *url.URL, options linkOptions, sintf string) error
|
|||
}
|
||||
|
||||
func (l *linkMPATH) listen(url *url.URL, sintf string) (*Listener, error) {
|
||||
hostport := url.Host
|
||||
if sintf != "" {
|
||||
if host, port, err := net.SplitHostPort(hostport); err == nil {
|
||||
hostport = fmt.Sprintf("[%s%%%s]:%s", host, sintf, port)
|
||||
/*
|
||||
hostport := url.Host
|
||||
if sintf != "" {
|
||||
if host, port, err := net.SplitHostPort(hostport); err == nil {
|
||||
hostport = fmt.Sprintf("[%s%%%s]:%s", host, sintf, port)
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
_, cancel := context.WithCancel(l.core.ctx)
|
||||
listener, err := l.listenFor(url, sintf)
|
||||
if err != nil {
|
||||
|
|
|
@ -55,6 +55,9 @@ func (l *linkSCTP) dial(url *url.URL, options linkOptions, sintf string) error {
|
|||
return err
|
||||
}
|
||||
err = conn.(*sctp.SCTPConn).Connect(raddress)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
//conn.(*sctp.SCTPConn).SetWriteBuffer(324288)
|
||||
//conn.(*sctp.SCTPConn).SetReadBuffer(324288)
|
||||
//wbuf, _ := conn.(*sctp.SCTPConn).GetWriteBuffer()
|
||||
|
@ -62,7 +65,10 @@ func (l *linkSCTP) dial(url *url.URL, options linkOptions, sintf string) error {
|
|||
|
||||
//l.core.log.Printf("Read buffer %d", rbuf)
|
||||
//l.core.log.Printf("Write buffer %d", wbuf)
|
||||
conn.(*sctp.SCTPConn).SetEvents(sctp.SCTP_EVENT_DATA_IO)
|
||||
err = conn.(*sctp.SCTPConn).SetEvents(sctp.SCTP_EVENT_DATA_IO)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dial := &linkDial{
|
||||
url: url,
|
||||
sintf: sintf,
|
||||
|
@ -72,12 +78,14 @@ func (l *linkSCTP) dial(url *url.URL, options linkOptions, sintf string) error {
|
|||
|
||||
func (l *linkSCTP) listen(url *url.URL, sintf string) (*Listener, error) {
|
||||
//_, cancel := context.WithCancel(l.core.ctx)
|
||||
hostport := url.Host
|
||||
if sintf != "" {
|
||||
if host, port, err := net.SplitHostPort(hostport); err == nil {
|
||||
hostport = fmt.Sprintf("[%s%%%s]:%s", host, sintf, port)
|
||||
/*
|
||||
hostport := url.Host
|
||||
if sintf != "" {
|
||||
if host, port, err := net.SplitHostPort(hostport); err == nil {
|
||||
hostport = fmt.Sprintf("[%s%%%s]:%s", host, sintf, port)
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
addr := l.getAddress(url.Host)
|
||||
listener, err := sctp.NewSCTPListener(addr, sctp.InitMsg{NumOstreams: 2, MaxInstreams: 2, MaxAttempts: 2, MaxInitTimeout: 5}, sctp.OneToOne, false)
|
||||
|
||||
|
@ -85,7 +93,10 @@ func (l *linkSCTP) listen(url *url.URL, sintf string) (*Listener, error) {
|
|||
//cancel()
|
||||
return nil, err
|
||||
}
|
||||
listener.SetEvents(sctp.SCTP_EVENT_DATA_IO)
|
||||
err = listener.SetEvents(sctp.SCTP_EVENT_DATA_IO)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
entry := &Listener{
|
||||
Listener: listener,
|
||||
closed: make(chan struct{}),
|
||||
|
@ -155,7 +166,7 @@ func (l *linkSCTP) getAddr() *net.TCPAddr {
|
|||
return addr
|
||||
}
|
||||
|
||||
//SCTP infrastructure
|
||||
// SCTP infrastructure
|
||||
func (l *linkSCTP) getAddress(host string) *sctp.SCTPAddr {
|
||||
|
||||
//sctp supports multihoming but current implementation reuires only one path
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue