Skip to content

Instantly share code, notes, and snippets.

@chanux
Last active September 24, 2017 06:53
Show Gist options
  • Save chanux/7eeed4b1254c1803b642 to your computer and use it in GitHub Desktop.
Save chanux/7eeed4b1254c1803b642 to your computer and use it in GitHub Desktop.
Simple go clone of z.ero.cool 1337
``````
`./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
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()
}
@chanux
Copy link
Author

chanux commented Aug 24, 2017

Live demo nc chanux.me 1337*

* No uptime guarantee ;)

@chanux
Copy link
Author

chanux commented Sep 24, 2017

I complicated things a bit https://github.com/chanux/zerocool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment