SlideShare a Scribd company logo
go
for the paranoid network programme
r

(now with WebSockets
)

@feyeleanor
1
go for the paranoid network programmer slideshare.net/feyeleanor
twitter://@feyeleanor
go for the paranoid network programmer slideshare.net/feyeleanor
high voltage
networkin
g

concurrenc
y

cryptograph
y

go for the paranoid network programmer slideshare.net/feyeleanor
http
4
go for the paranoid network programmer slideshare.net/feyeleanor
package mai
n

import
(

. "fmt
"

"net/http"
)

const MESSAGE = "hello world
"

const ADDRESS = ":1024
"

func main()
{

http.HandleFunc("/hello", Hello
)

if e := http.ListenAndServe(ADDRESS, nil); e != nil
{

Println(e
)

}
}

func Hello(w http.ResponseWriter, r *http.Request)
{

w.Header().Set("Content-Type", "text/plain"
)

Fprintf(w, MESSAGE
)

}
go for the paranoid network programmer slideshare.net/feyeleanor
5
package mai
n

import
(

. "fmt
"

. "net/http"
)

const MESSAGE = "hello world
"

const ADDRESS = ":1024
"

func main()
{

HandleFunc("/hello", Hello
)

if e := ListenAndServe(ADDRESS, nil); e != nil
{

Println(e
)

}
}

func Hello(w ResponseWriter, r *Request)
{

w.Header().Set("Content-Type", "text/plain"
)

Fprintf(w, MESSAGE
)

}
go for the paranoid network programmer slideshare.net/feyeleanor
6
package mai
n

import
(

. "fmt
"

. ”net/http
"

)

const MESSAGE = "hello world
"

const ADDRESS = ":1024
"

func main()
{

HandleFunc("/hello", Hello
)

if e := ListenAndServe(ADDRESS, nil); e != nil
{

Println(e
)

}
}

func Hello(w ResponseWriter, r *Request)
{

w.Header().Set("Content-Type", "text/plain"
)

Fprintf(w, MESSAGE
)

}
go for the paranoid network programmer slideshare.net/feyeleanor
7
package mai
n

import
(

. "fmt
"

. ”net/http
"

)

const MESSAGE = "hello world
"

const ADDRESS = ":1024
"

func main()
{

HandleFunc("/hello", Hello
)

if e := ListenAndServe(ADDRESS, nil); e != nil
{

Println(e
)

}
}

func Hello(w ResponseWriter, r *Request)
{

w.Header().Set("Content-Type", "text/plain"
)

Fprintf(w, MESSAGE
)

}
go for the paranoid network programmer slideshare.net/feyeleanor
8
package mai
n

import
(

. "fmt
"

. ”net/http
"

)

const MESSAGE = "hello world
"

const ADDRESS = ":1024
"

func main()
{

HandleFunc("/hello", Hello
)

if e := ListenAndServe(ADDRESS, nil); e != nil
{

Println(e
)

}
}

func Hello(w ResponseWriter, r *Request)
{

w.Header().Set("Content-Type", "text/plain")
Fprintf(w, MESSAGE
)

}
go for the paranoid network programmer slideshare.net/feyeleanor
9
package mai
n

import
(

. "fmt
"

. ”net/http
"

)

const MESSAGE = "hello world
"

const ADDRESS = ":1024"
func main()
{

HandleFunc("/hello", Hello
)

if e := ListenAndServe(ADDRESS, nil); e != nil
{

Println(e
)

}
}

func Hello(w ResponseWriter, r *Request)
{

w.Header().Set("Content-Type", "text/plain"
)

Fprintf(w, MESSAGE
)

}
go for the paranoid network programmer slideshare.net/feyeleanor
10
package mai
n

import
(

. "fmt
"

. ”net/http
"

)

const MESSAGE = "hello world
"

const ADDRESS = ":1024
"

func main()
{

HandleFunc("/hello", Hello
)

if e := ListenAndServe(ADDRESS, nil); e != nil {
Println(e)
}
}

func Hello(w ResponseWriter, r *Request)
{

w.Header().Set("Content-Type", "text/plain"
)

Fprintf(w, MESSAGE
)

}
go for the paranoid network programmer slideshare.net/feyeleanor
11
package mai
n

import
(

. "fmt
"

. "net/http
"

)

const MESSAGE = "hello world
"

const ADDRESS = ":1024
"

func main()
{

HandleFunc("/hello", func(w ResponseWriter, r *Request) {
w.Header().Set("Content-Type", "text/plain"
)

Fprintf(w, MESSAGE
)

}
)

ListenAndServe(ADDRESS, nil
)

}
go for the paranoid network programmer slideshare.net/feyeleanor
12
package mai
n

import
(

. "fmt
"

. "net/http
"

)

const MESSAGE = "hello world
"

const ADDRESS = ":1024
"

func main()
{

HandleFunc("/hello", func(w ResponseWriter, r *Request) {
w.Header().Set("Content-Type", "text/plain"
)

Fprintf(w, MESSAGE
)

}
)

ListenAndServe(ADDRESS, nil
)

}
go for the paranoid network programmer slideshare.net/feyeleanor
13
https
14
go for the paranoid network programmer slideshare.net/feyeleanor
package mai
n

import
(

. "fmt
"

. "net/http
"

)

const ADDRESS = ":1025
"

func main()
{

message := "hello world
"

HandleFunc("/hello", func(w ResponseWriter, r *Request) {
w.Header().Set("Content-Type", "text/plain"
)

Fprintf(w, message
)

}
)

ListenAndServeTLS(ADDRESS, "cert.pem", "key.pem", nil
)

}
go for the paranoid network programmer slideshare.net/feyeleanor
15
package mai
n

import
(

. "fmt
"

. "net/http
"

)

const ADDRESS = ":1025
"

func main()
{

message := "hello world
"

HandleFunc("/hello", func(w ResponseWriter, r *Request) {
w.Header().Set("Content-Type", "text/plain"
)

Fprintf(w, message
)

})
ListenAndServeTLS(ADDRESS, "cert.pem", "key.pem", nil
)

}
go for the paranoid network programmer slideshare.net/feyeleanor
16
package mai
n

import
(

. "fmt
"

. "net/http
"

)

const ADDRESS = ":1025
"

func main()
{

message := "hello world"
HandleFunc("/hello", func(w ResponseWriter, r *Request) {
w.Header().Set("Content-Type", "text/plain"
)

Fprintf(w, message
)

}
)

ListenAndServeTLS(ADDRESS, "cert.pem", "key.pem", nil
)

}
go for the paranoid network programmer slideshare.net/feyeleanor
17
multiple http servers
18
go for the paranoid network programmer slideshare.net/feyeleanor
package mai
n

import . "fmt
"

import . "net/http
"

func main()
{

HandleFunc("/hello", func(w ResponseWriter, r *Request)
{

w.Header().Set("Content-Type", "text/plain"
)

Fprintf(w, "hello world"
)

}
)

done := make(chan bool
)

go func()
{

ListenAndServe(":1024", nil
)

done <- tru
e

}(
)

ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil
)

<- don
e

}
go for the paranoid network programmer slideshare.net/feyeleanor
19
package mai
n

import . "fmt
"

import . "net/http
"

func main()
{

HandleFunc("/hello", func(w ResponseWriter, r *Request)
{

w.Header().Set("Content-Type", "text/plain"
)

Fprintf(w, "hello world"
)

}
)

done := make(chan bool
)

go func()
{

ListenAndServe(":1024", nil
)

done <- tru
e

}(
)

ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil
)

<- don
e

}
go for the paranoid network programmer slideshare.net/feyeleanor
20
package mai
n

import . "fmt
"

import . "net/http
"

func main()
{

HandleFunc("/hello", func(w ResponseWriter, r *Request)
{

w.Header().Set("Content-Type", "text/plain"
)

Fprintf(w, "hello world"
)

}
)

done := make(chan bool
)

go func() {
ListenAndServe(":1024", nil
)

done <- tru
e

}()
ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil
)

<- don
e

}
go for the paranoid network programmer slideshare.net/feyeleanor
21
package mai
n

import . "fmt
"

import . "net/http
"

func main()
{

HandleFunc("/hello", func(w ResponseWriter, r *Request)
{

w.Header().Set("Content-Type", "text/plain"
)

Fprintf(w, "hello world"
)

}
)

done := make(chan bool
)

go func() {
ListenAndServe(":1024", nil
)

done <- tru
e

}()
ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil
)

<- don
e

}
go for the paranoid network programmer slideshare.net/feyeleanor
22
package mai
n

import . "fmt
"

import . "net/http
"

func main()
{

HandleFunc("/hello", func(w ResponseWriter, r *Request)
{

w.Header().Set("Content-Type", "text/plain"
)

Fprintf(w, "hello world"
)

}
)

done := make(chan bool)
go func() {
ListenAndServe(":1024", nil
)

done <- tru
e

}()
ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil
)

<- done
}
go for the paranoid network programmer slideshare.net/feyeleanor
23
package mai
n

import . "fmt
"

import . "net/http
"

func main()
{

HandleFunc("/hello", func(w ResponseWriter, r *Request)
{

w.Header().Set("Content-Type", "text/plain"
)

Fprintf(w, "hello world"
)

}
)

done := make(chan bool)
go func() {
ListenAndServe(":1024", nil
)

done <- true
}()
ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil
)

<- done
}
go for the paranoid network programmer slideshare.net/feyeleanor
24
package mai
n

import . "fmt
"

import . "net/http
"

func main()
{

HandleFunc("/hello", func(w ResponseWriter, r *Request)
{

w.Header().Set("Content-Type", "text/plain"
)

Fprintf(w, "hello world"
)

}
)

done := make(chan bool)
go func() {
ListenAndServe(":1024", nil
)

done <- true
}()
ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil
)

<- done
}
go for the paranoid network programmer slideshare.net/feyeleanor
25
package mai
n

import . "fmt
"

import . "net/http
"

func main()
{

HandleFunc("/hello", func(w ResponseWriter, r *Request)
{

w.Header().Set("Content-Type", "text/plain"
)

Fprintf(w, "hello world"
)

}
)

done := make(chan bool)
go func() {
ListenAndServe(":1024", nil
)

done <- true
}()
ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil
)

<- done
}
go for the paranoid network programmer slideshare.net/feyeleanor
26
package mai
n

import . "fmt
"

import . "net/http
"

func main()
{

HandleFunc("/hello", func(w ResponseWriter, r *Request)
{

w.Header().Set("Content-Type", "text/plain"
)

Fprintf(w, "hello world"
)

}
)

Spawn
(

func()
{

ListenAndServe(":1024", nil)
}
,

func()
{

ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil
)

}
,

)
}
go for the paranoid network programmer slideshare.net/feyeleanor
27
package mai
n

import . "fmt
"

import . "net/http
"

func main()
{

HandleFunc("/hello", func(w ResponseWriter, r *Request)
{

w.Header().Set("Content-Type", "text/plain"
)

Fprintf(w, "hello world"
)

}
)

Spawn(func()
{

ListenAndServe(":1024", nil)
}
)

Spawn(func()
{

ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil)
})
}
go for the paranoid network programmer slideshare.net/feyeleanor
28
package mai
n

func Spawn(f ...func())
{

done := make(chan bool
)

for _, s := range f
{

go func(server func())
{

server(
)

done <- tru
e

}(s
)

}

for l := len(f); l > 0; l--
{

<- don
e

}

}
go for the paranoid network programmer slideshare.net/feyeleanor
29
package mai
n

func Spawn(f ...func())
{

done := make(chan bool
)

for _, s := range f
{

go func(server func())
{

server(
)

done <- tru
e

}(s
)

}
for l := len(f); l > 0; l--
{

<- don
e

}

}
go for the paranoid network programmer slideshare.net/feyeleanor
30
package mai
n

func Spawn(f ...func())
{

done := make(chan bool
)

for _, s := range f
{

go func(server func())
{

server(
)

done <- tru
e

}(s
)

}
for l := len(f); l > 0; l-- {
<- done
}
}
go for the paranoid network programmer slideshare.net/feyeleanor
31
package mai
n

func Spawn(f ...func())
{

done := make(chan bool
)

for _, s := range f
{

go func(server func())
{

server(
)

done <- tru
e

}(s
)

}
for _, _ = range f {
<- done
}
}
go for the paranoid network programmer slideshare.net/feyeleanor
32
package mai
n

func Spawn(f ...func())
{

done := make(chan bool
)

for _, s := range f
{

go func(server func())
{

server(
)

done <- tru
e

}(s
)

}
for range f {
<- done
}
}
go for the paranoid network programmer slideshare.net/feyeleanor
33
package mai
n

func Spawn(f ...func())
{

done := make(chan bool
)

for _, s := range f
{

go func(server func())
{

server(
)

done <- tru
e

}(s
)

<- done
}
}
go for the paranoid network programmer slideshare.net/feyeleanor
34
package mai
n

func Spawn(f ...func())
{

done := make(chan bool
)

for _, s := range f
{

go func(server func())
{

server(
)

done <- true
}(s
)

}

for range f
{

<- done
}

}
go for the paranoid network programmer slideshare.net/feyeleanor
35
package mai
n

func Spawn(f ...func())
{

done := make(chan bool
)

for _, s := range f
{

go func(server func()) {
server()
done <- true
}(s)
}

for range f
{

<- don
e

}

}
go for the paranoid network programmer slideshare.net/feyeleanor
36
package mai
n

func Spawn(f ...func())
{

done := make(chan bool
)

for _, s := range f
{

go func(server func())
{

server(
)

done <- tru
e

}(s
)

}

for range f
{

<- don
e

}

}
go for the paranoid network programmer slideshare.net/feyeleanor
37
package mai
n

func Spawn(f ...func())
{

done := make(chan bool
)

for _, s := range f
{

go func(server func()) {
server()
done <- true
}(s)
}

for range f
{

<- don
e

}

}
go for the paranoid network programmer slideshare.net/feyeleanor
38
waitgroups
39
go for the paranoid network programmer slideshare.net/feyeleanor
package mai
n

import . "net/http
"

import "sync
"

func main()
{

HandleFunc("/hello", func(w ResponseWriter, r *Request) {}
)

var servers sync.WaitGrou
p

servers.Add(1
)

go func()
{

defer servers.Done(
)

ListenAndServe(":1024", nil
)

}(
)

servers.Add(1
)

go func()
{

defer servers.Done(
)

ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil
)

}(
)

servers.Wait(
)

}
go for the paranoid network programmer slideshare.net/feyeleanor
40
package mai
n

import . "net/http
"

import "sync
"

func main()
{

HandleFunc("/hello", func(w ResponseWriter, r *Request) {}
)

var servers sync.WaitGroup
servers.Add(1
)

go func()
{

defer servers.Done(
)

ListenAndServe(":1024", nil
)

}(
)

servers.Add(1
)

go func()
{

defer servers.Done(
)

ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil
)

}(
)

servers.Wait(
)

}
go for the paranoid network programmer slideshare.net/feyeleanor
41
package mai
n

import . "net/http
"

import "sync
"

func main()
{

HandleFunc("/hello", func(w ResponseWriter, r *Request) {}
)

var servers sync.WaitGrou
p

servers.Add(1)
go func()
{

defer servers.Done()
ListenAndServe(":1024", nil
)

}(
)

servers.Add(1)
go func()
{

defer servers.Done()
ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil
)

}(
)

servers.Wait()
}
go for the paranoid network programmer slideshare.net/feyeleanor
42
package mai
n

import . "net/http
"

import "sync
"

func main()
{

HandleFunc("/hello", func(w ResponseWriter, r *Request) {}
)

var servers sync.WaitGroup
servers.Add(1)
go func()
{

defer servers.Done()
ListenAndServe(":1024", nil
)

}()
servers.Add(1)
go func() {
defer servers.Done()
ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil
)

}()
servers.Wait()
}
go for the paranoid network programmer slideshare.net/feyeleanor
43
package mai
n

import
(

. "fmt
"

. "net/http
"

"sync
"

)

var servers sync.WaitGrou
p

func main()
{

HandleFunc("/hello", func(w ResponseWriter, r *Request)
{

w.Header().Set("Content-Type", "text/plain"
)

Fprintf(w, "hello world"
)

}
)

Spawn(func() { ListenAndServe(":1024", nil) }
)

Spawn(func()
{

ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil
)

}
)

servers.Wait(
)

}
go for the paranoid network programmer slideshare.net/feyeleanor
44
package mai
n

import
(

. "fmt
"

. "net/http
"

"sync
"

)

var servers sync.WaitGrou
p

func main()
{

HandleFunc("/hello", func(w ResponseWriter, r *Request)
{

w.Header().Set("Content-Type", "text/plain"
)

Fprintf(w, "hello world"
)

}
)

Spawn(func() { ListenAndServe(":1024", nil) }
)

Spawn(func()
{

ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil
)

}
)

servers.Wait()
}
go for the paranoid network programmer slideshare.net/feyeleanor
45
package mai
n

func Spawn(f ...func())
{

for _, s := range f
{

servers.Add(1
)

go func(server func()) {
defer servers.Done(
)

server(
)

}(s
)

}

}
go for the paranoid network programmer slideshare.net/feyeleanor
46
package mai
n

func Spawn(f ...func())
{

for _, s := range f
{

servers.Add(1)
go func(server func())
{

defer servers.Done()
server(
)

}(s
)

}

}
go for the paranoid network programmer slideshare.net/feyeleanor
47
tcp server
48
go for the paranoid network programmer slideshare.net/feyeleanor
package mai
n

import . "fmt
"

import "net
"

func main()
{

if listener, e := net.Listen("tcp", ":1024"); e == nil
{

for
{

if connection, e := listener.Accept(); e == nil
{

go func(c net.Conn)
{

defer c.Close(
)

Fprintln(c, "hello world"
)

}(connection
)

}
}
}

}
go for the paranoid network programmer slideshare.net/feyeleanor
49
package mai
n

import . "fmt
"

import "net
"

func main()
{

if listener, e := net.Listen("tcp", ":1024"); e == nil
{

for
{

if connection, e := listener.Accept(); e == nil
{

go func(c net.Conn)
{

defer c.Close(
)

Fprintln(c, "hello world"
)

}(connection
)

}
}
}

}
go for the paranoid network programmer slideshare.net/feyeleanor
50
package mai
n

import . "fmt
"

import "net
"

func main()
{

if listener, e := net.Listen("tcp", ":1024"); e == nil
{

for
{

if connection, e := listener.Accept(); e == nil
{

go func(c net.Conn)
{

defer c.Close(
)

Fprintln(c, "hello world"
)

}(connection
)

}
}
}

}
go for the paranoid network programmer slideshare.net/feyeleanor
51
package mai
n

import . "fmt
"

import "net
"

func main()
{

if listener, e := net.Listen("tcp", ":1024"); e == nil
{

for
{

if connection, e := listener.Accept(); e == nil
{

go func(c net.Conn)
{

defer c.Close(
)

Fprintln(c, "hello world"
)

}(connection
)

}
}
}

}
go for the paranoid network programmer slideshare.net/feyeleanor
52
package mai
n

import . "fmt
"

import "net
"

func main()
{

Listen("tcp", ":1024", func(c net.Conn) {
defer c.Close(
)

Fprintln(c, "hello world"
)

}
)

}

