Compare commits

..

No commits in common. "e85b644e82755b8fa30cfc52f0896914502e0ae5" and "fbf1758ccb33c9e7e4fe2677b645285d16fc1797" have entirely different histories.

2 changed files with 3 additions and 12 deletions

View File

@ -38,14 +38,6 @@ Example usage:
panic(fmt.Errorf("failed to parse command flag 'secret': %w", err)) panic(fmt.Errorf("failed to parse command flag 'secret': %w", err))
} }
maxJitter, err := cmd.Flags().GetInt("maxjitter")
if err != nil {
panic(fmt.Errorf("failed to parse command flag 'maxjitter': %w", err))
}
if maxJitter < 1 || maxJitter > 1500 {
panic(fmt.Errorf("maxjitter must be value between 1 and 1500"))
}
secretBytes, err := os.ReadFile(secretFilePath) secretBytes, err := os.ReadFile(secretFilePath)
if err != nil { if err != nil {
log.Fatalf("failed to read file 'hyp.secret': %v", err) log.Fatalf("failed to read file 'hyp.secret': %v", err)
@ -58,12 +50,12 @@ Example usage:
} }
// Transmit // Transmit
fmt.Println("Transmitting knock sequence:", ports)
for _, port := range ports { for _, port := range ports {
fmt.Printf("knock | %s:%d\n", args[0], port)
conn, _ := net.Dial("udp", fmt.Sprintf("%s:%d", args[0], port)) conn, _ := net.Dial("udp", fmt.Sprintf("%s:%d", args[0], port))
conn.Write([]byte{0}) conn.Write([]byte{0})
conn.Close() conn.Close()
time.Sleep(time.Millisecond * time.Duration(maxJitter)) // TBD: Make this configurable with flag (maxJitter) time.Sleep(time.Millisecond * 200) // TBD: Make this configurable with flag (maxJitter)
} }
}, },
} }
@ -72,5 +64,4 @@ func init() {
rootCmd.AddCommand(knockCmd) rootCmd.AddCommand(knockCmd)
knockCmd.PersistentFlags().String("secret", "hyp.secret", "Path to the file containing the hyp secret.") knockCmd.PersistentFlags().String("secret", "hyp.secret", "Path to the file containing the hyp secret.")
knockCmd.PersistentFlags().Int("maxjitter", 200, "Specifies the time in milliseconds between knock sequence transmissions.")
} }

View File

@ -19,7 +19,7 @@ server and to clients.
Example: Example:
hypd generate secret > hyp.secret`, hypd generatesecret > hyp.secret`,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
sharedSecret, err := otphyp.GenerateSecret() sharedSecret, err := otphyp.GenerateSecret()
if err != nil { if err != nil {