working commit

This commit is contained in:
2026-03-24 23:18:34 +02:00
parent 8efe7090be
commit 1f5b4a71f1
28 changed files with 1623 additions and 51 deletions
+47
View File
@@ -0,0 +1,47 @@
package forwarder
import (
"context"
"time"
"helmet/pkg/client"
"helmet/pkg/mlbctl"
"github.com/spf13/cobra"
)
type DeleteForwarderParams struct {
Hostname string
Lport uint32
}
type DeleteForwarderResult struct{}
func (tool *Tool) DeleteForwarder(cmd *cobra.Command, args []string) {
tool.deleteForwarderParams.Hostname = args[0]
res, err := tool.deleteForwarder(&tool.deleteForwarderParams)
printResponse(res, err)
}
func (tool *Tool) deleteForwarder(params *DeleteForwarderParams) (*DeleteForwarderResult, error) {
var err error
res := &DeleteForwarderResult{}
ref, err := client.NewReferer(params.Hostname)
if err != nil {
return res, err
}
authCred := client.NewAuthCredential(ref.Userinfo())
conn, cli, err := client.NewClient(ref.Hostinfo(), authCred)
if err != nil {
return res, err
}
defer conn.Close()
ctx, _ := context.WithTimeout(context.Background(), 1*time.Second)
opReq := &mlbctl.DeleteForwarderParams{
Lport: params.Lport,
}
_, err = cli.DeleteForwarder(ctx, opReq)
if err != nil {
return res, err
}
return res, err
}