func Listen(p, a string, f func(net.Conn)) (e error)
{

var listener net.Listene
r

if listener, e = net.Listen(p, a); e == nil
{

for
{

if connection, e := listener.Accept(); e == nil
{

go f(connection
)

}
}
}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
53
package mai
n

import . "fmt
"

import "net
"

func main()
{

Listen("tcp", ":1024", func(c net.Conn) {
defer c.Close(
)

Fprintln(c, "hello world"
)

}
)

}

func Listen(p, a string, f func(net.Conn)) (e error)
{

var listener net.Listene
r

if listener, e = net.Listen(p, a); e == nil
{

for
{

if connection, e := listener.Accept(); e == nil
{

go f(connection
)

}
}
}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
54
package mai
n

import . "fmt
"

import "net
"

func main()
{

Listen("tcp", ":1024", func(c net.Conn) {
defer c.Close(
)

Fprintln(c, "hello world"
)

}
)

}

func Listen(p, a string, f func(net.Conn)) (e error)
{

var listener net.Listener
if listener, e = net.Listen(p, a); e == nil
{

for
{

if connection, e := listener.Accept(); e == nil
{

go f(connection
)

}
}
}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
55
package mai
n

import . "fmt
"

import "net
"

func main()
{

Listen("tcp", ":1024", func(c net.Conn) {
defer c.Close(
)

Fprintln(c, "hello world"
)

}
)

}

func Listen(p, a string, f func(net.Conn)) (e error)
{

var listener net.Listener
if listener, e = net.Listen(p, a); e == nil
{

for
{

if connection, e := listener.Accept(); e == nil
{

go f(connection
)

}
}
}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
56
tcp client
57
go for the paranoid network programmer slideshare.net/feyeleanor
package mai
n

import "bufio
"

import . "fmt
"

import "net
"

func main()
{

if c, e := net.Dial("tcp", ":1024"); e == nil
{

defer c.Close(
)

if m, e := bufio.NewReader(c).ReadString('n'); e == nil
{

Printf(m
)

}
}

}
go for the paranoid network programmer slideshare.net/feyeleanor
58
package mai
n

import "bufio
"

import . "fmt
"

import "net
"

func main()
{

if c, e := net.Dial("tcp", ":1024"); e == nil
{

defer c.Close()
if m, e := bufio.NewReader(c).ReadString('n'); e == nil
{

Printf(m
)

}
}

}
go for the paranoid network programmer slideshare.net/feyeleanor
59
package mai
n

import "bufio
"

import . "fmt
"

import "net
"

func main()
{

if c, e := net.Dial("tcp", ":1024"); e == nil
{

defer c.Close(
)

if m, e := bufio.NewReader(c).ReadString('n'); e == nil
{

Printf(m
)

}
}

}
go for the paranoid network programmer slideshare.net/feyeleanor
60
package mai
n

import "bufio
"

import . "fmt
"

import "net
"

func main()
{

if c, e := net.Dial("tcp", ":1024"); e == nil
{

defer c.Close(
)

if m, e := bufio.NewReader(c).ReadString('n'); e == nil
{

Printf(m
)

}
}

}
go for the paranoid network programmer slideshare.net/feyeleanor
61
package mai
n

import "bufio
"

import . "fmt
"

import "net
"

func main()
{

if c, e := net.Dial("tcp", ":1024"); e == nil
{

defer c.Close(
)

if m, e := bufio.NewReader(c).ReadString('n'); e == nil
{

Printf(m
)

}
}

}
go for the paranoid network programmer slideshare.net/feyeleanor
62
package mai
n

import "bufio
"

import . "fmt
"

import "net
"

func main()
{

Dial("tcp", ":1024", func(c net.Conn) {
if m, e := bufio.NewReader(c).ReadString('n'); e == nil
{

Printf(m
)

}

}
)

}

func Dial(p, a string, f func(net.Conn)) (e error)
{

var c net.Con
n

if c, e = net.Dial(p, a); e == nil
{

defer c.Close(
)

f(c
)

}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
63
package mai
n

import "bufio
"

import . "fmt
"

import "net
"

func main()
{

Dial("tcp", ":1024", func(c net.Conn) {
if m, e := bufio.NewReader(c).ReadString('n'); e == nil
{

Printf(m
)

}

}
)

}

func Dial(p, a string, f func(net.Conn)) (e error)
{

var c net.Con
n

if c, e = net.Dial(p, a); e == nil
{

defer c.Close(
)

f(c
)

}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
64
package mai
n

import "bufio
"

import . "fmt
"

import "net
"

func main()
{

Dial("tcp", ":1024", func(c net.Conn) {
if m, e := bufio.NewReader(c).ReadString('n'); e == nil
{

Printf(m
)

}

}
)

}

func Dial(p, a string, f func(net.Conn)) (e error)
{

var c net.Con
n

if c, e = net.Dial(p, a); e == nil
{

defer c.Close()
f(c
)

}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
65
tcp/tls server
66
go for the paranoid network programmer slideshare.net/feyeleanor
package mai
n

import "crypto/rand
"

import "crypto/tls
"

import . "fmt
"

func main()
{

Listen(":1025", ConfigTLS("scert", "skey"), func(c *tls.Conn) {
Fprintln(c, "hello world"
)

}
)

}

func ConfigTLS(c, k string) (r *tls.Config)
{

if cert, e := tls.LoadX509KeyPair(c, k); e == nil
{

r = &tls.Config
{

Certificates: []tls.Certificate{ cert }
,

Rand: rand.Reader
,

}
}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
67
package mai
n

import "crypto/rand
"

import "crypto/tls
"

import . "fmt
"

func main()
{

Listen(":1025", ConfigTLS("scert", "skey"), func(c *tls.Conn)
{

Fprintln(c, "hello world"
)

}
)

}

func ConfigTLS(c, k string) (r *tls.Config)
{

if cert, e := tls.LoadX509KeyPair(c, k); e == nil
{

r = &tls.Config
{

Certificates: []tls.Certificate{ cert }
,

Rand: rand.Reader
,

}
}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
68
package mai
n

import "crypto/rand
"

import "crypto/tls
"

import . "fmt
"

func main()
{

Listen(":1025", ConfigTLS("scert", "skey"), func(c *tls.Conn)
{

Fprintln(c, "hello world"
)

}
)

}

func ConfigTLS(c, k string) (r *tls.Config)
{

if cert, e := tls.LoadX509KeyPair(c, k); e == nil
{

r = &tls.Config
{

Certificates: []tls.Certificate{ cert }
,

Rand: rand.Reader
,

}
}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
69
package mai
n

import "crypto/rand
"

import "crypto/tls
"

import . "fmt
"

func main()
{

Listen(":1025", ConfigTLS("scert", "skey"), func(c *tls.Conn)
{

Fprintln(c, "hello world"
)

}
)

}

func ConfigTLS(c, k string) (r *tls.Config)
{

if cert, e := tls.LoadX509KeyPair(c, k); e == nil
{

r = &tls.Config{
Certificates: []tls.Certificate{ cert }
,

Rand: rand.Reader
,

}
}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
70
package mai
n

import "crypto/rand
"

import "crypto/tls
"

import . "fmt
"

func main()
{

Listen(":1025", ConfigTLS("scert", "skey"), func(c *tls.Conn)
{

Fprintln(c, "hello world"
)

}
)

}

func ConfigTLS(c, k string) (r *tls.Config)
{

if cert, e := tls.LoadX509KeyPair(c, k); e == nil
{

r = &tls.Config{
Certificates: []tls.Certificate{ cert }
,

Rand: rand.Reader
,

}
}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
71
package mai
n

import "crypto/tls
"

func Listen(a string, conf *tls.Config, f func(*tls.Conn))
{

if listener, e := tls.Listen("tcp", a, conf); e == nil
{

for
{

if connection, e := listener.Accept(); e == nil
{

go func(c *tls.Conn)
{

defer c.Close(
)

f(c
)

}(connection.(*tls.Conn)
)

}
}
}

}
go for the paranoid network programmer slideshare.net/feyeleanor
72
package mai
n

import "crypto/tls
"

func Listen(a string, conf *tls.Config, f func(*tls.Conn))
{

if listener, e := tls.Listen("tcp", a, conf); e == nil
{

for
{

if connection, e := listener.Accept(); e == nil
{

go func(c *tls.Conn)
{

defer c.Close(
)

f(c
)

}(connection.(*tls.Conn)
)

}
}
}

}
go for the paranoid network programmer slideshare.net/feyeleanor
73
package mai
n

import "crypto/tls
"

func Listen(a string, conf *tls.Config, f func(*tls.Conn))
{

if listener, e := tls.Listen("tcp", a, conf); e == nil
{

for
{

if connection, e := listener.Accept(); e == nil
{

go func(c *tls.Conn)
{

defer c.Close(
)

f(c
)

}(connection.(*tls.Conn)
)

}
}
}

}
go for the paranoid network programmer slideshare.net/feyeleanor
74
package mai
n

import "crypto/tls
"

func Listen(a string, conf *tls.Config, f func(*tls.Conn))
{

if listener, e := tls.Listen("tcp", a, conf); e == nil
{

for
{

if connection, e := listener.Accept(); e == nil
{

go func(c *tls.Conn)
{

defer c.Close(
)

f(c
)

}(connection.(*tls.Conn)
)

}
}
}

}
go for the paranoid network programmer slideshare.net/feyeleanor
75
package mai
n

import "crypto/tls
"

func Listen(a string, conf *tls.Config, f func(*tls.Conn))
{

if listener, e := tls.Listen("tcp", a, conf); e == nil
{

for
{

if connection, e := listener.Accept(); e == nil
{

go func(c *tls.Conn)
{

defer c.Close(
)

f(c
)

}(connection.(*tls.Conn)
)

}
}
}

}
go for the paranoid network programmer slideshare.net/feyeleanor
76
package mai
n

import "crypto/tls
"

func Listen(a string, conf *tls.Config, f func(*tls.Conn))
{

if listener, e := tls.Listen("tcp", a, conf); e == nil
{

for
{

if connection, e := listener.Accept(); e == nil
{

go func(c *tls.Conn)
{

defer c.Close(
)

f(c
)

}(connection.(*tls.Conn)
)

}
}
}

}
go for the paranoid network programmer slideshare.net/feyeleanor
77
package mai
n

import "crypto/tls
"

import "net
"

func Listen(a string, conf *tls.Config, f func(net.Conn))
{

if listener, e := tls.Listen("tcp", a, conf); e == nil
{

for
{

if connection, e := listener.Accept(); e == nil
{

go func(c net.Conn)
{

defer c.Close(
)

f(c
)

}(connection
)

}
}
}

}
go for the paranoid network programmer slideshare.net/feyeleanor
78
package mai
n

import "crypto/tls
"

import "net
"

func Listen(a string, conf *tls.Config, f func(net.Conn))
{

if listener, e := tls.Listen("tcp", a, conf); e == nil
{

for
{

if connection, e := listener.Accept(); e == nil
{

go func(c net.Conn)
{

defer c.Close(
)

f(c
)

}(connection
)

}
}
}

}
go for the paranoid network programmer slideshare.net/feyeleanor
79
package mai
n

import "crypto/tls
"

import "net
"

func Listen(a string, conf *tls.Config, f func(net.Conn))
{

if listener, e := tls.Listen("tcp", a, conf); e == nil
{

for
{

if c, e := listener.Accept(); e == nil
{

go Handle(c, f
)

}
}
}
}

func Handle(c net.Conn, f func(net.Conn))
{

defer c.Close(
)

f(c
)

}
go for the paranoid network programmer slideshare.net/feyeleanor
80
tcp/tls client
81
go for the paranoid network programmer slideshare.net/feyeleanor
package mai
n

import "bufio
"

import "crypto/tls
"

import . "fmt
"

import "net
"

 

func main()
{

Dial(":1025", ConfigTLS("ccert", "ckey"), func(c net.Conn) {
if m, e := bufio.NewReader(c).ReadString('n'); e == nil
{

Printf(m
)

}

}
)

}

func ConfigTLS(c, k string) (r *tls.Config)
{

if cert, e := tls.LoadX509KeyPair(c, k); e == nil
{

r = &tls.Config
{

Certificates: []tls.Certificate{ cert }
,

InsecureSkipVerify: true
,

}
}

go for the paranoid network programmer slideshare.net/feyeleanor
82
package mai
n

import "bufio
"

import "crypto/tls
"

import . "fmt
"

import "net
"

 

func main()
{

Dial(":1025", ConfigTLS("ccert", "ckey"), func(c net.Conn) {
if m, e := bufio.NewReader(c).ReadString('n'); e == nil
{

Printf(m
)

}

}
)

}

func ConfigTLS(c, k string) (r *tls.Config)
{

if cert, e := tls.LoadX509KeyPair(c, k); e == nil
{

r = &tls.Config
{

Certificates: []tls.Certificate{ cert }
,

InsecureSkipVerify: true
,

}
}

go for the paranoid network programmer slideshare.net/feyeleanor
83
package mai
n

import "bufio
"

import "crypto/tls
"

import . "fmt
"

import "net
"

 

func main()
{

Dial(":1025", ConfigTLS("ccert", "ckey"), func(c net.Conn) {
if m, e := bufio.NewReader(c).ReadString('n'); e == nil
{

Printf(m
)

}

}
)

}

func ConfigTLS(c, k string) (r *tls.Config)
{

if cert, e := tls.LoadX509KeyPair(c, k); e == nil
{

r = &tls.Config
{

Certificates: []tls.Certificate{ cert }
,

InsecureSkipVerify: true
,

}
}

go for the paranoid network programmer slideshare.net/feyeleanor
84
package mai
n

import "bufio
"

import "crypto/tls
"

import . "fmt
"

import "net
"

 

func main()
{

Dial(":1025", ConfigTLS("ccert", "ckey"), func(c net.Conn) {
if m, e := bufio.NewReader(c).ReadString('n'); e == nil
{

Printf(m
)

}

}
)

}

func ConfigTLS(c, k string) (r *tls.Config)
{

if cert, e := tls.LoadX509KeyPair(c, k); e == nil
{

r = &tls.Config{
Certificates: []tls.Certificate{ cert }
,

InsecureSkipVerify: true
,

}
}

go for the paranoid network programmer slideshare.net/feyeleanor
85
package mai
n

import "bufio
"

import "crypto/tls
"

import . "fmt
"

import "net
"

 

func main()
{

Dial(":1025", ConfigTLS("ccert", "ckey"), func(c net.Conn) {
if m, e := bufio.NewReader(c).ReadString('n'); e == nil
{

Printf(m
)

}

}
)

}

func ConfigTLS(c, k string) (r *tls.Config)
{

if cert, e := tls.LoadX509KeyPair(c, k); e == nil
{

r = &tls.Config{
Certificates: []tls.Certificate{ cert }
,

InsecureSkipVerify: true
,

}
}

go for the paranoid network programmer slideshare.net/feyeleanor
86
package mai
n

import "bufio
"

import "crypto/tls
"

import . "fmt
"

import "net
"

 

func main()
{

Dial(":1025", ConfigTLS("ccert", "ckey"), func(c net.Conn) {
if m, e := bufio.NewReader(c).ReadString('n'); e == nil
{

Printf(m
)

}

}
)

}

func Dial(a string, conf *tls.Config, f func(net.Conn))
{

if c, e := tls.Dial("tcp", a, conf); e == nil
{

defer c.Close(
)

f(c
)

}

}
go for the paranoid network programmer slideshare.net/feyeleanor
87
package mai
n

import "bufio
"

import "crypto/tls
"

import . "fmt
"

import "net
"

 

func main()
{

Dial(":1025", ConfigTLS("ccert", "ckey"), func(c net.Conn) {
if m, e := bufio.NewReader(c).ReadString('n'); e == nil
{

Printf(m
)

}

}
)

}

func Dial(a string, conf *tls.Config, f func(net.Conn))
{

if c, e := tls.Dial("tcp", a, conf); e == nil
{

defer c.Close(
)

f(c
)

}

}
go for the paranoid network programmer slideshare.net/feyeleanor
88
udp serve
89
go for the paranoid network programmer slideshare.net/feyeleanor
package mai
n

import "net
"

func main()
{

HELLO_WORLD := []byte("Hello Worldn"
)

Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
c.WriteToUDP(HELLO_WORLD, a
)

}
)

}

func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte))
{

if address, e := net.ResolveUDPAddr("udp", a); e == nil
{

if conn, e := net.ListenUDP("udp", address); e == nil
{

for b := make([]byte, 1024); ; b = make([]byte, 1024)
{

if n, client, e := conn.ReadFromUDP(b); e == nil
{

go f(conn, client, b[:n]
)

}
}
}
}

}
go for the paranoid network programmer slideshare.net/feyeleanor
90
package mai
n

import "net
"

func main()
{

HELLO_WORLD := []byte("Hello Worldn"
)

Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
c.WriteToUDP(HELLO_WORLD, a
)

}
)

}

func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte))
{

if address, e := net.ResolveUDPAddr("udp", a); e == nil
{

if conn, e := net.ListenUDP("udp", address); e == nil
{

for b := make([]byte, 1024); ; b = make([]byte, 1024)
{

if n, client, e := conn.ReadFromUDP(b); e == nil
{

go f(conn, client, b[:n]
)

}
}
}
}

}
go for the paranoid network programmer slideshare.net/feyeleanor
91
package mai
n

import "net
"

func main()
{

HELLO_WORLD := []byte("Hello Worldn"
)

Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
c.WriteToUDP(HELLO_WORLD, a
)

}
)

}

func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte))
{

if address, e := net.ResolveUDPAddr("udp", a); e == nil
{

if conn, e := net.ListenUDP("udp", address); e == nil
{

for b := make([]byte, 1024); ; b = make([]byte, 1024)
{

if n, client, e := conn.ReadFromUDP(b); e == nil
{

go f(conn, client, b[:n]
)

}
}
}
}

}
go for the paranoid network programmer slideshare.net/feyeleanor
92
package mai
n

import "net
"

func main()
{

HELLO_WORLD := []byte("Hello Worldn"
)

Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
c.WriteToUDP(HELLO_WORLD, a
)

}
)

}

func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte))
{

if address, e := net.ResolveUDPAddr("udp", a); e == nil
{

if conn, e := net.ListenUDP("udp", address); e == nil
{

for b := make([]byte, 1024); ; b = make([]byte, 1024)
{

if n, client, e := conn.ReadFromUDP(b); e == nil
{

go f(conn, client, b[:n]
)

}
}
}
}

}
go for the paranoid network programmer slideshare.net/feyeleanor
93
package mai
n

import "net
"

func main()
{

HELLO_WORLD := []byte("Hello Worldn"
)

Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
c.WriteToUDP(HELLO_WORLD, a
)

}
)

}

func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte))
{

if address, e := net.ResolveUDPAddr("udp", a); e == nil
{

if conn, e := net.ListenUDP("udp", address); e == nil
{

for b := make([]byte, 1024); ; b = make([]byte, 1024)
{

if n, client, e := conn.ReadFromUDP(b); e == nil
{

go f(conn, client, b[:n]
)

}
}
}
}

}
go for the paranoid network programmer slideshare.net/feyeleanor
94
package mai
n

import "net
"

func main()
{

HELLO_WORLD := []byte("Hello Worldn"
)

Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte)
{

c.WriteToUDP(HELLO_WORLD, a
)

}
)

}

func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte))
{

if address, e := net.ResolveUDPAddr("udp", a); e == nil
{

if conn, e := net.ListenUDP("udp", address); e == nil
{

for b := make([]byte, 1024); ; b = make([]byte, 1024)
{

if n, client, e := conn.ReadFromUDP(b); e == nil
{

go f(conn, client, b[:n]
)

}
}
}
}

}
go for the paranoid network programmer slideshare.net/feyeleanor
95
package mai
n

import "net
"

func main()
{

HELLO_WORLD := []byte("Hello Worldn"
)

Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte)
{

c.WriteToUDP(HELLO_WORLD, a
)

}
)

}

func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte))
{

if address, e := net.ResolveUDPAddr("udp", a); e == nil
{

if conn, e := net.ListenUDP("udp", address); e == nil
{

for b := make([]byte, 1024); ; b = make([]byte, 1024)
{

if n, client, e := conn.ReadFromUDP(b); e == nil
{

go f(conn, client, b[:n]
)

}
}
}
}

}
go for the paranoid network programmer slideshare.net/feyeleanor
96
package mai
n

import "net
"

func main()
{

HELLO_WORLD := []byte("Hello Worldn"
)

Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte)
{

c.WriteToUDP(HELLO_WORLD, a
)

}
)

}

func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte))
{

if address, e := net.ResolveUDPAddr("udp", a); e == nil
{

if conn, e := net.ListenUDP("udp", address); e == nil
{

for b := make([]byte, 1024); ; b = make([]byte, 1024) {
if n, client, e := conn.ReadFromUDP(b); e == nil
{

go f(conn, client, b[:n]
)

}
}
}
}

}
go for the paranoid network programmer slideshare.net/feyeleanor
97
package mai
n

import "net
"

func main()
{

HELLO_WORLD := []byte("Hello Worldn"
)

Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte)
{

c.WriteToUDP(HELLO_WORLD, a
)

}
)

}

func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte))
{

if address, e := net.ResolveUDPAddr("udp", a); e == nil
{

if conn, e := net.ListenUDP("udp", address); e == nil
{

for b := make([]byte, 1024); ; b = make([]byte, 1024) {
if n, client, e := conn.ReadFromUDP(b); e == nil
{

go f(conn, client, b[:n]
)

}
}
}
}

}
go for the paranoid network programmer slideshare.net/feyeleanor
98
package mai
n

import "net
"

func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte))
{

if address, e := net.ResolveUDPAddr("udp", a); e == nil
{

if conn, e := net.ListenUDP("udp", address); e == nil
{

ServeUDP(conn, func(c *net.UDPAddr, b []byte)
{

f(conn, c, b
)

})
}
}
}

func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte))
{

for b := make([]byte, 1024); ; b = make([]byte, 1024)
{

if n, client, e := c.ReadFromUDP(b); e == nil
{

go f(client, b[:n]
)

}
}

}
go for the paranoid network programmer slideshare.net/feyeleanor
99
package mai
n

import "net
"

func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte))
{

if address, e := net.ResolveUDPAddr("udp", a); e == nil
{

if conn, e := net.ListenUDP("udp", address); e == nil
{

ServeUDP(conn, func(c *net.UDPAddr, b []byte)
{

f(conn, c, b
)

})
}
}
}

func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte))
{

for b := make([]byte, 1024); ; b = make([]byte, 1024) {
if n, client, e := c.ReadFromUDP(b); e == nil
{

go f(client, b[:n]
)

}
}

}
go for the paranoid network programmer slideshare.net/feyeleanor
100
package mai
n

import "net
"

func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte))
{

if address, e := net.ResolveUDPAddr("udp", a); e == nil
{

if conn, e := net.ListenUDP("udp", address); e == nil
{

ServeUDP(conn, func(c *net.UDPAddr, b []byte)
{

f(conn, c, b
)

})
}
}
}

func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte))
{

for b := make([]byte, 1024); ; b = make([]byte, 1024) {
if n, client, e := c.ReadFromUDP(b); e == nil
{

go f(client, b[:n]
)

}
}

}
go for the paranoid network programmer slideshare.net/feyeleanor
101
package mai
n

import "net
"

func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte))
{

if address, e := net.ResolveUDPAddr("udp", a); e == nil
{

if conn, e := net.ListenUDP("udp", address); e == nil
{

ServeUDP(conn, func(c *net.UDPAddr, b []byte)
{

f(conn, c, b
)

})
}
}
}

func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte))
{

for b := make([]byte, 1024); ; b = make([]byte, 1024) {
if n, client, e := c.ReadFromUDP(b); e == nil
{

go f(client, b[:n]
)

}
}

}
go for the paranoid network programmer slideshare.net/feyeleanor
102
package mai
n

import "net
"

func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte))
{

if address, e := net.ResolveUDPAddr("udp", a); e == nil
{

if conn, e := net.ListenUDP("udp", address); e == nil
{

ServeUDP(conn, func(c *net.UDPAddr, b []byte)
{

f(conn, c, b
)

})
}
}
}

func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte))
{

for b := make([]byte, 1024); ; b = make([]byte, 1024) {
if n, client, e := c.ReadFromUDP(b); e == nil
{

go f(client, b[:n]
)

}
}

}
go for the paranoid network programmer slideshare.net/feyeleanor
103
package mai
n

import "net
"

func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte))
{

if address, e := net.ResolveUDPAddr("udp", a); e == nil
{

if conn, e := net.ListenUDP("udp", address); e == nil
{

ServeUDP(conn, func(c *net.UDPAddr, b []byte)
{

f(conn, c, b
)

})
}
}
}

func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte))
{

for b := make([]byte, 1024); ; b = make([]byte, 1024) {
if n, client, e := c.ReadFromUDP(b); e == nil
{

go f(client, b[:n]
)

}
}

}
go for the paranoid network programmer slideshare.net/feyeleanor
104
package mai
n

import "net
"

func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte))
{

if address, e := net.ResolveUDPAddr("udp", a); e == nil
{

if conn, e := net.ListenUDP("udp", address); e == nil
{

ServeUDP(conn, func(c *net.UDPAddr, b []byte)
{

f(conn, c, b
)

})
}
}
}

func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte))
{

for b := make([]byte, 1024); ; b = make([]byte, 1024)
{

if n, client, e := c.ReadFromUDP(b); e == nil
{

go f(client, b[:n]
)

}
}

}
go for the paranoid network programmer slideshare.net/feyeleanor
105
udp request
106
go for the paranoid network programmer slideshare.net/feyeleanor
package mai
n

import "bufio
"

import . "fmt
"

import "net
"

func main()
{

Dial(":1024", func(conn net.Conn)
{

if _, e := conn.Write([]byte("n")); e == nil
{

if m, e := bufio.NewReader(conn).ReadString('n'); e == nil
{

Printf("%v", m
)

}
}

}
)

}

func Dial(a string, f func(net.Conn))
{

if address, e := net.ResolveUDPAddr("udp", a); e == nil
{

if conn, e := net.DialUDP("udp", nil, address); e == nil
{

defer conn.Close(
)

f(conn
)

}

go for the paranoid network programmer slideshare.net/feyeleanor
107
package mai
n

import "bufio
"

import . "fmt
"

import "net
"

func main()
{

Dial(":1024", func(conn net.Conn)
{

if _, e := conn.Write([]byte("n")); e == nil
{

if m, e := bufio.NewReader(conn).ReadString('n'); e == nil
{

Printf("%v", m
)

}
}

}
)

}

func Dial(a string, f func(net.Conn))
{

if address, e := net.ResolveUDPAddr("udp", a); e == nil
{

if conn, e := net.DialUDP("udp", nil, address); e == nil
{

defer conn.Close(
)

f(conn
)

}

go for the paranoid network programmer slideshare.net/feyeleanor
108
package mai
n

import "bufio
"

import . "fmt
"

import "net
"

func main()
{

Dial(":1024", func(conn net.Conn)
{

if _, e := conn.Write([]byte("n")); e == nil
{

if m, e := bufio.NewReader(conn).ReadString('n'); e == nil
{

Printf("%v", m
)

}
}

}
)

}

func Dial(a string, f func(net.Conn))
{

if address, e := net.ResolveUDPAddr("udp", a); e == nil
{

if conn, e := net.DialUDP("udp", nil, address); e == nil
{

defer conn.Close(
)

f(conn
)

}

go for the paranoid network programmer slideshare.net/feyeleanor
109
package mai
n

import "bufio
"

import . "fmt
"

import "net
"

func main()
{

Dial(":1024", func(conn net.Conn) {
if _, e := conn.Write([]byte("n")); e == nil
{

if m, e := bufio.NewReader(conn).ReadString('n'); e == nil
{

Printf("%v", m
)

}
}

}
)

}

func Dial(a string, f func(net.Conn))
{

if address, e := net.ResolveUDPAddr("udp", a); e == nil
{

if conn, e := net.DialUDP("udp", nil, address); e == nil
{

defer conn.Close(
)

f(conn
)

}

go for the paranoid network programmer slideshare.net/feyeleanor
110
package mai
n

import "bufio
"

import . "fmt
"

import "net
"

func main()
{

Dial(":1024", func(conn net.Conn) {
if _, e := conn.Write([]byte("n")); e == nil
{

if m, e := bufio.NewReader(conn).ReadString('n'); e == nil
{

Printf("%v", m
)

}
}

}
)

}

func Dial(a string, f func(net.Conn))
{

if address, e := net.ResolveUDPAddr("udp", a); e == nil
{

if conn, e := net.DialUDP("udp", nil, address); e == nil
{

defer conn.Close(
)

f(conn
)

}

go for the paranoid network programmer slideshare.net/feyeleanor
111
package mai
n

import "bufio
"

import . "fmt
"

import "net
"

func main()
{

Dial(":1024", func(conn net.Conn) {
if _, e := conn.Write([]byte("n")); e == nil
{

if m, e := bufio.NewReader(conn).ReadString('n'); e == nil
{

Printf("%v", m
)

}
}

}
)

}

func Dial(a string, f func(net.Conn))
{

if address, e := net.ResolveUDPAddr("udp", a); e == nil
{

if conn, e := net.DialUDP("udp", nil, address); e == nil
{

defer conn.Close(
)

f(conn
)

}

go for the paranoid network programmer slideshare.net/feyeleanor
112
aes encrypt
113
go for the paranoid network programmer slideshare.net/feyeleanor
go for the paranoid network programmer slideshare.net/feyeleanor
114
package mai
n

import "net
"

const AES_KEY = "0123456789012345
"

func main()
{

Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
if m, e := Encrypt("Hello World", AES_KEY); e == nil
{

c.WriteToUDP(m, a
)

}

}
)

}

func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte))
{

// see udp serv
e

}

func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte))
{

// see udp serv
e

}
go for the paranoid network programmer slideshare.net/feyeleanor
115
package mai
n

import "net
"

const AES_KEY = "0123456789012345"
func main()
{

Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
if m, e := Encrypt("Hello World", AES_KEY); e == nil
{

c.WriteToUDP(m, a
)

}

}
)

}

func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte))
{

// see udp serv
e

}

func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte))
{

// see udp serv
e

}
go for the paranoid network programmer slideshare.net/feyeleanor
116
package mai
n

import "net
"

const AES_KEY = "0123456789012345"
func main()
{

Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
if m, e := Encrypt("Hello World", AES_KEY); e == nil
{

c.WriteToUDP(m, a
)

}

}
)

}

func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte))
{

// see udp serv
e

}

func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte))
{

// see udp serv
e

}
package mai
n

import "crypto/aes
"

import "crypto/cipher
"

func Encrypt(m, k string) (o []byte, e error)
{

if o, e = PaddedBuffer([]byte(m)); e == nil
{

var b cipher.Bloc
k

if b, e = aes.NewCipher([]byte(k)); e == nil
{

o = CryptBlocks(o, b
)

}
}

retur
n

}

func PaddedBuffer(m []byte) (b []byte, e error)
{

b = append(b, m...
)

if p := len(b) % aes.BlockSize; p != 0
{

p = aes.BlockSize -
p

b = append(b, make([]byte, p)…) // padding with NUL!!!
!

}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
117
package mai
n

import "crypto/aes
"

import "crypto/cipher
"

func Encrypt(m, k string) (o []byte, e error)
{

if o, e = PaddedBuffer([]byte(m)); e == nil
{

var b cipher.Bloc
k

if b, e = aes.NewCipher([]byte(k)); e == nil
{

o = CryptBlocks(o, b
)

}
}

retur
n

}

func PaddedBuffer(m []byte) (b []byte, e error)
{

b = append(b, m...
)

if p := len(b) % aes.BlockSize; p != 0
{

p = aes.BlockSize -
p

b = append(b, make([]byte, p)…) // padding with NUL!!!
!

}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
118
package mai
n

import "crypto/aes
"

import "crypto/cipher
"

func Encrypt(m, k string) (o []byte, e error)
{

if o, e = PaddedBuffer([]byte(m)); e == nil
{

var b cipher.Bloc
k

if b, e = aes.NewCipher([]byte(k)); e == nil
{

o = CryptBlocks(o, b
)

}
}

retur
n

}

func PaddedBuffer(m []byte) (b []byte, e error)
{

b = append(b, m...
)

if p := len(b) % aes.BlockSize; p != 0
{

p = aes.BlockSize -
p

b = append(b, make([]byte, p)…) // padding with NUL!!!
!

}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
119
package mai
n

import "crypto/aes
"

import "crypto/cipher
"

func Encrypt(m, k string) (o []byte, e error)
{

if o, e = PaddedBuffer([]byte(m)); e == nil
{

var b cipher.Bloc
k

if b, e = aes.NewCipher([]byte(k)); e == nil
{

o = CryptBlocks(o, b
)

}
}

retur
n

}

func PaddedBuffer(m []byte) (b []byte, e error)
{

b = append(b, m...
)

if p := len(b) % aes.BlockSize; p != 0
{

p = aes.BlockSize -
p

b = append(b, make([]byte, p)…) // padding with NUL!!!
!

}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
120
package mai
n

import "crypto/aes
"

import "crypto/cipher
"

func Encrypt(m, k string) (o []byte, e error)
{

if o, e = PaddedBuffer([]byte(m)); e == nil
{

var b cipher.Bloc
k

if b, e = aes.NewCipher([]byte(k)); e == nil
{

o = CryptBlocks(o, b
)

}
}

retur
n

}

func PaddedBuffer(m []byte) (b []byte, e error)
{

b = append(b, m...
)

if p := len(b) % aes.BlockSize; p != 0
{

p = aes.BlockSize - p
b = append(b, make([]byte, p)…) // padding with NUL!!!
!

}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
121
package mai
n

import "crypto/aes
"

import "crypto/cipher
"

func Encrypt(m, k string) (o []byte, e error)
{

if o, e = PaddedBuffer([]byte(m)); e == nil
{

var b cipher.Bloc
k

if b, e = aes.NewCipher([]byte(k)); e == nil
{

o = CryptBlocks(o, b
)

}
}

retur
n

}

func PaddedBuffer(m []byte) (b []byte, e error)
{

b = append(b, m...
)

if p := len(b) % aes.BlockSize; p != 0
{

p = aes.BlockSize - p
b = append(b, make([]byte, p)...) // padding with NUL!!!
!

}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
122
package mai
n

import "crypto/aes
"

import "crypto/cipher
"

func Encrypt(m, k string) (o []byte, e error)
{

if o, e = PaddedBuffer([]byte(m)); e == nil
{

var b cipher.Bloc
k

if b, e = aes.NewCipher([]byte(k)); e == nil
{

o = CryptBlocks(o, b
)

}
}

retur
n

}

func PaddedBuffer(m []byte) (b []byte, e error)
{

b = append(b, m...
)

if p := len(b) % aes.BlockSize; p != 0
{

p = aes.BlockSize - p
b = append(b, make([]byte, p)...) // padding with NUL!!!!
}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
123
package mai
n

import "crypto/aes
"

import "crypto/cipher
"

func Encrypt(m, k string) (o []byte, e error)
{

if o, e = PaddedBuffer([]byte(m)); e == nil
{

var b cipher.Block
if b, e = aes.NewCipher([]byte(k)); e == nil
{

o = CryptBlocks(o, b
)

}
}

retur
n

}

func PaddedBuffer(m []byte) (b []byte, e error)
{

b = append(b, m...
)

if p := len(b) % aes.BlockSize; p != 0
{

p = aes.BlockSize -
p

b = append(b, make([]byte, p)...) // padding with NUL!!!
!

}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
124
package mai
n

import "crypto/aes
"

import "crypto/cipher
"

func Encrypt(m, k string) (o []byte, e error)
{

if o, e = PaddedBuffer([]byte(m)); e == nil
{

var b cipher.Block
if b, e = aes.NewCipher([]byte(k)); e == nil
{

o = CryptBlocks(o, b
)

}
}

retur
n

}

func PaddedBuffer(m []byte) (b []byte, e error)
{

b = append(b, m...
)

if p := len(b) % aes.BlockSize; p != 0
{

p = aes.BlockSize -
p

b = append(b, make([]byte, p)...) // padding with NUL!!!
!

}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
125
package mai
n

import "crypto/aes
"

import "crypto/cipher
"

func CryptBlocks(b []byte, c cipher.Block) (o []byte)
{

o = make([]byte, aes.BlockSize + len(b)
)

copy(o, IV()
)

enc := cipher.NewCBCEncrypter(c, o[:aes.BlockSize]
)

enc.CryptBlocks(o[aes.BlockSize:], b
)

retur
n

}

func IV() (b []byte)
{

b = make([]byte, aes.BlockSize
)

if _, e := rand.Read(b); e != nil
{

panic(e
)

}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
126
package mai
n

import "crypto/aes
"

import "crypto/cipher
"

func CryptBlocks(b []byte, c cipher.Block) (o []byte)
{

o = make([]byte, aes.BlockSize + len(b)
)

copy(o, IV()
)

enc := cipher.NewCBCEncrypter(c, o[:aes.BlockSize]
)

enc.CryptBlocks(o[aes.BlockSize:], b
)

retur
n

}

func IV() (b []byte)
{

b = make([]byte, aes.BlockSize
)

if _, e := rand.Read(b); e != nil
{

panic(e
)

}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
127
package mai
n

import "crypto/aes
"

import "crypto/cipher
"

func CryptBlocks(b []byte, c cipher.Block) (o []byte)
{

o = make([]byte, aes.BlockSize + len(b)
)

copy(o, IV()
)

enc := cipher.NewCBCEncrypter(c, o[:aes.BlockSize]
)

enc.CryptBlocks(o[aes.BlockSize:], b
)

retur
n

}

func IV() (b []byte)
{

b = make([]byte, aes.BlockSize
)

if _, e := rand.Read(b); e != nil
{

panic(e
)

}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
128
package mai
n

import "crypto/aes
"

import "crypto/cipher
"

func CryptBlocks(b []byte, c cipher.Block) (o []byte)
{

o = make([]byte, aes.BlockSize + len(b)
)

copy(o, IV()
)

enc := cipher.NewCBCEncrypter(c, o[:aes.BlockSize]
)

enc.CryptBlocks(o[aes.BlockSize:], b
)

retur
n

}

func IV() (b []byte)
{

b = make([]byte, aes.BlockSize
)

if _, e := rand.Read(b); e != nil
{

panic(e
)

}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
129
package mai
n

import "crypto/aes
"

import "crypto/cipher
"

func CryptBlocks(b []byte, c cipher.Block) (o []byte)
{

o = make([]byte, aes.BlockSize + len(b)
)

copy(o, IV()
)

enc := cipher.NewCBCEncrypter(c, o[:aes.BlockSize]
)

enc.CryptBlocks(o[aes.BlockSize:], b
)

retur
n

}

func IV() (b []byte)
{

b = make([]byte, aes.BlockSize
)

if _, e := rand.Read(b); e != nil
{

panic(e
)

}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
130
package mai
n

import "crypto/aes
"

import "crypto/cipher
"

func CryptBlocks(b []byte, c cipher.Block) (o []byte)
{

o = make([]byte, aes.BlockSize + len(b)
)

copy(o, IV()
)

enc := cipher.NewCBCEncrypter(c, o[:aes.BlockSize]
)

enc.CryptBlocks(o[aes.BlockSize:], b
)

retur
n

}

func IV() (b []byte)
{

b = make([]byte, aes.BlockSize
)

if _, e := rand.Read(b); e != nil
{

panic(e
)

}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
131
package mai
n

import "crypto/aes
"

import "crypto/cipher
"

func CryptBlocks(b []byte, c cipher.Block) (o []byte)
{

o = make([]byte, aes.BlockSize + len(b)
)

copy(o, IV()
)

enc := cipher.NewCBCEncrypter(c, o[:aes.BlockSize]
)

enc.CryptBlocks(o[aes.BlockSize:], b
)

retur
n

}

func IV() (b []byte)
{

b = make([]byte, aes.BlockSize
)

if _, e := rand.Read(b); e != nil
{

panic(e
)

}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
132
package mai
n

import "crypto/aes
"

import "crypto/cipher
"

func CryptBlocks(b []byte, c cipher.Block) (o []byte)
{

o = make([]byte, aes.BlockSize + len(b)
)

copy(o, IV()
)

enc := cipher.NewCBCEncrypter(c, o[:aes.BlockSize]
)

enc.CryptBlocks(o[aes.BlockSize:], b
)

retur
n

}

func IV() (b []byte)
{

b = make([]byte, aes.BlockSize
)

if _, e := rand.Read(b); e != nil
{

panic(e
)

}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
133
aes decrypt
134
go for the paranoid network programmer slideshare.net/feyeleanor
package mai
n

import . "fmt
"

import "net
"

const AES_KEY = "0123456789012345
"

func main()
{

Dial(":1025", func(conn net.Conn) {
RequestMessage(conn, func(m []byte)
{

if m, e := Decrypt(m, AES_KEY); e == nil
{

Printf("%sn", m
)

}

}
)

}
)

}

func Dial(a string, f func(net.Conn))
{

// see udp reques
t

}

go for the paranoid network programmer slideshare.net/feyeleanor
135
package mai
n

import . "fmt
"

import "net
"

const AES_KEY = "0123456789012345
"

func main()
{

Dial(":1025", func(conn net.Conn) {
RequestMessage(conn, func(m []byte) {
if m, e := Decrypt(m, AES_KEY); e == nil
{

Printf("%sn", m
)

}

}
)

}
)

}

func Dial(a string, f func(net.Conn))
{

// see udp reques
t

}

go for the paranoid network programmer slideshare.net/feyeleanor
136
package mai
n

import . "fmt
"

import "net
"

const AES_KEY = "0123456789012345"
func main()
{

Dial(":1025", func(conn net.Conn) {
RequestMessage(conn, func(m []byte) {
if m, e := Decrypt(m, AES_KEY); e == nil
{

Printf("%sn", m
)

}

}
)

}
)

}

func Dial(a string, f func(net.Conn))
{

// see udp reques
t

}

go for the paranoid network programmer slideshare.net/feyeleanor
137
package mai
n

import "net
"

func RequestMessage(conn net.Conn, f func([]byte)) (e error)
{

if _, e = conn.Write([]byte("n")); e == nil
{

m := make([]byte, 1024
)

var n in
t

if n, e = conn.Read(m); e == nil
{

f(m[:n]
)

}

}

retur
n

}

go for the paranoid network programmer slideshare.net/feyeleanor
138
package mai
n

import "net
"

func RequestMessage(conn net.Conn, f func([]byte)) (e error)
{

if _, e = conn.Write([]byte("n")); e == nil
{

m := make([]byte, 1024
)

var n in
t

if n, e = conn.Read(m); e == nil
{

f(m[:n]
)

}

}

retur
n

}

go for the paranoid network programmer slideshare.net/feyeleanor
139
package mai
n

import "net
"

func RequestMessage(conn net.Conn, f func([]byte)) (e error)
{

if _, e = conn.Write([]byte("n")); e == nil
{

m := make([]byte, 1024
)

var n in
t

if n, e = conn.Read(m); e == nil
{

f(m[:n]
)

}

}

retur
n

}

go for the paranoid network programmer slideshare.net/feyeleanor
140
package mai
n

import "net
"

func RequestMessage(conn net.Conn, f func([]byte)) (e error)
{

if _, e = conn.Write([]byte("n")); e == nil
{

m := make([]byte, 1024
)

var n in
t

if n, e = conn.Read(m); e == nil
{

f(m[:n]
)

}

}

retur
n

}

go for the paranoid network programmer slideshare.net/feyeleanor
141
package mai
n

import "net
"

func RequestMessage(conn net.Conn, f func([]byte)) (e error)
{

if _, e = conn.Write([]byte("n")); e == nil
{

m := make([]byte, 1024
)

var n in
t

if n, e = conn.Read(m); e == nil
{

f(m[:n]
)

}

}

retur
n

}

go for the paranoid network programmer slideshare.net/feyeleanor
142
package mai
n

import "crypto/cipher
"

import "crypto/aes
"

func Decrypt(m []byte, k string) (r []byte, e error)
{

var b cipher.Bloc
k

if b, e = aes.NewCipher([]byte(k)); e == nil
{

var iv []byt
e

iv, m = Unpack(m
)

c := cipher.NewCBCDecrypter(b, iv
)

r = make([]byte, len(m)
)

c.CryptBlocks(r, m
)

}

retur
n

}

func Unpack(m []byte) (iv, r []byte)
{

return m[:aes.BlockSize], m[aes.BlockSize:
]

}
go for the paranoid network programmer slideshare.net/feyeleanor
143
package mai
n

import "crypto/cipher
"

import "crypto/aes
"

func Decrypt(m []byte, k string) (r []byte, e error)
{

var b cipher.Bloc
k

if b, e = aes.NewCipher([]byte(k)); e == nil
{

var iv []byt
e

iv, m = Unpack(m
)

c := cipher.NewCBCDecrypter(b, iv
)

r = make([]byte, len(m)
)

c.CryptBlocks(r, m
)

}

retur
n

}

func Unpack(m []byte) (iv, r []byte)
{

return m[:aes.BlockSize], m[aes.BlockSize:
]

}
go for the paranoid network programmer slideshare.net/feyeleanor
144
package mai
n

import "crypto/cipher
"

import "crypto/aes
"

func Decrypt(m []byte, k string) (r []byte, e error)
{

var b cipher.Bloc
k

if b, e = aes.NewCipher([]byte(k)); e == nil
{

var iv []byt
e

iv, m = Unpack(m
)

c := cipher.NewCBCDecrypter(b, iv
)

r = make([]byte, len(m)
)

c.CryptBlocks(r, m
)

}

retur
n

}

func Unpack(m []byte) (iv, r []byte)
{

return m[:aes.BlockSize], m[aes.BlockSize:
]

}
go for the paranoid network programmer slideshare.net/feyeleanor
145
package mai
n

import "crypto/cipher
"

import "crypto/aes
"

func Decrypt(m []byte, k string) (r []byte, e error)
{

var b cipher.Bloc
k

if b, e = aes.NewCipher([]byte(k)); e == nil
{

var iv []byt
e

iv, m = Unpack(m
)

c := cipher.NewCBCDecrypter(b, iv
)

r = make([]byte, len(m)
)

c.CryptBlocks(r, m
)

}

retur
n

}

func Unpack(m []byte) (iv, r []byte)
{

return m[:aes.BlockSize], m[aes.BlockSize:
]

}
go for the paranoid network programmer slideshare.net/feyeleanor
146
package mai
n

import "crypto/cipher
"

import "crypto/aes
"

func Decrypt(m []byte, k string) (r []byte, e error)
{

var b cipher.Bloc
k

if b, e = aes.NewCipher([]byte(k)); e == nil
{

var iv []byt
e

iv, m = Unpack(m
)

c := cipher.NewCBCDecrypter(b, iv
)

r = make([]byte, len(m)
)

c.CryptBlocks(r, m
)

}

retur
n

}

func Unpack(m []byte) (iv, r []byte)
{

return m[:aes.BlockSize], m[aes.BlockSize:
]

}
go for the paranoid network programmer slideshare.net/feyeleanor
147
package mai
n

import "crypto/cipher
"

import "crypto/aes
"

func Decrypt(m []byte, k string) (r []byte, e error)
{

var b cipher.Bloc
k

if b, e = aes.NewCipher([]byte(k)); e == nil
{

var iv []byt
e

iv, m = Unpack(m
)

c := cipher.NewCBCDecrypter(b, iv
)

r = make([]byte, len(m)
)

c.CryptBlocks(r, m
)

}

retur
n

}

func Unpack(m []byte) (iv, r []byte)
{

return m[:aes.BlockSize], m[aes.BlockSize:
]

}
go for the paranoid network programmer slideshare.net/feyeleanor
148
package mai
n

import "crypto/cipher
"

import "crypto/aes
"

func Decrypt(m []byte, k string) (r []byte, e error)
{

var b cipher.Bloc
k

if b, e = aes.NewCipher([]byte(k)); e == nil
{

var iv []byt
e

iv, m = Unpack(m
)

c := cipher.NewCBCDecrypter(b, iv
)

r = make([]byte, len(m)
)

c.CryptBlocks(r, m
)

}

retur
n

}

func Unpack(m []byte) (iv, r []byte)
{

return m[:aes.BlockSize], m[aes.BlockSize:
]

}
go for the paranoid network programmer slideshare.net/feyeleanor
149
package mai
n

import "crypto/cipher
"

import "crypto/aes
"

func Decrypt(m []byte, k string) (r []byte, e error)
{

var b cipher.Bloc
k

if b, e = aes.NewCipher([]byte(k)); e == nil
{

var iv []byt
e

iv, m = Unpack(m
)

c := cipher.NewCBCDecrypter(b, iv
)

r = make([]byte, len(m)
)

c.CryptBlocks(r, m
)

}

retur
n

}

func Unpack(m []byte) (iv, r []byte)
{

return m[:aes.BlockSize], m[aes.BlockSize:
]

}
go for the paranoid network programmer slideshare.net/feyeleanor
150
rsa encrypt
151
go for the paranoid network programmer slideshare.net/feyeleanor
package mai
n

import . "bytes
"

import "crypto/rsa
"

import "encoding/gob
"

import "net
"

func main()
{

HELLO_WORLD := []byte("Hello World"
)

RSA_LABEL := []byte("served"
)

Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
var key rsa.PublicKe
y

if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil
{

if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil
{

c.WriteToUDP(m, a
)

}

}

retur
n

}
)

}
go for the paranoid network programmer slideshare.net/feyeleanor
152
package mai
n

import . "bytes
"

import "crypto/rsa
"

import "encoding/gob
"

import "net
"

func main()
{

HELLO_WORLD := []byte("Hello World"
)

RSA_LABEL := []byte("served"
)

Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
var key rsa.PublicKey
if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil
{

if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil
{

c.WriteToUDP(m, a
)

}

}

retur
n

}
)

}
go for the paranoid network programmer slideshare.net/feyeleanor
153
package mai
n

import . "bytes
"

import "crypto/rsa
"

import "encoding/gob
"

import "net
"

func main()
{

HELLO_WORLD := []byte("Hello World"
)

RSA_LABEL := []byte("served"
)

Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
var key rsa.PublicKe
y

if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil
{

if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil
{

c.WriteToUDP(m, a
)

}

}

retur
n

}
)

}
go for the paranoid network programmer slideshare.net/feyeleanor
154
package mai
n

import . "bytes
"

import "crypto/rsa
"

import "encoding/gob
"

import "net
"

func main()
{

HELLO_WORLD := []byte("Hello World"
)

RSA_LABEL := []byte("served"
)

Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
var key rsa.PublicKe
y

if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil
{

if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil
{

c.WriteToUDP(m, a
)

}

}

retur
n

}
)

}
go for the paranoid network programmer slideshare.net/feyeleanor
155
package mai
n

import . "bytes
"

import "crypto/rsa
"

import "encoding/gob
"

import "net
"

func main()
{

HELLO_WORLD := []byte("Hello World"
)

RSA_LABEL := []byte("served"
)

Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
var key rsa.PublicKe
y

if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil
{

if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil
{

c.WriteToUDP(m, a
)

}

}

retur
n

}
)

}
go for the paranoid network programmer slideshare.net/feyeleanor
156
package mai
n

import . "bytes
"

import "crypto/rsa
"

import "encoding/gob
"

import "net
"

func main()
{

HELLO_WORLD := []byte("Hello World"
)

RSA_LABEL := []byte("served"
)

Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
var key rsa.PublicKe
y

if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil
{

if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil
{

c.WriteToUDP(m, a
)

}

}

retur
n

}
)

}
go for the paranoid network programmer slideshare.net/feyeleanor
157
package mai
n

import . "bytes
"

import "crypto/rsa
"

import "encoding/gob
"

import "net
"

func main()
{

HELLO_WORLD := []byte("Hello World"
)

RSA_LABEL := []byte("served"
)

Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) {
var key rsa.PublicKe
y

if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil
{

if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil
{

c.WriteToUDP(m, a
)

}

}

retur
n

}
)

}
go for the paranoid network programmer slideshare.net/feyeleanor
158
package mai
n

import "crypto/rand
"

import "crypto/rsa
"

import "crypto/sha1
"

func Encrypt(key *rsa.PublicKey, m, l []byte) ([]byte, error)
{

return rsa.EncryptOAEP(sha1.New(), rand.Reader, key, m, l
)

}
go for the paranoid network programmer slideshare.net/feyeleanor
159
package mai
n

import "crypto/rand
"

import "crypto/rsa
"

import "crypto/sha1
"

func Encrypt(key *rsa.PublicKey, m, l []byte) ([]byte, error)
{

return rsa.EncryptOAEP(sha1.New(), rand.Reader, key, m, l
)

}
go for the paranoid network programmer slideshare.net/feyeleanor
160
package mai
n

import "crypto/rand
"

import "crypto/rsa
"

import "crypto/sha1
"

func Encrypt(key *rsa.PublicKey, m, l []byte) ([]byte, error)
{

return rsa.EncryptOAEP(sha1.New(), rand.Reader, key, m, l
)

}
go for the paranoid network programmer slideshare.net/feyeleanor
161
package mai
n

import "crypto/rand
"

import "crypto/rsa
"

import "crypto/sha1
"

func Encrypt(key *rsa.PublicKey, m, l []byte) ([]byte, error)
{

return rsa.EncryptOAEP(sha1.New(), rand.Reader, key, m, l
)

}
go for the paranoid network programmer slideshare.net/feyeleanor
162
package mai
n

import "crypto/rand
"

import "crypto/rsa
"

import "crypto/sha1
"

func Encrypt(key *rsa.PublicKey, m, l []byte) ([]byte, error)
{

return rsa.EncryptOAEP(sha1.New(), rand.Reader, key, m, l
)

}
go for the paranoid network programmer slideshare.net/feyeleanor
163
rsa decrypt
164
go for the paranoid network programmer slideshare.net/feyeleanor
package mai
n

import "crypto/rsa
"

import . "fmt
"

import "net
"

func main()
{

Dial(":1025", "ckey", func(c *net.UDPConn, k *rsa.PrivateKey) {
if m, e := ReadStream(c); e == nil
{

if m, e := Decrypt(k, m, []byte("served")); e == nil
{

Println(string(m)
)

}

}

}
)

}
go for the paranoid network programmer slideshare.net/feyeleanor
165
package mai
n

import "crypto/rsa
"

import . "fmt
"

import "net
"

func main()
{

Dial(":1025", "ckey", func(c *net.UDPConn, k *rsa.PrivateKey)
{

if m, e := ReadStream(c); e == nil
{

if m, e := Decrypt(k, m, []byte("served")); e == nil
{

Println(string(m)
)

}

}

}
)

}
go for the paranoid network programmer slideshare.net/feyeleanor
166
package mai
n

import "crypto/rand
"

import "crypto/rsa
"

import "crypto/sha1
"

func Decrypt(key *rsa.PrivateKey, m, l []byte) ([]byte, error)
{

return rsa.DecryptOAEP(sha1.New(), rand.Reader, key, m, l
)

}
go for the paranoid network programmer slideshare.net/feyeleanor
167
package mai
n

import "crypto/rsa
"

import . "fmt
"

import "net
"

func main()
{

Dial(":1025", "ckey", func(c *net.UDPConn, k *rsa.PrivateKey)
{

if m, e := ReadStream(c); e == nil
{

if m, e := Decrypt(k, m, []byte("served")); e == nil
{

Println(string(m)
)

}

}

}
)

}
go for the paranoid network programmer slideshare.net/feyeleanor
168
package mai
n

import "crypto/rsa
"

import . "fmt
"

import "net
"

func main()
{

Dial(":1025", "ckey", func(c *net.UDPConn, k *rsa.PrivateKey) {
if m, e := ReadStream(c); e == nil
{

if m, e := Decrypt(k, m, []byte("served")); e == nil
{

Println(string(m)
)

}

}

}
)

}
go for the paranoid network programmer slideshare.net/feyeleanor
169
package mai
n

import "crypto/rsa
"

import . "fmt
"

import "net
"

func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey))
{

if k, e := LoadPrivateKey(file); e == nil
{

if address, e := net.ResolveUDPAddr("udp", a); e == nil
{

if conn, e := net.DialUDP("udp", nil, address); e == nil
{

defer conn.Close(
)

SendKey(conn, k.PublicKey, func()
{

f(conn, k
)

}
)

}

}

}

}
go for the paranoid network programmer slideshare.net/feyeleanor
170
package mai
n

import "crypto/rsa
"

import . "fmt
"

import "net
"

func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey))
{

if k, e := LoadPrivateKey(file); e == nil
{

if address, e := net.ResolveUDPAddr("udp", a); e == nil
{

if conn, e := net.DialUDP("udp", nil, address); e == nil
{

defer conn.Close(
)

SendKey(conn, k.PublicKey, func()
{

f(conn, k
)

}
)

}

}

}

}
go for the paranoid network programmer slideshare.net/feyeleanor
171
package mai
n

