Various clean-ups

This commit is contained in:
Neil Alexander 2024-07-20 12:31:58 +01:00
parent 8ecc402d7c
commit 04c0acf71b
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944
11 changed files with 11 additions and 37 deletions

View File

@ -12,7 +12,7 @@ type AddPeerRequest struct {
type AddPeerResponse 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) u, err := url.Parse(req.Uri)
if err != nil { if err != nil {
return fmt.Errorf("unable to parse peering URI: %w", err) return fmt.Errorf("unable to parse peering URI: %w", err)

View File

@ -201,10 +201,6 @@ func (a *AdminSocket) SetupAdminHandlers() {
return res, nil 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. // IsStarted returns true if the module has been started.
@ -269,7 +265,6 @@ func (a *AdminSocket) listen() {
case "tcp": case "tcp":
a.listener, err = net.Listen("tcp", u.Host) a.listener, err = net.Listen("tcp", u.Host)
default: default:
// err = errors.New(fmt.Sprint("protocol not supported: ", u.Scheme))
a.listener, err = net.Listen("tcp", listenaddr) a.listener, err = net.Listen("tcp", listenaddr)
} }
} else { } else {
@ -309,23 +304,6 @@ func (a *AdminSocket) handleRequest(conn net.Conn) {
defer conn.Close() 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 { for {
var err error var err error
var buf json.RawMessage var buf json.RawMessage

View File

@ -23,7 +23,7 @@ type PathEntry struct {
Sequence uint64 `json:"sequence"` 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() paths := a.core.GetPaths()
res.Paths = make([]PathEntry, 0, len(paths)) res.Paths = make([]PathEntry, 0, len(paths))
for _, p := range paths { for _, p := range paths {

View File

@ -32,7 +32,7 @@ type PeerEntry struct {
LastError string `json:"last_error,omitempty"` 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() peers := a.core.GetPeers()
res.Peers = make([]PeerEntry, 0, len(peers)) res.Peers = make([]PeerEntry, 0, len(peers))
for _, p := range peers { for _, p := range peers {

View File

@ -17,7 +17,7 @@ type GetSelfResponse struct {
Subnet string `json:"subnet"` 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() self := a.core.GetSelf()
snet := a.core.Subnet() snet := a.core.Subnet()
res.BuildName = version.BuildName() res.BuildName = version.BuildName()

View File

@ -23,7 +23,7 @@ type SessionEntry struct {
Uptime float64 `json:"uptime"` 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() sessions := a.core.GetSessions()
res.Sessions = make([]SessionEntry, 0, len(sessions)) res.Sessions = make([]SessionEntry, 0, len(sessions))
for _, s := range sessions { for _, s := range sessions {

View File

@ -20,11 +20,9 @@ type TreeEntry struct {
PublicKey string `json:"key"` PublicKey string `json:"key"`
Parent string `json:"parent"` Parent string `json:"parent"`
Sequence uint64 `json:"sequence"` 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() tree := a.core.GetTree()
res.Tree = make([]TreeEntry, 0, len(tree)) res.Tree = make([]TreeEntry, 0, len(tree))
for _, d := range tree { for _, d := range tree {
@ -34,8 +32,6 @@ func (a *AdminSocket) getTreeHandler(req *GetTreeRequest, res *GetTreeResponse)
PublicKey: hex.EncodeToString(d.Key[:]), PublicKey: hex.EncodeToString(d.Key[:]),
Parent: hex.EncodeToString(d.Parent[:]), Parent: hex.EncodeToString(d.Parent[:]),
Sequence: d.Sequence, Sequence: d.Sequence,
//Port: d.Port,
//Rest: d.Rest,
}) })
} }
sort.SliceStable(res.Tree, func(i, j int) bool { sort.SliceStable(res.Tree, func(i, j int) bool {

View File

@ -12,7 +12,7 @@ type RemovePeerRequest struct {
type RemovePeerResponse 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) u, err := url.Parse(req.Uri)
if err != nil { if err != nil {
return fmt.Errorf("unable to parse peering URI: %w", err) return fmt.Errorf("unable to parse peering URI: %w", err)

View File

@ -378,7 +378,7 @@ func (l *links) add(u *url.URL, sintf string, linkType linkType) error {
return retErr 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 var retErr error
phony.Block(l, func() { phony.Block(l, func() {
// Generate the link info and see whether we think we already // Generate the link info and see whether we think we already
@ -566,7 +566,7 @@ func (l *links) handler(linkType linkType, options linkOptions, conn net.Conn, s
switch { switch {
case err != nil: case err != nil:
return fmt.Errorf("write handshake: %w", err) return fmt.Errorf("write handshake: %w", err)
case err == nil && n != len(metaBytes): case n != len(metaBytes):
return fmt.Errorf("incomplete handshake send") return fmt.Errorf("incomplete handshake send")
} }
meta = version_metadata{} meta = version_metadata{}

View File

@ -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 return t.tcpContext
} }

View File

@ -11,7 +11,7 @@ type GetMulticastInterfacesResponse struct {
Interfaces []string `json:"multicast_interfaces"` 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{} res.Interfaces = []string{}
for _, v := range m.Interfaces() { for _, v := range m.Interfaces() {
res.Interfaces = append(res.Interfaces, v.Name) res.Interfaces = append(res.Interfaces, v.Name)