Skip to content

Commit

Permalink
Various clean-ups
Browse files Browse the repository at this point in the history
  • Loading branch information
neilalexander committed Jul 20, 2024
1 parent 8ecc402 commit 04c0acf
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/admin/addpeer.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type AddPeerRequest struct {

type AddPeerResponse struct{}

func (a *AdminSocket) addPeerHandler(req *AddPeerRequest, res *AddPeerResponse) error {
func (a *AdminSocket) addPeerHandler(req *AddPeerRequest, _ *AddPeerResponse) error {
u, err := url.Parse(req.Uri)
if err != nil {
return fmt.Errorf("unable to parse peering URI: %w", err)
Expand Down
22 changes: 0 additions & 22 deletions src/admin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,6 @@ func (a *AdminSocket) SetupAdminHandlers() {
return res, nil
},
)
//_ = a.AddHandler("getNodeInfo", []string{"key"}, t.proto.nodeinfo.nodeInfoAdminHandler)
//_ = a.AddHandler("debug_remoteGetSelf", []string{"key"}, t.proto.getSelfHandler)
//_ = a.AddHandler("debug_remoteGetPeers", []string{"key"}, t.proto.getPeersHandler)
//_ = a.AddHandler("debug_remoteGetDHT", []string{"key"}, t.proto.getDHTHandler)
}

// IsStarted returns true if the module has been started.
Expand Down Expand Up @@ -269,7 +265,6 @@ func (a *AdminSocket) listen() {
case "tcp":
a.listener, err = net.Listen("tcp", u.Host)
default:
// err = errors.New(fmt.Sprint("protocol not supported: ", u.Scheme))
a.listener, err = net.Listen("tcp", listenaddr)
}
} else {
Expand Down Expand Up @@ -309,23 +304,6 @@ func (a *AdminSocket) handleRequest(conn net.Conn) {

defer conn.Close()

/*
defer func() {
r := recover()
if r != nil {
fmt.Println("ERROR:", r)
a.log.Debugln("Admin socket error:", r)
if err := encoder.Encode(&ErrorResponse{
Error: "Check your syntax and input types",
}); err != nil {
fmt.Println("ERROR 2:", err)
a.log.Debugln("Admin socket JSON encode error:", err)
}
conn.Close()
}
}()
*/

for {
var err error
var buf json.RawMessage
Expand Down
2 changes: 1 addition & 1 deletion src/admin/getpaths.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type PathEntry struct {
Sequence uint64 `json:"sequence"`
}

func (a *AdminSocket) getPathsHandler(req *GetPathsRequest, res *GetPathsResponse) error {
func (a *AdminSocket) getPathsHandler(_ *GetPathsRequest, res *GetPathsResponse) error {
paths := a.core.GetPaths()
res.Paths = make([]PathEntry, 0, len(paths))
for _, p := range paths {
Expand Down
2 changes: 1 addition & 1 deletion src/admin/getpeers.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type PeerEntry struct {
LastError string `json:"last_error,omitempty"`
}

func (a *AdminSocket) getPeersHandler(req *GetPeersRequest, res *GetPeersResponse) error {
func (a *AdminSocket) getPeersHandler(_ *GetPeersRequest, res *GetPeersResponse) error {
peers := a.core.GetPeers()
res.Peers = make([]PeerEntry, 0, len(peers))
for _, p := range peers {
Expand Down
2 changes: 1 addition & 1 deletion src/admin/getself.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type GetSelfResponse struct {
Subnet string `json:"subnet"`
}

func (a *AdminSocket) getSelfHandler(req *GetSelfRequest, res *GetSelfResponse) error {
func (a *AdminSocket) getSelfHandler(_ *GetSelfRequest, res *GetSelfResponse) error {
self := a.core.GetSelf()
snet := a.core.Subnet()
res.BuildName = version.BuildName()
Expand Down
2 changes: 1 addition & 1 deletion src/admin/getsessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type SessionEntry struct {
Uptime float64 `json:"uptime"`
}

func (a *AdminSocket) getSessionsHandler(req *GetSessionsRequest, res *GetSessionsResponse) error {
func (a *AdminSocket) getSessionsHandler(_ *GetSessionsRequest, res *GetSessionsResponse) error {
sessions := a.core.GetSessions()
res.Sessions = make([]SessionEntry, 0, len(sessions))
for _, s := range sessions {
Expand Down
6 changes: 1 addition & 5 deletions src/admin/gettree.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ type TreeEntry struct {
PublicKey string `json:"key"`
Parent string `json:"parent"`
Sequence uint64 `json:"sequence"`
//Port uint64 `json:"port"`
//Rest uint64 `json:"rest"`
}

func (a *AdminSocket) getTreeHandler(req *GetTreeRequest, res *GetTreeResponse) error {
func (a *AdminSocket) getTreeHandler(_ *GetTreeRequest, res *GetTreeResponse) error {
tree := a.core.GetTree()
res.Tree = make([]TreeEntry, 0, len(tree))
for _, d := range tree {
Expand All @@ -34,8 +32,6 @@ func (a *AdminSocket) getTreeHandler(req *GetTreeRequest, res *GetTreeResponse)
PublicKey: hex.EncodeToString(d.Key[:]),
Parent: hex.EncodeToString(d.Parent[:]),
Sequence: d.Sequence,
//Port: d.Port,
//Rest: d.Rest,
})
}
sort.SliceStable(res.Tree, func(i, j int) bool {
Expand Down
2 changes: 1 addition & 1 deletion src/admin/removepeer.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type RemovePeerRequest struct {

type RemovePeerResponse struct{}

func (a *AdminSocket) removePeerHandler(req *RemovePeerRequest, res *RemovePeerResponse) error {
func (a *AdminSocket) removePeerHandler(req *RemovePeerRequest, _ *RemovePeerResponse) error {
u, err := url.Parse(req.Uri)
if err != nil {
return fmt.Errorf("unable to parse peering URI: %w", err)
Expand Down
4 changes: 2 additions & 2 deletions src/core/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ func (l *links) add(u *url.URL, sintf string, linkType linkType) error {
return retErr
}

func (l *links) remove(u *url.URL, sintf string, linkType linkType) error {
func (l *links) remove(u *url.URL, sintf string, _ linkType) error {
var retErr error
phony.Block(l, func() {
// Generate the link info and see whether we think we already
Expand Down Expand Up @@ -566,7 +566,7 @@ func (l *links) handler(linkType linkType, options linkOptions, conn net.Conn, s
switch {
case err != nil:
return fmt.Errorf("write handshake: %w", err)
case err == nil && n != len(metaBytes):
case n != len(metaBytes):
return fmt.Errorf("incomplete handshake send")
}
meta = version_metadata{}
Expand Down
2 changes: 1 addition & 1 deletion src/core/link_tcp_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ func (t *linkTCP) tcpContext(network, address string, c syscall.RawConn) error {
}
}

func (t *linkTCP) getControl(sintf string) func(string, string, syscall.RawConn) error {
func (t *linkTCP) getControl(_ string) func(string, string, syscall.RawConn) error {
return t.tcpContext
}
2 changes: 1 addition & 1 deletion src/multicast/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type GetMulticastInterfacesResponse struct {
Interfaces []string `json:"multicast_interfaces"`
}

func (m *Multicast) getMulticastInterfacesHandler(req *GetMulticastInterfacesRequest, res *GetMulticastInterfacesResponse) error {
func (m *Multicast) getMulticastInterfacesHandler(_ *GetMulticastInterfacesRequest, res *GetMulticastInterfacesResponse) error {
res.Interfaces = []string{}
for _, v := range m.Interfaces() {
res.Interfaces = append(res.Interfaces, v.Name)
Expand Down

0 comments on commit 04c0acf

Please sign in to comment.