import "crypto/rsa
"

import . "fmt
"

import "net
"

func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey))
{

if k, e := LoadPrivateKey(file); e == nil
{

if address, e := net.ResolveUDPAddr("udp", a); e == nil
{

if conn, e := net.DialUDP("udp", nil, address); e == nil
{

defer conn.Close(
)

SendKey(conn, k.PublicKey, func()
{

f(conn, k
)

}
)

}

}

}

}
go for the paranoid network programmer slideshare.net/feyeleanor
172
package mai
n

import "crypto/rsa
"

import "crypto/x509
"

import "encoding/pem
"

import "io/ioutil
"

func LoadPrivateKey(file string) (r *rsa.PrivateKey, e error)
{

if file, e := ioutil.ReadFile(file); e == nil
{

if block, _ := pem.Decode(file); block != nil
{

if block.Type == "RSA PRIVATE KEY"
{

r, e = x509.ParsePKCS1PrivateKey(block.Bytes
)

}

}

}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
173
package mai
n

import "crypto/rsa
"

import "crypto/x509
"

import "encoding/pem
"

import "io/ioutil
"

func LoadPrivateKey(file string) (r *rsa.PrivateKey, e error)
{

if file, e := ioutil.ReadFile(file); e == nil
{

if block, _ := pem.Decode(file); block != nil
{

if block.Type == "RSA PRIVATE KEY"
{

r, e = x509.ParsePKCS1PrivateKey(block.Bytes
)

}

}

}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
174
package mai
n

import "crypto/rsa
"

import "crypto/x509
"

import "encoding/pem
"

import "io/ioutil
"

func LoadPrivateKey(file string) (r *rsa.PrivateKey, e error)
{

if file, e := ioutil.ReadFile(file); e == nil
{

if block, _ := pem.Decode(file); block != nil
{

if block.Type == "RSA PRIVATE KEY"
{

r, e = x509.ParsePKCS1PrivateKey(block.Bytes
)

}

}

}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
175
package mai
n

import "crypto/rsa
"

import "crypto/x509
"

import "encoding/pem
"

import "io/ioutil
"

func LoadPrivateKey(file string) (r *rsa.PrivateKey, e error)
{

if file, e := ioutil.ReadFile(file); e == nil
{

if block, _ := pem.Decode(file); block != nil
{

if block.Type == "RSA PRIVATE KEY"
{

r, e = x509.ParsePKCS1PrivateKey(block.Bytes
)

}

}

}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
176
package mai
n

import "crypto/rsa
"

import "crypto/x509
"

import "encoding/pem
"

import "io/ioutil
"

func LoadPrivateKey(file string) (r *rsa.PrivateKey, e error)
{

if file, e := ioutil.ReadFile(file); e == nil
{

if block, _ := pem.Decode(file); block != nil
{

if block.Type == "RSA PRIVATE KEY"
{

r, e = x509.ParsePKCS1PrivateKey(block.Bytes
)

}

}

}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
177
package mai
n

import "crypto/rsa
"

import "crypto/x509
"

import "encoding/pem
"

import "io/ioutil
"

func LoadPrivateKey(file string) (r *rsa.PrivateKey, e error)
{

if file, e := ioutil.ReadFile(file); e == nil
{

if block, _ := pem.Decode(file); block != nil
{

if block.Type == "RSA PRIVATE KEY"
{

r, e = x509.ParsePKCS1PrivateKey(block.Bytes
)

}

}

}

retur
n

}
go for the paranoid network programmer slideshare.net/feyeleanor
178
package mai
n

import "crypto/rsa
"

import . "fmt
"

import "net
"

func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey))
{

if k, e := LoadPrivateKey(file); e == nil
{

if address, e := net.ResolveUDPAddr("udp", a); e == nil
{

if conn, e := net.DialUDP("udp", nil, address); e == nil
{

defer conn.Close(
)

SendKey(conn, k.PublicKey, func()
{

f(conn, k
)

}
)

}

}

}

}
go for the paranoid network programmer slideshare.net/feyeleanor
179
package mai
n

import "crypto/rsa
"

import . "fmt
"

import "net
"

func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey))
{

if k, e := LoadPrivateKey(file); e == nil
{

if address, e := net.ResolveUDPAddr("udp", a); e == nil
{

if conn, e := net.DialUDP("udp", nil, address); e == nil
{

defer conn.Close(
)

SendKey(conn, k.PublicKey, func()
{

f(conn, k
)

}
)

}

}

}

}
go for the paranoid network programmer slideshare.net/feyeleanor
180
package mai
n

import "crypto/rsa
"

import . "fmt
"

import "net
"

func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey))
{

if k, e := LoadPrivateKey(file); e == nil
{

if address, e := net.ResolveUDPAddr("udp", a); e == nil
{

if conn, e := net.DialUDP("udp", nil, address); e == nil
{

defer conn.Close(
)

SendKey(conn, k.PublicKey, func()
{

f(conn, k
)

}
)

}

}

}

}
go for the paranoid network programmer slideshare.net/feyeleanor
181
package mai
n

import "bytes
"

import “crypto/rsa
"

import "encoding/gob
"

import "net
"

func SendKey(c *net.UDPConn, k rsa.PublicKey, f func())
{

var b bytes.Buffe
r

if e := gob.NewEncoder(&b).Encode(k); e == nil
{

if _, e = c.Write(b.Bytes()); e == nil
{

f(
)

}

}

}
go for the paranoid network programmer slideshare.net/feyeleanor
182
package mai
n

import "bytes
"

import “crypto/rsa
"

import "encoding/gob
"

import "net
"

func SendKey(c *net.UDPConn, k rsa.PublicKey, f func())
{

var b bytes.Buffe
r

if e := gob.NewEncoder(&b).Encode(k); e == nil
{

if _, e = c.Write(b.Bytes()); e == nil
{

f(
)

}

}

}
go for the paranoid network programmer slideshare.net/feyeleanor
183
package mai
n

import "bytes
"

import “crypto/rsa
"

import "encoding/gob
"

import "net
"

func SendKey(c *net.UDPConn, k rsa.PublicKey, f func())
{

var b bytes.Buffe
r

if e := gob.NewEncoder(&b).Encode(k); e == nil
{

if _, e = c.Write(b.Bytes()); e == nil
{

f(
)

}

}

}
go for the paranoid network programmer slideshare.net/feyeleanor
184
package mai
n

import "crypto/rsa
"

import . "fmt
"

import "net
"

func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey))
{

if k, e := LoadPrivateKey(file); e == nil
{

if address, e := net.ResolveUDPAddr("udp", a); e == nil
{

if conn, e := net.DialUDP("udp", nil, address); e == nil
{

defer conn.Close(
)

SendKey(conn, k.PublicKey, func()
{

f(conn, k)
}
)

}

}

}

}
go for the paranoid network programmer slideshare.net/feyeleanor
185
serving websockets
186
go for the paranoid network programmer slideshare.net/feyeleanor
ws_hello.htm
l

<!DOCTYPE html
>

<html
>

<head
>

<meta charset='UTF-8' /
>

<title>WEBSOCKET HELLO</title
>

<script src="js"></script
>

</head
>

<body></body
>

</html
>

ws_hello.j
s

window.onload = function()
{

var socket = new WebSocket("ws://localhost:3000/hello")
;

socket.onmessage = m =>
{

div = document.createElement("div")
;

div.innerText = JSON.parse(m.data)
;

document.body.append(div)
;

}
;

}

go for the paranoid network programmer slideshare.net/feyeleanor
187
ws_hello.htm
l

<!DOCTYPE html
>

<html
>

<head
>

<meta charset='UTF-8' /
>

<title>WEBSOCKET HELLO</title
>

<script src="js"></script
>

</head
>

<body></body
>

</html
>

ws_hello.j
s

window.onload = function()
{

var socket = new WebSocket("ws://localhost:3000/hello")
;

socket.onmessage = m =>
{

div = document.createElement("div")
;

div.innerText = JSON.parse(m.data)
;

document.body.append(div)
;

}
;

}

go for the paranoid network programmer slideshare.net/feyeleanor
188
package mai
n

import "fmt
"

import "golang.org/x/net/websocket
"

import "io/ioutil
"

import "net/http
"

func ServeFile(route, name, mime_type string)
{

b, _ := ioutil.ReadFile(name
)

http.HandleFunc(route, func(w http.ResponseWriter, r *http.Request)
{

w.Header().Set("Content-Type", mime_type
)

fmt.Fprint(w, string(b)
)

}
)

}

func main()
{

http.Handle("/hello", websocket.Handler(func(ws *websocket.Conn)
{

websocket.JSON.Send(ws, "Hello"
)

})
)

ServeFile("/", "ws_hello.html", "text/html"
)

ServeFile("/js", "ws_hello.js", "application/javascript"
)

http.ListenAndServe(":3000", nil
)

}

go for the paranoid network programmer slideshare.net/feyeleanor
189
package mai
n

import "fmt
"

import "golang.org/x/net/websocket
"

import "io/ioutil
"

import "net/http
"

func ServeFile(route, name, mime_type string)
{

b, _ := ioutil.ReadFile(name
)

http.HandleFunc(route, func(w http.ResponseWriter, r *http.Request)
{

w.Header().Set("Content-Type", mime_type
)

fmt.Fprint(w, string(b)
)

}
)

}

func main()
{

http.Handle("/hello", websocket.Handler(func(ws *websocket.Conn)
{

websocket.JSON.Send(ws, "Hello"
)

})
)

ServeFile("/", "ws_hello.html", "text/html"
)

ServeFile("/js", "ws_hello.js", "application/javascript"
)

http.ListenAndServe(":3000", nil
)

}

go for the paranoid network programmer slideshare.net/feyeleanor
190
package mai
n

import "fmt
"

import "golang.org/x/net/websocket
"

import "io/ioutil
"

import "net/http
"

func ServeFile(route, name, mime_type string)
{

b, _ := ioutil.ReadFile(name
)

http.HandleFunc(route, func(w http.ResponseWriter, r *http.Request)
{

w.Header().Set("Content-Type", mime_type)
fmt.Fprint(w, string(b)
)

}
)

}

func main()
{

http.Handle("/hello", websocket.Handler(func(ws *websocket.Conn)
{

websocket.JSON.Send(ws, "Hello"
)

})
)

ServeFile("/", "ws_hello.html", "text/html"
)

ServeFile("/js", "ws_hello.js", "application/javascript"
)

http.ListenAndServe(":3000", nil
)

}

go for the paranoid network programmer slideshare.net/feyeleanor
191
package mai
n

import "fmt
"

import "golang.org/x/net/websocket
"

import "io/ioutil
"

import "net/http
"

func ServeFile(route, name, mime_type string)
{

b, _ := ioutil.ReadFile(name
)

http.HandleFunc(route, func(w http.ResponseWriter, r *http.Request)
{

w.Header().Set("Content-Type", mime_type
)

fmt.Fprint(w, string(b)
)

}
)

}

func main()
{

http.Handle("/hello", websocket.Handler(func(ws *websocket.Conn)
{

websocket.JSON.Send(ws, "Hello"
)

})
)

ServeFile("/", "ws_hello.html", "text/html"
)

ServeFile("/js", "ws_hello.js", "application/javascript"
)

http.ListenAndServe(":3000", nil
)

}

go for the paranoid network programmer slideshare.net/feyeleanor
192
package mai
n

import "fmt
"

import "golang.org/x/net/websocket
"

import "io/ioutil
"

import "net/http
"

func ServeFile(route, name, mime_type string)
{

b, _ := ioutil.ReadFile(name
)

http.HandleFunc(route, func(w http.ResponseWriter, r *http.Request)
{

w.Header().Set("Content-Type", mime_type
)

fmt.Fprint(w, string(b)
)

}
)

}

func main()
{

http.Handle("/hello", websocket.Handler(func(ws *websocket.Conn)
{

websocket.JSON.Send(ws, "Hello"
)

})
)

ServeFile("/", "ws_hello.html", "text/html"
)

ServeFile("/js", "ws_hello.js", "application/javascript"
)

http.ListenAndServe(":3000", nil
)

}

go for the paranoid network programmer slideshare.net/feyeleanor
193
package mai
n

import "fmt
"

import "golang.org/x/net/websocket
"

import "io/ioutil
"

import "net/http
"

func ServeFile(route, name, mime_type string)
{

b, _ := ioutil.ReadFile(name
)

http.HandleFunc(route, func(w http.ResponseWriter, r *http.Request)
{

w.Header().Set("Content-Type", mime_type
)

fmt.Fprint(w, string(b)
)

}
)

}

func main()
{

http.Handle("/hello", websocket.Handler(func(ws *websocket.Conn)
{

websocket.JSON.Send(ws, "Hello"
)

})
)

ServeFile("/", "ws_hello.html", "text/html"
)

ServeFile("/js", "ws_hello.js", "application/javascript"
)

http.ListenAndServe(":3000", nil
)

}

go for the paranoid network programmer slideshare.net/feyeleanor
194
accessing websockets
195
go for the paranoid network programmer slideshare.net/feyeleanor
package mai
n

import "fmt
"

import "golang.org/x/net/websocket
"

const SERVER = "ws://localhost:3000/hello
"

const ADDRESS = "http://localhost/
"

func main()
{

if ws, e := websocket.Dial(SERVER, "", ADDRESS); e == nil
{

var s strin
g

if e := websocket.JSON.Receive(ws, &s); e == nil
{

fmt.Println(s
)

}

}

}

go for the paranoid network programmer slideshare.net/feyeleanor
196
package mai
n

import "fmt
"

import "golang.org/x/net/websocket
"

const SERVER = "ws://localhost:3000/hello
"

const ADDRESS = "http://localhost/
"

func main()
{

if ws, e := websocket.Dial(SERVER, "", ADDRESS); e == nil
{

var s strin
g

if e := websocket.JSON.Receive(ws, &s); e == nil
{

fmt.Println(s
)

}

}

}

go for the paranoid network programmer slideshare.net/feyeleanor
197
package mai
n

import "fmt
"

import "golang.org/x/net/websocket
"

const SERVER = "ws://localhost:3000/hello
"

const ADDRESS = "http://localhost/
"

func main()
{

if ws, e := websocket.Dial(SERVER, "", ADDRESS); e == nil
{

var s string
if e := websocket.JSON.Receive(ws, &s); e == nil
{

fmt.Println(s
)

}

}

}

go for the paranoid network programmer slideshare.net/feyeleanor
198
twitter://@feyeleanor
go for the paranoid network programmer slideshare.net/feyeleanor

More Related Content

What's hot

Abusing text/template for data transformation
Abusing text/template for data transformationAbusing text/template for data transformation
Abusing text/template for data transformation
Arnaud Porterie
 
Whispered secrets
Whispered secretsWhispered secrets
Whispered secrets
Eleanor McHugh
 
Implementing Virtual Machines in Go & C
Implementing Virtual Machines in Go & CImplementing Virtual Machines in Go & C
Implementing Virtual Machines in Go & C
Eleanor McHugh
 
OSDC.TW - Gutscript for PHP haters
OSDC.TW - Gutscript for PHP hatersOSDC.TW - Gutscript for PHP haters
OSDC.TW - Gutscript for PHP hatersLin Yo-An
 
What's New in PHP 5.5
What's New in PHP 5.5What's New in PHP 5.5
What's New in PHP 5.5
Corey Ballou
 
Rust言語紹介
Rust言語紹介Rust言語紹介
Rust言語紹介
Paweł Rusin
 
Rust-lang
Rust-langRust-lang
Unix Programming with Perl 2
Unix Programming with Perl 2Unix Programming with Perl 2
Unix Programming with Perl 2
Kazuho Oku
 
Code Generation in PHP - PHPConf 2015
Code Generation in PHP - PHPConf 2015Code Generation in PHP - PHPConf 2015
Code Generation in PHP - PHPConf 2015
Lin Yo-An
 
Python utan-stodhjul-motorsag
Python utan-stodhjul-motorsagPython utan-stodhjul-motorsag
Python utan-stodhjul-motorsagniklal
 
Unix Programming with Perl
Unix Programming with PerlUnix Programming with Perl
Unix Programming with PerlKazuho Oku
 
Functional pe(a)rls: Huey's zipper
Functional pe(a)rls: Huey's zipperFunctional pe(a)rls: Huey's zipper
Functional pe(a)rls: Huey's zipper
osfameron
 
groovy & grails - lecture 3
groovy & grails - lecture 3groovy & grails - lecture 3
groovy & grails - lecture 3
Alexandre Masselot
 
The Ring programming language version 1.10 book - Part 92 of 212
The Ring programming language version 1.10 book - Part 92 of 212The Ring programming language version 1.10 book - Part 92 of 212
The Ring programming language version 1.10 book - Part 92 of 212
Mahmoud Samir Fayed
 
Build a compiler in 2hrs - NCrafts Paris 2015
Build a compiler in 2hrs -  NCrafts Paris 2015Build a compiler in 2hrs -  NCrafts Paris 2015
Build a compiler in 2hrs - NCrafts Paris 2015
Phillip Trelford
 

What's hot (20)

Abusing text/template for data transformation
Abusing text/template for data transformationAbusing text/template for data transformation
Abusing text/template for data transformation
 
Whispered secrets
Whispered secretsWhispered secrets
Whispered secrets
 
Implementing Virtual Machines in Go & C
Implementing Virtual Machines in Go & CImplementing Virtual Machines in Go & C
Implementing Virtual Machines in Go & C
 
08 php-files
08 php-files08 php-files
08 php-files
 
Having Fun Programming!
Having Fun Programming!Having Fun Programming!
Having Fun Programming!
 
OSDC.TW - Gutscript for PHP haters
OSDC.TW - Gutscript for PHP hatersOSDC.TW - Gutscript for PHP haters
OSDC.TW - Gutscript for PHP haters
 
What's New in PHP 5.5
What's New in PHP 5.5What's New in PHP 5.5
What's New in PHP 5.5
 
Pdr ppt
Pdr pptPdr ppt
Pdr ppt
 
C99[2]
C99[2]C99[2]
C99[2]
 
Rust言語紹介
Rust言語紹介Rust言語紹介
Rust言語紹介
 
Rust-lang
Rust-langRust-lang
Rust-lang
 
Unix Programming with Perl 2
Unix Programming with Perl 2Unix Programming with Perl 2
Unix Programming with Perl 2
 
C99
C99C99
C99
 
Code Generation in PHP - PHPConf 2015
Code Generation in PHP - PHPConf 2015Code Generation in PHP - PHPConf 2015
Code Generation in PHP - PHPConf 2015
 
Python utan-stodhjul-motorsag
Python utan-stodhjul-motorsagPython utan-stodhjul-motorsag
Python utan-stodhjul-motorsag
 
Unix Programming with Perl
Unix Programming with PerlUnix Programming with Perl
Unix Programming with Perl
 
Functional pe(a)rls: Huey's zipper
Functional pe(a)rls: Huey's zipperFunctional pe(a)rls: Huey's zipper
Functional pe(a)rls: Huey's zipper
 
groovy & grails - lecture 3
groovy & grails - lecture 3groovy & grails - lecture 3
groovy & grails - lecture 3
 
The Ring programming language version 1.10 book - Part 92 of 212
The Ring programming language version 1.10 book - Part 92 of 212The Ring programming language version 1.10 book - Part 92 of 212
The Ring programming language version 1.10 book - Part 92 of 212
 
Build a compiler in 2hrs - NCrafts Paris 2015
Build a compiler in 2hrs -  NCrafts Paris 2015Build a compiler in 2hrs -  NCrafts Paris 2015
Build a compiler in 2hrs - NCrafts Paris 2015
 

Similar to Go for the paranoid network programmer, 3rd edition

Go for the would be network programmer
Go for the would be network programmerGo for the would be network programmer
Go for the would be network programmerEleanor McHugh
 
Go for the paranoid network programmer
Go for the paranoid network programmerGo for the paranoid network programmer
Go for the paranoid network programmer
Eleanor McHugh
 
Iss letcure 7_8
Iss letcure 7_8Iss letcure 7_8
Iss letcure 7_8Ali Habeeb
 
Using Flow-based programming to write tools and workflows for Scientific Comp...
Using Flow-based programming to write tools and workflows for Scientific Comp...Using Flow-based programming to write tools and workflows for Scientific Comp...
Using Flow-based programming to write tools and workflows for Scientific Comp...
Samuel Lampa
 
Go serving: Building server app with go
Go serving: Building server app with goGo serving: Building server app with go
Go serving: Building server app with go
Hean Hong Leong
 
How to Leverage Go for Your Networking Needs
How to Leverage Go for Your Networking NeedsHow to Leverage Go for Your Networking Needs
How to Leverage Go for Your Networking Needs
DigitalOcean
 
Beauty and Power of Go
Beauty and Power of GoBeauty and Power of Go
Beauty and Power of Go
Frank Müller
 
Case EasyLocus
Case EasyLocusCase EasyLocus
Case EasyLocus
Henrique Holanda
 
TDC2018SP | Trilha Go - Case Easylocus
TDC2018SP | Trilha Go - Case EasylocusTDC2018SP | Trilha Go - Case Easylocus
TDC2018SP | Trilha Go - Case Easylocus
tdc-globalcode
 
Using and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middlewareUsing and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middleware
Alona Mekhovova
 
Websockets talk at Rubyconf Uruguay 2010
Websockets talk at Rubyconf Uruguay 2010Websockets talk at Rubyconf Uruguay 2010
Websockets talk at Rubyconf Uruguay 2010Ismael Celis
 
Composer for busy developers - DPC13
Composer for busy developers - DPC13Composer for busy developers - DPC13
Composer for busy developers - DPC13
Rafael Dohms
 
ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...
ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...
ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...
DynamicInfraDays
 
Netty from the trenches
Netty from the trenchesNetty from the trenches
Netty from the trenches
Jordi Gerona
 
H2O World - Intro to R, Python, and Flow - Amy Wang
H2O World - Intro to R, Python, and Flow - Amy WangH2O World - Intro to R, Python, and Flow - Amy Wang
H2O World - Intro to R, Python, and Flow - Amy Wang
Sri Ambati
 
Interceptors: Into the Core of Pedestal
Interceptors: Into the Core of PedestalInterceptors: Into the Core of Pedestal
Interceptors: Into the Core of Pedestal
Kent Ohashi
 
rioinfo2012
rioinfo2012rioinfo2012
rioinfo2012
Juan Lopes
 
Meetup talk: Readying your Go Webservice
Meetup talk: Readying your Go WebserviceMeetup talk: Readying your Go Webservice
Meetup talk: Readying your Go Webservice
Ralph Ligtenberg
 
Lightning fast with Varnish
Lightning fast with VarnishLightning fast with Varnish
Lightning fast with Varnish
Varnish Software
 

Similar to Go for the paranoid network programmer, 3rd edition (20)

Go for the would be network programmer
Go for the would be network programmerGo for the would be network programmer
Go for the would be network programmer
 
Go for the paranoid network programmer
Go for the paranoid network programmerGo for the paranoid network programmer
Go for the paranoid network programmer
 
Iss letcure 7_8
Iss letcure 7_8Iss letcure 7_8
Iss letcure 7_8
 
Using Flow-based programming to write tools and workflows for Scientific Comp...
Using Flow-based programming to write tools and workflows for Scientific Comp...Using Flow-based programming to write tools and workflows for Scientific Comp...
Using Flow-based programming to write tools and workflows for Scientific Comp...
 
goatwork2014
goatwork2014goatwork2014
goatwork2014
 
Go serving: Building server app with go
Go serving: Building server app with goGo serving: Building server app with go
Go serving: Building server app with go
 
How to Leverage Go for Your Networking Needs
How to Leverage Go for Your Networking NeedsHow to Leverage Go for Your Networking Needs
How to Leverage Go for Your Networking Needs
 
Beauty and Power of Go
Beauty and Power of GoBeauty and Power of Go
Beauty and Power of Go
 
Case EasyLocus
Case EasyLocusCase EasyLocus
Case EasyLocus
 
TDC2018SP | Trilha Go - Case Easylocus
TDC2018SP | Trilha Go - Case EasylocusTDC2018SP | Trilha Go - Case Easylocus
TDC2018SP | Trilha Go - Case Easylocus
 
Using and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middlewareUsing and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middleware
 
Websockets talk at Rubyconf Uruguay 2010
Websockets talk at Rubyconf Uruguay 2010Websockets talk at Rubyconf Uruguay 2010
Websockets talk at Rubyconf Uruguay 2010
 
Composer for busy developers - DPC13
Composer for busy developers - DPC13Composer for busy developers - DPC13
Composer for busy developers - DPC13
 
ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...
ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...
ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...
 
Netty from the trenches
Netty from the trenchesNetty from the trenches
Netty from the trenches
 
H2O World - Intro to R, Python, and Flow - Amy Wang
H2O World - Intro to R, Python, and Flow - Amy WangH2O World - Intro to R, Python, and Flow - Amy Wang
H2O World - Intro to R, Python, and Flow - Amy Wang
 
Interceptors: Into the Core of Pedestal
Interceptors: Into the Core of PedestalInterceptors: Into the Core of Pedestal
Interceptors: Into the Core of Pedestal
 
rioinfo2012
rioinfo2012rioinfo2012
rioinfo2012
 
Meetup talk: Readying your Go Webservice
Meetup talk: Readying your Go WebserviceMeetup talk: Readying your Go Webservice
Meetup talk: Readying your Go Webservice
 
Lightning fast with Varnish
Lightning fast with VarnishLightning fast with Varnish
Lightning fast with Varnish
 

More from Eleanor McHugh

[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdf[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdf
Eleanor McHugh
 
Generics, Reflection, and Efficient Collections
Generics, Reflection, and Efficient CollectionsGenerics, Reflection, and Efficient Collections
Generics, Reflection, and Efficient Collections
Eleanor McHugh
 
The Relevance of Liveness - Biometrics and Data Integrity
The Relevance of Liveness - Biometrics and Data IntegrityThe Relevance of Liveness - Biometrics and Data Integrity
The Relevance of Liveness - Biometrics and Data Integrity
Eleanor McHugh
 
An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]
Eleanor McHugh
 
An introduction to functional programming with go
An introduction to functional programming with goAn introduction to functional programming with go
An introduction to functional programming with go
Eleanor McHugh
 
Implementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxImplementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 redux
Eleanor McHugh
 
Identity & trust in Monitored Spaces
Identity & trust in Monitored SpacesIdentity & trust in Monitored Spaces
Identity & trust in Monitored Spaces
Eleanor McHugh
 
Don't Ask, Don't Tell - The Virtues of Privacy By Design
Don't Ask, Don't Tell - The Virtues of Privacy By DesignDon't Ask, Don't Tell - The Virtues of Privacy By Design
Don't Ask, Don't Tell - The Virtues of Privacy By Design
Eleanor McHugh
 
Don't ask, don't tell the virtues of privacy by design
Don't ask, don't tell   the virtues of privacy by designDon't ask, don't tell   the virtues of privacy by design
Don't ask, don't tell the virtues of privacy by design
Eleanor McHugh
 
Anonymity, identity, trust
Anonymity, identity, trustAnonymity, identity, trust
Anonymity, identity, trust
Eleanor McHugh
 
Going Loopy - Adventures in Iteration with Google Go
Going Loopy - Adventures in Iteration with Google GoGoing Loopy - Adventures in Iteration with Google Go
Going Loopy - Adventures in Iteration with Google Go
Eleanor McHugh
 
Distributed Ledgers: Anonymity & Immutability at Scale
Distributed Ledgers: Anonymity & Immutability at ScaleDistributed Ledgers: Anonymity & Immutability at Scale
Distributed Ledgers: Anonymity & Immutability at Scale
Eleanor McHugh
 
Finding a useful outlet for my many Adventures in go
Finding a useful outlet for my many Adventures in goFinding a useful outlet for my many Adventures in go
Finding a useful outlet for my many Adventures in go
Eleanor McHugh
 
Anonymity, trust, accountability
Anonymity, trust, accountabilityAnonymity, trust, accountability
Anonymity, trust, accountability
Eleanor McHugh
 
Implementing Virtual Machines in Ruby & C
Implementing Virtual Machines in Ruby & CImplementing Virtual Machines in Ruby & C
Implementing Virtual Machines in Ruby & C
Eleanor McHugh
 
Implementing Software Machines in C and Go
Implementing Software Machines in C and GoImplementing Software Machines in C and Go
Implementing Software Machines in C and Go
Eleanor McHugh
 
Implementing Software Machines in Go and C
Implementing Software Machines in Go and CImplementing Software Machines in Go and C
Implementing Software Machines in Go and C
Eleanor McHugh
 
Privacy is always a requirement
Privacy is always a requirementPrivacy is always a requirement
Privacy is always a requirement
Eleanor McHugh
 
Hybrid Cryptography with examples in Ruby and Go
Hybrid Cryptography with examples in Ruby and GoHybrid Cryptography with examples in Ruby and Go
Hybrid Cryptography with examples in Ruby and Go
Eleanor McHugh
 
Go a crash course
Go   a crash courseGo   a crash course
Go a crash course
Eleanor McHugh
 

More from Eleanor McHugh (20)

[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdf[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdf
 
Generics, Reflection, and Efficient Collections
Generics, Reflection, and Efficient CollectionsGenerics, Reflection, and Efficient Collections
Generics, Reflection, and Efficient Collections
 
The Relevance of Liveness - Biometrics and Data Integrity
The Relevance of Liveness - Biometrics and Data IntegrityThe Relevance of Liveness - Biometrics and Data Integrity
The Relevance of Liveness - Biometrics and Data Integrity
 
An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]
 
An introduction to functional programming with go
An introduction to functional programming with goAn introduction to functional programming with go
An introduction to functional programming with go
 
Implementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxImplementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 redux
 
Identity & trust in Monitored Spaces
Identity & trust in Monitored SpacesIdentity & trust in Monitored Spaces
Identity & trust in Monitored Spaces
 
Don't Ask, Don't Tell - The Virtues of Privacy By Design
Don't Ask, Don't Tell - The Virtues of Privacy By DesignDon't Ask, Don't Tell - The Virtues of Privacy By Design
Don't Ask, Don't Tell - The Virtues of Privacy By Design
 
Don't ask, don't tell the virtues of privacy by design
Don't ask, don't tell   the virtues of privacy by designDon't ask, don't tell   the virtues of privacy by design
Don't ask, don't tell the virtues of privacy by design
 
Anonymity, identity, trust
Anonymity, identity, trustAnonymity, identity, trust
Anonymity, identity, trust
 
Going Loopy - Adventures in Iteration with Google Go
Going Loopy - Adventures in Iteration with Google GoGoing Loopy - Adventures in Iteration with Google Go
Going Loopy - Adventures in Iteration with Google Go
 
Distributed Ledgers: Anonymity & Immutability at Scale
Distributed Ledgers: Anonymity & Immutability at ScaleDistributed Ledgers: Anonymity & Immutability at Scale
Distributed Ledgers: Anonymity & Immutability at Scale
 
Finding a useful outlet for my many Adventures in go
Finding a useful outlet for my many Adventures in goFinding a useful outlet for my many Adventures in go
Finding a useful outlet for my many Adventures in go
 
Anonymity, trust, accountability
Anonymity, trust, accountabilityAnonymity, trust, accountability
Anonymity, trust, accountability
 
Implementing Virtual Machines in Ruby & C
Implementing Virtual Machines in Ruby & CImplementing Virtual Machines in Ruby & C
Implementing Virtual Machines in Ruby & C
 
Implementing Software Machines in C and Go
Implementing Software Machines in C and GoImplementing Software Machines in C and Go
Implementing Software Machines in C and Go
 
Implementing Software Machines in Go and C
Implementing Software Machines in Go and CImplementing Software Machines in Go and C
Implementing Software Machines in Go and C
 
Privacy is always a requirement
Privacy is always a requirementPrivacy is always a requirement
Privacy is always a requirement
 
Hybrid Cryptography with examples in Ruby and Go
Hybrid Cryptography with examples in Ruby and GoHybrid Cryptography with examples in Ruby and Go
Hybrid Cryptography with examples in Ruby and Go
 
Go a crash course
Go   a crash courseGo   a crash course
Go a crash course
 

Recently uploaded

Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
Srikant77
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Jay Das
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 

Recently uploaded (20)

Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 

Go for the paranoid network programmer, 3rd edition

  • 1. go for the paranoid network programme r (now with WebSockets ) @feyeleanor 1 go for the paranoid network programmer slideshare.net/feyeleanor
  • 2. twitter://@feyeleanor go for the paranoid network programmer slideshare.net/feyeleanor
  • 3. high voltage networkin g concurrenc y cryptograph y go for the paranoid network programmer slideshare.net/feyeleanor
  • 4. http 4 go for the paranoid network programmer slideshare.net/feyeleanor
  • 5. package mai n import ( . "fmt " "net/http" ) const MESSAGE = "hello world " const ADDRESS = ":1024 " func main() { http.HandleFunc("/hello", Hello ) if e := http.ListenAndServe(ADDRESS, nil); e != nil { Println(e ) } } func Hello(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/plain" ) Fprintf(w, MESSAGE ) } go for the paranoid network programmer slideshare.net/feyeleanor 5
  • 6. package mai n import ( . "fmt " . "net/http" ) const MESSAGE = "hello world " const ADDRESS = ":1024 " func main() { HandleFunc("/hello", Hello ) if e := ListenAndServe(ADDRESS, nil); e != nil { Println(e ) } } func Hello(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain" ) Fprintf(w, MESSAGE ) } go for the paranoid network programmer slideshare.net/feyeleanor 6
  • 7. package mai n import ( . "fmt " . ”net/http " ) const MESSAGE = "hello world " const ADDRESS = ":1024 " func main() { HandleFunc("/hello", Hello ) if e := ListenAndServe(ADDRESS, nil); e != nil { Println(e ) } } func Hello(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain" ) Fprintf(w, MESSAGE ) } go for the paranoid network programmer slideshare.net/feyeleanor 7
  • 8. package mai n import ( . "fmt " . ”net/http " ) const MESSAGE = "hello world " const ADDRESS = ":1024 " func main() { HandleFunc("/hello", Hello ) if e := ListenAndServe(ADDRESS, nil); e != nil { Println(e ) } } func Hello(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain" ) Fprintf(w, MESSAGE ) } go for the paranoid network programmer slideshare.net/feyeleanor 8
  • 9. package mai n import ( . "fmt " . ”net/http " ) const MESSAGE = "hello world " const ADDRESS = ":1024 " func main() { HandleFunc("/hello", Hello ) if e := ListenAndServe(ADDRESS, nil); e != nil { Println(e ) } } func Hello(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, MESSAGE ) } go for the paranoid network programmer slideshare.net/feyeleanor 9
  • 10. package mai n import ( . "fmt " . ”net/http " ) const MESSAGE = "hello world " const ADDRESS = ":1024" func main() { HandleFunc("/hello", Hello ) if e := ListenAndServe(ADDRESS, nil); e != nil { Println(e ) } } func Hello(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain" ) Fprintf(w, MESSAGE ) } go for the paranoid network programmer slideshare.net/feyeleanor 10
  • 11. package mai n import ( . "fmt " . ”net/http " ) const MESSAGE = "hello world " const ADDRESS = ":1024 " func main() { HandleFunc("/hello", Hello ) if e := ListenAndServe(ADDRESS, nil); e != nil { Println(e) } } func Hello(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain" ) Fprintf(w, MESSAGE ) } go for the paranoid network programmer slideshare.net/feyeleanor 11
  • 12. package mai n import ( . "fmt " . "net/http " ) const MESSAGE = "hello world " const ADDRESS = ":1024 " func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain" ) Fprintf(w, MESSAGE ) } ) ListenAndServe(ADDRESS, nil ) } go for the paranoid network programmer slideshare.net/feyeleanor 12
  • 13. package mai n import ( . "fmt " . "net/http " ) const MESSAGE = "hello world " const ADDRESS = ":1024 " func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain" ) Fprintf(w, MESSAGE ) } ) ListenAndServe(ADDRESS, nil ) } go for the paranoid network programmer slideshare.net/feyeleanor 13
  • 14. https 14 go for the paranoid network programmer slideshare.net/feyeleanor
  • 15. package mai n import ( . "fmt " . "net/http " ) const ADDRESS = ":1025 " func main() { message := "hello world " HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain" ) Fprintf(w, message ) } ) ListenAndServeTLS(ADDRESS, "cert.pem", "key.pem", nil ) } go for the paranoid network programmer slideshare.net/feyeleanor 15
  • 16. package mai n import ( . "fmt " . "net/http " ) const ADDRESS = ":1025 " func main() { message := "hello world " HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain" ) Fprintf(w, message ) }) ListenAndServeTLS(ADDRESS, "cert.pem", "key.pem", nil ) } go for the paranoid network programmer slideshare.net/feyeleanor 16
  • 17. package mai n import ( . "fmt " . "net/http " ) const ADDRESS = ":1025 " func main() { message := "hello world" HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain" ) Fprintf(w, message ) } ) ListenAndServeTLS(ADDRESS, "cert.pem", "key.pem", nil ) } go for the paranoid network programmer slideshare.net/feyeleanor 17
  • 18. multiple http servers 18 go for the paranoid network programmer slideshare.net/feyeleanor
  • 19. package mai n import . "fmt " import . "net/http " func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain" ) Fprintf(w, "hello world" ) } ) done := make(chan bool ) go func() { ListenAndServe(":1024", nil ) done <- tru e }( ) ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil ) <- don e } go for the paranoid network programmer slideshare.net/feyeleanor 19
  • 20. package mai n import . "fmt " import . "net/http " func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain" ) Fprintf(w, "hello world" ) } ) done := make(chan bool ) go func() { ListenAndServe(":1024", nil ) done <- tru e }( ) ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil ) <- don e } go for the paranoid network programmer slideshare.net/feyeleanor 20
  • 21. package mai n import . "fmt " import . "net/http " func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain" ) Fprintf(w, "hello world" ) } ) done := make(chan bool ) go func() { ListenAndServe(":1024", nil ) done <- tru e }() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil ) <- don e } go for the paranoid network programmer slideshare.net/feyeleanor 21
  • 22. package mai n import . "fmt " import . "net/http " func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain" ) Fprintf(w, "hello world" ) } ) done := make(chan bool ) go func() { ListenAndServe(":1024", nil ) done <- tru e }() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil ) <- don e } go for the paranoid network programmer slideshare.net/feyeleanor 22
  • 23. package mai n import . "fmt " import . "net/http " func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain" ) Fprintf(w, "hello world" ) } ) done := make(chan bool) go func() { ListenAndServe(":1024", nil ) done <- tru e }() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil ) <- done } go for the paranoid network programmer slideshare.net/feyeleanor 23
  • 24. package mai n import . "fmt " import . "net/http " func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain" ) Fprintf(w, "hello world" ) } ) done := make(chan bool) go func() { ListenAndServe(":1024", nil ) done <- true }() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil ) <- done } go for the paranoid network programmer slideshare.net/feyeleanor 24
  • 25. package mai n import . "fmt " import . "net/http " func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain" ) Fprintf(w, "hello world" ) } ) done := make(chan bool) go func() { ListenAndServe(":1024", nil ) done <- true }() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil ) <- done } go for the paranoid network programmer slideshare.net/feyeleanor 25
  • 26. package mai n import . "fmt " import . "net/http " func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain" ) Fprintf(w, "hello world" ) } ) done := make(chan bool) go func() { ListenAndServe(":1024", nil ) done <- true }() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil ) <- done } go for the paranoid network programmer slideshare.net/feyeleanor 26
  • 27. package mai n import . "fmt " import . "net/http " func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain" ) Fprintf(w, "hello world" ) } ) Spawn ( func() { ListenAndServe(":1024", nil) } , func() { ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil ) } , ) } go for the paranoid network programmer slideshare.net/feyeleanor 27
  • 28. package mai n import . "fmt " import . "net/http " func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain" ) Fprintf(w, "hello world" ) } ) Spawn(func() { ListenAndServe(":1024", nil) } ) Spawn(func() { ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) }) } go for the paranoid network programmer slideshare.net/feyeleanor 28
  • 29. package mai n func Spawn(f ...func()) { done := make(chan bool ) for _, s := range f { go func(server func()) { server( ) done <- tru e }(s ) } for l := len(f); l > 0; l-- { <- don e } } go for the paranoid network programmer slideshare.net/feyeleanor 29
  • 30. package mai n func Spawn(f ...func()) { done := make(chan bool ) for _, s := range f { go func(server func()) { server( ) done <- tru e }(s ) } for l := len(f); l > 0; l-- { <- don e } } go for the paranoid network programmer slideshare.net/feyeleanor 30
  • 31. package mai n func Spawn(f ...func()) { done := make(chan bool ) for _, s := range f { go func(server func()) { server( ) done <- tru e }(s ) } for l := len(f); l > 0; l-- { <- done } } go for the paranoid network programmer slideshare.net/feyeleanor 31
  • 32. package mai n func Spawn(f ...func()) { done := make(chan bool ) for _, s := range f { go func(server func()) { server( ) done <- tru e }(s ) } for _, _ = range f { <- done } } go for the paranoid network programmer slideshare.net/feyeleanor 32
  • 33. package mai n func Spawn(f ...func()) { done := make(chan bool ) for _, s := range f { go func(server func()) { server( ) done <- tru e }(s ) } for range f { <- done } } go for the paranoid network programmer slideshare.net/feyeleanor 33
  • 34. package mai n func Spawn(f ...func()) { done := make(chan bool ) for _, s := range f { go func(server func()) { server( ) done <- tru e }(s ) <- done } } go for the paranoid network programmer slideshare.net/feyeleanor 34
  • 35. package mai n func Spawn(f ...func()) { done := make(chan bool ) for _, s := range f { go func(server func()) { server( ) done <- true }(s ) } for range f { <- done } } go for the paranoid network programmer slideshare.net/feyeleanor 35
  • 36. package mai n func Spawn(f ...func()) { done := make(chan bool ) for _, s := range f { go func(server func()) { server() done <- true }(s) } for range f { <- don e } } go for the paranoid network programmer slideshare.net/feyeleanor 36
  • 37. package mai n func Spawn(f ...func()) { done := make(chan bool ) for _, s := range f { go func(server func()) { server( ) done <- tru e }(s ) } for range f { <- don e } } go for the paranoid network programmer slideshare.net/feyeleanor 37
  • 38. package mai n func Spawn(f ...func()) { done := make(chan bool ) for _, s := range f { go func(server func()) { server() done <- true }(s) } for range f { <- don e } } go for the paranoid network programmer slideshare.net/feyeleanor 38
  • 39. waitgroups 39 go for the paranoid network programmer slideshare.net/feyeleanor
  • 40. package mai n import . "net/http " import "sync " func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) {} ) var servers sync.WaitGrou p servers.Add(1 ) go func() { defer servers.Done( ) ListenAndServe(":1024", nil ) }( ) servers.Add(1 ) go func() { defer servers.Done( ) ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil ) }( ) servers.Wait( ) } go for the paranoid network programmer slideshare.net/feyeleanor 40
  • 41. package mai n import . "net/http " import "sync " func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) {} ) var servers sync.WaitGroup servers.Add(1 ) go func() { defer servers.Done( ) ListenAndServe(":1024", nil ) }( ) servers.Add(1 ) go func() { defer servers.Done( ) ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil ) }( ) servers.Wait( ) } go for the paranoid network programmer slideshare.net/feyeleanor 41
  • 42. package mai n import . "net/http " import "sync " func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) {} ) var servers sync.WaitGrou p servers.Add(1) go func() { defer servers.Done() ListenAndServe(":1024", nil ) }( ) servers.Add(1) go func() { defer servers.Done() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil ) }( ) servers.Wait() } go for the paranoid network programmer slideshare.net/feyeleanor 42
  • 43. package mai n import . "net/http " import "sync " func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) {} ) var servers sync.WaitGroup servers.Add(1) go func() { defer servers.Done() ListenAndServe(":1024", nil ) }() servers.Add(1) go func() { defer servers.Done() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil ) }() servers.Wait() } go for the paranoid network programmer slideshare.net/feyeleanor 43
  • 44. package mai n import ( . "fmt " . "net/http " "sync " ) var servers sync.WaitGrou p func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain" ) Fprintf(w, "hello world" ) } ) Spawn(func() { ListenAndServe(":1024", nil) } ) Spawn(func() { ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil ) } ) servers.Wait( ) } go for the paranoid network programmer slideshare.net/feyeleanor 44
  • 45. package mai n import ( . "fmt " . "net/http " "sync " ) var servers sync.WaitGrou p func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain" ) Fprintf(w, "hello world" ) } ) Spawn(func() { ListenAndServe(":1024", nil) } ) Spawn(func() { ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil ) } ) servers.Wait() } go for the paranoid network programmer slideshare.net/feyeleanor 45
  • 46. package mai n func Spawn(f ...func()) { for _, s := range f { servers.Add(1 ) go func(server func()) { defer servers.Done( ) server( ) }(s ) } } go for the paranoid network programmer slideshare.net/feyeleanor 46
  • 47. package mai n func Spawn(f ...func()) { for _, s := range f { servers.Add(1) go func(server func()) { defer servers.Done() server( ) }(s ) } } go for the paranoid network programmer slideshare.net/feyeleanor 47
  • 48. tcp server 48 go for the paranoid network programmer slideshare.net/feyeleanor
  • 49. package mai n import . "fmt " import "net " func main() { if listener, e := net.Listen("tcp", ":1024"); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c net.Conn) { defer c.Close( ) Fprintln(c, "hello world" ) }(connection ) } } } } go for the paranoid network programmer slideshare.net/feyeleanor 49
  • 50. package mai n import . "fmt " import "net " func main() { if listener, e := net.Listen("tcp", ":1024"); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c net.Conn) { defer c.Close( ) Fprintln(c, "hello world" ) }(connection ) } } } } go for the paranoid network programmer slideshare.net/feyeleanor 50
  • 51. package mai n import . "fmt " import "net " func main() { if listener, e := net.Listen("tcp", ":1024"); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c net.Conn) { defer c.Close( ) Fprintln(c, "hello world" ) }(connection ) } } } } go for the paranoid network programmer slideshare.net/feyeleanor 51
  • 52. package mai n import . "fmt " import "net " func main() { if listener, e := net.Listen("tcp", ":1024"); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c net.Conn) { defer c.Close( ) Fprintln(c, "hello world" ) }(connection ) } } } } go for the paranoid network programmer slideshare.net/feyeleanor 52
  • 53. package mai n import . "fmt " import "net " func main() { Listen("tcp", ":1024", func(c net.Conn) { defer c.Close( ) Fprintln(c, "hello world" ) } ) } func Listen(p, a string, f func(net.Conn)) (e error) { var listener net.Listene r if listener, e = net.Listen(p, a); e == nil { for { if connection, e := listener.Accept(); e == nil { go f(connection ) } } } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 53
  • 54. package mai n import . "fmt " import "net " func main() { Listen("tcp", ":1024", func(c net.Conn) { defer c.Close( ) Fprintln(c, "hello world" ) } ) } func Listen(p, a string, f func(net.Conn)) (e error) { var listener net.Listene r if listener, e = net.Listen(p, a); e == nil { for { if connection, e := listener.Accept(); e == nil { go f(connection ) } } } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 54
  • 55. package mai n import . "fmt " import "net " func main() { Listen("tcp", ":1024", func(c net.Conn) { defer c.Close( ) Fprintln(c, "hello world" ) } ) } func Listen(p, a string, f func(net.Conn)) (e error) { var listener net.Listener if listener, e = net.Listen(p, a); e == nil { for { if connection, e := listener.Accept(); e == nil { go f(connection ) } } } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 55
  • 56. package mai n import . "fmt " import "net " func main() { Listen("tcp", ":1024", func(c net.Conn) { defer c.Close( ) Fprintln(c, "hello world" ) } ) } func Listen(p, a string, f func(net.Conn)) (e error) { var listener net.Listener if listener, e = net.Listen(p, a); e == nil { for { if connection, e := listener.Accept(); e == nil { go f(connection ) } } } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 56
  • 57. tcp client 57 go for the paranoid network programmer slideshare.net/feyeleanor
  • 58. package mai n import "bufio " import . "fmt " import "net " func main() { if c, e := net.Dial("tcp", ":1024"); e == nil { defer c.Close( ) if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m ) } } } go for the paranoid network programmer slideshare.net/feyeleanor 58
  • 59. package mai n import "bufio " import . "fmt " import "net " func main() { if c, e := net.Dial("tcp", ":1024"); e == nil { defer c.Close() if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m ) } } } go for the paranoid network programmer slideshare.net/feyeleanor 59
  • 60. package mai n import "bufio " import . "fmt " import "net " func main() { if c, e := net.Dial("tcp", ":1024"); e == nil { defer c.Close( ) if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m ) } } } go for the paranoid network programmer slideshare.net/feyeleanor 60
  • 61. package mai n import "bufio " import . "fmt " import "net " func main() { if c, e := net.Dial("tcp", ":1024"); e == nil { defer c.Close( ) if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m ) } } } go for the paranoid network programmer slideshare.net/feyeleanor 61
  • 62. package mai n import "bufio " import . "fmt " import "net " func main() { if c, e := net.Dial("tcp", ":1024"); e == nil { defer c.Close( ) if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m ) } } } go for the paranoid network programmer slideshare.net/feyeleanor 62
  • 63. package mai n import "bufio " import . "fmt " import "net " func main() { Dial("tcp", ":1024", func(c net.Conn) { if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m ) } } ) } func Dial(p, a string, f func(net.Conn)) (e error) { var c net.Con n if c, e = net.Dial(p, a); e == nil { defer c.Close( ) f(c ) } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 63
  • 64. package mai n import "bufio " import . "fmt " import "net " func main() { Dial("tcp", ":1024", func(c net.Conn) { if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m ) } } ) } func Dial(p, a string, f func(net.Conn)) (e error) { var c net.Con n if c, e = net.Dial(p, a); e == nil { defer c.Close( ) f(c ) } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 64
  • 65. package mai n import "bufio " import . "fmt " import "net " func main() { Dial("tcp", ":1024", func(c net.Conn) { if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m ) } } ) } func Dial(p, a string, f func(net.Conn)) (e error) { var c net.Con n if c, e = net.Dial(p, a); e == nil { defer c.Close() f(c ) } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 65
  • 66. tcp/tls server 66 go for the paranoid network programmer slideshare.net/feyeleanor
  • 67. package mai n import "crypto/rand " import "crypto/tls " import . "fmt " func main() { Listen(":1025", ConfigTLS("scert", "skey"), func(c *tls.Conn) { Fprintln(c, "hello world" ) } ) } func ConfigTLS(c, k string) (r *tls.Config) { if cert, e := tls.LoadX509KeyPair(c, k); e == nil { r = &tls.Config { Certificates: []tls.Certificate{ cert } , Rand: rand.Reader , } } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 67
  • 68. package mai n import "crypto/rand " import "crypto/tls " import . "fmt " func main() { Listen(":1025", ConfigTLS("scert", "skey"), func(c *tls.Conn) { Fprintln(c, "hello world" ) } ) } func ConfigTLS(c, k string) (r *tls.Config) { if cert, e := tls.LoadX509KeyPair(c, k); e == nil { r = &tls.Config { Certificates: []tls.Certificate{ cert } , Rand: rand.Reader , } } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 68
  • 69. package mai n import "crypto/rand " import "crypto/tls " import . "fmt " func main() { Listen(":1025", ConfigTLS("scert", "skey"), func(c *tls.Conn) { Fprintln(c, "hello world" ) } ) } func ConfigTLS(c, k string) (r *tls.Config) { if cert, e := tls.LoadX509KeyPair(c, k); e == nil { r = &tls.Config { Certificates: []tls.Certificate{ cert } , Rand: rand.Reader , } } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 69
  • 70. package mai n import "crypto/rand " import "crypto/tls " import . "fmt " func main() { Listen(":1025", ConfigTLS("scert", "skey"), func(c *tls.Conn) { Fprintln(c, "hello world" ) } ) } func ConfigTLS(c, k string) (r *tls.Config) { if cert, e := tls.LoadX509KeyPair(c, k); e == nil { r = &tls.Config{ Certificates: []tls.Certificate{ cert } , Rand: rand.Reader , } } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 70
  • 71. package mai n import "crypto/rand " import "crypto/tls " import . "fmt " func main() { Listen(":1025", ConfigTLS("scert", "skey"), func(c *tls.Conn) { Fprintln(c, "hello world" ) } ) } func ConfigTLS(c, k string) (r *tls.Config) { if cert, e := tls.LoadX509KeyPair(c, k); e == nil { r = &tls.Config{ Certificates: []tls.Certificate{ cert } , Rand: rand.Reader , } } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 71
  • 72. package mai n import "crypto/tls " func Listen(a string, conf *tls.Config, f func(*tls.Conn)) { if listener, e := tls.Listen("tcp", a, conf); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c *tls.Conn) { defer c.Close( ) f(c ) }(connection.(*tls.Conn) ) } } } } go for the paranoid network programmer slideshare.net/feyeleanor 72
  • 73. package mai n import "crypto/tls " func Listen(a string, conf *tls.Config, f func(*tls.Conn)) { if listener, e := tls.Listen("tcp", a, conf); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c *tls.Conn) { defer c.Close( ) f(c ) }(connection.(*tls.Conn) ) } } } } go for the paranoid network programmer slideshare.net/feyeleanor 73
  • 74. package mai n import "crypto/tls " func Listen(a string, conf *tls.Config, f func(*tls.Conn)) { if listener, e := tls.Listen("tcp", a, conf); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c *tls.Conn) { defer c.Close( ) f(c ) }(connection.(*tls.Conn) ) } } } } go for the paranoid network programmer slideshare.net/feyeleanor 74
  • 75. package mai n import "crypto/tls " func Listen(a string, conf *tls.Config, f func(*tls.Conn)) { if listener, e := tls.Listen("tcp", a, conf); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c *tls.Conn) { defer c.Close( ) f(c ) }(connection.(*tls.Conn) ) } } } } go for the paranoid network programmer slideshare.net/feyeleanor 75
  • 76. package mai n import "crypto/tls " func Listen(a string, conf *tls.Config, f func(*tls.Conn)) { if listener, e := tls.Listen("tcp", a, conf); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c *tls.Conn) { defer c.Close( ) f(c ) }(connection.(*tls.Conn) ) } } } } go for the paranoid network programmer slideshare.net/feyeleanor 76
  • 77. package mai n import "crypto/tls " func Listen(a string, conf *tls.Config, f func(*tls.Conn)) { if listener, e := tls.Listen("tcp", a, conf); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c *tls.Conn) { defer c.Close( ) f(c ) }(connection.(*tls.Conn) ) } } } } go for the paranoid network programmer slideshare.net/feyeleanor 77
  • 78. package mai n import "crypto/tls " import "net " func Listen(a string, conf *tls.Config, f func(net.Conn)) { if listener, e := tls.Listen("tcp", a, conf); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c net.Conn) { defer c.Close( ) f(c ) }(connection ) } } } } go for the paranoid network programmer slideshare.net/feyeleanor 78
  • 79. package mai n import "crypto/tls " import "net " func Listen(a string, conf *tls.Config, f func(net.Conn)) { if listener, e := tls.Listen("tcp", a, conf); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c net.Conn) { defer c.Close( ) f(c ) }(connection ) } } } } go for the paranoid network programmer slideshare.net/feyeleanor 79
  • 80. package mai n import "crypto/tls " import "net " func Listen(a string, conf *tls.Config, f func(net.Conn)) { if listener, e := tls.Listen("tcp", a, conf); e == nil { for { if c, e := listener.Accept(); e == nil { go Handle(c, f ) } } } } func Handle(c net.Conn, f func(net.Conn)) { defer c.Close( ) f(c ) } go for the paranoid network programmer slideshare.net/feyeleanor 80
  • 81. tcp/tls client 81 go for the paranoid network programmer slideshare.net/feyeleanor
  • 82. package mai n import "bufio " import "crypto/tls " import . "fmt " import "net " func main() { Dial(":1025", ConfigTLS("ccert", "ckey"), func(c net.Conn) { if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m ) } } ) } func ConfigTLS(c, k string) (r *tls.Config) { if cert, e := tls.LoadX509KeyPair(c, k); e == nil { r = &tls.Config { Certificates: []tls.Certificate{ cert } , InsecureSkipVerify: true , } } go for the paranoid network programmer slideshare.net/feyeleanor 82
  • 83. package mai n import "bufio " import "crypto/tls " import . "fmt " import "net " func main() { Dial(":1025", ConfigTLS("ccert", "ckey"), func(c net.Conn) { if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m ) } } ) } func ConfigTLS(c, k string) (r *tls.Config) { if cert, e := tls.LoadX509KeyPair(c, k); e == nil { r = &tls.Config { Certificates: []tls.Certificate{ cert } , InsecureSkipVerify: true , } } go for the paranoid network programmer slideshare.net/feyeleanor 83
  • 84. package mai n import "bufio " import "crypto/tls " import . "fmt " import "net " func main() { Dial(":1025", ConfigTLS("ccert", "ckey"), func(c net.Conn) { if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m ) } } ) } func ConfigTLS(c, k string) (r *tls.Config) { if cert, e := tls.LoadX509KeyPair(c, k); e == nil { r = &tls.Config { Certificates: []tls.Certificate{ cert } , InsecureSkipVerify: true , } } go for the paranoid network programmer slideshare.net/feyeleanor 84
  • 85. package mai n import "bufio " import "crypto/tls " import . "fmt " import "net " func main() { Dial(":1025", ConfigTLS("ccert", "ckey"), func(c net.Conn) { if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m ) } } ) } func ConfigTLS(c, k string) (r *tls.Config) { if cert, e := tls.LoadX509KeyPair(c, k); e == nil { r = &tls.Config{ Certificates: []tls.Certificate{ cert } , InsecureSkipVerify: true , } } go for the paranoid network programmer slideshare.net/feyeleanor 85
  • 86. package mai n import "bufio " import "crypto/tls " import . "fmt " import "net " func main() { Dial(":1025", ConfigTLS("ccert", "ckey"), func(c net.Conn) { if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m ) } } ) } func ConfigTLS(c, k string) (r *tls.Config) { if cert, e := tls.LoadX509KeyPair(c, k); e == nil { r = &tls.Config{ Certificates: []tls.Certificate{ cert } , InsecureSkipVerify: true , } } go for the paranoid network programmer slideshare.net/feyeleanor 86
  • 87. package mai n import "bufio " import "crypto/tls " import . "fmt " import "net " func main() { Dial(":1025", ConfigTLS("ccert", "ckey"), func(c net.Conn) { if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m ) } } ) } func Dial(a string, conf *tls.Config, f func(net.Conn)) { if c, e := tls.Dial("tcp", a, conf); e == nil { defer c.Close( ) f(c ) } } go for the paranoid network programmer slideshare.net/feyeleanor 87
  • 88. package mai n import "bufio " import "crypto/tls " import . "fmt " import "net " func main() { Dial(":1025", ConfigTLS("ccert", "ckey"), func(c net.Conn) { if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m ) } } ) } func Dial(a string, conf *tls.Config, f func(net.Conn)) { if c, e := tls.Dial("tcp", a, conf); e == nil { defer c.Close( ) f(c ) } } go for the paranoid network programmer slideshare.net/feyeleanor 88
  • 89. udp serve 89 go for the paranoid network programmer slideshare.net/feyeleanor
  • 90. package mai n import "net " func main() { HELLO_WORLD := []byte("Hello Worldn" ) Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { c.WriteToUDP(HELLO_WORLD, a ) } ) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := conn.ReadFromUDP(b); e == nil { go f(conn, client, b[:n] ) } } } } } go for the paranoid network programmer slideshare.net/feyeleanor 90
  • 91. package mai n import "net " func main() { HELLO_WORLD := []byte("Hello Worldn" ) Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { c.WriteToUDP(HELLO_WORLD, a ) } ) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := conn.ReadFromUDP(b); e == nil { go f(conn, client, b[:n] ) } } } } } go for the paranoid network programmer slideshare.net/feyeleanor 91
  • 92. package mai n import "net " func main() { HELLO_WORLD := []byte("Hello Worldn" ) Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { c.WriteToUDP(HELLO_WORLD, a ) } ) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := conn.ReadFromUDP(b); e == nil { go f(conn, client, b[:n] ) } } } } } go for the paranoid network programmer slideshare.net/feyeleanor 92
  • 93. package mai n import "net " func main() { HELLO_WORLD := []byte("Hello Worldn" ) Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { c.WriteToUDP(HELLO_WORLD, a ) } ) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := conn.ReadFromUDP(b); e == nil { go f(conn, client, b[:n] ) } } } } } go for the paranoid network programmer slideshare.net/feyeleanor 93
  • 94. package mai n import "net " func main() { HELLO_WORLD := []byte("Hello Worldn" ) Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { c.WriteToUDP(HELLO_WORLD, a ) } ) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := conn.ReadFromUDP(b); e == nil { go f(conn, client, b[:n] ) } } } } } go for the paranoid network programmer slideshare.net/feyeleanor 94
  • 95. package mai n import "net " func main() { HELLO_WORLD := []byte("Hello Worldn" ) Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { c.WriteToUDP(HELLO_WORLD, a ) } ) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := conn.ReadFromUDP(b); e == nil { go f(conn, client, b[:n] ) } } } } } go for the paranoid network programmer slideshare.net/feyeleanor 95
  • 96. package mai n import "net " func main() { HELLO_WORLD := []byte("Hello Worldn" ) Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { c.WriteToUDP(HELLO_WORLD, a ) } ) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := conn.ReadFromUDP(b); e == nil { go f(conn, client, b[:n] ) } } } } } go for the paranoid network programmer slideshare.net/feyeleanor 96
  • 97. package mai n import "net " func main() { HELLO_WORLD := []byte("Hello Worldn" ) Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { c.WriteToUDP(HELLO_WORLD, a ) } ) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := conn.ReadFromUDP(b); e == nil { go f(conn, client, b[:n] ) } } } } } go for the paranoid network programmer slideshare.net/feyeleanor 97
  • 98. package mai n import "net " func main() { HELLO_WORLD := []byte("Hello Worldn" ) Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { c.WriteToUDP(HELLO_WORLD, a ) } ) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := conn.ReadFromUDP(b); e == nil { go f(conn, client, b[:n] ) } } } } } go for the paranoid network programmer slideshare.net/feyeleanor 98
  • 99. package mai n import "net " func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { ServeUDP(conn, func(c *net.UDPAddr, b []byte) { f(conn, c, b ) }) } } } func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte)) { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := c.ReadFromUDP(b); e == nil { go f(client, b[:n] ) } } } go for the paranoid network programmer slideshare.net/feyeleanor 99
  • 100. package mai n import "net " func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { ServeUDP(conn, func(c *net.UDPAddr, b []byte) { f(conn, c, b ) }) } } } func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte)) { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := c.ReadFromUDP(b); e == nil { go f(client, b[:n] ) } } } go for the paranoid network programmer slideshare.net/feyeleanor 100
  • 101. package mai n import "net " func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { ServeUDP(conn, func(c *net.UDPAddr, b []byte) { f(conn, c, b ) }) } } } func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte)) { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := c.ReadFromUDP(b); e == nil { go f(client, b[:n] ) } } } go for the paranoid network programmer slideshare.net/feyeleanor 101
  • 102. package mai n import "net " func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { ServeUDP(conn, func(c *net.UDPAddr, b []byte) { f(conn, c, b ) }) } } } func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte)) { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := c.ReadFromUDP(b); e == nil { go f(client, b[:n] ) } } } go for the paranoid network programmer slideshare.net/feyeleanor 102
  • 103. package mai n import "net " func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { ServeUDP(conn, func(c *net.UDPAddr, b []byte) { f(conn, c, b ) }) } } } func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte)) { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := c.ReadFromUDP(b); e == nil { go f(client, b[:n] ) } } } go for the paranoid network programmer slideshare.net/feyeleanor 103
  • 104. package mai n import "net " func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { ServeUDP(conn, func(c *net.UDPAddr, b []byte) { f(conn, c, b ) }) } } } func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte)) { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := c.ReadFromUDP(b); e == nil { go f(client, b[:n] ) } } } go for the paranoid network programmer slideshare.net/feyeleanor 104
  • 105. package mai n import "net " func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { ServeUDP(conn, func(c *net.UDPAddr, b []byte) { f(conn, c, b ) }) } } } func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte)) { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := c.ReadFromUDP(b); e == nil { go f(client, b[:n] ) } } } go for the paranoid network programmer slideshare.net/feyeleanor 105
  • 106. udp request 106 go for the paranoid network programmer slideshare.net/feyeleanor
  • 107. package mai n import "bufio " import . "fmt " import "net " func main() { Dial(":1024", func(conn net.Conn) { if _, e := conn.Write([]byte("n")); e == nil { if m, e := bufio.NewReader(conn).ReadString('n'); e == nil { Printf("%v", m ) } } } ) } func Dial(a string, f func(net.Conn)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close( ) f(conn ) } go for the paranoid network programmer slideshare.net/feyeleanor 107
  • 108. package mai n import "bufio " import . "fmt " import "net " func main() { Dial(":1024", func(conn net.Conn) { if _, e := conn.Write([]byte("n")); e == nil { if m, e := bufio.NewReader(conn).ReadString('n'); e == nil { Printf("%v", m ) } } } ) } func Dial(a string, f func(net.Conn)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close( ) f(conn ) } go for the paranoid network programmer slideshare.net/feyeleanor 108
  • 109. package mai n import "bufio " import . "fmt " import "net " func main() { Dial(":1024", func(conn net.Conn) { if _, e := conn.Write([]byte("n")); e == nil { if m, e := bufio.NewReader(conn).ReadString('n'); e == nil { Printf("%v", m ) } } } ) } func Dial(a string, f func(net.Conn)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close( ) f(conn ) } go for the paranoid network programmer slideshare.net/feyeleanor 109
  • 110. package mai n import "bufio " import . "fmt " import "net " func main() { Dial(":1024", func(conn net.Conn) { if _, e := conn.Write([]byte("n")); e == nil { if m, e := bufio.NewReader(conn).ReadString('n'); e == nil { Printf("%v", m ) } } } ) } func Dial(a string, f func(net.Conn)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close( ) f(conn ) } go for the paranoid network programmer slideshare.net/feyeleanor 110
  • 111. package mai n import "bufio " import . "fmt " import "net " func main() { Dial(":1024", func(conn net.Conn) { if _, e := conn.Write([]byte("n")); e == nil { if m, e := bufio.NewReader(conn).ReadString('n'); e == nil { Printf("%v", m ) } } } ) } func Dial(a string, f func(net.Conn)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close( ) f(conn ) } go for the paranoid network programmer slideshare.net/feyeleanor 111
  • 112. package mai n import "bufio " import . "fmt " import "net " func main() { Dial(":1024", func(conn net.Conn) { if _, e := conn.Write([]byte("n")); e == nil { if m, e := bufio.NewReader(conn).ReadString('n'); e == nil { Printf("%v", m ) } } } ) } func Dial(a string, f func(net.Conn)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close( ) f(conn ) } go for the paranoid network programmer slideshare.net/feyeleanor 112
  • 113. aes encrypt 113 go for the paranoid network programmer slideshare.net/feyeleanor
  • 114. go for the paranoid network programmer slideshare.net/feyeleanor 114 package mai n import "net " const AES_KEY = "0123456789012345 " func main() { Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { if m, e := Encrypt("Hello World", AES_KEY); e == nil { c.WriteToUDP(m, a ) } } ) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { // see udp serv e } func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte)) { // see udp serv e }
  • 115. go for the paranoid network programmer slideshare.net/feyeleanor 115 package mai n import "net " const AES_KEY = "0123456789012345" func main() { Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { if m, e := Encrypt("Hello World", AES_KEY); e == nil { c.WriteToUDP(m, a ) } } ) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { // see udp serv e } func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte)) { // see udp serv e }
  • 116. go for the paranoid network programmer slideshare.net/feyeleanor 116 package mai n import "net " const AES_KEY = "0123456789012345" func main() { Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { if m, e := Encrypt("Hello World", AES_KEY); e == nil { c.WriteToUDP(m, a ) } } ) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { // see udp serv e } func ServeUDP(c *net.UDPConn, f func(*net.UDPAddr, []byte)) { // see udp serv e }
  • 117. package mai n import "crypto/aes " import "crypto/cipher " func Encrypt(m, k string) (o []byte, e error) { if o, e = PaddedBuffer([]byte(m)); e == nil { var b cipher.Bloc k if b, e = aes.NewCipher([]byte(k)); e == nil { o = CryptBlocks(o, b ) } } retur n } func PaddedBuffer(m []byte) (b []byte, e error) { b = append(b, m... ) if p := len(b) % aes.BlockSize; p != 0 { p = aes.BlockSize - p b = append(b, make([]byte, p)…) // padding with NUL!!! ! } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 117
  • 118. package mai n import "crypto/aes " import "crypto/cipher " func Encrypt(m, k string) (o []byte, e error) { if o, e = PaddedBuffer([]byte(m)); e == nil { var b cipher.Bloc k if b, e = aes.NewCipher([]byte(k)); e == nil { o = CryptBlocks(o, b ) } } retur n } func PaddedBuffer(m []byte) (b []byte, e error) { b = append(b, m... ) if p := len(b) % aes.BlockSize; p != 0 { p = aes.BlockSize - p b = append(b, make([]byte, p)…) // padding with NUL!!! ! } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 118
  • 119. package mai n import "crypto/aes " import "crypto/cipher " func Encrypt(m, k string) (o []byte, e error) { if o, e = PaddedBuffer([]byte(m)); e == nil { var b cipher.Bloc k if b, e = aes.NewCipher([]byte(k)); e == nil { o = CryptBlocks(o, b ) } } retur n } func PaddedBuffer(m []byte) (b []byte, e error) { b = append(b, m... ) if p := len(b) % aes.BlockSize; p != 0 { p = aes.BlockSize - p b = append(b, make([]byte, p)…) // padding with NUL!!! ! } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 119
  • 120. package mai n import "crypto/aes " import "crypto/cipher " func Encrypt(m, k string) (o []byte, e error) { if o, e = PaddedBuffer([]byte(m)); e == nil { var b cipher.Bloc k if b, e = aes.NewCipher([]byte(k)); e == nil { o = CryptBlocks(o, b ) } } retur n } func PaddedBuffer(m []byte) (b []byte, e error) { b = append(b, m... ) if p := len(b) % aes.BlockSize; p != 0 { p = aes.BlockSize - p b = append(b, make([]byte, p)…) // padding with NUL!!! ! } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 120
  • 121. package mai n import "crypto/aes " import "crypto/cipher " func Encrypt(m, k string) (o []byte, e error) { if o, e = PaddedBuffer([]byte(m)); e == nil { var b cipher.Bloc k if b, e = aes.NewCipher([]byte(k)); e == nil { o = CryptBlocks(o, b ) } } retur n } func PaddedBuffer(m []byte) (b []byte, e error) { b = append(b, m... ) if p := len(b) % aes.BlockSize; p != 0 { p = aes.BlockSize - p b = append(b, make([]byte, p)…) // padding with NUL!!! ! } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 121
  • 122. package mai n import "crypto/aes " import "crypto/cipher " func Encrypt(m, k string) (o []byte, e error) { if o, e = PaddedBuffer([]byte(m)); e == nil { var b cipher.Bloc k if b, e = aes.NewCipher([]byte(k)); e == nil { o = CryptBlocks(o, b ) } } retur n } func PaddedBuffer(m []byte) (b []byte, e error) { b = append(b, m... ) if p := len(b) % aes.BlockSize; p != 0 { p = aes.BlockSize - p b = append(b, make([]byte, p)...) // padding with NUL!!! ! } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 122
  • 123. package mai n import "crypto/aes " import "crypto/cipher " func Encrypt(m, k string) (o []byte, e error) { if o, e = PaddedBuffer([]byte(m)); e == nil { var b cipher.Bloc k if b, e = aes.NewCipher([]byte(k)); e == nil { o = CryptBlocks(o, b ) } } retur n } func PaddedBuffer(m []byte) (b []byte, e error) { b = append(b, m... ) if p := len(b) % aes.BlockSize; p != 0 { p = aes.BlockSize - p b = append(b, make([]byte, p)...) // padding with NUL!!!! } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 123
  • 124. package mai n import "crypto/aes " import "crypto/cipher " func Encrypt(m, k string) (o []byte, e error) { if o, e = PaddedBuffer([]byte(m)); e == nil { var b cipher.Block if b, e = aes.NewCipher([]byte(k)); e == nil { o = CryptBlocks(o, b ) } } retur n } func PaddedBuffer(m []byte) (b []byte, e error) { b = append(b, m... ) if p := len(b) % aes.BlockSize; p != 0 { p = aes.BlockSize - p b = append(b, make([]byte, p)...) // padding with NUL!!! ! } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 124
  • 125. package mai n import "crypto/aes " import "crypto/cipher " func Encrypt(m, k string) (o []byte, e error) { if o, e = PaddedBuffer([]byte(m)); e == nil { var b cipher.Block if b, e = aes.NewCipher([]byte(k)); e == nil { o = CryptBlocks(o, b ) } } retur n } func PaddedBuffer(m []byte) (b []byte, e error) { b = append(b, m... ) if p := len(b) % aes.BlockSize; p != 0 { p = aes.BlockSize - p b = append(b, make([]byte, p)...) // padding with NUL!!! ! } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 125
  • 126. package mai n import "crypto/aes " import "crypto/cipher " func CryptBlocks(b []byte, c cipher.Block) (o []byte) { o = make([]byte, aes.BlockSize + len(b) ) copy(o, IV() ) enc := cipher.NewCBCEncrypter(c, o[:aes.BlockSize] ) enc.CryptBlocks(o[aes.BlockSize:], b ) retur n } func IV() (b []byte) { b = make([]byte, aes.BlockSize ) if _, e := rand.Read(b); e != nil { panic(e ) } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 126
  • 127. package mai n import "crypto/aes " import "crypto/cipher " func CryptBlocks(b []byte, c cipher.Block) (o []byte) { o = make([]byte, aes.BlockSize + len(b) ) copy(o, IV() ) enc := cipher.NewCBCEncrypter(c, o[:aes.BlockSize] ) enc.CryptBlocks(o[aes.BlockSize:], b ) retur n } func IV() (b []byte) { b = make([]byte, aes.BlockSize ) if _, e := rand.Read(b); e != nil { panic(e ) } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 127
  • 128. package mai n import "crypto/aes " import "crypto/cipher " func CryptBlocks(b []byte, c cipher.Block) (o []byte) { o = make([]byte, aes.BlockSize + len(b) ) copy(o, IV() ) enc := cipher.NewCBCEncrypter(c, o[:aes.BlockSize] ) enc.CryptBlocks(o[aes.BlockSize:], b ) retur n } func IV() (b []byte) { b = make([]byte, aes.BlockSize ) if _, e := rand.Read(b); e != nil { panic(e ) } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 128
  • 129. package mai n import "crypto/aes " import "crypto/cipher " func CryptBlocks(b []byte, c cipher.Block) (o []byte) { o = make([]byte, aes.BlockSize + len(b) ) copy(o, IV() ) enc := cipher.NewCBCEncrypter(c, o[:aes.BlockSize] ) enc.CryptBlocks(o[aes.BlockSize:], b ) retur n } func IV() (b []byte) { b = make([]byte, aes.BlockSize ) if _, e := rand.Read(b); e != nil { panic(e ) } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 129
  • 130. package mai n import "crypto/aes " import "crypto/cipher " func CryptBlocks(b []byte, c cipher.Block) (o []byte) { o = make([]byte, aes.BlockSize + len(b) ) copy(o, IV() ) enc := cipher.NewCBCEncrypter(c, o[:aes.BlockSize] ) enc.CryptBlocks(o[aes.BlockSize:], b ) retur n } func IV() (b []byte) { b = make([]byte, aes.BlockSize ) if _, e := rand.Read(b); e != nil { panic(e ) } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 130
  • 131. package mai n import "crypto/aes " import "crypto/cipher " func CryptBlocks(b []byte, c cipher.Block) (o []byte) { o = make([]byte, aes.BlockSize + len(b) ) copy(o, IV() ) enc := cipher.NewCBCEncrypter(c, o[:aes.BlockSize] ) enc.CryptBlocks(o[aes.BlockSize:], b ) retur n } func IV() (b []byte) { b = make([]byte, aes.BlockSize ) if _, e := rand.Read(b); e != nil { panic(e ) } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 131
  • 132. package mai n import "crypto/aes " import "crypto/cipher " func CryptBlocks(b []byte, c cipher.Block) (o []byte) { o = make([]byte, aes.BlockSize + len(b) ) copy(o, IV() ) enc := cipher.NewCBCEncrypter(c, o[:aes.BlockSize] ) enc.CryptBlocks(o[aes.BlockSize:], b ) retur n } func IV() (b []byte) { b = make([]byte, aes.BlockSize ) if _, e := rand.Read(b); e != nil { panic(e ) } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 132
  • 133. package mai n import "crypto/aes " import "crypto/cipher " func CryptBlocks(b []byte, c cipher.Block) (o []byte) { o = make([]byte, aes.BlockSize + len(b) ) copy(o, IV() ) enc := cipher.NewCBCEncrypter(c, o[:aes.BlockSize] ) enc.CryptBlocks(o[aes.BlockSize:], b ) retur n } func IV() (b []byte) { b = make([]byte, aes.BlockSize ) if _, e := rand.Read(b); e != nil { panic(e ) } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 133
  • 134. aes decrypt 134 go for the paranoid network programmer slideshare.net/feyeleanor
  • 135. package mai n import . "fmt " import "net " const AES_KEY = "0123456789012345 " func main() { Dial(":1025", func(conn net.Conn) { RequestMessage(conn, func(m []byte) { if m, e := Decrypt(m, AES_KEY); e == nil { Printf("%sn", m ) } } ) } ) } func Dial(a string, f func(net.Conn)) { // see udp reques t } go for the paranoid network programmer slideshare.net/feyeleanor 135
  • 136. package mai n import . "fmt " import "net " const AES_KEY = "0123456789012345 " func main() { Dial(":1025", func(conn net.Conn) { RequestMessage(conn, func(m []byte) { if m, e := Decrypt(m, AES_KEY); e == nil { Printf("%sn", m ) } } ) } ) } func Dial(a string, f func(net.Conn)) { // see udp reques t } go for the paranoid network programmer slideshare.net/feyeleanor 136
  • 137. package mai n import . "fmt " import "net " const AES_KEY = "0123456789012345" func main() { Dial(":1025", func(conn net.Conn) { RequestMessage(conn, func(m []byte) { if m, e := Decrypt(m, AES_KEY); e == nil { Printf("%sn", m ) } } ) } ) } func Dial(a string, f func(net.Conn)) { // see udp reques t } go for the paranoid network programmer slideshare.net/feyeleanor 137
  • 138. package mai n import "net " func RequestMessage(conn net.Conn, f func([]byte)) (e error) { if _, e = conn.Write([]byte("n")); e == nil { m := make([]byte, 1024 ) var n in t if n, e = conn.Read(m); e == nil { f(m[:n] ) } } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 138
  • 139. package mai n import "net " func RequestMessage(conn net.Conn, f func([]byte)) (e error) { if _, e = conn.Write([]byte("n")); e == nil { m := make([]byte, 1024 ) var n in t if n, e = conn.Read(m); e == nil { f(m[:n] ) } } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 139
  • 140. package mai n import "net " func RequestMessage(conn net.Conn, f func([]byte)) (e error) { if _, e = conn.Write([]byte("n")); e == nil { m := make([]byte, 1024 ) var n in t if n, e = conn.Read(m); e == nil { f(m[:n] ) } } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 140
  • 141. package mai n import "net " func RequestMessage(conn net.Conn, f func([]byte)) (e error) { if _, e = conn.Write([]byte("n")); e == nil { m := make([]byte, 1024 ) var n in t if n, e = conn.Read(m); e == nil { f(m[:n] ) } } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 141
  • 142. package mai n import "net " func RequestMessage(conn net.Conn, f func([]byte)) (e error) { if _, e = conn.Write([]byte("n")); e == nil { m := make([]byte, 1024 ) var n in t if n, e = conn.Read(m); e == nil { f(m[:n] ) } } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 142
  • 143. package mai n import "crypto/cipher " import "crypto/aes " func Decrypt(m []byte, k string) (r []byte, e error) { var b cipher.Bloc k if b, e = aes.NewCipher([]byte(k)); e == nil { var iv []byt e iv, m = Unpack(m ) c := cipher.NewCBCDecrypter(b, iv ) r = make([]byte, len(m) ) c.CryptBlocks(r, m ) } retur n } func Unpack(m []byte) (iv, r []byte) { return m[:aes.BlockSize], m[aes.BlockSize: ] } go for the paranoid network programmer slideshare.net/feyeleanor 143
  • 144. package mai n import "crypto/cipher " import "crypto/aes " func Decrypt(m []byte, k string) (r []byte, e error) { var b cipher.Bloc k if b, e = aes.NewCipher([]byte(k)); e == nil { var iv []byt e iv, m = Unpack(m ) c := cipher.NewCBCDecrypter(b, iv ) r = make([]byte, len(m) ) c.CryptBlocks(r, m ) } retur n } func Unpack(m []byte) (iv, r []byte) { return m[:aes.BlockSize], m[aes.BlockSize: ] } go for the paranoid network programmer slideshare.net/feyeleanor 144
  • 145. package mai n import "crypto/cipher " import "crypto/aes " func Decrypt(m []byte, k string) (r []byte, e error) { var b cipher.Bloc k if b, e = aes.NewCipher([]byte(k)); e == nil { var iv []byt e iv, m = Unpack(m ) c := cipher.NewCBCDecrypter(b, iv ) r = make([]byte, len(m) ) c.CryptBlocks(r, m ) } retur n } func Unpack(m []byte) (iv, r []byte) { return m[:aes.BlockSize], m[aes.BlockSize: ] } go for the paranoid network programmer slideshare.net/feyeleanor 145
  • 146. package mai n import "crypto/cipher " import "crypto/aes " func Decrypt(m []byte, k string) (r []byte, e error) { var b cipher.Bloc k if b, e = aes.NewCipher([]byte(k)); e == nil { var iv []byt e iv, m = Unpack(m ) c := cipher.NewCBCDecrypter(b, iv ) r = make([]byte, len(m) ) c.CryptBlocks(r, m ) } retur n } func Unpack(m []byte) (iv, r []byte) { return m[:aes.BlockSize], m[aes.BlockSize: ] } go for the paranoid network programmer slideshare.net/feyeleanor 146
  • 147. package mai n import "crypto/cipher " import "crypto/aes " func Decrypt(m []byte, k string) (r []byte, e error) { var b cipher.Bloc k if b, e = aes.NewCipher([]byte(k)); e == nil { var iv []byt e iv, m = Unpack(m ) c := cipher.NewCBCDecrypter(b, iv ) r = make([]byte, len(m) ) c.CryptBlocks(r, m ) } retur n } func Unpack(m []byte) (iv, r []byte) { return m[:aes.BlockSize], m[aes.BlockSize: ] } go for the paranoid network programmer slideshare.net/feyeleanor 147
  • 148. package mai n import "crypto/cipher " import "crypto/aes " func Decrypt(m []byte, k string) (r []byte, e error) { var b cipher.Bloc k if b, e = aes.NewCipher([]byte(k)); e == nil { var iv []byt e iv, m = Unpack(m ) c := cipher.NewCBCDecrypter(b, iv ) r = make([]byte, len(m) ) c.CryptBlocks(r, m ) } retur n } func Unpack(m []byte) (iv, r []byte) { return m[:aes.BlockSize], m[aes.BlockSize: ] } go for the paranoid network programmer slideshare.net/feyeleanor 148
  • 149. package mai n import "crypto/cipher " import "crypto/aes " func Decrypt(m []byte, k string) (r []byte, e error) { var b cipher.Bloc k if b, e = aes.NewCipher([]byte(k)); e == nil { var iv []byt e iv, m = Unpack(m ) c := cipher.NewCBCDecrypter(b, iv ) r = make([]byte, len(m) ) c.CryptBlocks(r, m ) } retur n } func Unpack(m []byte) (iv, r []byte) { return m[:aes.BlockSize], m[aes.BlockSize: ] } go for the paranoid network programmer slideshare.net/feyeleanor 149
  • 150. package mai n import "crypto/cipher " import "crypto/aes " func Decrypt(m []byte, k string) (r []byte, e error) { var b cipher.Bloc k if b, e = aes.NewCipher([]byte(k)); e == nil { var iv []byt e iv, m = Unpack(m ) c := cipher.NewCBCDecrypter(b, iv ) r = make([]byte, len(m) ) c.CryptBlocks(r, m ) } retur n } func Unpack(m []byte) (iv, r []byte) { return m[:aes.BlockSize], m[aes.BlockSize: ] } go for the paranoid network programmer slideshare.net/feyeleanor 150
  • 151. rsa encrypt 151 go for the paranoid network programmer slideshare.net/feyeleanor
  • 152. package mai n import . "bytes " import "crypto/rsa " import "encoding/gob " import "net " func main() { HELLO_WORLD := []byte("Hello World" ) RSA_LABEL := []byte("served" ) Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { var key rsa.PublicKe y if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil { if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil { c.WriteToUDP(m, a ) } } retur n } ) } go for the paranoid network programmer slideshare.net/feyeleanor 152
  • 153. package mai n import . "bytes " import "crypto/rsa " import "encoding/gob " import "net " func main() { HELLO_WORLD := []byte("Hello World" ) RSA_LABEL := []byte("served" ) Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { var key rsa.PublicKey if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil { if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil { c.WriteToUDP(m, a ) } } retur n } ) } go for the paranoid network programmer slideshare.net/feyeleanor 153
  • 154. package mai n import . "bytes " import "crypto/rsa " import "encoding/gob " import "net " func main() { HELLO_WORLD := []byte("Hello World" ) RSA_LABEL := []byte("served" ) Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { var key rsa.PublicKe y if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil { if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil { c.WriteToUDP(m, a ) } } retur n } ) } go for the paranoid network programmer slideshare.net/feyeleanor 154
  • 155. package mai n import . "bytes " import "crypto/rsa " import "encoding/gob " import "net " func main() { HELLO_WORLD := []byte("Hello World" ) RSA_LABEL := []byte("served" ) Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { var key rsa.PublicKe y if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil { if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil { c.WriteToUDP(m, a ) } } retur n } ) } go for the paranoid network programmer slideshare.net/feyeleanor 155
  • 156. package mai n import . "bytes " import "crypto/rsa " import "encoding/gob " import "net " func main() { HELLO_WORLD := []byte("Hello World" ) RSA_LABEL := []byte("served" ) Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { var key rsa.PublicKe y if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil { if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil { c.WriteToUDP(m, a ) } } retur n } ) } go for the paranoid network programmer slideshare.net/feyeleanor 156
  • 157. package mai n import . "bytes " import "crypto/rsa " import "encoding/gob " import "net " func main() { HELLO_WORLD := []byte("Hello World" ) RSA_LABEL := []byte("served" ) Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { var key rsa.PublicKe y if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil { if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil { c.WriteToUDP(m, a ) } } retur n } ) } go for the paranoid network programmer slideshare.net/feyeleanor 157
  • 158. package mai n import . "bytes " import "crypto/rsa " import "encoding/gob " import "net " func main() { HELLO_WORLD := []byte("Hello World" ) RSA_LABEL := []byte("served" ) Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { var key rsa.PublicKe y if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil { if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil { c.WriteToUDP(m, a ) } } retur n } ) } go for the paranoid network programmer slideshare.net/feyeleanor 158
  • 159. package mai n import "crypto/rand " import "crypto/rsa " import "crypto/sha1 " func Encrypt(key *rsa.PublicKey, m, l []byte) ([]byte, error) { return rsa.EncryptOAEP(sha1.New(), rand.Reader, key, m, l ) } go for the paranoid network programmer slideshare.net/feyeleanor 159
  • 160. package mai n import "crypto/rand " import "crypto/rsa " import "crypto/sha1 " func Encrypt(key *rsa.PublicKey, m, l []byte) ([]byte, error) { return rsa.EncryptOAEP(sha1.New(), rand.Reader, key, m, l ) } go for the paranoid network programmer slideshare.net/feyeleanor 160
  • 161. package mai n import "crypto/rand " import "crypto/rsa " import "crypto/sha1 " func Encrypt(key *rsa.PublicKey, m, l []byte) ([]byte, error) { return rsa.EncryptOAEP(sha1.New(), rand.Reader, key, m, l ) } go for the paranoid network programmer slideshare.net/feyeleanor 161
  • 162. package mai n import "crypto/rand " import "crypto/rsa " import "crypto/sha1 " func Encrypt(key *rsa.PublicKey, m, l []byte) ([]byte, error) { return rsa.EncryptOAEP(sha1.New(), rand.Reader, key, m, l ) } go for the paranoid network programmer slideshare.net/feyeleanor 162
  • 163. package mai n import "crypto/rand " import "crypto/rsa " import "crypto/sha1 " func Encrypt(key *rsa.PublicKey, m, l []byte) ([]byte, error) { return rsa.EncryptOAEP(sha1.New(), rand.Reader, key, m, l ) } go for the paranoid network programmer slideshare.net/feyeleanor 163
  • 164. rsa decrypt 164 go for the paranoid network programmer slideshare.net/feyeleanor
  • 165. package mai n import "crypto/rsa " import . "fmt " import "net " func main() { Dial(":1025", "ckey", func(c *net.UDPConn, k *rsa.PrivateKey) { if m, e := ReadStream(c); e == nil { if m, e := Decrypt(k, m, []byte("served")); e == nil { Println(string(m) ) } } } ) } go for the paranoid network programmer slideshare.net/feyeleanor 165
  • 166. package mai n import "crypto/rsa " import . "fmt " import "net " func main() { Dial(":1025", "ckey", func(c *net.UDPConn, k *rsa.PrivateKey) { if m, e := ReadStream(c); e == nil { if m, e := Decrypt(k, m, []byte("served")); e == nil { Println(string(m) ) } } } ) } go for the paranoid network programmer slideshare.net/feyeleanor 166
  • 167. package mai n import "crypto/rand " import "crypto/rsa " import "crypto/sha1 " func Decrypt(key *rsa.PrivateKey, m, l []byte) ([]byte, error) { return rsa.DecryptOAEP(sha1.New(), rand.Reader, key, m, l ) } go for the paranoid network programmer slideshare.net/feyeleanor 167
  • 168. package mai n import "crypto/rsa " import . "fmt " import "net " func main() { Dial(":1025", "ckey", func(c *net.UDPConn, k *rsa.PrivateKey) { if m, e := ReadStream(c); e == nil { if m, e := Decrypt(k, m, []byte("served")); e == nil { Println(string(m) ) } } } ) } go for the paranoid network programmer slideshare.net/feyeleanor 168
  • 169. package mai n import "crypto/rsa " import . "fmt " import "net " func main() { Dial(":1025", "ckey", func(c *net.UDPConn, k *rsa.PrivateKey) { if m, e := ReadStream(c); e == nil { if m, e := Decrypt(k, m, []byte("served")); e == nil { Println(string(m) ) } } } ) } go for the paranoid network programmer slideshare.net/feyeleanor 169
  • 170. package mai n import "crypto/rsa " import . "fmt " import "net " func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey)) { if k, e := LoadPrivateKey(file); e == nil { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close( ) SendKey(conn, k.PublicKey, func() { f(conn, k ) } ) } } } } go for the paranoid network programmer slideshare.net/feyeleanor 170
  • 171. package mai n import "crypto/rsa " import . "fmt " import "net " func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey)) { if k, e := LoadPrivateKey(file); e == nil { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close( ) SendKey(conn, k.PublicKey, func() { f(conn, k ) } ) } } } } go for the paranoid network programmer slideshare.net/feyeleanor 171
  • 172. package mai n import "crypto/rsa " import . "fmt " import "net " func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey)) { if k, e := LoadPrivateKey(file); e == nil { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close( ) SendKey(conn, k.PublicKey, func() { f(conn, k ) } ) } } } } go for the paranoid network programmer slideshare.net/feyeleanor 172
  • 173. package mai n import "crypto/rsa " import "crypto/x509 " import "encoding/pem " import "io/ioutil " func LoadPrivateKey(file string) (r *rsa.PrivateKey, e error) { if file, e := ioutil.ReadFile(file); e == nil { if block, _ := pem.Decode(file); block != nil { if block.Type == "RSA PRIVATE KEY" { r, e = x509.ParsePKCS1PrivateKey(block.Bytes ) } } } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 173
  • 174. package mai n import "crypto/rsa " import "crypto/x509 " import "encoding/pem " import "io/ioutil " func LoadPrivateKey(file string) (r *rsa.PrivateKey, e error) { if file, e := ioutil.ReadFile(file); e == nil { if block, _ := pem.Decode(file); block != nil { if block.Type == "RSA PRIVATE KEY" { r, e = x509.ParsePKCS1PrivateKey(block.Bytes ) } } } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 174
  • 175. package mai n import "crypto/rsa " import "crypto/x509 " import "encoding/pem " import "io/ioutil " func LoadPrivateKey(file string) (r *rsa.PrivateKey, e error) { if file, e := ioutil.ReadFile(file); e == nil { if block, _ := pem.Decode(file); block != nil { if block.Type == "RSA PRIVATE KEY" { r, e = x509.ParsePKCS1PrivateKey(block.Bytes ) } } } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 175
  • 176. package mai n import "crypto/rsa " import "crypto/x509 " import "encoding/pem " import "io/ioutil " func LoadPrivateKey(file string) (r *rsa.PrivateKey, e error) { if file, e := ioutil.ReadFile(file); e == nil { if block, _ := pem.Decode(file); block != nil { if block.Type == "RSA PRIVATE KEY" { r, e = x509.ParsePKCS1PrivateKey(block.Bytes ) } } } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 176
  • 177. package mai n import "crypto/rsa " import "crypto/x509 " import "encoding/pem " import "io/ioutil " func LoadPrivateKey(file string) (r *rsa.PrivateKey, e error) { if file, e := ioutil.ReadFile(file); e == nil { if block, _ := pem.Decode(file); block != nil { if block.Type == "RSA PRIVATE KEY" { r, e = x509.ParsePKCS1PrivateKey(block.Bytes ) } } } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 177
  • 178. package mai n import "crypto/rsa " import "crypto/x509 " import "encoding/pem " import "io/ioutil " func LoadPrivateKey(file string) (r *rsa.PrivateKey, e error) { if file, e := ioutil.ReadFile(file); e == nil { if block, _ := pem.Decode(file); block != nil { if block.Type == "RSA PRIVATE KEY" { r, e = x509.ParsePKCS1PrivateKey(block.Bytes ) } } } retur n } go for the paranoid network programmer slideshare.net/feyeleanor 178
  • 179. package mai n import "crypto/rsa " import . "fmt " import "net " func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey)) { if k, e := LoadPrivateKey(file); e == nil { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close( ) SendKey(conn, k.PublicKey, func() { f(conn, k ) } ) } } } } go for the paranoid network programmer slideshare.net/feyeleanor 179
  • 180. package mai n import "crypto/rsa " import . "fmt " import "net " func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey)) { if k, e := LoadPrivateKey(file); e == nil { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close( ) SendKey(conn, k.PublicKey, func() { f(conn, k ) } ) } } } } go for the paranoid network programmer slideshare.net/feyeleanor 180
  • 181. package mai n import "crypto/rsa " import . "fmt " import "net " func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey)) { if k, e := LoadPrivateKey(file); e == nil { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close( ) SendKey(conn, k.PublicKey, func() { f(conn, k ) } ) } } } } go for the paranoid network programmer slideshare.net/feyeleanor 181
  • 182. package mai n import "bytes " import “crypto/rsa " import "encoding/gob " import "net " func SendKey(c *net.UDPConn, k rsa.PublicKey, f func()) { var b bytes.Buffe r if e := gob.NewEncoder(&b).Encode(k); e == nil { if _, e = c.Write(b.Bytes()); e == nil { f( ) } } } go for the paranoid network programmer slideshare.net/feyeleanor 182
  • 183. package mai n import "bytes " import “crypto/rsa " import "encoding/gob " import "net " func SendKey(c *net.UDPConn, k rsa.PublicKey, f func()) { var b bytes.Buffe r if e := gob.NewEncoder(&b).Encode(k); e == nil { if _, e = c.Write(b.Bytes()); e == nil { f( ) } } } go for the paranoid network programmer slideshare.net/feyeleanor 183
  • 184. package mai n import "bytes " import “crypto/rsa " import "encoding/gob " import "net " func SendKey(c *net.UDPConn, k rsa.PublicKey, f func()) { var b bytes.Buffe r if e := gob.NewEncoder(&b).Encode(k); e == nil { if _, e = c.Write(b.Bytes()); e == nil { f( ) } } } go for the paranoid network programmer slideshare.net/feyeleanor 184
  • 185. package mai n import "crypto/rsa " import . "fmt " import "net " func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey)) { if k, e := LoadPrivateKey(file); e == nil { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close( ) SendKey(conn, k.PublicKey, func() { f(conn, k) } ) } } } } go for the paranoid network programmer slideshare.net/feyeleanor 185
  • 186. serving websockets 186 go for the paranoid network programmer slideshare.net/feyeleanor
  • 187. ws_hello.htm l <!DOCTYPE html > <html > <head > <meta charset='UTF-8' / > <title>WEBSOCKET HELLO</title > <script src="js"></script > </head > <body></body > </html > ws_hello.j s window.onload = function() { var socket = new WebSocket("ws://localhost:3000/hello") ; socket.onmessage = m => { div = document.createElement("div") ; div.innerText = JSON.parse(m.data) ; document.body.append(div) ; } ; } go for the paranoid network programmer slideshare.net/feyeleanor 187
  • 188. ws_hello.htm l <!DOCTYPE html > <html > <head > <meta charset='UTF-8' / > <title>WEBSOCKET HELLO</title > <script src="js"></script > </head > <body></body > </html > ws_hello.j s window.onload = function() { var socket = new WebSocket("ws://localhost:3000/hello") ; socket.onmessage = m => { div = document.createElement("div") ; div.innerText = JSON.parse(m.data) ; document.body.append(div) ; } ; } go for the paranoid network programmer slideshare.net/feyeleanor 188
  • 189. package mai n import "fmt " import "golang.org/x/net/websocket " import "io/ioutil " import "net/http " func ServeFile(route, name, mime_type string) { b, _ := ioutil.ReadFile(name ) http.HandleFunc(route, func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", mime_type ) fmt.Fprint(w, string(b) ) } ) } func main() { http.Handle("/hello", websocket.Handler(func(ws *websocket.Conn) { websocket.JSON.Send(ws, "Hello" ) }) ) ServeFile("/", "ws_hello.html", "text/html" ) ServeFile("/js", "ws_hello.js", "application/javascript" ) http.ListenAndServe(":3000", nil ) } go for the paranoid network programmer slideshare.net/feyeleanor 189
  • 190. package mai n import "fmt " import "golang.org/x/net/websocket " import "io/ioutil " import "net/http " func ServeFile(route, name, mime_type string) { b, _ := ioutil.ReadFile(name ) http.HandleFunc(route, func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", mime_type ) fmt.Fprint(w, string(b) ) } ) } func main() { http.Handle("/hello", websocket.Handler(func(ws *websocket.Conn) { websocket.JSON.Send(ws, "Hello" ) }) ) ServeFile("/", "ws_hello.html", "text/html" ) ServeFile("/js", "ws_hello.js", "application/javascript" ) http.ListenAndServe(":3000", nil ) } go for the paranoid network programmer slideshare.net/feyeleanor 190
  • 191. package mai n import "fmt " import "golang.org/x/net/websocket " import "io/ioutil " import "net/http " func ServeFile(route, name, mime_type string) { b, _ := ioutil.ReadFile(name ) http.HandleFunc(route, func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", mime_type) fmt.Fprint(w, string(b) ) } ) } func main() { http.Handle("/hello", websocket.Handler(func(ws *websocket.Conn) { websocket.JSON.Send(ws, "Hello" ) }) ) ServeFile("/", "ws_hello.html", "text/html" ) ServeFile("/js", "ws_hello.js", "application/javascript" ) http.ListenAndServe(":3000", nil ) } go for the paranoid network programmer slideshare.net/feyeleanor 191
  • 192. package mai n import "fmt " import "golang.org/x/net/websocket " import "io/ioutil " import "net/http " func ServeFile(route, name, mime_type string) { b, _ := ioutil.ReadFile(name ) http.HandleFunc(route, func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", mime_type ) fmt.Fprint(w, string(b) ) } ) } func main() { http.Handle("/hello", websocket.Handler(func(ws *websocket.Conn) { websocket.JSON.Send(ws, "Hello" ) }) ) ServeFile("/", "ws_hello.html", "text/html" ) ServeFile("/js", "ws_hello.js", "application/javascript" ) http.ListenAndServe(":3000", nil ) } go for the paranoid network programmer slideshare.net/feyeleanor 192
  • 193. package mai n import "fmt " import "golang.org/x/net/websocket " import "io/ioutil " import "net/http " func ServeFile(route, name, mime_type string) { b, _ := ioutil.ReadFile(name ) http.HandleFunc(route, func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", mime_type ) fmt.Fprint(w, string(b) ) } ) } func main() { http.Handle("/hello", websocket.Handler(func(ws *websocket.Conn) { websocket.JSON.Send(ws, "Hello" ) }) ) ServeFile("/", "ws_hello.html", "text/html" ) ServeFile("/js", "ws_hello.js", "application/javascript" ) http.ListenAndServe(":3000", nil ) } go for the paranoid network programmer slideshare.net/feyeleanor 193
  • 194. package mai n import "fmt " import "golang.org/x/net/websocket " import "io/ioutil " import "net/http " func ServeFile(route, name, mime_type string) { b, _ := ioutil.ReadFile(name ) http.HandleFunc(route, func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", mime_type ) fmt.Fprint(w, string(b) ) } ) } func main() { http.Handle("/hello", websocket.Handler(func(ws *websocket.Conn) { websocket.JSON.Send(ws, "Hello" ) }) ) ServeFile("/", "ws_hello.html", "text/html" ) ServeFile("/js", "ws_hello.js", "application/javascript" ) http.ListenAndServe(":3000", nil ) } go for the paranoid network programmer slideshare.net/feyeleanor 194
  • 195. accessing websockets 195 go for the paranoid network programmer slideshare.net/feyeleanor
  • 196. package mai n import "fmt " import "golang.org/x/net/websocket " const SERVER = "ws://localhost:3000/hello " const ADDRESS = "http://localhost/ " func main() { if ws, e := websocket.Dial(SERVER, "", ADDRESS); e == nil { var s strin g if e := websocket.JSON.Receive(ws, &s); e == nil { fmt.Println(s ) } } } go for the paranoid network programmer slideshare.net/feyeleanor 196
  • 197. package mai n import "fmt " import "golang.org/x/net/websocket " const SERVER = "ws://localhost:3000/hello " const ADDRESS = "http://localhost/ " func main() { if ws, e := websocket.Dial(SERVER, "", ADDRESS); e == nil { var s strin g if e := websocket.JSON.Receive(ws, &s); e == nil { fmt.Println(s ) } } } go for the paranoid network programmer slideshare.net/feyeleanor 197
  • 198. package mai n import "fmt " import "golang.org/x/net/websocket " const SERVER = "ws://localhost:3000/hello " const ADDRESS = "http://localhost/ " func main() { if ws, e := websocket.Dial(SERVER, "", ADDRESS); e == nil { var s string if e := websocket.JSON.Receive(ws, &s); e == nil { fmt.Println(s ) } } } go for the paranoid network programmer slideshare.net/feyeleanor 198
  • 199. twitter://@feyeleanor go for the paranoid network programmer slideshare.net/feyeleanor