Last active
April 28, 2019 07:39
-
-
Save xvzf/1daf6583d01a609f3fb384e193bb361e to your computer and use it in GitHub Desktop.
Lanarama Morse Uplink
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
package main | |
import ( | |
"crypto/rand" | |
"fmt" | |
"net" | |
"time" | |
) | |
type morse struct { | |
send bool | |
sleep int | |
} | |
// lanarama morse code | |
func main() { | |
b := make([]byte, 4096) | |
dit := 100 // Morse code dit | |
dah := 3 * dit // Morse code dah | |
// .-.. .- -. .- .-. .- -- .- | |
morse := []morse{ | |
{true, dit}, | |
{true, dah}, | |
{true, dit}, | |
{true, dit}, | |
{false, dah}, | |
{true, dit}, | |
{true, dah}, | |
{false, dah}, | |
{true, dah}, | |
{true, dit}, | |
{false, dah}, | |
{true, dit}, | |
{true, dah}, | |
{false, dah}, | |
{true, dit}, | |
{true, dah}, | |
{true, dit}, | |
{false, dah}, | |
{true, dit}, | |
{true, dah}, | |
{false, dah}, | |
{true, dah}, | |
{true, dah}, | |
{false, dah}, | |
{true, dit}, | |
{true, dah}, | |
} | |
rand.Read(b) | |
c, err := net.Dial("udp", "[::1]:1337") | |
if err != nil { | |
fmt.Printf("Error while opening udp socket: %v", err) | |
return | |
} | |
defer c.Close() | |
for _, s := range morse { | |
tts := time.Duration(int64(time.Second) * int64(s.sleep)) | |
if s.send { | |
fmt.Println("sending") | |
} else { | |
fmt.Println("not sending") | |
} | |
for start := time.Now(); time.Since(start) < tts; { | |
if s.send { | |
c.Write(b) | |
} | |
} | |
time.Sleep(time.Duration(int64(time.Second) * int64(dit))) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment