-
Notifications
You must be signed in to change notification settings - Fork 612
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #381 from AkihiroSuda/fix-380
pkg/hostagent/dns: truncate messages
- Loading branch information
Showing
4 changed files
with
69 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package main | ||
|
||
import ( | ||
"strconv" | ||
|
||
"github.com/lima-vm/lima/pkg/hostagent/dns" | ||
"github.com/sirupsen/logrus" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func newDebugCommand() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "debug", | ||
Short: "Debug utilities", | ||
Long: "DO NOT USE! THE COMMAND SYNTAX IS SUBJECT TO CHANGE!", | ||
Hidden: true, | ||
} | ||
cmd.AddCommand(newDebugDNSCommand()) | ||
return cmd | ||
} | ||
|
||
func newDebugDNSCommand() *cobra.Command { | ||
var cmd = &cobra.Command{ | ||
Use: "dns UDPPORT [TCPPORT]", | ||
Short: "Debug built-in DNS", | ||
Long: "DO NOT USE! THE COMMAND SYNTAX IS SUBJECT TO CHANGE!", | ||
Args: cobra.RangeArgs(1, 2), | ||
RunE: debugDNSAction, | ||
} | ||
return cmd | ||
} | ||
|
||
func debugDNSAction(cmd *cobra.Command, args []string) error { | ||
udpLocalPort, err := strconv.Atoi(args[0]) | ||
if err != nil { | ||
return err | ||
} | ||
tcpLocalPort := 0 | ||
if len(args) > 2 { | ||
tcpLocalPort, err = strconv.Atoi(args[1]) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
srv, err := dns.Start(udpLocalPort, tcpLocalPort) | ||
if err != nil { | ||
return err | ||
} | ||
logrus.Infof("Started srv %+v (UDP %d, TCP %d)", srv, udpLocalPort, tcpLocalPort) | ||
for { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters