Last active
September 24, 2017 06:53
-
-
Save chanux/7eeed4b1254c1803b642 to your computer and use it in GitHub Desktop.
Simple go clone of z.ero.cool 1337
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
`````` | |
`./syhddddddhys/.` | |
`-sdNmy+/:....:/+ymNds-` | |
:dNd+- ``.....` -+dNd: | |
`yMd: .:++ooooooo+:. :dMy` | |
.dMs` .+ooo+:----:+ooo+. `sMd. | |
dMs .////. ./ooo: sMd | |
/Mm` :ooo. `mM/ | |
oMy ooo/ yMo | |
oMy `ooo: yMo | |
/Mm` `/ooo. `mM/ | |
dMs .////-` `-+oo+- sMd | |
.dMs` ./ooo+/::::/+ooo/` `sMd. | |
`yMd: .:/+oooooo+/-` :dMy` | |
:dNd+- ```..``` -+dNd: | |
`-sdNmy+/:....:/+ymNds-` | |
`./syhddddddhys/.` | |
`````` | |
Hi I'm Chanux! | |
I built this because I was excited by now defunct `nc z.ero.cool 1337` | |
It's just a simple go program you can find on my gists[1] | |
[1] https://gist.github.com/chanux/7eeed4b1254c1803b642 |
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 ( | |
"bufio" | |
"flag" | |
"fmt" | |
"net" | |
"os" | |
"time" | |
) | |
var ( | |
port string | |
file string | |
delay int | |
) | |
func main() { | |
flag.StringVar(&port, "p", "1337", "Port to listen on") | |
flag.StringVar(&file, "f", "example.txt", "File to serve") | |
flag.IntVar(&delay, "d", 50, "Delay between characters") | |
flag.Parse() | |
ln, err := net.Listen("tcp", ":"+port) | |
if err != nil { | |
fmt.Println("Error listening: ", err) | |
} | |
defer ln.Close() | |
for { | |
conn, err := ln.Accept() | |
if err != nil { | |
fmt.Println("Error handling request: ", err) | |
} | |
go handleConnection(conn) | |
} | |
} | |
func handleConnection(conn net.Conn) { | |
f, err := os.Open(file) | |
if err != nil { | |
fmt.Println("Error opening file: ", err) | |
} | |
defer f.Close() | |
reader := bufio.NewReader(f) | |
for { | |
//Well.. ASCII only. | |
char, err := reader.ReadByte() | |
if err != nil { | |
break | |
} | |
conn.Write([]byte{char}) | |
time.Sleep(time.Duration(delay) * time.Millisecond) | |
} | |
conn.Close() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Live demo
nc chanux.me 1337
** No uptime guarantee ;)