[windows_kext] Fix some Go linter warnings

This commit is contained in:
Daniel
2024-05-16 13:51:10 +02:00
parent 6f9b0a8249
commit 8a6f925c8b
5 changed files with 114 additions and 71 deletions

View File

@@ -5,6 +5,7 @@ import (
"io"
)
// Command IDs.
const (
CommandShutdown = 0
CommandVerdict = 1
@@ -17,8 +18,10 @@ const (
CommandCleanEndedConnections = 8
)
// KextVerdict is the verdict ID used to with the kext.
type KextVerdict uint8
// Kext Verdicts.
// Make sure this is in sync with the Rust version.
const (
// VerdictUndecided is the default status of new connections.
@@ -37,20 +40,20 @@ const (
type Verdict struct {
command uint8
Id uint64
ID uint64
Verdict uint8
}
type RedirectV4 struct {
command uint8
Id uint64
ID uint64
RemoteAddress [4]byte
RemotePort uint16
}
type RedirectV6 struct {
command uint8
Id uint64
ID uint64
RemoteAddress [16]byte
RemotePort uint16
}
@@ -75,46 +78,55 @@ type UpdateV6 struct {
Verdict uint8
}
// SendShutdownCommand sends a Shutdown command to the kext.
func SendShutdownCommand(writer io.Writer) error {
_, err := writer.Write([]byte{CommandShutdown})
return err
}
// SendVerdictCommand sends a Verdict command to the kext.
func SendVerdictCommand(writer io.Writer, verdict Verdict) error {
verdict.command = CommandVerdict
return binary.Write(writer, binary.LittleEndian, verdict)
}
// SendUpdateV4Command sends a UpdateV4 command to the kext.
func SendUpdateV4Command(writer io.Writer, update UpdateV4) error {
update.command = CommandUpdateV4
return binary.Write(writer, binary.LittleEndian, update)
}
// SendUpdateV6Command sends a UpdateV6 command to the kext.
func SendUpdateV6Command(writer io.Writer, update UpdateV6) error {
update.command = CommandUpdateV6
return binary.Write(writer, binary.LittleEndian, update)
}
// SendClearCacheCommand sends a ClearCache command to the kext.
func SendClearCacheCommand(writer io.Writer) error {
_, err := writer.Write([]byte{CommandClearCache})
return err
}
// SendGetLogsCommand sends a GetLogs command to the kext.
func SendGetLogsCommand(writer io.Writer) error {
_, err := writer.Write([]byte{CommandGetLogs})
return err
}
// SendGetBandwidthStatsCommand sends a GetBandwidthStats command to the kext.
func SendGetBandwidthStatsCommand(writer io.Writer) error {
_, err := writer.Write([]byte{CommandBandwidthStats})
return err
}
// SendPrintMemoryStatsCommand sends a PrintMemoryStats command to the kext.
func SendPrintMemoryStatsCommand(writer io.Writer) error {
_, err := writer.Write([]byte{CommandPrintMemoryStats})
return err
}
// SendCleanEndedConnectionsCommand sends a CleanEndedConnections command to the kext.
func SendCleanEndedConnectionsCommand(writer io.Writer) error {
_, err := writer.Write([]byte{CommandCleanEndedConnections})
return err