-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: coldstarter * fix: Dockerfile.testing * fix: ci * fix: ci * chore: tmate * fix: CGO * chore: coldstarter tests * chore: wait ports test * chore: install nc * chore: watch ports * chore: more debugging * chore: minor log improvments * chore: sleep * chore: temp disable long test * chore: more logging * chore: test * fix: tests context cancel to early * chore: static build * chore: replace stupid pcap with unpopular pcap * chore: entrypoint
- Loading branch information
Showing
41 changed files
with
2,469 additions
and
120 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"strconv" | ||
"time" | ||
|
||
"github.com/highcard-dev/daemon/internal/core/services" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var PortMonitorCmd = &cobra.Command{ | ||
Use: "port", | ||
Short: "Monitor ports", | ||
Args: cobra.MinimumNArgs(1), | ||
Long: "Utility to monitor ports and show their status and activity", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
|
||
ports := make([]int, len(args)) | ||
|
||
for idx, port := range args { | ||
i, err := strconv.Atoi(port) | ||
if err != nil { | ||
return err | ||
} | ||
ports[idx] = i | ||
} | ||
|
||
portMonitor := services.NewPortService(ports) | ||
|
||
go portMonitor.StartMonitoring(cmd.Context(), watchPortsInterfaces) | ||
|
||
for { | ||
ps := portMonitor.GetPorts() | ||
for _, p := range ps { | ||
fmt.Printf("Port %s: %d, last activity %v, open: %t \n", p.Port.Name, p.Port.Port, p.InactiveSince, p.Open) | ||
} | ||
time.Sleep(5 * time.Second) | ||
} | ||
|
||
}, | ||
} | ||
|
||
func init() { | ||
PortMonitorCmd.Flags().StringArrayVarP(&watchPortsInterfaces, "watch-ports-interfaces", "", []string{"lo0"}, "Interfaces to watch for port activity") | ||
} |
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
Oops, something went wrong.